Accepting request 330968 from home:michael-chang:branches:Base:System
- Set default GRUB_DISTRIBUTOR from /etc/os-release if it is empty or not set by user (bsc#942519) * added grub2-default-distributor.patch * modified grub.default OBS-URL: https://build.opensuse.org/request/show/330968 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=177
This commit is contained in:
parent
47a255b20c
commit
d1103405c2
@ -1,6 +1,9 @@
|
|||||||
# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
|
# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
|
||||||
# /boot/grub2/grub.cfg.
|
# /boot/grub2/grub.cfg.
|
||||||
GRUB_DISTRIBUTOR="openSUSE"
|
|
||||||
|
# Uncomment to set your own custom distributor. If you leave it unset or empty, the default
|
||||||
|
# policy is to determine the value from /etc/os-release
|
||||||
|
# GRUB_DISTRIBUTOR=""
|
||||||
|
|
||||||
GRUB_DEFAULT=0
|
GRUB_DEFAULT=0
|
||||||
GRUB_HIDDEN_TIMEOUT=0
|
GRUB_HIDDEN_TIMEOUT=0
|
||||||
|
@ -2,7 +2,7 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- grub-2.02~beta2.orig/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
|
+++ grub-2.02~beta2/grub-core/osdep/unix/config.c
|
||||||
@@ -82,6 +82,19 @@ grub_util_load_config (struct grub_util_
|
@@ -200,6 +200,19 @@ grub_util_load_config (struct grub_util_
|
||||||
if (v)
|
if (v)
|
||||||
cfg->grub_distributor = xstrdup (v);
|
cfg->grub_distributor = xstrdup (v);
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
|
|||||||
cfgfile = grub_util_get_config_filename ();
|
cfgfile = grub_util_get_config_filename ();
|
||||||
if (!grub_util_is_regular (cfgfile))
|
if (!grub_util_is_regular (cfgfile))
|
||||||
return;
|
return;
|
||||||
@@ -105,8 +118,8 @@ grub_util_load_config (struct grub_util_
|
@@ -223,8 +236,8 @@ grub_util_load_config (struct grub_util_
|
||||||
*ptr++ = *iptr;
|
*ptr++ = *iptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
177
grub2-default-distributor.patch
Normal file
177
grub2-default-distributor.patch
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
Index: grub-2.02~beta2/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)
|
||||||
|
return LOCALEDIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifdef __linux__
|
||||||
|
+
|
||||||
|
+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;
|
||||||
|
+
|
||||||
|
+ cfgfile = grub_util_path_concat (2, GRUB_SYSCONFDIR, "os-release");
|
||||||
|
+ if (!grub_util_is_regular (cfgfile))
|
||||||
|
+ {
|
||||||
|
+ grub_free (cfgfile);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ argv[0] = "sh";
|
||||||
|
+ argv[1] = "-c";
|
||||||
|
+
|
||||||
|
+ script = xmalloc (4 * strlen (cfgfile) + 300);
|
||||||
|
+
|
||||||
|
+ ptr = script;
|
||||||
|
+ memcpy (ptr, ". '", 3);
|
||||||
|
+ ptr += 3;
|
||||||
|
+ for (iptr = cfgfile; *iptr; iptr++)
|
||||||
|
+ {
|
||||||
|
+ if (*iptr == '\\')
|
||||||
|
+ {
|
||||||
|
+ memcpy (ptr, "'\\''", 4);
|
||||||
|
+ ptr += 4;
|
||||||
|
+ 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);
|
||||||
|
+
|
||||||
|
+ return def_dist;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
void
|
||||||
|
grub_util_load_config (struct grub_util_config *cfg)
|
||||||
|
{
|
||||||
|
@@ -125,7 +243,17 @@ grub_util_load_config (struct grub_util_
|
||||||
|
waitpid (pid, NULL, 0);
|
||||||
|
}
|
||||||
|
if (f)
|
||||||
|
- return;
|
||||||
|
+ {
|
||||||
|
+#ifdef __linux__
|
||||||
|
+ if (!cfg->grub_distributor || cfg->grub_distributor[0] == '\0')
|
||||||
|
+ {
|
||||||
|
+ if (cfg->grub_distributor)
|
||||||
|
+ grub_free (cfg->grub_distributor);
|
||||||
|
+ cfg->grub_distributor = grub_util_default_distributor ();
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
f = grub_util_fopen (cfgfile, "r");
|
||||||
|
if (f)
|
||||||
|
@@ -136,4 +264,13 @@ grub_util_load_config (struct grub_util_
|
||||||
|
else
|
||||||
|
grub_util_warn (_("cannot open configuration file `%s': %s"),
|
||||||
|
cfgfile, strerror (errno));
|
||||||
|
+
|
||||||
|
+#ifdef __linux__
|
||||||
|
+ if (!cfg->grub_distributor || cfg->grub_distributor[0] == '\0')
|
||||||
|
+ {
|
||||||
|
+ if (cfg->grub_distributor)
|
||||||
|
+ grub_free (cfg->grub_distributor);
|
||||||
|
+ cfg->grub_distributor = grub_util_default_distributor ();
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
Index: grub-2.02~beta2/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"
|
||||||
|
|
||||||
|
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"
|
||||||
|
+ GRUB_DISTRIBUTOR="${NAME} ${VERSION}"
|
||||||
|
+fi
|
||||||
|
|
||||||
|
# These are defined in this script, export them here so that user can
|
||||||
|
# override them.
|
@ -1,3 +1,11 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Sep 14 06:36:04 UTC 2015 - mchang@suse.com
|
||||||
|
|
||||||
|
- Set default GRUB_DISTRIBUTOR from /etc/os-release if it is empty
|
||||||
|
or not set by user (bsc#942519)
|
||||||
|
* added grub2-default-distributor.patch
|
||||||
|
* modified grub.default
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Aug 18 09:53:54 UTC 2015 - mchang@suse.com
|
Tue Aug 18 09:53:54 UTC 2015 - mchang@suse.com
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ Patch66: grub2-glibc-2.20.patch
|
|||||||
Patch67: grub2-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
|
Patch67: grub2-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
|
||||||
Patch68: grub2-btrfs-fix-get_root-key-comparison-failures-due-to-en.patch
|
Patch68: grub2-btrfs-fix-get_root-key-comparison-failures-due-to-en.patch
|
||||||
Patch69: grub2-getroot-fix-get-btrfs-fs-prefix-big-endian.patch
|
Patch69: grub2-getroot-fix-get-btrfs-fs-prefix-big-endian.patch
|
||||||
|
Patch70: grub2-default-distributor.patch
|
||||||
# Btrfs snapshot booting related patches
|
# Btrfs snapshot booting related patches
|
||||||
Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
|
Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
|
||||||
Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
|
Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
|
||||||
@ -464,6 +465,7 @@ mv po/grub.pot po/%{name}.pot
|
|||||||
%patch67 -p1
|
%patch67 -p1
|
||||||
%patch68 -p1
|
%patch68 -p1
|
||||||
%patch69 -p1
|
%patch69 -p1
|
||||||
|
%patch70 -p1
|
||||||
%patch101 -p1
|
%patch101 -p1
|
||||||
%patch102 -p1
|
%patch102 -p1
|
||||||
%patch103 -p1
|
%patch103 -p1
|
||||||
|
Loading…
Reference in New Issue
Block a user