Accepting request 431416 from home:michael-chang:branches:Base:System

- use $PRETTY_NAME instead of $NAME $VERSION for $GRUB_DISTRIBUTOR
  in openSUSE Tumbleweed (bsc#995549)
  * modified grub2-default-distributor.patch 
- grub2.spec: add http module to grub.efi (fate#320129)

OBS-URL: https://build.opensuse.org/request/show/431416
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=232
This commit is contained in:
Dirk Mueller 2016-09-30 12:07:25 +00:00 committed by Git OBS Bridge
parent f922778020
commit ac85133778
3 changed files with 136 additions and 108 deletions

View File

@ -1,23 +1,77 @@
Index: grub-2.02~beta2/grub-core/osdep/unix/config.c Index: grub-2.02~beta3/grub-core/osdep/unix/config.c
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/grub-core/osdep/unix/config.c --- grub-2.02~beta3.orig/grub-core/osdep/unix/config.c
+++ grub-2.02~beta2/grub-core/osdep/unix/config.c +++ grub-2.02~beta3/grub-core/osdep/unix/config.c
@@ -61,6 +61,124 @@ grub_util_get_localedir (void) @@ -61,6 +61,140 @@ grub_util_get_localedir (void)
return LOCALEDIR; return LOCALEDIR;
} }
+#ifdef __linux__ +#ifdef __linux__
+static char *
+os_release_get_val (const char *buf, const char *key)
+{
+ const char *ptr = buf;
+ char *ret;
+
+ while (*ptr && grub_isspace(*ptr))
+ ptr++;
+
+ if (*ptr == '#')
+ return NULL;
+
+ if (grub_strncmp (ptr, key, grub_strlen (key)) != 0)
+ return NULL;
+
+ ptr += grub_strlen (key);
+ if (*ptr++ != '=' || *ptr == '\0')
+ return NULL;
+
+ if (*ptr == '"' || *ptr == '\'')
+ {
+ char c = *ptr;
+ int i = 0;
+ char *tmp, *ptmp;
+
+ if (*++ptr == '\0')
+ return NULL;
+
+ tmp = grub_strdup (ptr);
+ if ((ptmp = grub_strrchr (tmp, c)))
+ *ptmp = '\0';
+
+ ret = malloc (grub_strlen (tmp) + 1);
+ ptmp = tmp;
+ while (*ptmp)
+ {
+ if (*ptmp != '\\' || *(ptmp + 1) != c)
+ ret[i++] = *ptmp;
+ ++ptmp;
+ }
+
+ grub_free (tmp);
+ ret[i] = '\0';
+ }
+ else
+ {
+ char *pret;
+
+ ret = grub_strdup (ptr);
+ if ((pret = grub_strchr (ret, ' ')))
+ *pret = '\0';
+ }
+
+ return ret;
+}
+ +
+static char* +static char*
+grub_util_default_distributor (void) +grub_util_default_distributor (void)
+{ +{
+ pid_t pid; + char *cfgfile;
+ const char *argv[4]; + char buf[1024];
+ char *script, *ptr; + FILE *fp = NULL;
+ char *cfgfile, *iptr; + char *os_pretty_name = NULL;
+ FILE *f = NULL; + char *os_name = NULL;
+ int fd; + char *os_version = NULL;
+ char *def_dist = NULL;
+ +
+ cfgfile = grub_util_path_concat (2, GRUB_SYSCONFDIR, "os-release"); + cfgfile = grub_util_path_concat (2, GRUB_SYSCONFDIR, "os-release");
+ if (!grub_util_is_regular (cfgfile)) + if (!grub_util_is_regular (cfgfile))
@ -26,108 +80,70 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
+ return NULL; + return NULL;
+ } + }
+ +
+ argv[0] = "sh"; + fp = grub_util_fopen (cfgfile, "r");
+ argv[1] = "-c";
+ +
+ script = xmalloc (4 * strlen (cfgfile) + 300); + if (!fp)
+
+ ptr = script;
+ memcpy (ptr, ". '", 3);
+ ptr += 3;
+ for (iptr = cfgfile; *iptr; iptr++)
+ { + {
+ if (*iptr == '\\') + grub_util_warn (_("cannot open configuration file `%s': %s"),
+ { + cfgfile, strerror (errno));
+ memcpy (ptr, "'\\''", 4); + grub_free (cfgfile);
+ ptr += 4; + return NULL;
+ continue;
+ }
+ *ptr++ = *iptr;
+ } + }
+ +
+ strcpy (ptr, "'; printf \"OS_RELEASE_NAME=%s\\nOS_RELEASE_VERSION=%s\\n\" "
+ "\"$NAME\" \"$VERSION\"");
+
+ argv[2] = script;
+ argv[3] = '\0';
+
+ pid = grub_util_exec_pipe (argv, &fd);
+
+ if (pid)
+ f = fdopen (fd, "r");
+
+ if (f)
+ {
+ char *buffer = NULL;
+ size_t sz = 0;
+ char *name, *ver;
+
+ name = ver = NULL;
+
+ while (getline (&buffer, &sz, f) >= 0)
+ {
+ for (ptr = buffer; *ptr && grub_isspace (*ptr); ptr++);
+ if (grub_strncmp (ptr, "OS_RELEASE_NAME=",
+ sizeof ("OS_RELEASE_NAME=") - 1) == 0)
+ {
+ char *ptr2;
+ ptr += sizeof ("OS_RELEASE_NAME=") - 1;
+ name = grub_strdup (ptr);
+ for (ptr2 = name + grub_strlen (name) - 1;
+ ptr2 >= name && (*ptr2 == '\r' || *ptr2 == '\n'); ptr2--);
+ ptr2[1] = '\0';
+ continue;
+ }
+ if (grub_strncmp (ptr, "OS_RELEASE_VERSION=",
+ sizeof ("OS_RELEASE_VERSION=") - 1) == 0)
+ {
+ char *ptr2;
+ ptr += sizeof ("OS_RELEASE_VERSION=") - 1;
+ ver = grub_strdup (ptr);
+ for (ptr2 = ver + grub_strlen (ver) - 1;
+ ptr2 >= ver && (*ptr2 == '\r' || *ptr2 == '\n'); ptr2--);
+ ptr2[1] = '\0';
+ continue;
+ }
+ }
+
+ fclose (f);
+
+ if (name && ver)
+ {
+ def_dist = xmalloc (grub_strlen(name) + grub_strlen(ver) + 2);
+
+ ptr = def_dist;
+ grub_memcpy (ptr, name, grub_strlen (name));
+ ptr += grub_strlen (name);
+ *ptr++ = ' ';
+ grub_strcpy (ptr, ver);
+ }
+
+ if (name)
+ grub_free (name);
+ if (ver)
+ grub_free (ver);
+ }
+
+ if (pid)
+ {
+ close (fd);
+ waitpid (pid, NULL, 0);
+ }
+
+ grub_free (script);
+ grub_free (cfgfile); + grub_free (cfgfile);
+ +
+ return def_dist; + while (fgets (buf, sizeof (buf), fp))
+} + {
+ if (!os_pretty_name
+ && (os_pretty_name = os_release_get_val (buf, "PRETTY_NAME")))
+ continue;
+ if (!os_name
+ && (os_name = os_release_get_val (buf, "NAME")))
+ continue;
+ if (!os_version
+ && (os_version = os_release_get_val (buf, "VERSION")))
+ continue;
+ if (os_pretty_name && os_name && os_version)
+ break;
+ }
+ +
+ fclose (fp);
+
+ if (os_name && grub_strncmp (os_name, "openSUSE Tumbleweed", sizeof ("openSUSE Tumbleweed") - 1) == 0)
+ {
+ grub_free (os_name);
+ if (os_version)
+ grub_free (os_version);
+
+ return os_pretty_name;
+ }
+ else if (os_name && os_version)
+ {
+ char *os_name_version;
+
+ os_name_version = grub_xasprintf ("%s %s", os_name, os_version);
+
+ grub_free (os_name);
+ grub_free (os_version);
+ if (os_pretty_name)
+ grub_free (os_pretty_name);
+
+ return os_name_version;
+ }
+
+ if (os_pretty_name)
+ grub_free (os_pretty_name);
+ if (os_version)
+ grub_free (os_version);
+
+ return os_name;
+}
+#endif +#endif
+ +
void void
grub_util_load_config (struct grub_util_config *cfg) grub_util_load_config (struct grub_util_config *cfg)
{ {
@@ -125,7 +243,17 @@ grub_util_load_config (struct grub_util_ @@ -125,7 +259,17 @@ grub_util_load_config (struct grub_util_
waitpid (pid, NULL, 0); waitpid (pid, NULL, 0);
} }
if (f) if (f)
@ -146,7 +162,7 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
f = grub_util_fopen (cfgfile, "r"); f = grub_util_fopen (cfgfile, "r");
if (f) if (f)
@@ -136,4 +264,13 @@ grub_util_load_config (struct grub_util_ @@ -136,4 +280,13 @@ grub_util_load_config (struct grub_util_
else else
grub_util_warn (_("cannot open configuration file `%s': %s"), grub_util_warn (_("cannot open configuration file `%s': %s"),
cfgfile, strerror (errno)); cfgfile, strerror (errno));
@ -160,17 +176,21 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
+ } + }
+#endif +#endif
} }
Index: grub-2.02~beta2/util/grub-mkconfig.in Index: grub-2.02~beta3/util/grub-mkconfig.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub-mkconfig.in --- grub-2.02~beta3.orig/util/grub-mkconfig.in
+++ grub-2.02~beta2/util/grub-mkconfig.in +++ grub-2.02~beta3/util/grub-mkconfig.in
@@ -203,6 +203,10 @@ GRUB_ACTUAL_DEFAULT="$GRUB_DEFAULT" @@ -206,6 +206,14 @@ GRUB_ACTUAL_DEFAULT="$GRUB_DEFAULT"
if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi
+if [ x"${GRUB_DISTRIBUTOR}" = x ] && [ -f "${sysconfdir}/os-release" ] ; then +if [ x"${GRUB_DISTRIBUTOR}" = x ] && [ -f "${sysconfdir}/os-release" ] ; then
+ . "${sysconfdir}/os-release" + . "${sysconfdir}/os-release"
+ GRUB_DISTRIBUTOR="${NAME} ${VERSION}" + if echo "$NAME" | grep -q "^openSUSE Tumbleweed" ; then
+ GRUB_DISTRIBUTOR="${PRETTY_NAME}"
+ else
+ GRUB_DISTRIBUTOR="${NAME} ${VERSION}"
+ fi
+fi +fi
# These are defined in this script, export them here so that user can # These are defined in this script, export them here so that user can

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Sep 2 03:24:19 UTC 2016 - mchang@suse.com
- use $PRETTY_NAME instead of $NAME $VERSION for $GRUB_DISTRIBUTOR
in openSUSE Tumbleweed (bsc#995549)
* modified grub2-default-distributor.patch
- grub2.spec: add http module to grub.efi (fate#320129)
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Aug 31 15:40:28 UTC 2016 - matz@suse.com Wed Aug 31 15:40:28 UTC 2016 - matz@suse.com

View File

@ -536,7 +536,7 @@ CD_MODULES=" all_video boot cat chain configfile echo true \
jpeg minicmd normal part_apple part_msdos part_gpt \ jpeg minicmd normal part_apple part_msdos part_gpt \
password_pbkdf2 png reboot search search_fs_uuid \ password_pbkdf2 png reboot search search_fs_uuid \
search_fs_file search_label sleep test video fat loadenv" search_fs_file search_label sleep test video fat loadenv"
PXE_MODULES="efinet tftp" PXE_MODULES="efinet tftp http"
CRYPTO_MODULES="luks gcry_rijndael gcry_sha1 gcry_sha256" CRYPTO_MODULES="luks gcry_rijndael gcry_sha1 gcry_sha256"
%ifarch x86_64 %ifarch x86_64