From 53da9d8d7a266f719bcb8eee811a3bb6b40012dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Sun, 31 May 2020 21:39:55 -0300 Subject: [PATCH] dracut: add EFI kernel hook. - small formatting changes - use relative path in kernel-hook-postrm --- srcpkgs/dracut/files/dracut-uefi-hook.confd | 19 +++++++++++++++ srcpkgs/dracut/files/kernel-hook-postrm | 4 ++-- .../dracut/files/kernel-uefi-hook-postinst | 23 +++++++++++++++++++ srcpkgs/dracut/files/kernel-uefi-hook-postrm | 20 ++++++++++++++++ srcpkgs/dracut/template | 22 ++++++++++++++---- 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 srcpkgs/dracut/files/dracut-uefi-hook.confd create mode 100644 srcpkgs/dracut/files/kernel-uefi-hook-postinst create mode 100644 srcpkgs/dracut/files/kernel-uefi-hook-postrm diff --git a/srcpkgs/dracut/files/dracut-uefi-hook.confd b/srcpkgs/dracut/files/dracut-uefi-hook.confd new file mode 100644 index 00000000000..fc96090b38d --- /dev/null +++ b/srcpkgs/dracut/files/dracut-uefi-hook.confd @@ -0,0 +1,19 @@ +# Options for the dracut-uefi kernel hook script installed by the dracut package. + +# To enable EFI bundle creation in dracut, uncomment +#CREATE_UEFI_BUNDLES=yes +# This requires an EFI stub, usually provided by the gummiboot package, +# as well as setting the kernel command line. +# Booting without a kernel command line is unsupported. + +# You can set the kernel command line with +#KERNEL_CMDLINE="loglevel=4 slub_debug=P page_poison=1" +# or by setting kernel_cmdline in a dracut.conf(5) file. +# The bundle can also use the command line from a bootloader / boot manager +# if Secure Boot is disabled. + +# You can set command line options for the dracut command +#DRACUT_OPTIONS= + +# Output directory for the EFI bundle +#UEFI_BUNDLE_DIR="boot/efi/EFI/void/" diff --git a/srcpkgs/dracut/files/kernel-hook-postrm b/srcpkgs/dracut/files/kernel-hook-postrm index f35d076193b..f99458a4bfa 100644 --- a/srcpkgs/dracut/files/kernel-hook-postrm +++ b/srcpkgs/dracut/files/kernel-hook-postrm @@ -7,7 +7,7 @@ PKGNAME="$1" VERSION="$2" -if [ -f /boot/initramfs-${VERSION}.img ]; then - rm -f /boot/initramfs-${VERSION}.img +if [ -f boot/initramfs-${VERSION}.img ]; then + rm -f boot/initramfs-${VERSION}.img fi exit $? diff --git a/srcpkgs/dracut/files/kernel-uefi-hook-postinst b/srcpkgs/dracut/files/kernel-uefi-hook-postinst new file mode 100644 index 00000000000..d623c3f86df --- /dev/null +++ b/srcpkgs/dracut/files/kernel-uefi-hook-postinst @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Kernel post-install hook for dracut EFI bundle. +# +# Arguments passed to this script: $1 pkgname, $2 version. +# +PKGNAME="$1" +VERSION="$2" + +. "${ROOTDIR}/etc/default/dracut-uefi-hook" +if [ -z "${CREATE_UEFI_BUNDLES}" ]; then + exit 0 +fi + +if [ ! -x bin/dracut ]; then + exit 0 +fi + +mkdir -p ${UEFI_BUNDLE_DIR:=boot/efi/EFI/void} + +dracut -q --force ${KERNEL_CMDLINE:+--kernel-cmdline="${KERNEL_CMDLINE}"} ${DRACUT_OPTIONS} \ + --uefi ${UEFI_BUNDLE_DIR}/linux-${VERSION}.efi ${VERSION} +exit $? diff --git a/srcpkgs/dracut/files/kernel-uefi-hook-postrm b/srcpkgs/dracut/files/kernel-uefi-hook-postrm new file mode 100644 index 00000000000..09b90fe623e --- /dev/null +++ b/srcpkgs/dracut/files/kernel-uefi-hook-postrm @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Kernel post-remove hook for dracut EFI bundle. +# +# Arguments passed to this script: $1 pkgname, $2 version. +# +PKGNAME="$1" +VERSION="$2" + +. "${ROOTDIR}/etc/default/dracut-uefi-hook" +if [ -z "${CREATE_UEFI_BUNDLES}" ]; then + exit 0 +fi + +: "${UEFI_BUNDLE_DIR:=boot/efi/EFI/void}" + +if [ -f "${UEFI_BUNDLE_DIR}/linux-${VERSION}.efi" ]; then + rm -fv "${UEFI_BUNDLE_DIR}/linux-${VERSION}.efi" +fi +exit $? diff --git a/srcpkgs/dracut/template b/srcpkgs/dracut/template index b11335d06e3..ed9c0e8def0 100644 --- a/srcpkgs/dracut/template +++ b/srcpkgs/dracut/template @@ -1,7 +1,7 @@ # Template file for 'dracut' pkgname=dracut version=050 -revision=3 +revision=4 build_style=configure configure_args="--prefix=/usr --sysconfdir=/etc" conf_files="/etc/dracut.conf" @@ -16,8 +16,8 @@ distfiles="https://github.com/dracutdevs/dracut/archive/${version}.tar.gz" checksum=f9dbf18597e5929221365964293212c8c9ffb7d84529c5a338c834ecab06e333 make_dirs=" - /etc/dracut.conf.d 0755 root root - /usr/lib/dracut/dracut.conf.d 0755 root root" + /etc/dracut.conf.d 0755 root root + /usr/lib/dracut/dracut.conf.d 0755 root root" case "$XBPS_TARGET_MACHINE" in *-musl) # Add musl-fts implementation @@ -25,6 +25,13 @@ case "$XBPS_TARGET_MACHINE" in ;; esac +case "$XBPS_TARGET_MACHINE" in + i686*|x86_64*|aarch64*) # EFI bundle config and hooks + _efi_bundle=1 + conf_files+=" /etc/default/dracut-uefi-hook" + ;; +esac + do_build() { case "$XBPS_TARGET_MACHINE" in *-musl) make ${makejobs} LDLIBS="-lfts" ;; @@ -40,6 +47,13 @@ post_install() { # kernel hooks. vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 20-dracut vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 20-dracut + + if [ "${_efi_bundle}" ]; then + vinstall ${FILESDIR}/dracut-uefi-hook.confd 644 etc/default dracut-uefi-hook + vinstall ${FILESDIR}/kernel-uefi-hook-postinst 755 etc/kernel.d/post-install 20-dracut-uefi + vinstall ${FILESDIR}/kernel-uefi-hook-postrm 755 etc/kernel.d/post-remove 20-dracut-uefi + fi + # We don't need the systemd stuff. rm -rf ${DESTDIR}/usr/lib/dracut/modules.d/*systemd* rm -f ${DESTDIR}/usr/share/man/man8/*.service.* @@ -52,7 +66,7 @@ dracut-network_package() { archs=noarch pkg_install() { for f in 40network 90livenet 95fcoe 95iscsi \ - 95nbd 95nfs 95zfcp 95znet; do + 95nbd 95nfs 95zfcp 95znet; do vmove usr/lib/dracut/modules.d/${f} done }