From: Michael Tremer Date: Tue, 6 Apr 2021 15:59:49 +0000 (+0000) Subject: pakfire: Do not fail when /etc/os-release does not exist X-Git-Tag: 0.9.28~1285^2~429 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b7fb441e38c69a2c2561dff5faa3bed419897dc;p=pakfire.git pakfire: Do not fail when /etc/os-release does not exist Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 7fe81c915..552fd3d56 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -392,7 +392,9 @@ static int pakfire_safety_checks(Pakfire pakfire) { } static int pakfire_read_os_release(Pakfire pakfire) { - int r = 0; + char* line = NULL; + size_t l = 0; + int r = 1; char* path = pakfire_make_path(pakfire, "/etc/os-release"); if (!path) @@ -400,14 +402,15 @@ static int pakfire_read_os_release(Pakfire pakfire) { FILE* f = fopen(path, "r"); if (!f) { + // Ignore when the file does not exist + if (errno == ENOENT) + goto ERROR; + ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno)); - r = -1; + r = 1; goto ERROR; } - char* line = NULL; - size_t l = 0; - while (1) { ssize_t bytes_read = getline(&line, &l, f); if (bytes_read < 0) @@ -520,7 +523,7 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char // Read /etc/os-release r = pakfire_read_os_release(p); - if (r) + if (r && errno != ENOENT) goto ERROR; DEBUG(p, "Pakfire initialized at %p\n", p);