diff options
author | Niels Thykier <niels@thykier.net> | 2018-05-18 18:35:28 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2018-05-18 18:35:59 +0000 |
commit | 41f1ca9ed464300f5a84c9aebbf699e8b0e77928 (patch) | |
tree | e56c7af24d7a25816f8ff5d7c6a7924807e4c794 | |
parent | 3533ce28a8770f824e6fcaf7a2ed3c0b0b7a9406 (diff) | |
download | debhelper-41f1ca9ed464300f5a84c9aebbf699e8b0e77928.tar.gz |
dh_installinitramfs: New helper tool
-rw-r--r-- | autoscripts/postinst-initramfs-hook | 5 | ||||
-rw-r--r-- | autoscripts/postrm-initramfs-hook | 5 | ||||
-rw-r--r-- | debhelper.pod | 8 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rwxr-xr-x | dh | 1 | ||||
-rwxr-xr-x | dh_installinitramfs | 88 |
6 files changed, 110 insertions, 0 deletions
diff --git a/autoscripts/postinst-initramfs-hook b/autoscripts/postinst-initramfs-hook new file mode 100644 index 00000000..7785c643 --- /dev/null +++ b/autoscripts/postinst-initramfs-hook @@ -0,0 +1,5 @@ +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + if [ -x /usr/sbin/update-initramfs ] && [ -e /etc/initramfs-tools/initramfs.conf ]; then + update-initramfs -u + fi +fi diff --git a/autoscripts/postrm-initramfs-hook b/autoscripts/postrm-initramfs-hook new file mode 100644 index 00000000..9f688943 --- /dev/null +++ b/autoscripts/postrm-initramfs-hook @@ -0,0 +1,5 @@ +if [ "$1" = "remove" ]; then + if [ -x /usr/sbin/update-initramfs ] && [ -e /etc/initramfs-tools/initramfs.conf ]; then + update-initramfs -u + fi +fi diff --git a/debhelper.pod b/debhelper.pod index 0635951c..16e9aea2 100644 --- a/debhelper.pod +++ b/debhelper.pod @@ -798,6 +798,14 @@ the B<dwz> sequence obsolete and it will now fail with an error. If you want to skip B<dh_dwz>, then please insert an empty I<override_dh_dwz> target in F<debian/rules>. +=item - + +The B<dh_installinitramfs> tool automatically generates the maintainer +script snippets when it detects an initramfs hook script in the package. + +Previously, it would only generate these snippets when it installed +the hook itself. + =back =back diff --git a/debian/changelog b/debian/changelog index 81a1927e..fb602ab2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -53,6 +53,9 @@ debhelper (11.3) UNRELEASED; urgency=medium * Dh_Lib.pm: Re-organise exports. * Dh_Lib.pm: Retract "print_and_complex_doit"; the only potential consumer went with a different code snippet. + * dh_installinitramfs: New tool to install initramfs hook scripts and + handle related maintscripts. Thanks to Evgeni Golov for the + suggestion. (Closes: #491027) [ Dmitry Shachnev ] * qmake.pm: Use ${DEB_HOST_GNU_TYPE}-qmake wrapper for @@ -416,6 +416,7 @@ qw{ dh_installppp dh_installudev dh_installgsettings + dh_installinitramfs dh_bugfiles dh_ucf dh_lintian diff --git a/dh_installinitramfs b/dh_installinitramfs new file mode 100755 index 00000000..7b832031 --- /dev/null +++ b/dh_installinitramfs @@ -0,0 +1,88 @@ +#!/usr/bin/perl + +=head1 NAME + +dh_installinitramfs - install initramfs hooks and setup maintscripts + +=cut + +use strict; +use warnings; +use Debian::Debhelper::Dh_Lib; + +our $VERSION = DH_BUILTIN_VERSION; + +=head1 SYNOPSIS + +B<dh_installinitramfs> [S<B<debhelper options>>] [B<-n>] + +=head1 DESCRIPTION + +B<dh_installinitramfs> is a debhelper program that is responsible for +installing Debian package provided initramfs hooks. + +If B<dh_installinitramfs> installs or (in compat 12 or later) detects +one or more initramfs hooks in the package, then it also automatically +generates the F<postinst> and F<postrm> commands needed to interface +with the Debian initramfs system. These commands are inserted into +the maintainer scripts by L<dh_installdeb(1)>. + +=head1 FILES + +=over 4 + +=item debian/I<package>.initramfs-hook + +Assumed to be an initramfs hook that will be installed into F<< +usr/share/initramfs-tools/hooks/I<package> >> in the package build +directory. See B<HOOK SCRIPTS> in L<initramfs-tools(8)> for more +information about initramfs hooks. + +=back + +=head1 OPTIONS + +=over 4 + +=item B<-n>, B<--no-scripts> + +Do not modify F<postinst>/F<postrm> scripts. + +=back + +=cut + +init(); + +# PROMISE: DH NOOP WITHOUT initramfs-hook tmp(usr/share/initramfs-tools/hooks) + +foreach my $package (@{$dh{DOPACKAGES}}) { + my $tmp = tmpdir($package); + my $hook_script = pkgfile($package, 'initramfs-hook'); + my $has_hooks; + my $hook_dir = "${tmp}/usr/share/initramfs-tools/hooks"; + + if ($hook_script ne '') { + install_dir($hook_dir); + install_file($hook_script, "${hook_dir}/${package}"); + $has_hooks = 1; + } elsif (-d $hook_dir and not is_empty_dir($hook_dir) and not compat(11)) { + $has_hooks = 1; + + } + + if ($has_hooks && ! $dh{NOSCRIPTS}) { + autoscript($package, 'postinst', 'postinst-initramfs-hook'); + autoscript($package, 'postrm', 'postrm-initramfs-hook') + } +} + +=head1 SEE ALSO + +L<debhelper(7)> +L<update-initramfs(8)> +L<initramfs-tools(8)> + +This program is a part of debhelper. + +=cut |