Skip to content

Commit 16d6e67

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 8284639 commit 16d6e67

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

libdnf/dnf-context.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,9 +1825,34 @@ 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_clear_error(error);
1831+
g_autofree gchar *maybe_quoted_id = NULL;
1832+
maybe_quoted_id = g_key_file_get_string(key_file,
1833+
"os-release",
1834+
"ID",
1835+
error);
1836+
if (!maybe_quoted_id)
1837+
return FALSE;
1838+
1839+
g_autofree gchar *id = g_shell_unquote(maybe_quoted_id, error);
1840+
if (!id)
1841+
return FALSE;
1842+
if (g_ascii_strncasecmp(id, "debian", strlen("debian")) != 0 &&
1843+
g_ascii_strncasecmp(id, "arch", strlen("arch")) != 0) {
1844+
g_set_error(error, DNF_ERROR, DNF_ERROR_FAILED,
1845+
"'VERSION_ID' not found in os-release and source root "
1846+
"'%s' is not a known rolling release (debian or arch)",
1847+
source_root);
1848+
return FALSE;
1849+
}
1850+
1851+
/* Fake a high version number */
1852+
version = g_strdup("9999");
1853+
} else {
1854+
version = g_shell_unquote(maybe_quoted_version, error);
1855+
}
18311856
if (!version)
18321857
return FALSE;
18331858
dnf_context_set_release_ver(context, version);

0 commit comments

Comments
 (0)