From 45565277bb41b10f6bb653f5193c6e533c054bda Mon Sep 17 00:00:00 2001 From: prez Date: Sun, 18 Aug 2019 19:38:33 +0200 Subject: [PATCH] lilo: add configuration file for kernel hook Optionally allow the post-install hook to replace /etc/lilo.conf with one that uses the newest kernel --- srcpkgs/lilo/files/kernel.d/lilo.post-install | 33 +++++++++++++++++-- srcpkgs/lilo/files/kernel.d/lilo.post-remove | 14 -------- srcpkgs/lilo/files/lilo-kernel-hook.confd | 18 ++++++++++ srcpkgs/lilo/template | 8 +++-- 4 files changed, 54 insertions(+), 19 deletions(-) delete mode 100644 srcpkgs/lilo/files/kernel.d/lilo.post-remove create mode 100644 srcpkgs/lilo/files/lilo-kernel-hook.confd diff --git a/srcpkgs/lilo/files/kernel.d/lilo.post-install b/srcpkgs/lilo/files/kernel.d/lilo.post-install index 58fce923e62..c37c5cbb585 100644 --- a/srcpkgs/lilo/files/kernel.d/lilo.post-install +++ b/srcpkgs/lilo/files/kernel.d/lilo.post-install @@ -7,7 +7,36 @@ PKGNAME="$1" VERSION="$2" -[ -x "$(command -v lilo)" ] || \ +if [ ! -x "$(command -v lilo)" ] || [ ! -f /etc/lilo.conf ]; then exit 0 +fi -[ -f /etc/lilo.conf ] && lilo +. "${ROOTDIR}/etc/default/lilo-kernel-hook" +if [ -z "${MODIFY_LILO_CONF}" ] || [ -z "${BOOT}" ] || [ -z "${ROOT}" ]; then + lilo + exit 0 +fi + +cat < /etc/lilo.conf +lba32 +compact +read-only +map="/boot/System.map-${VERSION}" +boot=${BOOT} + +image="/boot/vmlinuz-${VERSION}" +EOF +if [ -n "${OPTIONS}" ]; then + echo " append=\"${OPTIONS}\"" >> /etc/lilo.conf +fi +if [ -n "${INITRD_ENABLED}" ]; then + echo " initrd=\"/boot/initramfs-${VERSION}.img\"" >> /etc/lilo.conf +fi +case "$ROOT" in + "PARTUUID"*) + echo " addappend=\" root=${ROOT}\"" >> /etc/lilo.conf ;; + *) + echo " root=\"${ROOT}\"" >> /etc/lilo.conf ;; +esac + +lilo diff --git a/srcpkgs/lilo/files/kernel.d/lilo.post-remove b/srcpkgs/lilo/files/kernel.d/lilo.post-remove deleted file mode 100644 index 9826229855e..00000000000 --- a/srcpkgs/lilo/files/kernel.d/lilo.post-remove +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# Kernel hook for LILO. -# -# Arguments passed to this script: $1 pkgname, $2 version. -# -PKGNAME="$1" -VERSION="$2" - -[ -x "$(command -v lilo)" ] || \ - exit 0 - -# Do not abort kernel removal on error. -[ -f /etc/lilo.conf ] && lilo || true diff --git a/srcpkgs/lilo/files/lilo-kernel-hook.confd b/srcpkgs/lilo/files/lilo-kernel-hook.confd new file mode 100644 index 00000000000..8ea0951f1a9 --- /dev/null +++ b/srcpkgs/lilo/files/lilo-kernel-hook.confd @@ -0,0 +1,18 @@ +# Options for the kernel hook script installed by the 'lilo' package. +# +# To allow the kernel hook to overwrite the lilo configuration file, set MODIFY_LILO_CONF=yes +# Do not use this mechanism if more than one root device or kernel is needed. +MODIFY_LILO_CONF="" +# +# To boot without an initrd, unset INITRD_ENABLED +INITRD_ENABLED=yes +# +# Disk where new boot sector should be written to. Passed as global option to lilo. Example: +#BOOT="/dev/sda" +# +# Root device passed as global option to lilo. +# Can also be a PARTUUID, even though lilo does not have proper support for it. Example: +#ROOT="LABEL=void" +# +# Kernel command-line options. Example: +#OPTIONS="loglevel=4 slub_debug=P page_poison=1" diff --git a/srcpkgs/lilo/template b/srcpkgs/lilo/template index 0a757995d97..986260e1bdf 100644 --- a/srcpkgs/lilo/template +++ b/srcpkgs/lilo/template @@ -1,7 +1,7 @@ # Template file for 'lilo' pkgname=lilo version=24.2 -revision=3 +revision=4 archs="i686* x86_64*" hostmakedepends="bin86" makedepends="device-mapper-devel" @@ -12,6 +12,8 @@ homepage="http://www.joonet.de/lilo" distfiles="${DEBIAN_SITE}/main/l/${pkgname}/${pkgname}_${version}.orig.tar.gz" checksum=e158f19de4560c935ebe0507c21b79bff17618b9230d8076fe8c5fff9fdbd5b1 +conf_files="/etc/default/lilo-kernel-hook" + pre_build() { sed -i Makefile src/Makefile \ -e 's|^\tmake|\t$(MAKE)|g' \ @@ -25,6 +27,7 @@ do_build() { do_install() { vmkdir usr/bin + vmkdir etc/ make DESTDIR=${DESTDIR} install mv ${DESTDIR}/sbin/* ${DESTDIR}/usr/bin mv ${DESTDIR}/usr/sbin/* ${DESTDIR}/usr/bin @@ -36,10 +39,9 @@ do_install() { # Setup kernel hooks rm -rf ${DESTDIR}/etc/initramfs ${DESTDIR}/etc/kernel + vinstall "${FILESDIR}/lilo-kernel-hook.confd" 644 etc/default lilo-kernel-hook vinstall ${FILESDIR}/kernel.d/lilo.post-install 750 \ etc/kernel.d/post-install 50-lilo - vinstall ${FILESDIR}/kernel.d/lilo.post-remove 750 \ - etc/kernel.d/post-remove 50-lilo vlicense COPYING }