make builddeb invoke calls to linux-update-symlink
PATCH 1/1 make builddeb invoke calls to linux-update-symlink
The official Debian kernel packages, in addition to running the scripts in /etc/kernel, also runs linux-update-symlinks via the postinst and postrm scripts. This maintains the /vmlinuz and /initrd.img (if it uses an initramfs) symlinks. This change makes the builddeb script generate those same calls.
--- scripts/package/builddeb | 8 ++++++++ 1 file changed, 8 insertions(+)
scripts/package/builddeb +8 -0
@@ -195,6 +195,14 @@ export DEB_MAINT_PARAMS="\$*" # Tell initramfs builder whether it's wanted export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) +$(case $script in +postinst) + echo linux-update-symlinks install $version $installed_image_path + ;; +postrm) + echo linux-update-symlinks remove $version $installed_image_path +esac) + test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 EOF
Signature · 1 line
2.26.0
Hi Ben,
Quoted 2 lines · Jason Self
The official Debian kernel packages,
I'd like to consult you.
Does this patch look OK?
Thanks.
Quoted 33 lines
in addition to running the
scripts in/etc/kernel, also runs linux-update-symlinks via the postinst and postrm scripts. This maintains the /vmlinuz and /initrd.img (if it uses an initramfs) symlinks. This change makes the builddeb script generate those same calls.Signed-off-by Jason Self <[email protected]>--- scripts/package/builddeb | 8 ++++++++ 1 file changed, 8 insertions(+)scripts/package/builddeb +8
-1@@ -195,6 +195,14 @@ export DEB_MAINT_PARAMS="\$*" # Tell initramfs builder whether it's wanted export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) +$(case $script in +postinst) + echo linux-update-symlinks install $version $installed_image_path + ;; +postrm) + echo linux-update-symlinks remove $version $installed_image_path +esac) + test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 EOF --2.26.0
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 8 lines · On Sat, 23 May 2020 02:01:17 +0900 Masahiro Yamada <[email protected]> wrote:
Hi Ben,
Quoted 2 lines · Jason Self
The official Debian kernel packages,
I'd like to consult you.
Does this patch look OK?
No. After submitting the patch I saw that I made a stupid mistake and forgot to terminate one of the case statements and to use /$installed_image_path instead of $installed_image_path so that it provides the absolute path. I can resubmit it with those corrections but have been waiting before doing so in case there is more feedback.
Quoted 7 lines · Masahiro Yamada
Hi Ben,
Quoted 1 line · Jason Self
The official Debian kernel packages,
I'd like to consult you.
Does this patch look OK?
No, it doesn't.
Quoted 19 lines
Quoted 19 lines
in addition to running the
scripts in/etc/kernel, also runs linux-update-symlinks via the postinst and postrm scripts. This maintains the /vmlinuz and /initrd.img (if it uses an initramfs) symlinks. This change makes the builddeb script generate those same calls.Signed-off-by Jason Self <[email protected]>--- scripts/package/builddeb | 8 ++++++++ 1 file changed, 8 insertions(+)scripts/package/builddeb +0
-0@@ -195,6 +195,14 @@ export DEB_MAINT_PARAMS="\$*" # Tell initramfs builder whether it's wanted export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No)
Quoted 7 lines
scripts/package/builddeb export DEB_MAINT_PARAMS="\$*" · line 204
Quoted 7 lines
scripts/package/builddeb +7
-0+$(case $script in +postinst) + echo linux-update-symlinks install $version $installed_image_path + ;; +postrm) + echo linux-update-symlinks remove $version $installed_image_path +esac)
This doesn't handle upgrades properly. The extra conditions in the maintainer scripts for official Debian packages really are needed.
It's also not correct to assume that linux-update-symlinks is always available. If the generated linux-image package depends on "linux-base (>= 4.1~)" then the postinst script can use it unconditionally. However, the postrm script will always have to check whether it is present.
Ben.
Quoted 8 lines
Quoted 6 lines
scripts/package/builddeb +0
-1test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 EOF --2.26.0
Signature · 2 lines
Ben Hutchings Every program is either trivial or else contains at least one bug
PATCH 1/1 make builddeb invoke calls to linux-update-symlinks
The official Debian kernel packages, in addition to running the scripts in /etc/kernel, also runs linux-update-symlinks via the postinst script. This updates the /vmlinuz and /initrd.img (if it uses an initramfs) symlinks to point to the newly installed kernel. This update causes the builddeb script to do the same.
This version of the patch incorporates the feedback from Ben Hutchings.
--- scripts/package/builddeb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
scripts/package/builddeb +31 -0
@@ -195,6 +195,37 @@ export DEB_MAINT_PARAMS="\$*" # Tell initramfs builder whether it's wanted export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) +$(case $script in + postinst) + echo "if [ -f /lib/modules/$version/.fresh-install ]; then + change=install +else + change=upgrade +fi +if command -v linux-update-symlinks > /dev/null; then + linux-update-symlinks $change $version /$installed_image_path +fi +rm -f /lib/modules/$version/.fresh-install" + ;; + postrm) + echo "if command -v linux-update-symlinks > /dev/null; then + linux-update-symlinks remove $version /$installed_image_path +fi" + ;; + preinst) + echo 'if [ "$1" = install ]; then + # Create a flag file for postinst + mkdir -p /lib/modules/$version + touch /lib/modules/$version/.fresh-install +fi' + ;; + prerm) + echo "if command -v linux-check-removal > /dev/null; then + linux-check-removal $version +fi" + ;; +esac) + test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 EOF
Signature · 1 line
2.26.0
Re: [PATCH] make builddeb invoke calls to linux-update-symlinks
Quoted 8 lines · Jason Self
The official Debian kernel packages, in addition to running the scripts in
/etc/kernel, also runs linux-update-symlinks via the postinst script. This updates the /vmlinuz and /initrd.img (if it uses an initramfs) symlinks to point to the newly installed kernel. This update causes the builddeb script to do the same.This version of the patch incorporates the feedback from Ben Hutchings.
Well, partly. You implemented detection of upgrades on the install side, but not on the remove side.
In case of an upgrade, both the old version's prerm and postrm, and the new version's preinst and postinst, will be run:
https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#details-of-unpack-phase-of-installation-or-upgrade
Quoted 19 lines
Signed-off-by Jason Self <[email protected]>--- scripts/package/builddeb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)scripts/package/builddeb +6
-0@@ -195,6 +195,37 @@ export DEB_MAINT_PARAMS="\$*" # Tell initramfs builder whether it's wanted export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) +$(case $script in + postinst) + echo "if [ -f /lib/modules/$version/.fresh-install ]; then + change=install +else + change=upgrade
scripts/package/builddeb export DEB_MAINT_PARAMS="\$*" · line 213
Quoted 10 lines
scripts/package/builddeb +10
-0+fi +if command -v linux-update-symlinks > /dev/null; then + linux-update-symlinks $change $version /$installed_image_path +fi +rm -f /lib/modules/$version/.fresh-install" + ;; + postrm) + echo "if command -v linux-update-symlinks > /dev/null; then + linux-update-symlinks remove $version /$installed_image_path +fi"
postrm should not run linux-update-symlinks if "$1" is "upgrade".
scripts/package/builddeb export DEB_MAINT_PARAMS="\$*" · line 225
Quoted 12 lines
scripts/package/builddeb +12
-0+ ;; + preinst) + echo 'if [ "$1" = install ]; then + # Create a flag file for postinst + mkdir -p /lib/modules/$version + touch /lib/modules/$version/.fresh-install +fi' + ;; + prerm) + echo "if command -v linux-check-removal > /dev/null; then + linux-check-removal $version +fi"
prerm should not run linux-check-removal if "$1" is "upgrade".
Also, you should mention use of linux-check-removal in the commit message.
Ben.
Quoted 6 lines
scripts/package/builddeb +3
-0+ ;; +esac) + test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 EOF
Signature · 2 lines
Ben Hutchings You can't have everything. Where would you put it?