[pve-devel] [PATCH pve-kernel-meta 3/5] proxmox-boot: maintscript: change logic whether to add diversion

Stoiko Ivanov s.ivanov at proxmox.com
Wed Jul 7 23:09:52 CEST 2021


Deciding whether or not to add the diversion based on the version
alone fails quite hard in case pve-kernel-helper is in dpkg-state 'rc'
(removed not purged) as reported in our community forum[0]:
* removing pve-kernel-helper removes the diversion of grub-install
* if config-files are still present the preinst script gets called
  with the version of the config-files (the version that got removed)
* if the version was newer than 6.4-1~ then no diversion is added
* unpacking fails, because grub-install would be overwritten leaving
  pve-kernel-helper in state 'ic'

Explicitly checking whether the diversion is in place sounds like a
robust approach here.

downside: documentation on dpkg-divert in maintainer scripts [1] uses
the version approach.

[0] https://forum.proxmox.com/threads/pve-kernel-helper-wont-install.90029/
[1] https://www.debian.org/doc/debian-policy/ap-pkg-diversions.html

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 debian/pve-kernel-helper.preinst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/pve-kernel-helper.preinst b/debian/pve-kernel-helper.preinst
index 9ec726d..e2464c9 100644
--- a/debian/pve-kernel-helper.preinst
+++ b/debian/pve-kernel-helper.preinst
@@ -4,7 +4,7 @@ set -e
 
 case "$1" in
     install|upgrade)
-        if dpkg --compare-versions "$2" lt "6.4-1~"; then
+        if ! dpkg -S /usr/sbin/grub-install|grep -q 'diversion by pve-kernel-helper'; then
             dpkg-divert --package pve-kernel-helper --add --rename \
                 --divert /usr/sbin/grub-install.real /usr/sbin/grub-install
         fi
-- 
2.30.2






More information about the pve-devel mailing list