diff --git a/Makefile b/Makefile index e99311c..3067df2 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,11 @@ submodule: buildir: $(BUILDDIR) $(BUILDDIR): submodule - rm -rf $(BUILDDIR) - mkdir $(BUILDDIR) - cp -a $(SRCDIR)/* $(BUILDDIR)/ - cp -R debian/* $(BUILDDIR)/debian/ + rm -rf $@ $@.tmp + cp -a $(SRCDIR)/ $@.tmp/ + rm -rf $@.tmp/debian + cp -a debian $@.tmp/ + mv $@.tmp $@ .PHONY: deb deb: $(DEB) diff --git a/debian/ifupdown2-pre.service b/debian/ifupdown2-pre.service new file mode 100644 index 0000000..b129a62 --- /dev/null +++ b/debian/ifupdown2-pre.service @@ -0,0 +1,13 @@ +[Unit] +Description=Helper to synchronize boot up for ifupdown +DefaultDependencies=no +Wants=systemd-udevd.service +After=systemd-udev-trigger.service +Before=network.target + +[Service] +Type=oneshot +TimeoutSec=180 +RemainAfterExit=yes +EnvironmentFile=-/etc/default/networking +ExecStart=/bin/udevadm settle diff --git a/debian/ifupdown2.networking.service b/debian/ifupdown2.networking.service index cdb3065..ee5f17a 100644 --- a/debian/ifupdown2.networking.service +++ b/debian/ifupdown2.networking.service @@ -5,8 +5,9 @@ DefaultDependencies=no After=local-fs.target network-pre.target Before=shutdown.target network.target network-online.target Conflicts=shutdown.target -Wants=systemd-udev-settle.service -After=systemd-udev-settle.service +Requires=ifupdown2-pre.service +Wants=network.target +After=local-fs.target network-pre.target systemd-sysctl.service systemd-modules-load.service ifupdown2-pre.service [Service] Type=oneshot @@ -19,4 +20,5 @@ ExecStop=/usr/share/ifupdown2/sbin/start-networking stop ExecReload=/usr/share/ifupdown2/sbin/start-networking reload [Install] -WantedBy=basic.target network.target shutdown.target +WantedBy=multi-user.target network-online.target + diff --git a/debian/ifupdown2.postinst b/debian/ifupdown2.postinst index 3689256..0137ea8 100644 --- a/debian/ifupdown2.postinst +++ b/debian/ifupdown2.postinst @@ -85,6 +85,25 @@ postinst_remove_diverts() _postinst_remove_diverts "/usr/share/man/man5/interfaces.5.gz" } +proxmox_compatibility() +{ + perl -e ' + my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; }; + exit if !$haspve_common; + my $config = PVE::INotify::read_file('interfaces', 1); + my $configdata = $config->{data}; + + PVE::INotify::write_file('interfaces', $configdata); + + $config = PVE::INotify::read_file('interfaces', 1); + + if (defined($config->{changes})) { + #print $config->{changes}; + print "\nnetwork config changes have been detected for ifupdown2 compatibility.\nSaved in /etc/network/interfaces.new for hot-apply or next reboot.\n\n"; + } + ' || true +} + case "$1" in configure) fix_dhclient_file_with_space @@ -92,6 +111,12 @@ case "$1" in process_udev chmod +x /usr/share/ifupdown2/__main__.py postinst_remove_diverts + if [ -f "/tmp/.ifupdown2-first-install" ] && [ ! -e /proxmox_install_mode ]; then + proxmox_compatibility + echo "Reloading network config on first install" + ifreload -a + rm /tmp/.ifupdown2-first-install + fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/debian/ifupdown2.postrm b/debian/ifupdown2.postrm index 5d90b21..fd62294 100644 --- a/debian/ifupdown2.postrm +++ b/debian/ifupdown2.postrm @@ -25,10 +25,30 @@ process_udev() fi } +proxmox_compatibility() +{ + perl -e ' + my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; }; + exit if !$haspve_common; + my $config = PVE::INotify::read_file('interfaces', 1); + my $configdata = $config->{data}; + + PVE::INotify::write_file('interfaces', $configdata); + + $config = PVE::INotify::read_file('interfaces', 1); + + if (defined($config->{changes})) { + #print $config->{changes}; + print "\nnetwork config changes have been detected for ifupdown2 to ifupdown1 switch compatibility.\nSaved in /etc/network/interfaces.new for next reboot\n\n"; + } + ' || true +} + case "$1" in purge|remove|abort-install|disappear) process_state_file process_udev + proxmox_compatibility ;; 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 diff --git a/debian/patches/pve/0006-networking.service-fix-dependencies-and-ordering.patch b/debian/patches/pve/0006-networking.service-fix-dependencies-and-ordering.patch deleted file mode 100644 index 48acf09..0000000 --- a/debian/patches/pve/0006-networking.service-fix-dependencies-and-ordering.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 154c536c711de1c09edbd880820da01c5b457a6c Mon Sep 17 00:00:00 2001 -From: Thomas Lamprecht -Date: Thu, 30 Jan 2020 12:48:23 +0100 -Subject: [PATCH 06/12] networking.service: fix dependencies and ordering - -IMPORTANT: DO NOT REMOVE IF UNSURE! - -ONLY IF IFUPDOWN2 FIXED THEIR SERVICE MESS. - -THEY CLOSED TWO PULL REQUESTS ALREADY WITHOUT REASON. - -SO WE JUST HAVE TO KEEP THIS DOWNSTREAM PATCH! - -BIG WARNING HERE IS DONE BECAUSE IT WAS ALREADY REMOVED BY MISTAKE -ONCE!! - -Signed-off-by: Thomas Lamprecht -Signed-off-by: Alexandre Derumier ---- - debian/ifupdown2-pre.service | 13 +++++++++++++ - debian/ifupdown2.networking.service | 8 +++++--- - debian/rules | 1 + - 3 files changed, 19 insertions(+), 3 deletions(-) - create mode 100644 debian/ifupdown2-pre.service - -diff --git a/debian/ifupdown2-pre.service b/debian/ifupdown2-pre.service -new file mode 100644 -index 0000000..b129a62 ---- /dev/null -+++ b/debian/ifupdown2-pre.service -@@ -0,0 +1,13 @@ -+[Unit] -+Description=Helper to synchronize boot up for ifupdown -+DefaultDependencies=no -+Wants=systemd-udevd.service -+After=systemd-udev-trigger.service -+Before=network.target -+ -+[Service] -+Type=oneshot -+TimeoutSec=180 -+RemainAfterExit=yes -+EnvironmentFile=-/etc/default/networking -+ExecStart=/bin/udevadm settle -diff --git a/debian/ifupdown2.networking.service b/debian/ifupdown2.networking.service -index cdb3065..ee5f17a 100644 ---- a/debian/ifupdown2.networking.service -+++ b/debian/ifupdown2.networking.service -@@ -5,8 +5,9 @@ DefaultDependencies=no - After=local-fs.target network-pre.target - Before=shutdown.target network.target network-online.target - Conflicts=shutdown.target --Wants=systemd-udev-settle.service --After=systemd-udev-settle.service -+Requires=ifupdown2-pre.service -+Wants=network.target -+After=local-fs.target network-pre.target systemd-sysctl.service systemd-modules-load.service ifupdown2-pre.service - - [Service] - Type=oneshot -@@ -19,4 +20,5 @@ ExecStop=/usr/share/ifupdown2/sbin/start-networking stop - ExecReload=/usr/share/ifupdown2/sbin/start-networking reload - - [Install] --WantedBy=basic.target network.target shutdown.target -+WantedBy=multi-user.target network-online.target -+ -diff --git a/debian/rules b/debian/rules -index ea6f434..fcb304f 100755 ---- a/debian/rules -+++ b/debian/rules -@@ -15,6 +15,7 @@ override_dh_install: - dh_install - mkdir -p debian/ifupdown2/lib/systemd/system/ - install --mode=644 debian/ifup@.service debian/ifupdown2/lib/systemd/system/ -+ install --mode=644 debian/ifupdown2-pre.service debian/ifupdown2/lib/systemd/system/ - - - override_dh_systemd_start: --- -2.30.2 - diff --git a/debian/patches/pve/0007-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch b/debian/patches/pve/0006-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch similarity index 100% rename from debian/patches/pve/0007-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch rename to debian/patches/pve/0006-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch diff --git a/debian/patches/pve/0008-allow-vlan-tag-inside-vxlan-tunnel.patch b/debian/patches/pve/0007-allow-vlan-tag-inside-vxlan-tunnel.patch similarity index 100% rename from debian/patches/pve/0008-allow-vlan-tag-inside-vxlan-tunnel.patch rename to debian/patches/pve/0007-allow-vlan-tag-inside-vxlan-tunnel.patch diff --git a/debian/patches/pve/0013-lacp-bond-remove-bond-min-links-0-warning.patch b/debian/patches/pve/0008-lacp-bond-remove-bond-min-links-0-warning.patch similarity index 100% rename from debian/patches/pve/0013-lacp-bond-remove-bond-min-links-0-warning.patch rename to debian/patches/pve/0008-lacp-bond-remove-bond-min-links-0-warning.patch diff --git a/debian/patches/pve/0009-postinst-rm-update-network-config-compatibility.patch b/debian/patches/pve/0009-postinst-rm-update-network-config-compatibility.patch deleted file mode 100644 index 05aa1ee..0000000 --- a/debian/patches/pve/0009-postinst-rm-update-network-config-compatibility.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 2fe84449da923d01de8bbed84f4f8ce15548225f Mon Sep 17 00:00:00 2001 -From: Alexandre Derumier -Date: Fri, 21 Feb 2020 10:01:59 +0100 -Subject: [PATCH 09/12] postinst/rm : update network config compatibility - -Signed-off-by: Alexandre Derumier ---- - 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..b7de485 100644 ---- a/debian/ifupdown2.postinst -+++ b/debian/ifupdown2.postinst -@@ -85,6 +85,25 @@ postinst_remove_diverts() - _postinst_remove_diverts "/usr/share/man/man5/interfaces.5.gz" - } - -+proxmox_compatibility() -+{ -+ perl -e ' -+ my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; }; -+ exit if !$haspve_common; -+ my $config = PVE::INotify::read_file('interfaces', 1); -+ my $configdata = $config->{data}; -+ -+ PVE::INotify::write_file('interfaces', $configdata); -+ -+ $config = PVE::INotify::read_file('interfaces', 1); -+ -+ if (defined($config->{changes})) { -+ #print $config->{changes}; -+ print "\nnetwork config changes have been detected for ifupdown2 compatibility.\nSaved in /etc/network/interfaces.new for hot-apply or next reboot.\n\n"; -+ } -+ ' || true -+} -+ - case "$1" in - configure) - fix_dhclient_file_with_space -@@ -92,6 +111,10 @@ case "$1" in - process_udev - chmod +x /usr/share/ifupdown2/__main__.py - postinst_remove_diverts -+ 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..fd62294 100644 ---- a/debian/ifupdown2.postrm -+++ b/debian/ifupdown2.postrm -@@ -25,10 +25,30 @@ process_udev() - fi - } - -+proxmox_compatibility() -+{ -+ perl -e ' -+ my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; }; -+ exit if !$haspve_common; -+ my $config = PVE::INotify::read_file('interfaces', 1); -+ my $configdata = $config->{data}; -+ -+ PVE::INotify::write_file('interfaces', $configdata); -+ -+ $config = PVE::INotify::read_file('interfaces', 1); -+ -+ if (defined($config->{changes})) { -+ #print $config->{changes}; -+ print "\nnetwork config changes have been detected for ifupdown2 to ifupdown1 switch compatibility.\nSaved in /etc/network/interfaces.new for next reboot\n\n"; -+ } -+ ' || true -+} -+ - case "$1" in - purge|remove|abort-install|disappear) - process_state_file - process_udev -+ proxmox_compatibility - ;; - - 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.30.2 - diff --git a/debian/patches/pve/0010-d-rules-drop-now-default-with-systemd.patch b/debian/patches/pve/0010-d-rules-drop-now-default-with-systemd.patch deleted file mode 100644 index b1a8ab6..0000000 --- a/debian/patches/pve/0010-d-rules-drop-now-default-with-systemd.patch +++ /dev/null @@ -1,27 +0,0 @@ -From fb44a9192381498ec4f0fbf89c717d07c8fb5dc2 Mon Sep 17 00:00:00 2001 -From: Thomas Lamprecht -Date: Mon, 24 May 2021 12:32:46 +0200 -Subject: [PATCH 10/12] d/rules: drop now default "with=systemd" - -Signed-off-by: Thomas Lamprecht -Signed-off-by: Alexandre Derumier ---- - debian/rules | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/debian/rules b/debian/rules -index fcb304f..ec1b214 100755 ---- a/debian/rules -+++ b/debian/rules -@@ -5,7 +5,7 @@ export PYBUILD_NAME=ifupdown2 - export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/ --install-scripts=/usr/share/ - - %: -- dh $@ --with=python3 --with systemd --buildsystem=pybuild -+ dh $@ --with=python3 --buildsystem=pybuild - - override_dh_installman: - ./ifupdown2/man/genmanpages.sh ./ifupdown2/man ./man --- -2.30.2 - diff --git a/debian/patches/pve/0011-d-rules-add-dh_installsystemd-override-for-compat-12.patch b/debian/patches/pve/0011-d-rules-add-dh_installsystemd-override-for-compat-12.patch deleted file mode 100644 index ac24d3c..0000000 --- a/debian/patches/pve/0011-d-rules-add-dh_installsystemd-override-for-compat-12.patch +++ /dev/null @@ -1,29 +0,0 @@ -From ff810060d779488ba093bfad67b6cd36071ebdfd Mon Sep 17 00:00:00 2001 -From: Thomas Lamprecht -Date: Tue, 25 May 2021 10:34:16 +0200 -Subject: [PATCH 11/12] d/rules: add dh_installsystemd override for compat >= - 12 - -Signed-off-by: Thomas Lamprecht -Signed-off-by: Alexandre Derumier ---- - debian/rules | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/debian/rules b/debian/rules -index ec1b214..6539b24 100755 ---- a/debian/rules -+++ b/debian/rules -@@ -24,5 +24,9 @@ override_dh_systemd_start: - override_dh_systemd_enable: - dh_systemd_enable --name=networking - -+# above are depreacated and won't be used in DH compat level >= 12 -+override_dh_installsystemd: -+ dh_installsystemd --name=networking --no-start -+ - override_dh_compress: - dh_compress -X.py --- -2.30.2 - diff --git a/debian/patches/pve/0012-postinst-reload-network-config-on-first-install.patch b/debian/patches/pve/0012-postinst-reload-network-config-on-first-install.patch deleted file mode 100644 index d5e94ca..0000000 --- a/debian/patches/pve/0012-postinst-reload-network-config-on-first-install.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 9f8dfcaf862738b7439d5b0cb0d76dc24c3b50bc Mon Sep 17 00:00:00 2001 -From: Dominik Csapak -Date: Tue, 6 Jul 2021 13:11:24 +0200 -Subject: [PATCH 12/12] postinst: reload network config on first install - -Signed-off-by: Dominik Csapak -Signed-off-by: Alexandre Derumier ---- - debian/ifupdown2.postinst | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/debian/ifupdown2.postinst b/debian/ifupdown2.postinst -index b7de485..0137ea8 100644 ---- a/debian/ifupdown2.postinst -+++ b/debian/ifupdown2.postinst -@@ -111,8 +111,10 @@ case "$1" in - process_udev - chmod +x /usr/share/ifupdown2/__main__.py - postinst_remove_diverts -- if [ -f "/tmp/.ifupdown2-first-install" ]; then -+ if [ -f "/tmp/.ifupdown2-first-install" ] && [ ! -e /proxmox_install_mode ]; then - proxmox_compatibility -+ echo "Reloading network config on first install" -+ ifreload -a - rm /tmp/.ifupdown2-first-install - fi - ;; --- -2.30.2 - diff --git a/debian/patches/series b/debian/patches/series index ab3863c..4cfa797 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,12 +3,7 @@ pve/0002-add-dummy-mtu-bridgevlanport-modules.patch pve/0003-don-t-remove-bridge-is-tap-veth-are-still-plugged.patch pve/0004-ifreload-down-up-vxlan-vlan-interfaces-when-ifreload.patch pve/0005-config-tuning.patch -pve/0006-networking.service-fix-dependencies-and-ordering.patch -pve/0007-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch -pve/0008-allow-vlan-tag-inside-vxlan-tunnel.patch -pve/0009-postinst-rm-update-network-config-compatibility.patch -pve/0010-d-rules-drop-now-default-with-systemd.patch -pve/0011-d-rules-add-dh_installsystemd-override-for-compat-12.patch -pve/0012-postinst-reload-network-config-on-first-install.patch -pve/0013-lacp-bond-remove-bond-min-links-0-warning.patch -upstream/0001-add-ipv6-slaac-support-inet6-auto-accept_ra.patch \ No newline at end of file +pve/0006-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch +pve/0007-allow-vlan-tag-inside-vxlan-tunnel.patch +pve/0008-lacp-bond-remove-bond-min-links-0-warning.patch +upstream/0001-add-ipv6-slaac-support-inet6-auto-accept_ra.patch diff --git a/debian/rules b/debian/rules index ea6f434..6539b24 100755 --- a/debian/rules +++ b/debian/rules @@ -5,7 +5,7 @@ export PYBUILD_NAME=ifupdown2 export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/ --install-scripts=/usr/share/ %: - dh $@ --with=python3 --with systemd --buildsystem=pybuild + dh $@ --with=python3 --buildsystem=pybuild override_dh_installman: ./ifupdown2/man/genmanpages.sh ./ifupdown2/man ./man @@ -15,6 +15,7 @@ override_dh_install: dh_install mkdir -p debian/ifupdown2/lib/systemd/system/ install --mode=644 debian/ifup@.service debian/ifupdown2/lib/systemd/system/ + install --mode=644 debian/ifupdown2-pre.service debian/ifupdown2/lib/systemd/system/ override_dh_systemd_start: @@ -23,5 +24,9 @@ override_dh_systemd_start: override_dh_systemd_enable: dh_systemd_enable --name=networking +# above are depreacated and won't be used in DH compat level >= 12 +override_dh_installsystemd: + dh_installsystemd --name=networking --no-start + override_dh_compress: dh_compress -X.py