forked from pool/grub2
Accepting request 571597 from Base:System
OBS-URL: https://build.opensuse.org/request/show/571597 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=175
This commit is contained in:
parent
9bda449c6c
commit
a80af7b39d
125
grub2-check-default.sh
Normal file
125
grub2-check-default.sh
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
fallback_entry () {
|
||||||
|
|
||||||
|
local saved=$1
|
||||||
|
local FALLBACK_MATCH=`echo $saved | sed -e '/>/!d' -e '/>/s/>.*$//'`
|
||||||
|
|
||||||
|
if [ -n "$FALLBACK_MATCH" ]; then
|
||||||
|
for i in $MENU_ENTRIES; do
|
||||||
|
if expr match "$i" "^$FALLBACK_MATCH" >/dev/null ; then
|
||||||
|
echo "$i"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
run_command () {
|
||||||
|
[ x"$DEBUG_RUN" = x1 ] && echo $@ || $@
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_print () {
|
||||||
|
[ x"$DEBUG_RUN" = x1 ] && echo $@ || true
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
-d|--debug)
|
||||||
|
DEBUG_RUN=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
GRUB_EDITENV="/usr/bin/grub2-editenv"
|
||||||
|
GRUB_SET_DEFAULT="/usr/sbin/grub2-set-default"
|
||||||
|
|
||||||
|
SAVED_ENTRY=`${GRUB_EDITENV} list | sed -ne "/^saved_entry=/{s@\"\(.*\)\"@\1@;t 1;s@'\(.*\)'@\1@;: 1;s@^[^=]\+=@@;p;b}"`
|
||||||
|
|
||||||
|
debug_print "SAVED_ENTRY=$SAVED_ENTRY"
|
||||||
|
|
||||||
|
[ -z "$SAVED_ENTRY" ] && exit 0
|
||||||
|
|
||||||
|
MENU_ENTRIES=`awk '
|
||||||
|
BEGIN {
|
||||||
|
bracket = 0
|
||||||
|
}
|
||||||
|
{
|
||||||
|
patsplit($0, words, "([^[:blank:]]+)|(\"[^\"]+\")|('\''[^'\'']*'\'')", sep)
|
||||||
|
|
||||||
|
cmd = words[1]
|
||||||
|
arg1 = words[2]
|
||||||
|
|
||||||
|
if (substr(arg1, 1, 1) == "\"" || substr(arg1, 1, 1) == "'\''") {
|
||||||
|
len = length(arg1)
|
||||||
|
arg1 = substr(arg1, 2, len - 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd == "submenu") {
|
||||||
|
submenu[bracket] = arg1
|
||||||
|
} else if (cmd == "menuentry") {
|
||||||
|
title = ""
|
||||||
|
for (i = 0; i < bracket; i++) {
|
||||||
|
if (i in submenu)
|
||||||
|
title = title submenu[i] ">"
|
||||||
|
}
|
||||||
|
print title arg1
|
||||||
|
}
|
||||||
|
|
||||||
|
for (w in words) {
|
||||||
|
if (words[w] == "{") {
|
||||||
|
bracket++
|
||||||
|
} else if (words[w] == "}") {
|
||||||
|
bracket--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' /boot/grub2/grub.cfg`
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
debug_print "MENU_ENTRIES="
|
||||||
|
for i in $MENU_ENTRIES; do
|
||||||
|
debug_print "$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in $MENU_ENTRIES; do
|
||||||
|
if [ "$SAVED_ENTRY" = "$i" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
FALLBACK=`fallback_entry $SAVED_ENTRY`
|
||||||
|
|
||||||
|
if [ -n "$FALLBACK" ]; then
|
||||||
|
run_command ${GRUB_SET_DEFAULT} "$FALLBACK"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
source /etc/os-release
|
||||||
|
|
||||||
|
NEW_SAVED_ENTRY=`echo $SAVED_ENTRY | sed -ne "s/$NAME [0-9a-zA-Z_.-]\\+/$NAME $VERSION/pg"`
|
||||||
|
|
||||||
|
debug_print "NEW_SAVED_ENTRY=$NEW_SAVED_ENTRY"
|
||||||
|
|
||||||
|
if [ "$NEW_SAVED_ENTRY" = "$SAVED_ENTRY" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
for i in $MENU_ENTRIES; do
|
||||||
|
if [ $NEW_SAVED_ENTRY = $i ]; then
|
||||||
|
run_command ${GRUB_SET_DEFAULT} "$NEW_SAVED_ENTRY"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
FALLBACK=`fallback_entry $NEW_SAVED_ENTRY`
|
||||||
|
|
||||||
|
if [ -n "$FALLBACK" ]; then
|
||||||
|
run_command ${GRUB_SET_DEFAULT} "$FALLBACK"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
43
grub2-getroot-scan-disk-pv.patch
Normal file
43
grub2-getroot-scan-disk-pv.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From: Michael Chang <mchang@suse.com>
|
||||||
|
Subject: Fix grub2-mkconfig warning when disk is LVM PV
|
||||||
|
References: bsc#1071239
|
||||||
|
|
||||||
|
When a disk device was found in grub_util_biosdisk_get_grub_dev, its grub
|
||||||
|
hostdisk device name just returned. Since the disk could also be used as PV
|
||||||
|
disk, use grub_util_get_ldm to kick scanning of on disk metadata and adding it
|
||||||
|
to VG array.
|
||||||
|
|
||||||
|
---
|
||||||
|
Index: grub-2.02/util/getroot.c
|
||||||
|
===================================================================
|
||||||
|
--- grub-2.02.orig/util/getroot.c
|
||||||
|
+++ grub-2.02/util/getroot.c
|
||||||
|
@@ -272,8 +272,28 @@ grub_util_biosdisk_get_grub_dev (const c
|
||||||
|
grub_util_info ("%s is a parent of %s", sys_disk, os_dev);
|
||||||
|
if (!is_part)
|
||||||
|
{
|
||||||
|
+#if defined(__APPLE__)
|
||||||
|
free (sys_disk);
|
||||||
|
return make_device_name (drive);
|
||||||
|
+#else
|
||||||
|
+ char *name, *ldm_name;
|
||||||
|
+ grub_disk_t disk;
|
||||||
|
+
|
||||||
|
+ free (sys_disk);
|
||||||
|
+ name = make_device_name (drive);
|
||||||
|
+ disk = grub_disk_open (name);
|
||||||
|
+ if (!disk)
|
||||||
|
+ return name;
|
||||||
|
+ ldm_name = grub_util_get_ldm (disk, 0);
|
||||||
|
+ if (ldm_name)
|
||||||
|
+ {
|
||||||
|
+ grub_disk_close (disk);
|
||||||
|
+ grub_free (name);
|
||||||
|
+ return ldm_name;
|
||||||
|
+ }
|
||||||
|
+ grub_disk_close (disk);
|
||||||
|
+ return name;
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
free (sys_disk);
|
||||||
|
|
16
grub2-mkconfig-default-entry-correction.patch
Normal file
16
grub2-mkconfig-default-entry-correction.patch
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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
|
||||||
|
@@ -311,6 +311,11 @@ and /etc/grub.d/* files or please file a
|
||||||
|
else
|
||||||
|
# none of the children aborted with error, install the new grub.cfg
|
||||||
|
mv -f ${grub_cfg}.new ${grub_cfg}
|
||||||
|
+ # check if default entry need to be corrected for updated distributor version
|
||||||
|
+ # and/or use fallback entry if default kernel entry removed
|
||||||
|
+ if test -x /usr/sbin/grub2-check-default; then
|
||||||
|
+ /usr/sbin/grub2-check-default >&2
|
||||||
|
+ fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
@ -1,3 +1,13 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jan 23 04:41:22 UTC 2018 - mchang@suse.com
|
||||||
|
|
||||||
|
- Check if default entry need to be corrected for updated distributor version
|
||||||
|
and/or use fallback entry if default kernel entry removed (bsc#1065349)
|
||||||
|
* grub2-check-default.sh
|
||||||
|
* grub2-mkconfig-default-entry-correction.patch
|
||||||
|
- Fix grub2-mkconfig warning when disk is LVM PV (bsc#1071239)
|
||||||
|
* grub2-getroot-scan-disk-pv.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Dec 8 09:30:46 UTC 2017 - mchang@suse.com
|
Fri Dec 8 09:30:46 UTC 2017 - mchang@suse.com
|
||||||
|
|
||||||
|
11
grub2.spec
11
grub2.spec
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package grub2
|
# spec file for package grub2
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -160,6 +160,7 @@ Source15: grub2-once.service
|
|||||||
Source16: grub2-xen-pv-firmware.cfg
|
Source16: grub2-xen-pv-firmware.cfg
|
||||||
# required hook for systemd-sleep (bsc#941758)
|
# required hook for systemd-sleep (bsc#941758)
|
||||||
Source17: grub2-systemd-sleep.sh
|
Source17: grub2-systemd-sleep.sh
|
||||||
|
Source18: grub2-check-default.sh
|
||||||
Source1000: PATCH_POLICY
|
Source1000: PATCH_POLICY
|
||||||
Patch1: rename-grub-info-file-to-grub2.patch
|
Patch1: rename-grub-info-file-to-grub2.patch
|
||||||
Patch2: grub2-linux.patch
|
Patch2: grub2-linux.patch
|
||||||
@ -213,6 +214,7 @@ Patch82: grub2-diskfilter-support-pv-without-metadatacopies.patch
|
|||||||
Patch83: grub2-efi-uga-64bit-fb.patch
|
Patch83: grub2-efi-uga-64bit-fb.patch
|
||||||
Patch84: grub2-s390x-09-improve-zipl-setup.patch
|
Patch84: grub2-s390x-09-improve-zipl-setup.patch
|
||||||
Patch85: grub2-install-remove-useless-check-PReP-partition-is-empty.patch
|
Patch85: grub2-install-remove-useless-check-PReP-partition-is-empty.patch
|
||||||
|
Patch86: grub2-getroot-scan-disk-pv.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
|
||||||
@ -273,6 +275,9 @@ Patch412: 0013-tpm-i386-pc-diskboot-img.patch
|
|||||||
# UEFI HTTP and related network protocol support (FATE#320130)
|
# UEFI HTTP and related network protocol support (FATE#320130)
|
||||||
Patch420: 0001-add-support-for-UEFI-network-protocols.patch
|
Patch420: 0001-add-support-for-UEFI-network-protocols.patch
|
||||||
Patch421: 0002-AUDIT-0-http-boot-tracker-bug.patch
|
Patch421: 0002-AUDIT-0-http-boot-tracker-bug.patch
|
||||||
|
# check if default entry need to be corrected for updated distributor version
|
||||||
|
# and/or use fallback entry if default kernel entry removed (bsc#1065349)
|
||||||
|
Patch430: grub2-mkconfig-default-entry-correction.patch
|
||||||
|
|
||||||
Requires: gettext-runtime
|
Requires: gettext-runtime
|
||||||
%if 0%{?suse_version} >= 1140
|
%if 0%{?suse_version} >= 1140
|
||||||
@ -487,6 +492,7 @@ swap partition while in resuming
|
|||||||
%patch83 -p1
|
%patch83 -p1
|
||||||
%patch84 -p1
|
%patch84 -p1
|
||||||
%patch85 -p1
|
%patch85 -p1
|
||||||
|
%patch86 -p1
|
||||||
%patch101 -p1
|
%patch101 -p1
|
||||||
%patch102 -p1
|
%patch102 -p1
|
||||||
%patch103 -p1
|
%patch103 -p1
|
||||||
@ -537,6 +543,7 @@ swap partition while in resuming
|
|||||||
%patch412 -p1
|
%patch412 -p1
|
||||||
%patch420 -p1
|
%patch420 -p1
|
||||||
%patch421 -p1
|
%patch421 -p1
|
||||||
|
%patch430 -p1
|
||||||
# patches above may update the timestamp of grub.texi
|
# patches above may update the timestamp of grub.texi
|
||||||
# and via build-aux/mdate-sh they end up in grub2.info, breaking build-compare
|
# and via build-aux/mdate-sh they end up in grub2.info, breaking build-compare
|
||||||
[ -z "$SOURCE_DATE_EPOCH" ] ||\
|
[ -z "$SOURCE_DATE_EPOCH" ] ||\
|
||||||
@ -795,6 +802,7 @@ install -m 755 -D %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/80_suse_btrfs
|
|||||||
install -m 644 -D %{SOURCE15} $RPM_BUILD_ROOT%{_unitdir}/grub2-once.service
|
install -m 644 -D %{SOURCE15} $RPM_BUILD_ROOT%{_unitdir}/grub2-once.service
|
||||||
install -m 755 -D %{SOURCE17} $RPM_BUILD_ROOT%{_libdir}/systemd/system-sleep/grub2.sleep
|
install -m 755 -D %{SOURCE17} $RPM_BUILD_ROOT%{_libdir}/systemd/system-sleep/grub2.sleep
|
||||||
%endif
|
%endif
|
||||||
|
install -m 755 -D %{SOURCE18} $RPM_BUILD_ROOT%{_sbindir}/grub2-check-default
|
||||||
|
|
||||||
R=$RPM_BUILD_ROOT
|
R=$RPM_BUILD_ROOT
|
||||||
%ifarch %{ix86} x86_64
|
%ifarch %{ix86} x86_64
|
||||||
@ -1018,6 +1026,7 @@ fi
|
|||||||
%{_sbindir}/%{name}-probe
|
%{_sbindir}/%{name}-probe
|
||||||
%{_sbindir}/%{name}-reboot
|
%{_sbindir}/%{name}-reboot
|
||||||
%{_sbindir}/%{name}-set-default
|
%{_sbindir}/%{name}-set-default
|
||||||
|
%{_sbindir}/%{name}-check-default
|
||||||
%{_bindir}/%{name}-editenv
|
%{_bindir}/%{name}-editenv
|
||||||
%{_bindir}/%{name}-file
|
%{_bindir}/%{name}-file
|
||||||
%{_bindir}/%{name}-fstest
|
%{_bindir}/%{name}-fstest
|
||||||
|
Loading…
Reference in New Issue
Block a user