Remove GRUB Legacy support
GRUB Legacy is retired since Fedora 19, hence its support can be removed. This brings a noticeable simplification of memtest-setup script. The new-memtest-pkg script is only tied to GRUB Legacy, so it's no longer needed. Without this script, grubby and util-linux dependencies can also be removed. The memtest-setup man page didn't contain all available options and also referred to GRUB Legacy, hence it's completely rewritten. The new man page is also used as a template for memtest-setup help message. Signed-off-by: Jan Hlavac <jhlavac@redhat.com>
This commit is contained in:
parent
f57d02b763
commit
48b4c452b8
19
README
19
README
@ -2,8 +2,8 @@ Install memtest86+ into your grub menu by the following command:
|
|||||||
|
|
||||||
# memtest-setup
|
# memtest-setup
|
||||||
|
|
||||||
If you use GRUB 2 (the default) it will install 20_memtest86+ GRUB template
|
It will install 20_memtest86+ GRUB 2 template into /etc/grub.d and you will also
|
||||||
into /etc/grub.d and you will also need to regenerate GRUB 2 config by running:
|
need to regenerate GRUB 2 config by running:
|
||||||
|
|
||||||
# grub2-mkconfig -o /boot/grub2/grub.cfg
|
# grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||||
|
|
||||||
@ -16,13 +16,12 @@ version by running:
|
|||||||
|
|
||||||
# memtest-setup -b
|
# memtest-setup -b
|
||||||
|
|
||||||
Or with GRUB 2 you can switch between ELF and non-ELF versions of memtest86+
|
Or you can switch between ELF and non-ELF versions of memtest86+ by using
|
||||||
by using INSTALL_ELF variable from /etc/memtest86+.conf. Setting it to '1'
|
INSTALL_ELF variable from /etc/memtest86+.conf. Setting it to '1' will instruct
|
||||||
will instruct GRUB 2 to install ELF version of memtest86+ and setting it
|
GRUB 2 to install ELF version of memtest86+ and setting it to '0' will instruct
|
||||||
to '0' will instruct GRUB2 to install non-ELF version. If the variable
|
GRUB 2 to install non-ELF version. If the variable is empty or unset, the ELF
|
||||||
is empty or unset, the ELF version is installed (it's due to backward
|
version is installed (it's due to backward compatibility). For the change
|
||||||
compatibility). For the change to take effect you need to regenerate your
|
to take effect you need to regenerate your GRUB 2 config by running:
|
||||||
GRUB 2 config by running:
|
|
||||||
|
|
||||||
# grub2-mkconfig -o /boot/grub2/grub.cfg
|
# grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ The memtest86+ now supports some command line parameters:
|
|||||||
|
|
||||||
You can add memtest86+ command line parameters into grub like you are
|
You can add memtest86+ command line parameters into grub like you are
|
||||||
used with kernel command line parameters, e.g.:
|
used with kernel command line parameters, e.g.:
|
||||||
kernel /memtest86+-VERSION console=ttyS0
|
linux16 /memtest86+-VERSION console=ttyS0
|
||||||
|
|
||||||
Unfortunately this is currently supported only with non-ELF memtest86+ image.
|
Unfortunately this is currently supported only with non-ELF memtest86+ image.
|
||||||
You cannot use the command line parameters with the ELF image, because the
|
You cannot use the command line parameters with the ELF image, because the
|
||||||
|
131
memtest-setup
131
memtest-setup
@ -1,26 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# package name
|
|
||||||
PNAME="memtest86+"
|
|
||||||
|
|
||||||
# binary image
|
|
||||||
BNAME="memtest86+"
|
|
||||||
|
|
||||||
# ELF image
|
|
||||||
ELFNAME="elf-$BNAME"
|
|
||||||
|
|
||||||
# executable image to be installed
|
|
||||||
ENAME="$ELFNAME"
|
|
||||||
|
|
||||||
# GRUB 2 template
|
# GRUB 2 template
|
||||||
G2TEMPL="20_memtest86+"
|
G2TEMPL="20_memtest86+"
|
||||||
|
|
||||||
# GRUB 2 environment file
|
# GRUB 2 environment file
|
||||||
CONF_FILE="/etc/memtest86+.conf"
|
CONF_FILE="/etc/memtest86+.conf"
|
||||||
|
|
||||||
# GRUB legacy configuration file
|
|
||||||
GRUBCONF="/boot/grub/grub.conf"
|
|
||||||
|
|
||||||
# GRUB2 configuration file
|
# GRUB2 configuration file
|
||||||
GRUB2CFG="/boot/grub2/grub.cfg"
|
GRUB2CFG="/boot/grub2/grub.cfg"
|
||||||
|
|
||||||
@ -32,22 +17,24 @@ ELF=1
|
|||||||
|
|
||||||
if [ "$1" = "--help" -o "$1" = "-h" ]; then
|
if [ "$1" = "--help" -o "$1" = "-h" ]; then
|
||||||
cat <<:EOF
|
cat <<:EOF
|
||||||
usage: memtest-setup [OPTIONS]
|
Usage:
|
||||||
|
memtest-setup [-b|-e|-h]
|
||||||
|
memtest-setup [--bin|--elf|--help]
|
||||||
|
|
||||||
This utility installs Memtest86+ into your GRUB boot loader menu.
|
The memtest-setup utility installs Memtest86+ into GRUB 2 boot loader menu.
|
||||||
It supports both GRUB 2 and GRUB Legacy (i.e. GRUB 0.9x).
|
It installs GRUB 2 template into /etc/grub.d directory.
|
||||||
In case of GRUB 2 it installs GRUB 2 template into /etc/grub.d and GRUB 2
|
|
||||||
config needs to be regenerated manually by running:
|
|
||||||
|
|
||||||
grub2-mkconfig -o $GRUB2CFG
|
GRUB 2 configuration file needs to be regenerated manually by running:
|
||||||
|
|
||||||
This is not done automatically because it could overwrite any custom changes
|
grub2-mkconfig -o $GRUB2CFG
|
||||||
in /boot/grub2/grub.cfg.
|
|
||||||
|
|
||||||
OPTIONS:
|
This is not done automatically because it could overwrite any custom changes
|
||||||
-e , --elf installs ELF image (the default)
|
in GRUB 2 configuration file.
|
||||||
-b , --bin installs binary image (non-ELF)
|
|
||||||
-h , --help show this help
|
Options:
|
||||||
|
-b, --bin Install a binary Memtest86+ image.
|
||||||
|
-e, --elf Install an ELF Memtest86+ image (the default).
|
||||||
|
-h, --help Print a help message and exit.
|
||||||
|
|
||||||
:EOF
|
:EOF
|
||||||
exit 0
|
exit 0
|
||||||
@ -56,83 +43,41 @@ fi
|
|||||||
[ "$1" = "-b" -o "$1" = "--bin" ] && ELF=0
|
[ "$1" = "-b" -o "$1" = "--bin" ] && ELF=0
|
||||||
[ "$1" = "-e" -o "$1" = "--elf" ] && ELF=1
|
[ "$1" = "-e" -o "$1" = "--elf" ] && ELF=1
|
||||||
|
|
||||||
if [ "$ELF" = 1 ]; then
|
|
||||||
# BANNER_SUFFIX needs to be simultaneously changed also in grub2 template
|
|
||||||
BANNER_SUFFIX=
|
|
||||||
ENAME="$ELFNAME"
|
|
||||||
else
|
|
||||||
ELF=0
|
|
||||||
BANNER_SUFIX="(non-ELF)"
|
|
||||||
ENAME="$BNAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d /sys/firmware/efi ]; then
|
if [ -d /sys/firmware/efi ]; then
|
||||||
echo "ERROR: memtest86+ does not support EFI platforms."
|
echo "ERROR: memtest86+ does not support EFI platforms."
|
||||||
exit 254
|
exit 254
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -r "$GRUBCONF" -a ! -r "$GRUB2CFG" ]; then
|
if [ ! -r "$GRUB2CFG" ]; then
|
||||||
echo "ERROR: unable to read grub configuration file. Do you have enough permissions?"
|
echo "ERROR: unable to read grub configuration file. Do you have enough permissions?"
|
||||||
echo "Try to run as root."
|
echo "Try to run as root."
|
||||||
exit 249
|
exit 249
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$GRUB2CFG" ]; then
|
# install GRUB 2 template
|
||||||
echo "GRUB 2 detected, installing template..."
|
if [ ! -d /etc/grub.d ]; then
|
||||||
if [ ! -d /etc/grub.d ]; then
|
echo "ERROR: unable to find /etc/grub.d"
|
||||||
echo "ERROR: unable to find /etc/grub.d"
|
exit 253
|
||||||
exit 253
|
|
||||||
fi
|
|
||||||
if [ ! -r /usr/share/memtest86+/$G2TEMPL ]; then
|
|
||||||
echo "ERROR: unable to find GRUB 2 template."
|
|
||||||
exit 251
|
|
||||||
fi
|
|
||||||
if ! cp /usr/share/memtest86+/$G2TEMPL /etc/grub.d; then
|
|
||||||
echo "ERROR: unable to copy GRUB 2 template, do you have write permission to"
|
|
||||||
echo "/etc/grub.d?"
|
|
||||||
# EX_IOERR
|
|
||||||
exit 74
|
|
||||||
fi
|
|
||||||
if [ ! -w "$CONF_FILE" ]
|
|
||||||
then
|
|
||||||
echo "ERROR: file '$CONF_FILE' is not writable."
|
|
||||||
exit 250
|
|
||||||
fi
|
|
||||||
chmod a+x /etc/grub.d/$G2TEMPL
|
|
||||||
echo "GRUB 2 template installed."
|
|
||||||
echo "Do not forget to regenerate your grub.cfg by:"
|
|
||||||
echo " # grub2-mkconfig -o $GRUB2CFG"
|
|
||||||
else
|
|
||||||
MTVERSION=`rpm -q --qf '%{version}' $PNAME`
|
|
||||||
MTPATH="/boot/$ENAME-$MTVERSION"
|
|
||||||
|
|
||||||
if [ ! -r "$GRUBCONF" ]; then
|
|
||||||
echo "ERROR: $GRUBCONF not found or not readable."
|
|
||||||
exit 252
|
|
||||||
fi
|
|
||||||
|
|
||||||
MENT=`cat /boot/grub/grub.conf | grep "$ENAME-$MTVERSION"` &> /dev/null
|
|
||||||
if [ "$MENT" != "" ]; then
|
|
||||||
echo "$MTPATH is already configured. Exiting..."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $MTPATH ]; then
|
|
||||||
echo "ERROR: $MTPATH does not exist."
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
/sbin/new-memtest-pkg --install $MTVERSION --banner="Memtest86+${BANNER_SUFFIX}" --kernel-name="$ENAME"
|
|
||||||
RETVAL="$?"
|
|
||||||
|
|
||||||
if [ "$RETVAL" != "0" ]; then
|
|
||||||
echo "ERROR: grubby failed to configure your bootloader for $MTPATH."
|
|
||||||
exit $RETVAL
|
|
||||||
else
|
|
||||||
[ "$ELF" = 1 ] && sed -i -e"s,kernel \(/boot\)\?/$ENAME,kernel --type=netbsd \1/$ENAME," /boot/grub/grub.conf
|
|
||||||
sed -i -e"s,/$ENAME-$MTVERSION.*,/$ENAME-$MTVERSION," /boot/grub/grub.conf
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
if [ ! -r /usr/share/memtest86+/$G2TEMPL ]; then
|
||||||
|
echo "ERROR: unable to find GRUB 2 template."
|
||||||
|
exit 251
|
||||||
|
fi
|
||||||
|
if ! cp /usr/share/memtest86+/$G2TEMPL /etc/grub.d; then
|
||||||
|
echo "ERROR: unable to copy GRUB 2 template, do you have write permission to"
|
||||||
|
echo "/etc/grub.d?"
|
||||||
|
# EX_IOERR
|
||||||
|
exit 74
|
||||||
|
fi
|
||||||
|
if [ ! -w "$CONF_FILE" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: file '$CONF_FILE' is not writable."
|
||||||
|
exit 250
|
||||||
|
fi
|
||||||
|
chmod a+x /etc/grub.d/$G2TEMPL
|
||||||
|
echo "GRUB 2 template installed."
|
||||||
|
echo "Do not forget to regenerate your grub.cfg by:"
|
||||||
|
echo " # grub2-mkconfig -o $GRUB2CFG"
|
||||||
|
|
||||||
# update/add configuration variable to the configuration file
|
# update/add configuration variable to the configuration file
|
||||||
if grep -q "^\s*$CONF_VAR\s*=" "$CONF_FILE"
|
if grep -q "^\s*$CONF_VAR\s*=" "$CONF_FILE"
|
||||||
|
@ -1,38 +1,32 @@
|
|||||||
.TH "MEMTEST\-SETUP" "8" "Aug 26, 2014" "memtest-setup" "Memtest86+ User Manual"
|
.TH MEMTEST-SETUP 8 2018-05-17 Memtest86+ "Memtest86+ Manual"
|
||||||
.nh
|
|
||||||
.ad l
|
.SH NAME
|
||||||
.SH "NAME"
|
memtest-setup \- install Memtest86+ into GRUB\ 2 boot loader menu
|
||||||
memtest\-setup \- Install Memtest86+ into your GRUB boot loader menu
|
|
||||||
.SH "SYNOPSIS"
|
.SH SYNOPSIS
|
||||||
.HP \w'\fBmemtest\-setup\fR\ 'u
|
.BR memtest-setup " [" \-b | \-e | \-h ]
|
||||||
.B memtest\-setup
|
.br
|
||||||
.RI [ OPTIONS ]
|
.BR memtest-setup " [" \-\-bin | \-\-elf | \-\-help ]
|
||||||
.SH "DESCRIPTION"
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.RB "The " memtest-setup " utility installs Memtest86+ into GRUB\ 2 boot"
|
||||||
|
loader menu.
|
||||||
|
.RI "It installs GRUB\ 2 template into " /etc/grub.d " directory."
|
||||||
.PP
|
.PP
|
||||||
\fBmemtest\-setup\fR
|
GRUB\ 2 configuration file needs to be regenerated manually by running:
|
||||||
installs Memtest86+ into your GRUB boot loader menu. It supports both GRUB\ 2
|
.IP
|
||||||
and GRUB Legacy (i.e. GRUB 0.9x). In case of GRUB\ 2 it installs GRUB\ 2 template
|
.RI "grub2-mkconfig -o " /boot/grub2/grub.cfg
|
||||||
into \fI/etc/grub.d\fR and GRUB\ 2 config needs to be regenerated manually by
|
.PP
|
||||||
running \fBgrub2-mkconfig\ -o\ \fI/boot/grub2/grub.cfg\fR under root.
|
This is not done automatically because it could overwrite any custom
|
||||||
This is not done automatically because it could overwrite any custom changes in
|
changes in GRUB\ 2 configuration file.
|
||||||
\fI/boot/grub2/grub.cfg\fR.
|
|
||||||
.SH "OPTIONS"
|
.SH OPTIONS
|
||||||
.SS
|
.TP
|
||||||
|
.BR \-b ", " \-\-bin
|
||||||
|
Install a binary Memtest86+ image.
|
||||||
|
.TP
|
||||||
|
.BR \-e ", " \-\-elf
|
||||||
|
Install an ELF Memtest86+ image (the default).
|
||||||
.TP
|
.TP
|
||||||
.BR \-h ", " \-\-help
|
.BR \-h ", " \-\-help
|
||||||
Shows help.
|
Print a help message and exit.
|
||||||
.SH "AUTHOR"
|
|
||||||
.PP
|
|
||||||
\fBJaroslav Škarvada\fR <\&jskarvad@redhat\&.com\&>
|
|
||||||
.RS 4
|
|
||||||
Manpage author\&.
|
|
||||||
.RE
|
|
||||||
.SH "COPYRIGHT"
|
|
||||||
.BR
|
|
||||||
Copyright \(co 2014 Jaroslav Škarvada
|
|
||||||
.BR
|
|
||||||
.PP
|
|
||||||
Permission is granted to copy, distribute and/or modify this document under the terms of the
|
|
||||||
GNU
|
|
||||||
General Public License, Version 2 or (at your option) any later version published by the Free Software Foundation\&.
|
|
||||||
.SP
|
|
||||||
|
@ -15,11 +15,10 @@ Summary: Stand-alone memory tester for x86 and x86-64 computers
|
|||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
Source0: http://www.memtest.org/download/%{version}/%{name}-%{version}.tar.gz
|
Source0: http://www.memtest.org/download/%{version}/%{name}-%{version}.tar.gz
|
||||||
Source1: memtest-setup
|
Source1: memtest-setup
|
||||||
Source2: new-memtest-pkg
|
Source2: 20_memtest86+
|
||||||
Source3: 20_memtest86+
|
Source3: memtest-setup.8
|
||||||
Source4: memtest-setup.8
|
Source4: memtest86+.conf
|
||||||
Source5: memtest86+.conf
|
Source5: README
|
||||||
Source6: README
|
|
||||||
# reported upstream
|
# reported upstream
|
||||||
Patch0: memtest86+-5.01-no-scp.patch
|
Patch0: memtest86+-5.01-no-scp.patch
|
||||||
# patches to get memtest86+ working with gcc-4.7.2 or later + PCI scan fix
|
# patches to get memtest86+ working with gcc-4.7.2 or later + PCI scan fix
|
||||||
@ -33,7 +32,7 @@ Patch4: memtest86+-5.01-fgnu89-inline.patch
|
|||||||
URL: http://www.memtest.org
|
URL: http://www.memtest.org
|
||||||
# require glibc-devel.i386 via this file:
|
# require glibc-devel.i386 via this file:
|
||||||
BuildRequires: %{_includedir}/gnu/stubs-32.h
|
BuildRequires: %{_includedir}/gnu/stubs-32.h
|
||||||
Requires: grubby sed coreutils util-linux
|
Requires: sed coreutils
|
||||||
ExclusiveArch: %{ix86} x86_64
|
ExclusiveArch: %{ix86} x86_64
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -53,7 +52,7 @@ to add the %{name} entry to your GRUB boot menu.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
cp -p %{SOURCE6} README.%{readme_suffix}
|
cp -p %{SOURCE5} README.%{readme_suffix}
|
||||||
%patch0 -p1 -b .no-scp
|
%patch0 -p1 -b .no-scp
|
||||||
%patch1 -p1 -b .no-optimization
|
%patch1 -p1 -b .no-optimization
|
||||||
%patch2 -p1 -b .compile-fix
|
%patch2 -p1 -b .compile-fix
|
||||||
@ -80,7 +79,6 @@ install -m644 memtest %{buildroot}/boot/elf-%{name}-%{version}
|
|||||||
# the floppy (memtest.bin) version.
|
# the floppy (memtest.bin) version.
|
||||||
install -m644 memtest.bin %{buildroot}/boot/%{name}-%{version}
|
install -m644 memtest.bin %{buildroot}/boot/%{name}-%{version}
|
||||||
|
|
||||||
install -m755 %{SOURCE2} %{buildroot}%{_sbindir}/new-memtest-pkg
|
|
||||||
install -m755 %{SOURCE1} %{buildroot}%{_sbindir}/memtest-setup
|
install -m755 %{SOURCE1} %{buildroot}%{_sbindir}/memtest-setup
|
||||||
sed -i 's/\r//' $RPM_BUILD_DIR/%{name}-%{version}/README
|
sed -i 's/\r//' $RPM_BUILD_DIR/%{name}-%{version}/README
|
||||||
|
|
||||||
@ -88,32 +86,24 @@ mkdir -p %{buildroot}%{_sysconfdir}/grub.d
|
|||||||
touch %{buildroot}%{_sysconfdir}/grub.d/20_memtest86+
|
touch %{buildroot}%{_sysconfdir}/grub.d/20_memtest86+
|
||||||
|
|
||||||
install -Dd %{buildroot}%{_datadir}/%{name}
|
install -Dd %{buildroot}%{_datadir}/%{name}
|
||||||
install -m644 %{SOURCE3} %{buildroot}%{_datadir}/%{name}
|
install -m644 %{SOURCE2} %{buildroot}%{_datadir}/%{name}
|
||||||
|
|
||||||
# install manual page
|
# install manual page
|
||||||
install -Dpm 0644 %{SOURCE4} %{buildroot}%{_mandir}/man8/memtest-setup.8
|
install -Dpm 0644 %{SOURCE3} %{buildroot}%{_mandir}/man8/memtest-setup.8
|
||||||
|
|
||||||
# install configuration file
|
# install configuration file
|
||||||
install -Dpm 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/memtest86+.conf
|
install -Dpm 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/memtest86+.conf
|
||||||
|
|
||||||
%post
|
%post
|
||||||
%if %{with update_grub}
|
%if %{with update_grub}
|
||||||
/usr/sbin/memtest-setup
|
/usr/sbin/memtest-setup
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%preun
|
|
||||||
if [ -f /boot/grub/grub.conf ]
|
|
||||||
then
|
|
||||||
sed -i -e's,kernel --type=netbsd /elf-%{name}-%{version},kernel /elf-%{name}-%{version},' /boot/grub/grub.conf
|
|
||||||
%{_sbindir}/new-memtest-pkg --remove %{version}
|
|
||||||
fi
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%doc README README.%{readme_suffix}
|
%doc README README.%{readme_suffix}
|
||||||
%config(noreplace) %{_sysconfdir}/memtest86+.conf
|
%config(noreplace) %{_sysconfdir}/memtest86+.conf
|
||||||
/boot/%{name}-%{version}
|
/boot/%{name}-%{version}
|
||||||
/boot/elf-%{name}-%{version}
|
/boot/elf-%{name}-%{version}
|
||||||
%{_sbindir}/new-memtest-pkg
|
|
||||||
%dir %{_datadir}/%{name}
|
%dir %{_datadir}/%{name}
|
||||||
%{_datadir}/%{name}/20_memtest86+
|
%{_datadir}/%{name}/20_memtest86+
|
||||||
%ghost %attr(0755,-,-) %{_sysconfdir}/grub.d/20_memtest86+
|
%ghost %attr(0755,-,-) %{_sysconfdir}/grub.d/20_memtest86+
|
||||||
|
352
new-memtest-pkg
352
new-memtest-pkg
@ -1,352 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Invoked upon installation or removal of a kernel package, the following
|
|
||||||
# tasks are/can be done here:
|
|
||||||
# creation/removal of initrd
|
|
||||||
# run of depmod/removal of depmod generated files
|
|
||||||
# addition/removal of kernel images from grub/lilo configuration (via grubby)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2002, 2003 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
|
|
||||||
PATH=/sbin:/bin:$PATH
|
|
||||||
|
|
||||||
lilo=/usr/sbin/lilo
|
|
||||||
|
|
||||||
# some defaults that are sane for most arches
|
|
||||||
kernelName=elf-memtest86+
|
|
||||||
|
|
||||||
if [ -x ./grubby ]; then
|
|
||||||
grubby=./grubby
|
|
||||||
else
|
|
||||||
grubby=/usr/sbin/grubby
|
|
||||||
fi
|
|
||||||
|
|
||||||
cfgGrub=""
|
|
||||||
cfgLilo=""
|
|
||||||
runLilo=""
|
|
||||||
grubConfig=""
|
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
|
|
||||||
if [ $ARCH = 'ia64' ]; then
|
|
||||||
liloConfig=/boot/efi/EFI/redhat/elilo.conf
|
|
||||||
bootPrefix=/boot/efi/EFI/redhat
|
|
||||||
liloFlag=elilo
|
|
||||||
isx86=""
|
|
||||||
elif [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then
|
|
||||||
liloConfig=/etc/yaboot.conf
|
|
||||||
bootPrefix=/boot
|
|
||||||
lilo=/usr/sbin/ybin
|
|
||||||
kernelName=vmlinux
|
|
||||||
liloFlag=yaboot
|
|
||||||
runLilo="yes"
|
|
||||||
isx86=""
|
|
||||||
elif [ $ARCH = 'sparc' -o $ARCH = 'sparc64' ]; then
|
|
||||||
liloConfig=/etc/silo.conf
|
|
||||||
bootPrefix=/boot
|
|
||||||
liloFlag=silo
|
|
||||||
lilo=/usr/sbin/silo
|
|
||||||
isx86=""
|
|
||||||
elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
|
|
||||||
liloConfig=/etc/zipl.conf
|
|
||||||
bootPrefix=/boot
|
|
||||||
liloFlag=zipl
|
|
||||||
lilo=/usr/sbin/zipl
|
|
||||||
runLilo="yes"
|
|
||||||
isx86=""
|
|
||||||
else
|
|
||||||
# this leaves i?86 and x86_64
|
|
||||||
liloConfig=/etc/lilo.conf
|
|
||||||
grubConfig=/boot/grub/grub.conf
|
|
||||||
bootPrefix=/boot
|
|
||||||
liloFlag=lilo
|
|
||||||
isx86="yes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mode=""
|
|
||||||
version=""
|
|
||||||
initrd=""
|
|
||||||
initrdfile=""
|
|
||||||
moddep=""
|
|
||||||
verbose=""
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2
|
|
||||||
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
|
|
||||||
echo " [--kernel-args=<args>] [--banner=<banner>]" >&2
|
|
||||||
echo " [--kernel-name=<kernel-name>]" >&2
|
|
||||||
echo " <--install | --remove> <kernel-version>" >&2
|
|
||||||
echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
install() {
|
|
||||||
# XXX kernel should be able to be specified also (or work right on ia64)
|
|
||||||
if [ ! -f $bootPrefix/$kernelName-$version ] ; then
|
|
||||||
[ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
INITRD=""
|
|
||||||
if [ -f $initrdfile ]; then
|
|
||||||
[ -n "$verbose" ] && echo "found $initrdfile and using it with grubby"
|
|
||||||
INITRD="--initrd $initrdfile"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME: is this a good heuristic to find out if we're on iSeries?
|
|
||||||
if [ -d /proc/iSeries ]; then
|
|
||||||
[ -n "$verbose" ] && echo "On an iSeries, just making img file"
|
|
||||||
if [ -z $initrdfile ]; then
|
|
||||||
[ -n "$verbose" ] && echo "No initrd, just adding system map"
|
|
||||||
/usr/sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinitrd-$version
|
|
||||||
else
|
|
||||||
/usr/sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinux.sm-$version
|
|
||||||
/usr/sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null
|
|
||||||
rm $bootPrefix/vmlinux.sm-$version
|
|
||||||
fi
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# get the root filesystem to use; if it's on a label/uuid make sure it's
|
|
||||||
# been configured. if not, get the root device from mount
|
|
||||||
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)
|
|
||||||
short=$(echo $rootdevice | cut -d= -f1)
|
|
||||||
if [ "$short" == "LABEL" -o "$short" == "UUID" ]; then
|
|
||||||
if ! /usr/sbin/findfs "$rootdevice" &> /dev/null; then
|
|
||||||
rootdevice=$(mount | awk '$3 == "/" { print $1 }')
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$cfgGrub" ]; then
|
|
||||||
[ -n "$verbose" ] && echo "adding $version to $grubConfig"
|
|
||||||
|
|
||||||
if [ -n "$banner" ]; then
|
|
||||||
title="$banner ($version)"
|
|
||||||
elif [ -f /etc/redhat-release ]; then
|
|
||||||
title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)"
|
|
||||||
else
|
|
||||||
title="Red Hat Linux ($version)"
|
|
||||||
fi
|
|
||||||
# check whether grubby supports --grub argument
|
|
||||||
if /usr/sbin/grubby --help | grep -qe '--grub\W'; then
|
|
||||||
GRUB_ARG="--grub "
|
|
||||||
else
|
|
||||||
GRUB_ARG=
|
|
||||||
fi
|
|
||||||
/usr/sbin/grubby ${GRUB_ARG}--add-kernel=$bootPrefix/$kernelName-$version $INITRD \
|
|
||||||
--copy-default --title "$title" \
|
|
||||||
--args="root=$rootdevice $kernargs" \
|
|
||||||
--remove-kernel="TITLE=$title"
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$cfgLilo" ]; then
|
|
||||||
[ -n "$verbose" ] && echo "adding $version to $liloConfig"
|
|
||||||
|
|
||||||
/usr/sbin/grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD \
|
|
||||||
--copy-default --title $version \
|
|
||||||
--args="root=$rootdevice $kernargs" \
|
|
||||||
--remove-kernel="TITLE=$version" \
|
|
||||||
--$liloFlag
|
|
||||||
|
|
||||||
if [ -n "$runLilo" ]; then
|
|
||||||
[ -n "$verbose" ] && echo "running $lilo"
|
|
||||||
if [ ! -x $lilo ] ; then
|
|
||||||
[ -n "$verbose" ] && echo "$lilo does not exist"
|
|
||||||
else
|
|
||||||
$lilo > /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
remove() {
|
|
||||||
# FIXME: is this a good heuristic to find out if we're on iSeries?
|
|
||||||
if [ -d /proc/iSeries ]; then
|
|
||||||
[ -n "$verbose" ] && echo "On an iSeries, remove img file"
|
|
||||||
rm -f $bootPrefix/$kernelName-$version.img 2>/dev/null
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$cfgGrub" ]; then
|
|
||||||
[ -n "$verbose" ] && echo "removing $version from $grubConfig"
|
|
||||||
/usr/sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$cfgLilo" ]; then
|
|
||||||
[ -n "$verbose" ] && echo "removing $version from $liloConfig"
|
|
||||||
/usr/sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version \
|
|
||||||
--$liloFlag
|
|
||||||
|
|
||||||
if [ -n "$runLilo" ]; then
|
|
||||||
[ -n "$verbose" ] && echo "running $lilo"
|
|
||||||
if [ ! -x $lilo ] ; then
|
|
||||||
[ -n "$verbose" ] && echo "$lilo does not exist"
|
|
||||||
else
|
|
||||||
$lilo > /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
mkinitrd() {
|
|
||||||
[ -n "$verbose" ] && echo "creating initrd $initrdfile using $version"
|
|
||||||
/usr/sbin/mkinitrd -f $initrdfile $version
|
|
||||||
rc=$?
|
|
||||||
if [ $rc != 0 ]; then
|
|
||||||
echo "mkinitrd failed" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
rminitrd() {
|
|
||||||
[ -n "$verbose" ] && echo "removing initrd $initrdfile"
|
|
||||||
[ -f $initrdfile ] && rm -f $initrdfile
|
|
||||||
}
|
|
||||||
|
|
||||||
doDepmod() {
|
|
||||||
[ -n "$verbose" ] && echo "running depmod for $version"
|
|
||||||
depmod -ae -F /boot/System.map-$version $version
|
|
||||||
}
|
|
||||||
|
|
||||||
doRmmoddep() {
|
|
||||||
[ -n "$verbose" ] && echo "removing modules.dep info for $version"
|
|
||||||
[ -d /lib/modules/$version ] && rm -f /lib/modules/$version/modules.*
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case $1 in
|
|
||||||
--mkinitrd)
|
|
||||||
initrd="make"
|
|
||||||
;;
|
|
||||||
|
|
||||||
--rminitrd)
|
|
||||||
initrd="remove"
|
|
||||||
;;
|
|
||||||
|
|
||||||
--initrdfile*)
|
|
||||||
if echo $1 | grep '=' >/dev/null ; then
|
|
||||||
initrdfile=`echo $1 | sed 's/^--initrdfile=//'`
|
|
||||||
else
|
|
||||||
initrdfile=$2
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
--kernel-args*)
|
|
||||||
if echo $1 | grep '=' >/dev/null ; then
|
|
||||||
kernargs=`echo $1 | sed 's/^--kernel-args=//'`
|
|
||||||
else
|
|
||||||
kernargs=$2
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
--banner*)
|
|
||||||
if echo $1 | grep '=' >/dev/null ; then
|
|
||||||
banner=`echo $1 | sed 's/^--banner=//'`
|
|
||||||
else
|
|
||||||
banner=$2
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
--kernel-name*)
|
|
||||||
if echo $1 | grep '=' >/dev/null ; then
|
|
||||||
kernelName=`echo $1 | sed 's/^--kernel-name=//'`
|
|
||||||
else
|
|
||||||
kernelName=$2
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
--depmod)
|
|
||||||
moddep="make"
|
|
||||||
;;
|
|
||||||
|
|
||||||
--rmmoddep)
|
|
||||||
moddep="remove"
|
|
||||||
;;
|
|
||||||
|
|
||||||
-v)
|
|
||||||
verbose=-v
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
if [ -z "$mode" ]; then
|
|
||||||
mode=$1
|
|
||||||
elif [ -z "$version" ]; then
|
|
||||||
version=$1
|
|
||||||
else
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
# make sure the mode is valid
|
|
||||||
if [ "$mode" != "--install" -a "$mode" != "--remove" ] ; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set the initrd file based on arch; ia64 is the only currently known oddball
|
|
||||||
if [ -z "$initrdfile" ]; then
|
|
||||||
if [ `uname -m` = "ia64" ]; then
|
|
||||||
initrdfile="/boot/efi/EFI/redhat/initrd-$version.img"
|
|
||||||
else
|
|
||||||
initrdfile="/boot/initrd-$version.img"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
[ -n "$verbose" ] && echo "initrdfile is $initrdfile"
|
|
||||||
|
|
||||||
if [ "$moddep" == "make" ]; then
|
|
||||||
doDepmod
|
|
||||||
elif [ "$moddep" == "remove" ]; then
|
|
||||||
doRmmoddep
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$initrd" == "make" ]; then
|
|
||||||
mkinitrd
|
|
||||||
elif [ "$initrd" == "remove" ]; then
|
|
||||||
rminitrd
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x $grubby ] ; then
|
|
||||||
[ -n "$verbose" ] && echo "$grubby does not exist"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
[ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1;
|
|
||||||
[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;
|
|
||||||
|
|
||||||
# if we have a lilo config on an x86 box, see if the default boot loader
|
|
||||||
# is lilo to determine if it should be run
|
|
||||||
if [ -n "$cfgLilo" -a -n "$isx86" ]; then
|
|
||||||
runLilo=$($grubby --bootloader-probe | grep lilo)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$mode" == "--install" ]; then
|
|
||||||
install
|
|
||||||
elif [ "$mode" == "--remove" ]; then
|
|
||||||
remove
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
Loading…
Reference in New Issue
Block a user