From 9c20a57d93bd29c35d3857c882eaf3b3c452a004 Mon Sep 17 00:00:00 2001 From: Renan Rodrigo Date: Fri, 11 Oct 2024 08:59:25 -0300 Subject: [PATCH] postinst: migrate CIS to USG on Focal and Jammy The old CIS entitlement will not be recognized on Focal and Jammy after version 35. This converts the .list file and changes cis/ to usg/ both in the source and authentication files when running on these series. Signed-off-by: Renan Rodrigo --- debian/ubuntu-advantage-tools.postinst | 2 +- debian/ubuntu-pro-client.postinst | 2 +- lib/postinst-migrations.sh | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/debian/ubuntu-advantage-tools.postinst b/debian/ubuntu-advantage-tools.postinst index 68636b59e4..f803ddfda1 100644 --- a/debian/ubuntu-advantage-tools.postinst +++ b/debian/ubuntu-advantage-tools.postinst @@ -476,7 +476,7 @@ case "$1" in fi if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "31~"; then - /usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER + /usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER $VERSION_ID fi ;; esac diff --git a/debian/ubuntu-pro-client.postinst b/debian/ubuntu-pro-client.postinst index 25c3dac2e7..018a894ad0 100644 --- a/debian/ubuntu-pro-client.postinst +++ b/debian/ubuntu-pro-client.postinst @@ -53,7 +53,7 @@ case "$1" in # if dpkg --compare-versions "$PREVIOUS_PKG_VER" ge "31~"; then - /usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER + /usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER $VERSION_ID fi # diff --git a/lib/postinst-migrations.sh b/lib/postinst-migrations.sh index 46884cfed3..e8a373566b 100755 --- a/lib/postinst-migrations.sh +++ b/lib/postinst-migrations.sh @@ -45,6 +45,7 @@ set -e PREVIOUS_PKG_VER=$1 +VERSION_ID=$2 if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "32~"; then # When we perform the write operation through @@ -81,4 +82,15 @@ if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "35~"; then if [ -f "/var/lib/ubuntu-advantage/private/machine-token.json" ]; then touch "/var/lib/ubuntu-advantage/marker-only-series-check" fi + + # On Focal and Jammy, the CIS service transitioned to USG from v35 + # This changes the lists and authentication files to represent that + # in case CIS is enabled + if [ "$VERSION_ID" = "20.04" ] || [ "$VERSION_ID" = "22.04" ]; then + if [ -f /etc/apt/sources.list.d/ubuntu-cis.list ]; then + mv /etc/apt/sources.list.d/ubuntu-cis.list /etc/apt/sources.list.d/ubuntu-usg.list + sed -i 's#/cis/ubuntu#/usg/ubuntu#' /etc/apt/sources.list.d/ubuntu-usg.list + sed -i 's#/cis/ubuntu#/usg/ubuntu#' /etc/apt/auth.conf.d/90ubuntu-advantage + fi + fi fi