update-initramfs: Depend on kernel hook scripts rather than $ramdisk invocation

Official Debian and Ubuntu kernel packages will invoke us directly as
part of the $ramdisk handling inherited from kernel-package.  They
will later run our hook script, as will custom packages made with
'make-kpkg' or the upstream 'make deb-pkg'.

Currently, for official packages we perform an update on the first
invocation (possibly deferred using dpkg triggers) and then ignore the
second.  However, the long-term plan is to remove that first
invocation.  Therefore, ignore the first invocation and perform the
update on the second.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[ Use && op, we make the effort to not use -a evaluation. -maks ]
Signed-off-by: maximilian attems <max@stro.at>
Reviewed-by: Michael Prokop <mika@debian.org>
This commit is contained in:
Ben Hutchings 2011-03-04 12:55:26 +00:00 committed by maximilian attems
parent 58ee42c5eb
commit 7866542a5d
3 changed files with 40 additions and 35 deletions

View File

@ -9,19 +9,16 @@ if [ -z "${version}" ]; then
exit 2
fi
# kernel-package passes an extra arg
# exit if custom kernel does not need an initramfs
if [ -n "${KERNEL_PACKAGE_VERSION}" ] && [ "$INITRD" = 'No' ]; then
exit 0
fi
# absolute file name of kernel image may be passed as a second argument;
# create the initrd in the same directory
if [ -n "$2" ]; then
if [ -n "${KERNEL_PACKAGE_VERSION}" ]; then
# exit if custom kernel does not need an initramfs
if [ "$INITRD" = 'No' ]; then
exit 0
fi
bootdir=$(dirname "$2")
bootopt="-b ${bootdir}"
else
# official Debian linux-images take care themself
exit 0
fi
bootdir=$(dirname "$2")
bootopt="-b ${bootdir}"
fi
# avoid running multiple times
@ -33,4 +30,4 @@ if [ -n "$DEB_MAINT_PARAMS" ]; then
fi
# we're good - create initramfs. update runs do_bootloader
update-initramfs -c -t -k "${version}" ${bootopt} >&2
INITRAMFS_TOOLS_KERNEL_HOOK=1 update-initramfs -c -t -k "${version}" ${bootopt} >&2

View File

@ -9,19 +9,16 @@ if [ -z "${version}" ]; then
exit 0
fi
# kernel-package passes an extra arg
# exit if custom kernel does not need an initramfs
if [ -n "${KERNEL_PACKAGE_VERSION}" ] && [ "$INITRD" = 'No' ]; then
exit 0
fi
# absolute file name of kernel image may be passed as a second argument;
# create the initrd in the same directory
if [ -n "$2" ]; then
if [ -n "${KERNEL_PACKAGE_VERSION}" ]; then
# exit if custom kernel does not need an initramfs
if [ "$INITRD" = 'No' ]; then
exit 0
fi
bootdir=$(dirname "$2")
bootopt="-b ${bootdir}"
else
# official linux-images take care themself
exit 0
fi
bootdir=$(dirname "$2")
bootopt="-b ${bootdir}"
fi
# avoid running multiple times
@ -33,4 +30,4 @@ if [ -n "$DEB_MAINT_PARAMS" ]; then
fi
# delete initramfs
update-initramfs -d -t -k "${version}" ${bootopt} >&2
INITRAMFS_TOOLS_KERNEL_HOOK=1 update-initramfs -d -t -k "${version}" ${bootopt} >&2

View File

@ -14,17 +14,28 @@ set -e
[ -r ${CONF} ] && . ${CONF}
if $USETRIGGERS \
&& [ x"${DPKG_MAINTSCRIPT_PACKAGE:-}" != x ] \
&& [ $# = 1 ] \
&& [ x"$1" = x-u ] \
&& dpkg-trigger --check-supported 2>/dev/null
then
if dpkg-trigger --no-await update-initramfs; then
echo "update-initramfs: deferring update (trigger activated)"
case "$DPKG_MAINTSCRIPT_PACKAGE" in
linux-image-*)
if [ -z "$INITRAMFS_TOOLS_KERNEL_HOOK" ]; then
# kernel maintainer script called us directly; ignore
# it and let the hook script handle it instead
echo "update-initramfs: deferring update (hook will be called later)"
exit 0
fi
fi
;;
?*)
if $USETRIGGERS \
&& [ $# = 1 ] \
&& [ x"$1" = x-u ] \
&& dpkg-trigger --check-supported 2>/dev/null
then
if dpkg-trigger --no-await update-initramfs; then
echo "update-initramfs: deferring update (trigger activated)"
exit 0
fi
fi
;;
esac
usage()
{