Removed some spec artifacts (like buildroot cleaning)

- Fixed malformed "Loading" banner
- Introduced new configuration file (/etc/memtest86+.conf)
- Introduced new memtest-setup switches for selecting ELF/non-ELF versions
  Resolves: rhbz#1303804
This commit is contained in:
Jaroslav Škarvada 2016-02-23 17:02:36 +01:00
parent d552800479
commit 05c6babd98
6 changed files with 142 additions and 45 deletions

View File

@ -34,6 +34,20 @@ else
OS="${GRUB_DISTRIBUTOR} Memtest" OS="${GRUB_DISTRIBUTOR} Memtest"
fi fi
CONF_FILE="/etc/memtest86+.conf"
CONF_ELF_VAR="INSTALL_ELF"
MEMTEST86_ELF=`[ -r "$CONF_FILE" ] && sed -n "/^\s*${CONF_ELF_VAR}\s*=/ {s/^\s*${CONF_ELF_VAR}\s*=\s*\(.*\)$/\1/; T end; s/\s*\(\S\)*\s*/\1/; p; :end}" "$CONF_FILE" 2>/dev/null`
if [ "x${MEMTEST86_ELF}" = "x" ] || [ "x${MEMTEST86_ELF}" = "x1" ] || [ "x${MEMTEST86_ELF}" = "xtrue" ]; then
MEMTEST86_ELF=1
BANNER_SUFFIX=
IMAGE="elf-memtest"
else
MEMTEST86_ELF=0
IMAGE="memtest"
BANNER_SUFFIX=" (non-ELF)"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but # loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that. # the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in case ${GRUB_DEVICE} in
@ -65,7 +79,7 @@ memtest_entry ()
recovery="$3" recovery="$3"
args="$4" args="$4"
title="$(gettext_quoted "%s %s")" title="$(gettext_quoted "%s %s")"
printf "menuentry '${title}' {\n" "${os}" "${version}" printf "menuentry '${title}${BANNER_SUFFIX}' {\n" "${os}" "${version}"
if [ x$dirname = x/ ]; then if [ x$dirname = x/ ]; then
@ -79,22 +93,30 @@ memtest_entry ()
fi fi
printf '%s\n' "${prepare_boot_cache}" printf '%s\n' "${prepare_boot_cache}"
fi fi
message="$(gettext_printf "Loading %s %s ..." ${os} ${version})" message="$(gettext_printf "Loading %s %s ..." "${os}" "${version}")"
if [ "x${MEMTEST86_ELF}" = "x1" ]; then
cat << EOF cat << EOF
insmod bsd insmod bsd
echo '$message' echo '$message'
knetbsd ${rel_dirname}/${basename} knetbsd ${rel_dirname}/${basename}
} }
EOF EOF
else
cat << EOF
echo '$message'
linux16 ${rel_dirname}/${basename}
}
EOF
fi
} }
case x`uname -m` in case x`uname -m` in
xi?86 | xx86_64) xi?86 | xx86_64)
list=`for i in /boot/elf-memtest* ; do list=`for i in /boot/${IMAGE}* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` ;; done` ;;
*) *)
list=`for i in /boot/elf-memtest* ; do list=`for i in /boot/${IMAGE}* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` ;; done` ;;
esac esac

17
README
View File

@ -11,13 +11,20 @@ This is not done automatically because it could overwrite any custom changes
in /boot/grub2/grub.cfg. in /boot/grub2/grub.cfg.
By default ELF version of memtest86+ is installed, which should work on most of By default ELF version of memtest86+ is installed, which should work on most of
the systems. In case it doesn't work for you, you can try the non-ELF version: the systems. In case it doesn't work for you, you can try to install the non-ELF
version by running:
- in your grub.conf (usually /etc/grub.conf) locate the line containing: # memtest-setup -b
kernel --type=netbsd /elf-memtest86+-VERSION
- edit it to contain: Or with GRUB 2 you can switch between ELF and non-ELF versions of memtest86+
kernel /memtest86+-VERSION by using INSTALL_ELF variable from /etc/memtest86+.conf. Setting it to '1'
will instruct GRUB 2 to install ELF version of memtest86+ and setting it
to '0' will instruct GRUB2 to install non-ELF version. If the variable
is empty or unset, the ELF version is installed (it's due to backward
compatibility). For the change to take effect you need to regenerate your
GRUB 2 config by running:
# grub2-mkconfig -o /boot/grub2/grub.cfg
The non-ELF version is known to cause various problems and it may not work on The non-ELF version is known to cause various problems and it may not work on
several systems. That's why the ELF version is installed by default. several systems. That's why the ELF version is installed by default.

