forked from pool/grub2
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:
parent
f922778020
commit
ac85133778
@ -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~beta2/grub-core/osdep/unix/config.c
|
||||
@@ -61,6 +61,124 @@ grub_util_get_localedir (void)
|
||||
--- grub-2.02~beta3.orig/grub-core/osdep/unix/config.c
|
||||
+++ grub-2.02~beta3/grub-core/osdep/unix/config.c
|
||||
@@ -61,6 +61,140 @@ grub_util_get_localedir (void)
|
||||
return LOCALEDIR;
|
||||
}
|
||||
|
||||
+#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*
|
||||
+grub_util_default_distributor (void)
|
||||
+{
|
||||
+ pid_t pid;
|
||||
+ const char *argv[4];
|
||||
+ char *script, *ptr;
|
||||
+ char *cfgfile, *iptr;
|
||||
+ FILE *f = NULL;
|
||||
+ int fd;
|
||||
+ char *def_dist = NULL;
|
||||
+ char *cfgfile;
|
||||
+ char buf[1024];
|
||||
+ FILE *fp = NULL;
|
||||
+ char *os_pretty_name = NULL;
|
||||
+ char *os_name = NULL;
|
||||
+ char *os_version = NULL;
|
||||
+
|
||||
+ cfgfile = grub_util_path_concat (2, GRUB_SYSCONFDIR, "os-release");
|
||||
+ if (!grub_util_is_regular (cfgfile))
|
||||
@ -26,108 +80,70 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ argv[0] = "sh";
|
||||
+ argv[1] = "-c";
|
||||
+ fp = grub_util_fopen (cfgfile, "r");
|
||||
+
|
||||
+ script = xmalloc (4 * strlen (cfgfile) + 300);
|
||||
+
|
||||
+ ptr = script;
|
||||
+ memcpy (ptr, ". '", 3);
|
||||
+ ptr += 3;
|
||||
+ for (iptr = cfgfile; *iptr; iptr++)
|
||||
+ if (!fp)
|
||||
+ {
|
||||
+ if (*iptr == '\\')
|
||||
+ {
|
||||
+ memcpy (ptr, "'\\''", 4);
|
||||
+ ptr += 4;
|
||||
+ continue;
|
||||
+ }
|
||||
+ *ptr++ = *iptr;
|
||||
+ grub_util_warn (_("cannot open configuration file `%s': %s"),
|
||||
+ cfgfile, strerror (errno));
|
||||
+ grub_free (cfgfile);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ 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);
|
||||
+
|
||||
+ 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
|
||||
+
|
||||
void
|
||||
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);
|
||||
}
|
||||
if (f)
|
||||
@ -146,7 +162,7 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
|
||||
|
||||
f = grub_util_fopen (cfgfile, "r");
|
||||
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
|
||||
grub_util_warn (_("cannot open configuration file `%s': %s"),
|
||||
cfgfile, strerror (errno));
|
||||
@ -160,17 +176,21 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
|
||||
+ }
|
||||
+#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~beta2/util/grub-mkconfig.in
|
||||
@@ -203,6 +203,10 @@ GRUB_ACTUAL_DEFAULT="$GRUB_DEFAULT"
|
||||
--- grub-2.02~beta3.orig/util/grub-mkconfig.in
|
||||
+++ grub-2.02~beta3/util/grub-mkconfig.in
|
||||
@@ -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_DISTRIBUTOR}" = x ] && [ -f "${sysconfdir}/os-release" ] ; then
|
||||
+ . "${sysconfdir}/os-release"
|
||||
+ if echo "$NAME" | grep -q "^openSUSE Tumbleweed" ; then
|
||||
+ GRUB_DISTRIBUTOR="${PRETTY_NAME}"
|
||||
+ else
|
||||
+ GRUB_DISTRIBUTOR="${NAME} ${VERSION}"
|
||||
+ fi
|
||||
+fi
|
||||
|
||||
# These are defined in this script, export them here so that user can
|
||||
|
@ -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
|
||||
|
||||
|
@ -536,7 +536,7 @@ CD_MODULES=" all_video boot cat chain configfile echo true \
|
||||
jpeg minicmd normal part_apple part_msdos part_gpt \
|
||||
password_pbkdf2 png reboot search search_fs_uuid \
|
||||
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"
|
||||
|
||||
%ifarch x86_64
|
||||
|
Loading…
Reference in New Issue
Block a user