[pve-devel] [PATCH ifupdown2 3/3] update patch10: only rewrite config on first ifupdown2

Alexandre Derumier aderumier at odiso.com
Mon Sep 21 18:51:15 CEST 2020


we don't want to update config at each upgrade.

postinst can't detect upgrade vs install, it need to be done in preinst.

so I create a tmp file in preinst for first install, and detect this file
in postinst.
(as we need to have ifupdown2 installed first, to have the config rewrite working)

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 ...-update-network-config-compatibility.patch | 47 +++++++++++++++----
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/debian/patches/pve/0010-postinst-rm-update-network-config-compatibility.patch b/debian/patches/pve/0010-postinst-rm-update-network-config-compatibility.patch
index ad7c662..226728f 100644
--- a/debian/patches/pve/0010-postinst-rm-update-network-config-compatibility.patch
+++ b/debian/patches/pve/0010-postinst-rm-update-network-config-compatibility.patch
@@ -1,16 +1,18 @@
-From e93b858e2c6d46f3c7166f8b980518457e7f2e65 Mon Sep 17 00:00:00 2001
+From 723bfd8e3ed7a6140a411260a4881ed886efc829 Mon Sep 17 00:00:00 2001
 From: Alexandre Derumier <aderumier at odiso.com>
 Date: Fri, 21 Feb 2020 10:01:59 +0100
 Subject: [PATCH] postinst/rm : update network config compatibility
 
 Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
 ---
- debian/ifupdown2.postinst | 19 +++++++++++++++++++
- debian/ifupdown2.postrm   | 19 +++++++++++++++++++
- 2 files changed, 38 insertions(+)
+ debian/ifupdown2.postinst | 23 +++++++++++++++++++++++
+ debian/ifupdown2.postrm   | 20 ++++++++++++++++++++
+ debian/ifupdown2.preinst  | 20 ++++++++++++++++++++
+ 3 files changed, 63 insertions(+)
+ create mode 100644 debian/ifupdown2.preinst
 
 diff --git a/debian/ifupdown2.postinst b/debian/ifupdown2.postinst
-index 3689256..4b628e1 100644
+index 3689256..5162109 100644
 --- a/debian/ifupdown2.postinst
 +++ b/debian/ifupdown2.postinst
 @@ -85,6 +85,25 @@ postinst_remove_diverts()
@@ -39,16 +41,19 @@ index 3689256..4b628e1 100644
  case "$1" in
      configure)
          fix_dhclient_file_with_space
-@@ -92,6 +110,7 @@ case "$1" in
+@@ -92,6 +111,10 @@ case "$1" in
          process_udev
          chmod +x /usr/share/ifupdown2/__main__.py
          postinst_remove_diverts
-+        proxmox_compatibility
++        if [ -f "/tmp/.ifupdown2-first-install" ]; then
++            proxmox_compatibility
++            rm  /tmp/.ifupdown2-first-install
++        fi
      ;;
  
      abort-upgrade|abort-remove|abort-deconfigure)
 diff --git a/debian/ifupdown2.postrm b/debian/ifupdown2.postrm
-index 5d90b21..bab3dd0 100644
+index 5d90b21..fd62294 100644
 --- a/debian/ifupdown2.postrm
 +++ b/debian/ifupdown2.postrm
 @@ -25,10 +25,30 @@ process_udev()
@@ -82,6 +87,32 @@ index 5d90b21..bab3dd0 100644
      ;;
  
      upgrade|failed-upgrade|abort-upgrade|disappear)
+diff --git a/debian/ifupdown2.preinst b/debian/ifupdown2.preinst
+new file mode 100644
+index 0000000..aa8653e
+--- /dev/null
++++ b/debian/ifupdown2.preinst
+@@ -0,0 +1,20 @@
++#!/bin/sh
++set -e
++
++case "$1" in
++    install)
++        touch /tmp/.ifupdown2-first-install
++        ;;
++
++    upgrade|abort-upgrade)
++        ;;
++
++    *)
++        echo "postinst called with unknown argument \`$1'" >&2
++        exit 0
++        ;;
++esac
++
++#DEBHELPER#
++
++exit 0
 -- 
 2.20.1
 
-- 
2.20.1





More information about the pve-devel mailing list