View File

@ -3,12 +3,27 @@
# package name # package name
PNAME="memtest86+" PNAME="memtest86+"
# executable # binary image
ENAME="elf-memtest86+" 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
CONF_FILE="/etc/memtest86+.conf"
# GRUB2 environment variable to control image type
CONF_VAR="INSTALL_ELF"
# whether to install ELF image
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 [OPTIONS]
@ -24,12 +39,27 @@ This is not done automatically because it could overwrite any custom changes
in /boot/grub2/grub.cfg. in /boot/grub2/grub.cfg.
OPTIONS: OPTIONS:
-e , --elf installs ELF image (the default)
-b , --bin installs binary image (non-ELF)
-h , --help show this help -h , --help show this help
:EOF :EOF
exit 0 exit 0
fi fi
[ "$1" = "-b" -o "$1" = "--bin" ] && ELF=0
[ "$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 "memtest86+ does not support EFI platforms." echo "memtest86+ does not support EFI platforms."
exit 254 exit 254
@ -41,13 +71,6 @@ if [ -f /boot/grub2/grub.cfg ]; then
echo "ERROR: unable to find /etc/grub.d" echo "ERROR: unable to find /etc/grub.d"
exit 253 exit 253
fi fi
if [ -x /etc/grub.d/$G2TEMPL ]; then
echo "GRUB 2 template is already installed. Exiting..."
exit 252
fi
if [ -f /etc/grub.d/$G2TEMPL ]; then
echo "GRUB 2 template is already in place, only enabling..."
else
if [ ! -r /usr/share/memtest86+/$G2TEMPL ]; then if [ ! -r /usr/share/memtest86+/$G2TEMPL ]; then
echo "ERROR: unable to find GRUB 2 template." echo "ERROR: unable to find GRUB 2 template."
exit 251 exit 251
@ -58,6 +81,10 @@ if [ -f /boot/grub2/grub.cfg ]; then
# EX_IOERR # EX_IOERR
exit 74 exit 74
fi fi
if [ ! -w "$CONF_FILE" ]
then
echo "ERROR: file '$CONF_FILE' is not writable."
exit 250
fi fi
chmod a+x /etc/grub.d/$G2TEMPL chmod a+x /etc/grub.d/$G2TEMPL
echo "GRUB 2 template installed." echo "GRUB 2 template installed."
@ -78,16 +105,24 @@ else
exit 255 exit 255
fi fi
/sbin/new-memtest-pkg --install $MTVERSION --banner="Memtest86+" /sbin/new-memtest-pkg --install $MTVERSION --banner="Memtest86+${BANNER_SUFFIX}" --kernel-name="$ENAME"
RETVAL="$?" RETVAL="$?"
if [ "$RETVAL" != "0" ]; then if [ "$RETVAL" != "0" ]; then
echo "ERROR: grubby failed to configure your bootloader for $MTPATH." echo "ERROR: grubby failed to configure your bootloader for $MTPATH."
exit $RETVAL exit $RETVAL
else else
sed -i -e"s,kernel \(/boot\)\?/$ENAME,kernel --type=netbsd \1/$ENAME," /boot/grub/grub.conf [ "$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 sed -i -e"s,/$ENAME-$MTVERSION.*,/$ENAME-$MTVERSION," /boot/grub/grub.conf
fi fi
fi fi
# update/add configuration variable to the configuration file
if grep -q "^\s*$CONF_VAR\s*=" "$CONF_FILE"
then
sed -i "/^\s*$CONF_VAR\s*=/ s/\(\s*$CONF_VAR\s*=[\"']\?\)[^\"']*\([\"']\?\s*\)/\1${ELF}\2/g" "$CONF_FILE"
else
echo "$CONF_VAR=\"$ELF\"" >> "$CONF_FILE"
fi
echo "Setup complete." echo "Setup complete."

10
memtest86+.conf Normal file
View File

@ -0,0 +1,10 @@
# If INSTALL_ELF is set to 1 or if it is unset/empty, the ELF version of the
# memtest86+ will be installed, otherwise the non-ELF version will be
# installed. If you change this variable, you will have to regenerate your
# grub.conf for the changed to take effect, it is usually done by the
# following command:
#
# grub2-mkconfig -o /boot/grub2/grub.cfg
#
# For details see memtest86+ package documentation.
INSTALL_ELF=1

View File

@ -9,7 +9,7 @@
Name: memtest86+ Name: memtest86+
Version: 5.01 Version: 5.01
Release: 13%{?dist} Release: 14%{?dist}
License: GPLv2 License: GPLv2
Summary: Stand-alone memory tester for x86 and x86-64 computers Summary: Stand-alone memory tester for x86 and x86-64 computers
Group: System Environment/Base Group: System Environment/Base
@ -18,7 +18,8 @@ Source1: memtest-setup
Source2: new-memtest-pkg Source2: new-memtest-pkg
Source3: 20_memtest86+ Source3: 20_memtest86+
Source4: memtest-setup.8 Source4: memtest-setup.8
Source5: README Source5: memtest86+.conf
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
@ -54,7 +55,7 @@ to add the %{name} entry to your GRUB boot menu.
%prep %prep
%setup -q %setup -q
cp -p %{SOURCE5} README.%{readme_suffix} cp -p %{SOURCE6} 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
@ -74,9 +75,7 @@ sed -i -e's,$(LD) -s -T memtest.lds,$(LD) -s -T memtest.lds -z max-page-size=0x1
make make
%install %install
rm -rf %{buildroot} mkdir -p %{buildroot}/{boot,%{_sbindir}}
mkdir -p %{buildroot}/boot
mkdir -p %{buildroot}%{_sbindir}
# the ELF (memtest) version. # the ELF (memtest) version.
install -m644 memtest %{buildroot}/boot/elf-%{name}-%{version} install -m644 memtest %{buildroot}/boot/elf-%{name}-%{version}
@ -97,8 +96,12 @@ install -m644 %{SOURCE3} %{buildroot}%{_datadir}/%{name}
# install manual page # install manual page
install -Dpm 0644 %{SOURCE4} %{buildroot}%{_mandir}/man8/memtest-setup.8 install -Dpm 0644 %{SOURCE4} %{buildroot}%{_mandir}/man8/memtest-setup.8
# install configuration file
install -Dpm 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/memtest86+.conf
%post
%if %{with update_grub} %if %{with update_grub}
%post -p /usr/sbin/memtest-setup /usr/sbin/memtest-setup
%endif %endif
%preun %preun
@ -108,12 +111,9 @@ then
%{_sbindir}/new-memtest-pkg --remove %{version} %{_sbindir}/new-memtest-pkg --remove %{version}
fi fi
%clean
rm -rf %{buildroot}
%files %files
%defattr(-,root,root,-)
%doc README README.%{readme_suffix} %doc README README.%{readme_suffix}
%config(noreplace) %{_sysconfdir}/memtest86+.conf
/boot/%{name}-%{version} /boot/%{name}-%{version}
/boot/elf-%{name}-%{version} /boot/elf-%{name}-%{version}
%{_sbindir}/new-memtest-pkg %{_sbindir}/new-memtest-pkg
@ -124,6 +124,13 @@ rm -rf %{buildroot}
%{_mandir}/man8/*.8.gz %{_mandir}/man8/*.8.gz
%changelog %changelog
* Tue Feb 23 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 5.01-14
- Removed some spec artifacts (like buildroot cleaning)
- Fixed malformed "Loading" banner
- Introduced new configuration file (/etc/memtest86+.conf)
- Introduced new memtest-setup switches for selecting ELF/non-ELF versions
Resolves: rhbz#1303804
* Fri Feb 12 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 5.01-13 * Fri Feb 12 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 5.01-13
- Updated distribution specific README - Updated distribution specific README

View File

@ -75,6 +75,7 @@ usage() {
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2 echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
echo " [--kernel-args=<args>] [--banner=<banner>]" >&2 echo " [--kernel-args=<args>] [--banner=<banner>]" >&2
echo " [--kernel-name=<kernel-name>]" >&2
echo " <--install | --remove> <kernel-version>" >&2 echo " <--install | --remove> <kernel-version>" >&2
echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2 echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2
exit 1 exit 1
@ -127,7 +128,13 @@ install() {
else else
title="Red Hat Linux ($version)" title="Red Hat Linux ($version)"
fi fi
/usr/sbin/grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD \ # 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" \ --copy-default --title "$title" \
--args="root=$rootdevice $kernargs" \ --args="root=$rootdevice $kernargs" \
--remove-kernel="TITLE=$title" --remove-kernel="TITLE=$title"
@ -254,6 +261,15 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
--kernel-name*)
if echo $1 | grep '=' >/dev/null ; then
kernelName=`echo $1 | sed 's/^--kernel-name=//'`
else
kernelName=$2
shift
fi
;;
--depmod) --depmod)
moddep="make" moddep="make"
;; ;;