Skip to content

Commit 67106b0

Browse files
committed
[context] do not fail on rolling releases with no VERSION_ID
Archlinux and Debian Unstable have no VERSION_ID as they are rolling releases, but dnf-context's setup requires one. Fake a very high version number in those cases.
1 parent ac318b2 commit 67106b0

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

libdnf/dnf-context.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,9 +1825,27 @@ dnf_context_set_os_release(DnfContext *context, GError **error) try
18251825
"os-release",
18261826
"VERSION_ID",
18271827
error);
1828-
if (maybe_quoted_version == NULL)
1829-
return FALSE;
1830-
version = g_shell_unquote(maybe_quoted_version, error);
1828+
if (maybe_quoted_version == NULL) {
1829+
/* rolling releases like Arch or Debian Unstable have no VERSION_ID */
1830+
g_autofree gchar *maybe_quoted_id = NULL;
1831+
maybe_quoted_id = g_key_file_get_string(key_file,
1832+
"os-release",
1833+
"ID",
1834+
error);
1835+
if (!maybe_quoted_id)
1836+
return FALSE;
1837+
1838+
g_autofree gchar *id = g_shell_unquote(maybe_quoted_id, error);
1839+
if (g_ascii_strncasecmp(id, "debian", strlen("debian")) != 0 &&
1840+
g_ascii_strncasecmp(id, "arch", strlen("arch")) != 0)
1841+
return FALSE;
1842+
1843+
/* Fake a high version number */
1844+
version = g_strdup("9999");
1845+
g_clear_error(error);
1846+
} else {
1847+
version = g_shell_unquote(maybe_quoted_version, error);
1848+
}
18311849
if (!version)
18321850
return FALSE;
18331851
dnf_context_set_release_ver(context, version);

0 commit comments

Comments
 (0)