[pve-devel] [PATCH proxmox-ve] apt hook: disable on remove

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Mar 7 10:00:00 CET 2024


and (re-)enable on install. adapted from apt-listbugs/apt-listchanges, which
solve the issue of removing (instead of purging) the package keeping the
conffile while removing the hook binary in the same fashion.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
tested with:
- touch /please-remove-proxmox-ve
- remove proxmox-ve (works, hook config moved out of the way)
- purge proxmox-ve (works, disabled config removed)
- reinstall proxmox-ve (works, hook config reappears)

- touch /please-remove-proxmox-ve
- remove (works, hook config moved out of the way)
- reinstall (works, hook config reappears)

- touch /please-remove-proxmox-ve
- purge proxmox-ve (works, hook config removed)
- reinstall (works, hook config reappears)

 debian/proxmox-ve.postrm  | 33 +++++++++++++++++++++++++++++++++
 debian/proxmox-ve.preinst | 13 +++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 debian/proxmox-ve.postrm
 create mode 100644 debian/proxmox-ve.preinst

diff --git a/debian/proxmox-ve.postrm b/debian/proxmox-ve.postrm
new file mode 100644
index 0000000..f3eff33
--- /dev/null
+++ b/debian/proxmox-ve.postrm
@@ -0,0 +1,33 @@
+#! /bin/sh
+set -e
+
+hook=/etc/apt/apt.conf.d/10pveapthook
+
+case "$1" in
+    purge)
+        rm -f $hook.disabled
+        ;;
+
+    remove)
+        mv $hook $hook.disabled
+        ;;
+
+    abort-install)
+        if test "x$2" != "x" && test -f $hook
+        then
+            mv $hook $hook.disabled
+        fi
+        ;;
+
+    upgrade|failed-upgrade|abort-upgrade|disappear)
+        ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/proxmox-ve.preinst b/debian/proxmox-ve.preinst
new file mode 100644
index 0000000..e190c3d
--- /dev/null
+++ b/debian/proxmox-ve.preinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+hook=/etc/apt/apt.conf.d/10pveapthook
+if test -f $hook.disabled
+then
+    mv $hook.disabled $hook
+fi
+
+#DEBHELPER#
+
+exit 0
-- 
2.39.2





More information about the pve-devel mailing list