Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: deb-pkg: allow hooks also in /usr/share/kernel

By passing an additional directory to run-parts, allow Debian and its
derivatives to ship maintainer scripts in /usr while at the same time
allowing the local admin to override or disable them by placing hooks of
the same name in /etc. This adds support for the mechanism described in
the UAPI Configuration Files Specification for kernel hooks. The same
idea is also used by udev, systemd or modprobe for their config files.
https://uapi-group.org/specifications/specs/configuration_files_specification/

This functionality relies on run-parts 5.21 or later. It is the
responsibility of packages installing hooks into /usr/share/kernel to
also declare a Depends: debianutils (>= 5.21).

KDEB_HOOKDIR can be used to change the list of directories that is
searched. By default, /etc/kernel and /usr/share/kernel are hook
directories. Since the list of directories in KDEB_HOOKDIR is separated
by spaces, the paths must not contain the space character themselves.

Signed-off-by: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Johannes Schauer Marin Rodrigues and committed by
Masahiro Yamada
ac2c30f9 d9ecb92b

+16 -6
+16 -6
scripts/package/builddeb
··· 5 5 # 6 6 # Simple script to generate a deb package for a Linux kernel. All the 7 7 # complexity of what to do with a kernel after it is installed or removed 8 - # is left to other scripts and packages: they can install scripts in the 9 - # /etc/kernel/{pre,post}{inst,rm}.d/ directories (or an alternative location 10 - # specified in KDEB_HOOKDIR) that will be called on package install and 11 - # removal. 8 + # is left to other scripts and packages. Scripts can be placed into the 9 + # preinst, postinst, prerm and postrm directories in /etc/kernel or 10 + # /usr/share/kernel. A different list of search directories can be given 11 + # via KDEB_HOOKDIR. Scripts in directories earlier in the list will 12 + # override scripts of the same name in later directories. The script will 13 + # be called on package installation and removal. 12 14 13 15 set -eu 14 16 ··· 76 74 # kernel packages, as well as kernel packages built using make-kpkg. 77 75 # make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and 78 76 # so do we; recent versions of dracut and initramfs-tools will obey this. 79 - debhookdir=${KDEB_HOOKDIR:-/etc/kernel} 77 + debhookdir=${KDEB_HOOKDIR:-/etc/kernel /usr/share/kernel} 80 78 for script in postinst postrm preinst prerm; do 81 79 mkdir -p "${pdir}/DEBIAN" 82 80 cat <<-EOF > "${pdir}/DEBIAN/${script}" ··· 90 88 # Tell initramfs builder whether it's wanted 91 89 export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) 92 90 93 - test -d ${debhookdir}/${script}.d && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" ${debhookdir}/${script}.d 91 + # run-parts will error out if one of its directory arguments does not 92 + # exist, so filter the list of hook directories accordingly. 93 + hookdirs= 94 + for dir in ${debhookdir}; do 95 + test -d "\$dir/${script}.d" || continue 96 + hookdirs="\$hookdirs \$dir/${script}.d" 97 + done 98 + hookdirs="\${hookdirs# }" 99 + test -n "\$hookdirs" && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs 94 100 exit 0 95 101 EOF 96 102 chmod 755 "${pdir}/DEBIAN/${script}"