From 08f3708e7fe45227deff7424622b7c7a25428a8e Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 17 Jan 2014 12:37:23 -0500
Subject: [PATCH] text-progress-bar: prefer REDHAT_BUGZILLA_PRODUCT over
PRETTY_NAME
The latter is currently filled with incorrect information on install
images and it's apparently hard to fix.
---
src/libply-splash-core/ply-text-progress-bar.c | 53 +++++++++++++++-----------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/src/libply-splash-core/ply-text-progress-bar.c b/src/libply-splash-core/ply-text-progress-bar.c
index 8c4e759..8ca8816 100644
--- a/src/libply-splash-core/ply-text-progress-bar.c
+++ b/src/libply-splash-core/ply-text-progress-bar.c
@@ -92,89 +92,98 @@ ply_text_progress_bar_free (ply_text_progress_bar_t *progress_bar)
if (progress_bar == NULL)
return;
free (progress_bar);
}
static void
get_os_string (void)
{
int fd;
char *buf, *pos, *pos2;
struct stat sbuf;
buf = NULL;
fd = open (RELEASE_FILE, O_RDONLY|O_CLOEXEC);
if (fd == -1)
goto out;
if (fstat (fd, &sbuf) == -1) {
close (fd);
goto out;
}
buf = calloc (sbuf.st_size + 1, sizeof(char));
read (fd, buf, sbuf.st_size);
close (fd);
if (strcmp (RELEASE_FILE, "/etc/os-release") == 0)
{
- char key[] = "PRETTY_NAME=";
+ const char *keys[] = { "REDHAT_BUGZILLA_PRODUCT=", "PRETTY_NAME=", "NAME=", NULL };
+ int i;
- for (pos = strstr (buf, key);
- pos != NULL;
- pos = strstr (pos, key))
+ for (i = 0; keys[i] != NULL; i++)
{
- if (pos == buf || pos[-1] == '\n')
- break;
- }
-
- if (pos != NULL)
- {
- pos += strlen (key);
- pos2 = strstr (pos, "\n");
+ const char *key;
- if (pos2 != NULL)
- *pos2 = '\0';
- else
- pos2 = pos + strlen(pos) - 1;
+ key = keys[i];
- if ((*pos == '\"' && pos2[-1] == '\"') ||
- (*pos == '\'' && pos2[-1] == '\''))
+ for (pos = strstr (buf, key);
+ pos != NULL;
+ pos = strstr (pos, key))
{
- pos++;
- pos2--;
+ if (pos == buf || pos[-1] == '\n')
+ break;
+ }
- *pos2 = '\0';
+ if (pos != NULL)
+ {
+ pos += strlen (key);
+ pos2 = strstr (pos, "\n");
+
+ if (pos2 != NULL)
+ *pos2 = '\0';
+ else
+ pos2 = pos + strlen(pos) - 1;
+
+ if ((*pos == '\"' && pos2[-1] == '\"') ||
+ (*pos == '\'' && pos2[-1] == '\''))
+ {
+ pos++;
+ pos2--;
+
+ *pos2 = '\0';
+ }
+ asprintf (&os_string, " %s", pos);
+ goto out;
}
- asprintf (&os_string, " %s", pos);
}
goto out;
}
pos = strstr (buf, " release ");
if (pos == NULL)
goto out;
pos2 = strstr (pos, " (");
if (pos2 == NULL)
goto out;
*pos = '\0';
pos += strlen (" release ");
*pos2 = '\0';
asprintf (&os_string, " %s %s", buf, pos);
out:
free (buf);
if (os_string == NULL)
os_string = strdup ("");
}
void
ply_text_progress_bar_draw (ply_text_progress_bar_t *progress_bar)
{
--
1.8.3.1