* [pmg-devel] [PATCH v2 pmg-api] postinst: migrate/update APT auth config
@ 2022-09-14 8:05 Fabian Grünbichler
2022-09-14 8:55 ` [pmg-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Grünbichler @ 2022-09-14 8:05 UTC (permalink / raw)
To: pmg-devel
missed when switching over to Proxmox::RS::Subscription, which stores
the same info in the product-specific /etc/apt/auth.conf.d/pmg.conf .
the top-level file might contain non-PMG-managed entries, so only remove
entries matching "our" machine/
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Notes:
v2: read -r
debian/postinst | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/debian/postinst b/debian/postinst
index fdcecbf..8ea7158 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -19,6 +19,36 @@ ucf_register_templates() {
done
}
+migrate_apt_auth_conf() {
+ output=""
+ removed=""
+ match=0
+
+ while read -r l; do
+ if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pmg"; 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/pmg.conf; then
+ echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pmg.conf .."
+ echo "$removed" > /etc/apt/auth.conf.d/pmg.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)
@@ -81,6 +111,12 @@ case "$1" in
# rewrite banner
pmgbanner || true
fi
+
+ if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.1-7~'; then
+ if test -e /etc/apt/auth.conf ; then
+ migrate_apt_auth_conf
+ fi
+ fi
;;
abort-upgrade)
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pmg-devel] applied: [PATCH v2 pmg-api] postinst: migrate/update APT auth config
2022-09-14 8:05 [pmg-devel] [PATCH v2 pmg-api] postinst: migrate/update APT auth config Fabian Grünbichler
@ 2022-09-14 8:55 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-09-14 8:55 UTC (permalink / raw)
To: Fabian Grünbichler, pmg-devel
Am 14/09/2022 um 10:05 schrieb Fabian Grünbichler:
> missed when switching over to Proxmox::RS::Subscription, which stores
> the same info in the product-specific /etc/apt/auth.conf.d/pmg.conf .
>
> the top-level file might contain non-PMG-managed entries, so only remove
> entries matching "our" machine/
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
>
> Notes:
> v2: read -r
>
> debian/postinst | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
>
applied, thanks! fyi, I transformed that file to four spaces only indentation
in a followup, it was using both that and our odd mixed space/tab one, and I'd
like to contain the latter to existing usage in our perl usage.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-14 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 8:05 [pmg-devel] [PATCH v2 pmg-api] postinst: migrate/update APT auth config Fabian Grünbichler
2022-09-14 8:55 ` [pmg-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox