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