From bf09acfe7fd2e9d2aa06e172a5772ab8a0865ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 14 Sep 2022 10:05:54 +0200 Subject: [PATCH] postinst: migrate/update APT auth config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit missed when switching over to Proxmox::RS::Subscription, which stores the same info in the product-specific /etc/apt/auth.conf.d/pve.conf . the top-level file might contain non-PVE-managed entries, so only remove entries matching "our" machine. Signed-off-by: Fabian Grünbichler --- debian/postinst | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/debian/postinst b/debian/postinst index 7be1aa3d..5ea79a6d 100755 --- a/debian/postinst +++ b/debian/postinst @@ -62,6 +62,36 @@ EOF fi } +migrate_apt_auth_conf() { + output="" + removed="" + match=0 + + while read -r l; do + if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pve"; then + match=1 + elif echo "$l" | grep -q "machine"; then + match=0 + fi + + if test "$match" = "1"; then + removed="$removed\n$l" + else + output="$output\n$l" + fi + done < /etc/apt/auth.conf + + if test -n "$removed"; then + if test ! -e /etc/apt/auth.conf.d/pve.conf; then + echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pve.conf .." + echo "$removed" > /etc/apt/auth.conf.d/pve.conf + else + echo "Removing stale APT auth config from /etc/apt/auth.conf" + fi + echo "$output" > /etc/apt/auth.conf + fi +} + case "$1" in triggered) # We don't print a status message here, as dpkg already said @@ -190,6 +220,12 @@ case "$1" in fi done fi + + if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2.11~'; then + if test -e /etc/apt/auth.conf ; then + migrate_apt_auth_conf + fi + fi ;; abort-upgrade|abort-remove|abort-deconfigure)