diff mbox series

make builddeb invoke calls to linux-update-symlinks

Message ID 20200523203801.18277-1-j@jxself.org
State New, archived
Headers show
Series make builddeb invoke calls to linux-update-symlinks | expand

Commit Message

Jason Self May 23, 2020, 8:38 p.m. UTC
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.

Signed-off-by: Jason Self <j@jxself.org>
---
 scripts/package/builddeb | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Ben Hutchings May 24, 2020, 12:40 a.m. UTC | #1
On Sat, 2020-05-23 at 13:38 -0700, Jason Self wrote:
> 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

> Signed-off-by: Jason Self <j@jxself.org>
> ---
>  scripts/package/builddeb | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 6df3c9f8b2da..707693867c29 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -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"

postrm should not run linux-update-symlinks if "$1" is "upgrade".

> +        ;;
> +    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.

> +        ;;
> +esac)
> +
>  test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
>  exit 0
>  EOF
diff mbox series

Patch

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 6df3c9f8b2da..707693867c29 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -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