23 Commits

Author SHA1 Message Date
Benjamin Drung
2334de30e4 kernel/postinst.d: check for correct update-initramfs provider
Ubuntu's dracut package ships an `update-initramfs` command with the
same interface as initramfs-tools'. The difference is that it calls
dracut instead of mkinitramfs.

When installing dracut without purging initramfs-tools,
`/etc/kernel/postinst.d/initramfs-tools` will still execute
`update-initramfs` (in addition to dracut's kernel postinst hook).

So query the newly add `--version` parameter to determine which package
provided the `update-initramfs` script. Only run the kernel postinst
hook when the provider matches.
2025-03-24 11:31:13 +01:00
Benjamin Drung
687cff25b9 Explicitly call "set -e" instead of specifying on shebang
Scripts can be run as `sh $script`. In this case `-e` on the shebang is
ignored.

So explicitly call `set -e` instead of specifying `-e` on the shebang.
2025-01-20 11:27:54 +01:00
Ben Hutchings
181a35c05a update-initramfs: Remove test for direct invocation from kernel package
The direct invocation of update-initramfs in kernel package maintainer
scripts was removed in:

- Debian linux 2.6.39-1, thus in wheezy
- Ubuntu linux 4.15.0-18.19 (I think), thus in bionic
- kernel-package 12.001, thus in Debian squeeze and Ubuntu lucid

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2020-09-01 00:36:46 +01:00
Benjamin Drung
2bab73b939 Disable shellcheck for desired behaviour
Sometimes globbing and word splitting is wanted. Therefore explicitly
disable the check for these line.

Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
2018-12-18 13:37:07 +01:00
Ben Hutchings
1f105591ea kernel hooks: Remove use of update-initramfs -t option
This option no longer does anything since version 0.132.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2018-08-05 02:30:34 +08:00
Ben Hutchings
c48108dc0e Revert "initramfs-tools: Install script to be invoked by linux-signed postinst"
This reverts commit b19d13e7049cc971aeaec30cb06740056407ddf6.
Binary packages built by linux-signed now contain a full kernel
and invoke the same hook scripts.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2016-12-15 20:35:46 +00:00
Ben Hutchings
b19d13e704 initramfs-tools: Install script to be invoked by linux-signed postinst
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2016-04-17 17:31:12 +01:00
Ben Hutchings
07f2c88b2c kernel/postinst.d: Make test for update-initramfs consistent with invocation
We test whether /usr/sbin/update-initramfs exists, but then invoke it
as 'update-initramfs'.  Change the test to look in $PATH.

Closes: #768913
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2016-01-22 03:23:24 +00:00
Petr Baudis
1d6b272f9c initramfs-tools: allow disabling initrd for make deb-pkg
when creating kernel package by other means than make-kpkg
(e.g. using the kernel's make deb-pkg target), initrd creation
cannot be disabled easily, since the appropriate script checks
whether $KERNEL_PACKAGE_VERSION is set, for a reason that seems
entirely unclear to me. The patch below removes the superfluous
check.

Remove it from postrm script too. -maks

Closes: #664171
Signed-off-by: maximilian attems <max@stro.at>
2012-07-22 13:26:10 +02:00
maximilian attems
44b93e0016 initramfs-tools: guard too kernel postrm script
Same story as postinst script.

Signed-off-by: maximilian attems <max@stro.at>
2012-06-06 15:46:47 +02:00
Thomas Lange
c52544d9fd initramfs-tools: kernel script check for update-initramfs executuable
When removing initramfs-tools, it leaves the kernel script around,
which now fails at:
/etc/kernel/postinst.d/initramfs-tools: update-initramfs: not found

Closes: #669345

[ Make that patch applyable -maks ]
Signed-off-by: maximilian attems <max@stro.at>
2012-06-06 15:45:16 +02:00
Ben Hutchings
7866542a5d 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>
2011-03-30 11:43:13 +02:00
Ben Hutchings
58ee42c5eb kernel hooks: Enable error-exit (sh -e)
We should not continue after a command unexpectedly fails.

Change the $INITRD test so that failure is not treated as unexpected.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: maximilian attems <max@stro.at>
Reviewed-by: Michael Prokop <mika@debian.org>
2011-03-30 11:43:03 +02:00
Ben Hutchings
c018886f4f kernel hooks: Treat missing version argument as an error
The version argument is mandatory and we should complain if some package
doesn't pass it rather than quietly failing to do our job.

However, making package removal fail is generally unhelpful, so
continue to return 0 from the postrm hook.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[ Prefix new warnings as of 3a02c6f37d with W: -maks ]
Signed-off-by: maximilian attems <max@stro.at>
Reviewed-by: Michael Prokop <mika@debian.org>
2011-03-30 11:42:34 +02:00
Stephen Powell
ff6116f97b Redirect STDOUT to STDERR for post{inst,rm} hooks
Avoids output being swallowed by debconf's redirection of STDOUT.

Signed-off-by: maximilian attems <maks@debian.org>
2010-07-08 15:09:03 +02:00
Stephen Powell
09d251adb6 postinst hook: respect INITRD variable
Do not create an initial RAM file system image for a custom kernel
created by make-kpkg if one was not requested by the --initrd flag of
make-kpkg.

Signed-off-by: maximilian attems <maks@debian.org>
2010-07-08 15:09:03 +02:00
maximilian attems
3158f65132 kernel hook scripts: add comments
try to make the intention of the code more clear

Reported-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: maximilian attems <maks@debian.org>
2009-10-01 00:06:44 +02:00
maximilian attems
339235ef8f kernel hook scripts: Fix typo
/etc/kernel/postrm.d/initramfs-tools: line 12: =: command not found

It says:

  ${bootdir}= $(dirname "$2")

which should be:

  bootdir=$(dirname "$2")

Tested-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: maximilian attems <maks@debian.org>
2009-10-01 00:01:18 +02:00
maximilian attems
02cb277c7e /etc/kernel/postrm.d/i-t: use now takeover on delete
makes the script idempotent
(closes: #547365)

Reported-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: maximilian attems <maks@debian.org>
2009-09-25 19:49:51 +02:00
maximilian attems
072ad3179c /etc/kernel hook script support newer kernel-package
k-p no longer generates initramfs by itself,
so do it for it.

(closes: #523735)
2009-09-25 07:54:24 +02:00
Andres Salomon
7812c98cca initramfs-tools: Readd support for linux-2.6 make deb-pkg target.
..via /etc/kernel

Signed-off-by: Andres Salomon <dilinger@debian.org>

(closes: #504551)

[ fixed update-initramfs postinst call s/-u/-c/ -maks ]
Signed-off-by: maximilian attems <maks@debian.org>
2009-02-17 15:43:03 +01:00
maximilian attems
04356cfcee Revert "initramfs-tools: Add support for linux-2.6 make deb-pkg target"
This reverts commit c5a45496b9c72e41333e213979d43fbcff34da9f.

hinders removal of other package linux-image postinst call also
the /etc/kernel structure, thus delete needs a takeover and this
is postlenny material.

thanks Vincent Danjean <vdanjean@debian.org> for report.

(closes: #499270)
2008-09-17 15:36:16 +02:00
maximilian attems
c5a45496b9 initramfs-tools: Add support for linux-2.6 make deb-pkg target
it generates linux images that look into this directories
for maintainer script action.

make sure to generate an intramfs and also to remove it.
2008-09-16 14:54:06 +02:00