SHA256
1
0
forked from pool/grub2

Accepting request 135095 from devel:openSUSE:Factory

- add 20_memtest86+ (bnc#780622) (forwarded request 135094 from arvidjaar)

OBS-URL: https://build.opensuse.org/request/show/135095
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=44
This commit is contained in:
Stephan Kulow 2012-09-23 19:04:15 +00:00 committed by Git OBS Bridge
parent dbcded38d6
commit 9984bbaad9
3 changed files with 147 additions and 23 deletions

53
20_memtest86+ Normal file
View File

@ -0,0 +1,53 @@
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2011 Michal Ambroz <rebus@seznam.cz>
# Adapted for openSUSE by Andrey Borzenkov <arvidjaar@gmail.com>
#
# you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the script. If not, see <http://www.gnu.org/licenses/>.
. /usr/share/grub2/grub-mkconfig_lib
export TEXTDOMAIN=grub2
export TEXTDOMAINDIR=/usr/share/locale
CLASS="--class memtest86 --class gnu --class tools"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=Memtest
else
OS="${GRUB_DISTRIBUTOR} Memtest"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
fi
memtest=/boot/memtest.bin
if grub_file_is_not_garbage "$memtest" ; then
gettext_printf "Found memtest image: %s\n" "$memtest" >&2
basename=`basename $memtest`
dirname=`dirname $memtest`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE_BOOT}")"
printf "menuentry '%s' %s \$menuentry_id_option '%s' {\n" "${OS}" "${CLASS}" "memtest-$boot_device_id"
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
printf '%s\n' "${prepare_boot_cache}"
message="$(gettext_printf "Loading memtest ...\n")"
cat << EOF
echo '$message'
linux16 ${rel_dirname}/${basename}
}
EOF
fi

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Wed Sep 19 18:54:34 UTC 2012 - arvidjaar@gmail.com
- add 20_memtest86+ (bnc#780622)
-------------------------------------------------------------------
Tue Sep 18 09:26:29 UTC 2012 - mchang@suse.com
- Fix un-bootable grub2 testing entry in grub's menu.lst (bnc#779370)
- Not add new grub2 testing entry if it's not found in menu.lst
- Update grub2 stuff and config if there's grub2 entry in menu.lst
- Check for current bootloader as update-bootloader acts on it
-------------------------------------------------------------------
Thu Aug 30 08:00:54 UTC 2012 - mchang@suse.com

View File

@ -78,6 +78,7 @@ Source4: grub2.rpmlintrc
# rsync -Lrtvz translationproject.org::tp/latest/grub/ po
Source5: translations-20120622.tar.xz
Source6: grub2-once
Source7: 20_memtest86+
Source1000: PATCH_POLICY
Patch0: grub2-correct-font-path.patch
Patch1: rename-grub-info-file-to-grub2.patch
@ -254,6 +255,9 @@ make DESTDIR=$RPM_BUILD_ROOT install
# Script that makes part of grub.cfg persist across updates
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/
# Script to generate memtest86+ menu entry
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/
# Ghost config file
install -d $RPM_BUILD_ROOT/boot/%{name}
touch $RPM_BUILD_ROOT/boot/%{name}/grub.cfg
@ -272,39 +276,93 @@ install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once
/sbin/install-info %{_infodir}/grub-dev.info %{_infodir}/dir || :
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
mkdir -p /boot/%{name}/ 2>/dev/null || true
# Determine the partition with /boot
BOOT_PARTITION=$(df -h /boot |(read; awk '{print $1; exit}'))
# Generate core.img, but don't let it be installed in boot sector
%{name}-install --grub-setup=/bin/true $BOOT_PARTITION || true
exec >/dev/null 2>&1
# Remove stale menu.lst entries
/sbin/update-bootloader --remove --image /boot/%{name}/core.img --name="GNU GRUB 2" || true
# Add core.img as multiboot kernel to GRUB Legacy menu
/sbin/update-bootloader --add --image /boot/%{name}/core.img --name="GNU GRUB 2" || true
/sbin/update-bootloader --refresh || true
# To check by current loader settings
if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then
. %{_sysconfdir}/sysconfig/bootloader
fi
# If the grub is the current loader, we'll handle the grub2 testing entry
if [ "x${LOADER_TYPE}" = "xgrub" ]; then
exec >/dev/null 2>&1
# check if entry for grub2's core.img exists in the config
# if yes, we will correct obsoleted path and update grub2 stuff and config to make it work
# if no, do nothing
if [ -f /boot/grub/menu.lst ]; then
# If grub config contains obsolete core.img path, remove and use the new one
if /usr/bin/grep -l "^\s*kernel\s*.*/boot/%{name}/core.img" /boot/grub/menu.lst; then
/sbin/update-bootloader --remove --image /boot/%{name}/core.img || true
/sbin/update-bootloader --add --image /boot/%{name}/i386-pc/core.img --name "GNU GRUB 2" || true
fi
# Install grub2 stuff and config to make the grub2 testing entry to work with updated version
if /usr/bin/grep -l "^\s*kernel\s*.*/boot/%{name}/i386-pc/core.img" /boot/grub/menu.lst; then
# Determine the partition with /boot
BOOT_PARTITION=$(df -h /boot |(read; awk '{print $1; exit}'))
# Generate core.img, but don't let it be installed in boot sector
%{name}-install --grub-setup=/bin/true $BOOT_PARTITION || true
# Create a working grub2 config, otherwise that entry is un-bootable
/usr/sbin/grub2-mkconfig -o /boot/%{name}/grub.cfg
fi
fi
elif [ "x${LOADER_TYPE}" = "xgrub2" ]; then
# It's enought to call update-bootloader --refesh to install grub2 and update it's config
/sbin/update-bootloader --refresh || true
fi
%ifarch %{efi}
%post efi
/sbin/install-info %{_infodir}/grub-dev.info %{_infodir}/dir || :
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
# To check by current loader settings
if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then
. %{_sysconfdir}/etc/sysconfig/bootloader
fi
if [ "x${LOADER_TYPE}" = "xgrub2-efi" ]; then
# It's enought to call update-bootloader --refesh to install grub2 and update it's config
/sbin/update-bootloader --refresh || true
fi
%endif
%preun
if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/grub-dev.info %{_infodir}/dir || :
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
exec >/dev/null
if [ -e /boot/%{name}/core.img ] ; then
/sbin/update-bootloader --remove --image /boot/%{name}/core.img --name="GNU GRUB 2" || :
/sbin/update-bootloader --refresh || :
# To check by current loader settings
if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then
. %{_sysconfdir}/sysconfig/bootloader
fi
if [ "x${LOADER_TYPE}" = "xgrub" ]; then
exec >/dev/null 2>&1
if [ -f /boot/grub/menu.lst ]; then
# Remove grub2 testing entry in menu.lst if has any
for i in /boot/%{name}/core.img /boot/%{name}/i386-pc/core.img; do
if /usr/bin/grep -l "^\s*kernel\s*.*$i" /boot/grub/menu.lst; then
/sbin/update-bootloader --remove --image "$i" || true
fi
done
fi
# Cleanup config, to not confuse some tools determining bootloader in use
rm -f /boot/%{name}/grub.cfg
# Cleanup installed files
rm -f /boot/%{name}/*.mod
rm -f /boot/%{name}/*.img
rm -f /boot/%{name}/*.lst
rm -f /boot/%{name}/device.map
# Unless grub2 provides grub2-uninstall, we don't remove any file because
# we have no idea what's been installed. (And a blind remove is dangerous
# to remove user's or other package's file accidently ..)
fi
fi
%ifarch %{efi}