From 3db845580474c806b17ba083ae985a8f2bf4b3e1 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Tue, 12 Dec 2023 15:48:13 -0500 Subject: [PATCH 01/12] d/rules: remove old ubuntu release logic --- debian/rules | 4 ---- 1 file changed, 4 deletions(-) diff --git a/debian/rules b/debian/rules index fb8c6659a0..38bf01bda0 100755 --- a/debian/rules +++ b/debian/rules @@ -18,10 +18,6 @@ APT_PKG_DEPS="apt (>= 1.2.32), apt-transport-https (>= 1.2.32), apt-utils (>= 1. DISTRO_INFO_DEPS="distro-info (>= 0.14ubuntu0.2)," else ifeq (${VERSION_ID},"18.04") APT_PKG_DEPS="apt (>= 1.6.11), apt-utils (>= 1.6.11), libapt-inst2.0 (>= 1.6.11), libapt-pkg5.0 (>= 1.6.11)," -else ifeq (${VERSION_ID},"19.04") -APT_PKG_DEPS="apt (>= 1.8.1), apt-utils (>= 1.8.1), libapt-inst2.0 (>= 1.8.1), libapt-pkg5.0 (>= 1.8.1)," -else ifeq (${VERSION_ID},"19.10") -APT_PKG_DEPS="apt (>= 1.8.1), apt-utils (>= 1.8.1), libapt-pkg5.90 (>= 1.8.1)," endif %: From 9720d8990ac247216bb3c9d7fc355fd16a148365 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Fri, 8 Dec 2023 14:28:05 -0500 Subject: [PATCH 02/12] d/control: homepage and description improvements --- debian/control | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/debian/control b/debian/control index 78e3a08033..ee1eec9002 100644 --- a/debian/control +++ b/debian/control @@ -35,6 +35,7 @@ Vcs-Browser: https://github.com/canonical/ubuntu-pro-client Rules-Requires-Root: no Package: ubuntu-advantage-tools +Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/ Architecture: any Depends: ${misc:Depends}, ${python3:Depends}, @@ -43,13 +44,12 @@ Depends: ${misc:Depends}, python3-pkg-resources, ${extra:Depends} Recommends: ubuntu-pro-client-l10n -Description: management tools for Ubuntu Pro - Ubuntu Pro is the professional package of tooling, technology - and expertise from Canonical, helping organisations around the world - manage their Ubuntu deployments. - . - Subscribers to Ubuntu Pro will find helpful tools for accessing - services in this package. +Description: Management tools for Ubuntu Pro + Ubuntu Pro is a suite of additional services provided by Canonical on + top of Ubuntu. Whether you're an enterprise customer deploying systems + at scale or want security patching for your personal Ubuntu LTS + at home, the Ubuntu Pro Client (pro) is the command-line tool that + will help you manage the services you need. Package: ubuntu-pro-client-l10n Architecture: any @@ -59,11 +59,12 @@ Description: Translations for Ubuntu Pro Client languages. Package: ubuntu-advantage-pro +Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/en/latest/explanations/what_are_ubuntu_pro_cloud_instances/ Architecture: all Depends: ${misc:Depends}, ubuntu-advantage-tools (>=20.2) Replaces: ubuntu-advantage-tools (<<20.2) Breaks: ubuntu-advantage-tools (<<20.2) -Description: Additional services for Ubuntu Pro images +Description: Service to auto-attach Ubuntu Pro cloud images This package delivers an additional service that performs an auto-attach operation for Ubuntu Pro cloud instances. This package should not be manually installed, as it is already present on the cloud instances that require it. From b0bf6e0dec87defc24df443452b7ead89f238f78 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Fri, 8 Dec 2023 14:30:56 -0500 Subject: [PATCH 03/12] debian: rename binary packages We're renaming the following packages using transitional packages to align the package names with the product naming: * ubuntu-advantage-tools -> ubuntu-pro-client * ubuntu-advantage-pro -> ubuntu-pro-image-auto-attach Because old versions of ubuntu-advantage-tools will break ESM upon removal, and ubuntu-pro-client "Breaks" ubuntu-advantage-tools <<31~, we need to force existing instances to upgrade to ubuntu-advantage-tools 31 (the transitional package) in order to install the new ubuntu-pro-client package. Enforcing that is accomplished via a Depends: ubuntu-advantage-tools on existing Ubuntu releases. Future Ubuntu releases (Noble onward) will not have this Depends. Because of that, all previous package migrations (from versions older than 31) are left in ubuntu-advantage-tools.{preinst,postinst,postrm}. All future package migrations will happen in ubuntu-pro-client.{preinst,postinst,postrm}. --- debian/control | 28 +++++- debian/rules | 63 ++++++++---- debian/ubuntu-advantage-pro.lintian-overrides | 3 - debian/ubuntu-advantage-tools.postinst | 10 -- debian/ubuntu-advantage-tools.postrm | 26 ----- ...tion => ubuntu-pro-client.bash-completion} | 0 ...ge-tools.links => ubuntu-pro-client.links} | 0 debian/ubuntu-pro-client.lintian-overrides | 10 ++ ....logrotate => ubuntu-pro-client.logrotate} | 0 ...ls.manpages => ubuntu-pro-client.manpages} | 0 debian/ubuntu-pro-client.postinst | 98 +++++++++++++++++++ debian/ubuntu-pro-client.postrm | 37 +++++++ ...ge-tools.prerm => ubuntu-pro-client.prerm} | 0 ...tu-pro-image-auto-attach.lintian-overrides | 3 + features/attached_commands.feature | 2 +- features/unattached_commands.feature | 12 +-- preferences.d/ubuntu-pro-esm-apps | 2 +- preferences.d/ubuntu-pro-esm-infra | 2 +- setup.py | 2 +- tools/ua.bash | 2 +- uaclient/apt.py | 8 +- uaclient/messages/__init__.py | 2 +- uaclient/tests/test_apt.py | 6 +- uaclient/version.py | 4 +- 24 files changed, 235 insertions(+), 85 deletions(-) delete mode 100644 debian/ubuntu-advantage-pro.lintian-overrides rename debian/{ubuntu-advantage-tools.bash-completion => ubuntu-pro-client.bash-completion} (100%) rename debian/{ubuntu-advantage-tools.links => ubuntu-pro-client.links} (100%) create mode 100644 debian/ubuntu-pro-client.lintian-overrides rename debian/{ubuntu-advantage-tools.logrotate => ubuntu-pro-client.logrotate} (100%) rename debian/{ubuntu-advantage-tools.manpages => ubuntu-pro-client.manpages} (100%) create mode 100644 debian/ubuntu-pro-client.postinst create mode 100644 debian/ubuntu-pro-client.postrm rename debian/{ubuntu-advantage-tools.prerm => ubuntu-pro-client.prerm} (100%) create mode 100644 debian/ubuntu-pro-image-auto-attach.lintian-overrides diff --git a/debian/control b/debian/control index ee1eec9002..afad9ed428 100644 --- a/debian/control +++ b/debian/control @@ -35,6 +35,14 @@ Vcs-Browser: https://github.com/canonical/ubuntu-pro-client Rules-Requires-Root: no Package: ubuntu-advantage-tools +Depends: ubuntu-pro-client, ${misc:Depends} +Architecture: all +Priority: optional +Section: oldlibs +Description: transitional package + This is a transitional package. It can safely be removed. + +Package: ubuntu-pro-client Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/ Architecture: any Depends: ${misc:Depends}, @@ -44,6 +52,9 @@ Depends: ${misc:Depends}, python3-pkg-resources, ${extra:Depends} Recommends: ubuntu-pro-client-l10n +Breaks: ubuntu-advantage-tools (<<31~) +Replaces: ubuntu-advantage-tools (<<31~) +Provides: ubuntu-advantage-tools Description: Management tools for Ubuntu Pro Ubuntu Pro is a suite of additional services provided by Canonical on top of Ubuntu. Whether you're an enterprise customer deploying systems @@ -53,17 +64,26 @@ Description: Management tools for Ubuntu Pro Package: ubuntu-pro-client-l10n Architecture: any -Depends: ${misc:Depends}, ubuntu-advantage-tools (>=30~) +Depends: ${misc:Depends}, ubuntu-pro-client (= ${binary:Version}) Description: Translations for Ubuntu Pro Client This package delivers translations of Ubuntu Pro Client for various languages. Package: ubuntu-advantage-pro +Depends: ubuntu-pro-image-auto-attach, ${misc:Depends} +Architecture: all +Priority: optional +Section: oldlibs +Description: transitional package + This is a transitional package. It can safely be removed. + +Package: ubuntu-pro-image-auto-attach Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/en/latest/explanations/what_are_ubuntu_pro_cloud_instances/ Architecture: all -Depends: ${misc:Depends}, ubuntu-advantage-tools (>=20.2) -Replaces: ubuntu-advantage-tools (<<20.2) -Breaks: ubuntu-advantage-tools (<<20.2) +Depends: ${misc:Depends}, ubuntu-pro-client (>=31~) +Breaks: ubuntu-advantage-pro (<<31~) +Replaces: ubuntu-advantage-pro (<<31~) +Provides: ubuntu-advantage-pro Description: Service to auto-attach Ubuntu Pro cloud images This package delivers an additional service that performs an auto-attach operation for Ubuntu Pro cloud instances. This package should not be manually diff --git a/debian/rules b/debian/rules index 38bf01bda0..04fa018033 100755 --- a/debian/rules +++ b/debian/rules @@ -13,11 +13,30 @@ include /etc/os-release # versus Xenial to make those contraints applicable on each series. DISTRO_INFO_DEPS="distro-info (>= 0.18ubuntu0.18.04.1)," +# Xenial, Bionic, Focal, Jammy, and Mantic all began with only the +# ubuntu-advantage-tools. Even after the rename to ubuntu-pro-client, those +# releases need to keep ubuntu-advantage-tools installed, because the prerm +# script will break ESM access. In order to force ubuntu-advantage-tools to +# stay installed, we add ubuntu-advantage-tools to the Depends list for +# ubuntu-pro-client on those releases. +# On Noble onward, only ubuntu-pro-client needs to be installed, because it +# will have been there from the beginning of the release. ubuntu-advantage-tools +# still can be installed, but it will no longer cause any harm. +SELF_DEPS="" + ifeq (${VERSION_ID},"16.04") APT_PKG_DEPS="apt (>= 1.2.32), apt-transport-https (>= 1.2.32), apt-utils (>= 1.2.32), libapt-inst2.0 (>= 1.2.32), libapt-pkg5.0 (>= 1.2.32)," DISTRO_INFO_DEPS="distro-info (>= 0.14ubuntu0.2)," +SELF_DEPS="ubuntu-advantage-tools (>= 31~)," else ifeq (${VERSION_ID},"18.04") APT_PKG_DEPS="apt (>= 1.6.11), apt-utils (>= 1.6.11), libapt-inst2.0 (>= 1.6.11), libapt-pkg5.0 (>= 1.6.11)," +SELF_DEPS="ubuntu-advantage-tools (>= 31~)," +else ifeq (${VERSION_ID},"20.04") +SELF_DEPS="ubuntu-advantage-tools (>= 31~)," +else ifeq (${VERSION_ID},"22.04") +SELF_DEPS="ubuntu-advantage-tools (>= 31~)," +else ifeq (${VERSION_ID},"23.10") +SELF_DEPS="ubuntu-advantage-tools (>= 31~)," endif %: @@ -39,50 +58,54 @@ endif endif override_dh_gencontrol: - echo extra:Depends=$(APT_PKG_DEPS) $(DISTRO_INFO_DEPS) >> debian/ubuntu-advantage-tools.substvars + echo extra:Depends=$(APT_PKG_DEPS) $(DISTRO_INFO_DEPS) $(SELF_DEPS) >> debian/ubuntu-pro-client.substvars dh_gencontrol override_dh_systemd_enable: - dh_systemd_enable -pubuntu-advantage-pro ua-auto-attach.service - dh_systemd_enable -pubuntu-advantage-tools ua-reboot-cmds.service - dh_systemd_enable -pubuntu-advantage-tools ua-timer.timer - dh_systemd_enable -pubuntu-advantage-tools ua-timer.service - dh_systemd_enable -pubuntu-advantage-tools ubuntu-advantage.service + dh_systemd_enable -pubuntu-pro-image-auto-attach ua-auto-attach.service + dh_systemd_enable -pubuntu-pro-client ua-reboot-cmds.service + dh_systemd_enable -pubuntu-pro-client ua-timer.timer + dh_systemd_enable -pubuntu-pro-client ua-timer.service + dh_systemd_enable -pubuntu-pro-client ubuntu-advantage.service ifeq (${VERSION_ID},"16.04") # Only enable cloud-id-shim on Xenial - dh_systemd_enable -pubuntu-advantage-tools ubuntu-advantage-cloud-id-shim.service + dh_systemd_enable -pubuntu-pro-client ubuntu-advantage-cloud-id-shim.service endif override_dh_systemd_start: - dh_systemd_start -pubuntu-advantage-tools ua-timer.timer - dh_systemd_start -pubuntu-advantage-tools ubuntu-advantage.service + dh_systemd_start -pubuntu-pro-client ua-timer.timer + dh_systemd_start -pubuntu-pro-client ubuntu-advantage.service override_dh_auto_install: - dh_auto_install --destdir=debian/ubuntu-advantage-tools + dh_auto_install --destdir=debian/ubuntu-pro-client debian/jinja2_render debian/apparmor/ubuntu_pro_apt_news.jinja2 debian/apparmor/ubuntu_pro_apt_news ubuntu_codename=${UBUNTU_CODENAME} # quick syntax check on the generated profile apparmor_parser -K -T -Q debian/apparmor/ubuntu_pro_apt_news - install -D -m 644 $(CURDIR)/debian/apparmor/ubuntu_pro_apt_news $(CURDIR)/debian/ubuntu-advantage-tools/etc/apparmor.d/ubuntu_pro_apt_news - dh_apparmor -pubuntu-advantage-tools --profile-name=ubuntu_pro_apt_news + install -D -m 644 $(CURDIR)/debian/apparmor/ubuntu_pro_apt_news $(CURDIR)/debian/ubuntu-pro-client/etc/apparmor.d/ubuntu_pro_apt_news + dh_apparmor -pubuntu-pro-client --profile-name=ubuntu_pro_apt_news flist=$$(find $(CURDIR)/debian/ -type f -name version.py) && sed -i 's,@@PACKAGED_VERSION@@,$(DEB_VERSION),' $${flist:-did-not-find-version-py-for-replacement} # We install the conf file even on non-LTS version to avoid issues on upgrade scenarios - make -C apt-hook DESTDIR=$(CURDIR)/debian/ubuntu-advantage-tools install-conf - make -C apt-hook DESTDIR=$(CURDIR)/debian/ubuntu-advantage-tools install + make -C apt-hook DESTDIR=$(CURDIR)/debian/ubuntu-pro-client install-conf + make -C apt-hook DESTDIR=$(CURDIR)/debian/ubuntu-pro-client install # We want to guarantee that we are not shipping any conftest files - find $(CURDIR)/debian/ubuntu-advantage-tools -type f -name conftest.py -delete + find $(CURDIR)/debian/ubuntu-pro-client -type f -name conftest.py -delete ifneq (${VERSION_ID},"16.04") # Only install cloud-id-shim on Xenial - rm $(CURDIR)/debian/ubuntu-advantage-tools/lib/systemd/system/ubuntu-advantage-cloud-id-shim.service + rm $(CURDIR)/debian/ubuntu-pro-client/lib/systemd/system/ubuntu-advantage-cloud-id-shim.service endif - # Move ua-auto-attach.service out to ubuntu-advantage-pro - mkdir -p debian/ubuntu-advantage-pro/lib/systemd/system - mv debian/ubuntu-advantage-tools/lib/systemd/system/ua-auto-attach.* debian/ubuntu-advantage-pro/lib/systemd/system - cd debian/ubuntu-advantage-tools + # Move ua-auto-attach.service out to ubuntu-pro-image-auto-attach + mkdir -p debian/ubuntu-pro-image-auto-attach/lib/systemd/system + mv debian/ubuntu-pro-client/lib/systemd/system/ua-auto-attach.* debian/ubuntu-pro-image-auto-attach/lib/systemd/system + + # move migration scripts from before the package rename into ubuntu-advantage-tools + mkdir -p debian/ubuntu-advantage-tools/usr/lib/ubuntu-advantage + mv debian/ubuntu-pro-client/usr/lib/ubuntu-advantage/migrate_user_config.py debian/ubuntu-advantage-tools/usr/lib/ubuntu-advantage + mv debian/ubuntu-pro-client/usr/lib/ubuntu-advantage/patch_status_json.py debian/ubuntu-advantage-tools/usr/lib/ubuntu-advantage override_dh_auto_clean: diff --git a/debian/ubuntu-advantage-pro.lintian-overrides b/debian/ubuntu-advantage-pro.lintian-overrides deleted file mode 100644 index ba165de5ee..0000000000 --- a/debian/ubuntu-advantage-pro.lintian-overrides +++ /dev/null @@ -1,3 +0,0 @@ -# Avoid warning on wanted-by-target - -ubuntu-advantage-pro: systemd-service-file-refers-to-unusual-wantedby-target diff --git a/debian/ubuntu-advantage-tools.postinst b/debian/ubuntu-advantage-tools.postinst index b11748fee8..2fac82c5dc 100644 --- a/debian/ubuntu-advantage-tools.postinst +++ b/debian/ubuntu-advantage-tools.postinst @@ -450,7 +450,6 @@ case "$1" in rm_old_license_check_marker disable_new_timer_if_old_timer_already_disabled remove_old_systemd_units - /usr/lib/ubuntu-advantage/cloud-id-shim.sh || true # On old version of ubuntu-advantange-tools, we don't have a public # machine_token.json file on attached machines. Since the non-root @@ -474,15 +473,6 @@ case "$1" in if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "29~"; then rename_gpg_keys fi - - if grep -q "^ua_config:" /etc/ubuntu-advantage/uaclient.conf; then - echo "Warning: uaclient.conf contains old ua_config field." >&2 - echo " Please do the following:" >&2 - echo " 1. Run 'pro config set field=value' for each field/value pair" >&2 - echo " present under ua_config in /etc/ubuntu-advantage/uaclient.conf" >&2 - echo " 2. Delete ua_config and all sub-fields in" >&2 - echo " /etc/ubuntu-advantage/uaclient.conf" >&2 - fi ;; esac diff --git a/debian/ubuntu-advantage-tools.postrm b/debian/ubuntu-advantage-tools.postrm index e0e930daf6..cb64b0bfe6 100644 --- a/debian/ubuntu-advantage-tools.postrm +++ b/debian/ubuntu-advantage-tools.postrm @@ -3,33 +3,7 @@ set -e -remove_apt_auth(){ - # config file created at runtime, needs explicit handling on purge - rm -f /etc/apt/auth.conf.d/90ubuntu-advantage -} - -remove_cache_dir(){ - rm -rf /var/lib/ubuntu-advantage -} - -remove_logs(){ - rm -f /var/log/ubuntu-advantage.log* - rm -f /var/log/ubuntu-advantage-timer.log* - rm -f /var/log/ubuntu-advantage-license-check.log* - rm -f /var/log/ubuntu-advantage-daemon.log* -} - -remove_gpg_files(){ - rm -f /etc/apt/trusted.gpg.d/ubuntu-pro-*.gpg -} - case "$1" in - purge) - remove_apt_auth - remove_cache_dir - remove_logs - remove_gpg_files - ;; abort-install|abort-upgrade) # LP: #2004280 if dpkg --compare-versions "$2" lt "27.14~"; then diff --git a/debian/ubuntu-advantage-tools.bash-completion b/debian/ubuntu-pro-client.bash-completion similarity index 100% rename from debian/ubuntu-advantage-tools.bash-completion rename to debian/ubuntu-pro-client.bash-completion diff --git a/debian/ubuntu-advantage-tools.links b/debian/ubuntu-pro-client.links similarity index 100% rename from debian/ubuntu-advantage-tools.links rename to debian/ubuntu-pro-client.links diff --git a/debian/ubuntu-pro-client.lintian-overrides b/debian/ubuntu-pro-client.lintian-overrides new file mode 100644 index 0000000000..6dc2905272 --- /dev/null +++ b/debian/ubuntu-pro-client.lintian-overrides @@ -0,0 +1,10 @@ +# We are silencing this issue because of this LP: #1930121 +ubuntu-pro-client: command-with-path-in-maintainer-script + +# Ubuntu doesn't support sysv init.d +ubuntu-pro-client: package-supports-alternative-init-but-no-init.d-script + +# We have made the decision of delivering those files +ubuntu-pro-client: package-installs-apt-preferences + +ubuntu-pro-client: possible-bashism-in-maintainer-script diff --git a/debian/ubuntu-advantage-tools.logrotate b/debian/ubuntu-pro-client.logrotate similarity index 100% rename from debian/ubuntu-advantage-tools.logrotate rename to debian/ubuntu-pro-client.logrotate diff --git a/debian/ubuntu-advantage-tools.manpages b/debian/ubuntu-pro-client.manpages similarity index 100% rename from debian/ubuntu-advantage-tools.manpages rename to debian/ubuntu-pro-client.manpages diff --git a/debian/ubuntu-pro-client.postinst b/debian/ubuntu-pro-client.postinst new file mode 100644 index 0000000000..11f7ef95da --- /dev/null +++ b/debian/ubuntu-pro-client.postinst @@ -0,0 +1,98 @@ +#!/bin/sh + +set -e + +. /etc/os-release # For VERSION_ID + +# Needed even if this script doesn't call debconf, see: +# https://lintian.debian.org/tags/postinst-does-not-load-confmodule.html +# Note: this may re-exec the postinst script. +. /usr/share/debconf/confmodule + +if [ -z "${VERSION_ID}" ]; then + echo "Warning: missing VERSION_ID in /etc/os-release" >&2 + VERSION_ID="NO-VERSION_ID" +fi + + +XENIAL_CLOUD_ID_SHIM_UNIT_LOCATION="/etc/systemd/system/multi-user.target.wants/ubuntu-advantage-cloud-id-shim.service" + +NOTICES_DIR="/var/lib/ubuntu-advantage/notices" +TEMP_NOTICES_DIR="/run/ubuntu-advantage/notices" +REBOOT_CMD_MARKER_FILE="/var/lib/ubuntu-advantage/marker-reboot-cmds-required" + + +# +# Helpers that change state of pro-client +# +add_notice() { + notice=$1 + mkdir -p $NOTICES_DIR + touch $NOTICES_DIR/$notice +} +add_temp_notice() { + notice=$1 + mkdir -p $TEMP_NOTICES_DIR + touch $TEMP_NOTICES_DIR/$notice +} +mark_reboot_cmds_as_needed() { + if [ ! -f "$REBOOT_CMD_MARKER_FILE" ]; then + touch $REBOOT_CMD_MARKER_FILE + fi +} + + +case "$1" in + configure) + PREVIOUS_PKG_VER=$2 + + # + # Migrations from previous ubuntu-pro-client package versions + # + # These should always be version-gated using PREVIOUS_PKG_VER and execute in order from oldest to newest. + # For example: + # if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "33~"; then + # # do the migrations to version 33 + # fi + # if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "34~"; then + # # do the migrations to version 34 + # fi + # + + # none yet for ubuntu-pro-client package + + + # + # do-release-upgrade migrations from previous Ubuntu release ubuntu-pro-client package versions + # + + # Xenial -> Bionic: clean up unnecessary cloud-id-shim unit that is only in xenial packages + if [ "$VERSION_ID" = "18.04" ]; then + if echo "$PREVIOUS_PKG_VER" | grep -q "16.04"; then + if [ -L $XENIAL_CLOUD_ID_SHIM_UNIT_LOCATION ]; then + deb-systemd-helper purge ubuntu-advantage-cloud-id-shim.service > /dev/null || true + deb-systemd-helper unmask ubuntu-advantage-cloud-id-shim.service > /dev/null || true + fi + fi + fi + + + # + # Always do these to ensure ubuntu-pro-client is in correct state + # + + /usr/lib/ubuntu-advantage/cloud-id-shim.sh || true + + if grep -q "^ua_config:" /etc/ubuntu-advantage/uaclient.conf; then + echo "Warning: uaclient.conf contains old ua_config field." >&2 + echo " Please do the following:" >&2 + echo " 1. Run 'pro config set field=value' for each field/value pair" >&2 + echo " present under ua_config in /etc/ubuntu-advantage/uaclient.conf" >&2 + echo " 2. Delete ua_config and all sub-fields in" >&2 + echo " /etc/ubuntu-advantage/uaclient.conf" >&2 + fi + ;; +esac + +#DEBHELPER# +exit 0 diff --git a/debian/ubuntu-pro-client.postrm b/debian/ubuntu-pro-client.postrm new file mode 100644 index 0000000000..918384dffb --- /dev/null +++ b/debian/ubuntu-pro-client.postrm @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + + +remove_apt_auth(){ + # config file created at runtime, needs explicit handling on purge + rm -f /etc/apt/auth.conf.d/90ubuntu-advantage +} + +remove_cache_dir(){ + rm -rf /var/lib/ubuntu-advantage +} + +remove_logs(){ + rm -f /var/log/ubuntu-advantage.log* + rm -f /var/log/ubuntu-advantage-timer.log* + rm -f /var/log/ubuntu-advantage-license-check.log* + rm -f /var/log/ubuntu-advantage-daemon.log* +} + +remove_gpg_files(){ + rm -f /etc/apt/trusted.gpg.d/ubuntu-pro-*.gpg +} + +case "$1" in + purge) + remove_apt_auth + remove_cache_dir + remove_logs + remove_gpg_files + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/ubuntu-advantage-tools.prerm b/debian/ubuntu-pro-client.prerm similarity index 100% rename from debian/ubuntu-advantage-tools.prerm rename to debian/ubuntu-pro-client.prerm diff --git a/debian/ubuntu-pro-image-auto-attach.lintian-overrides b/debian/ubuntu-pro-image-auto-attach.lintian-overrides new file mode 100644 index 0000000000..f3c0c7b087 --- /dev/null +++ b/debian/ubuntu-pro-image-auto-attach.lintian-overrides @@ -0,0 +1,3 @@ +# Avoid warning on wanted-by-target + +ubuntu-pro-image-auto-attach: systemd-service-file-refers-to-unusual-wantedby-target diff --git a/features/attached_commands.feature b/features/attached_commands.feature index 226cd38763..f4fd9f7a2e 100644 --- a/features/attached_commands.feature +++ b/features/attached_commands.feature @@ -37,7 +37,7 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription """ /var/log/ubuntu-advantage.log """ - When I run `logrotate --force /etc/logrotate.d/ubuntu-advantage-tools` with sudo + When I run `logrotate --force /etc/logrotate.d/ubuntu-pro-client` with sudo And I run `sh -c "ls /var/log/ubuntu-advantage* | sort -d"` as non-root Then stdout matches regexp: """ diff --git a/features/unattached_commands.feature b/features/unattached_commands.feature index 70adb9a0ff..2b0dc124a9 100644 --- a/features/unattached_commands.feature +++ b/features/unattached_commands.feature @@ -179,7 +179,7 @@ Feature: Command behaviour when unattached """ .*\[info\].* A new version is available: 2:99.9.9 Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features. """ And I verify that files exist matching `/run/ubuntu-advantage/candidate-version` @@ -194,7 +194,7 @@ Feature: Command behaviour when unattached """ .*\[info\].* A new version is available: 2:99.9.9 Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features. """ When I run `pro status --format json` as non-root @@ -202,7 +202,7 @@ Feature: Command behaviour when unattached """ .*\[info\].* A new version is available: 2:99.9.9 Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features. """ When I run `pro config show` as non-root @@ -210,7 +210,7 @@ Feature: Command behaviour when unattached """ .*\[info\].* A new version is available: 2:99.9.9 Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features. """ When I run `pro api u.pro.version.v1` as non-root @@ -228,7 +228,7 @@ Feature: Command behaviour when unattached """ .*\[info\].* A new version is available: 2:99.9.9 Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features. """ When I apt update @@ -238,7 +238,7 @@ Feature: Command behaviour when unattached """ .*\[info\].* A new version is available: 2:99.9.9 Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features. """ diff --git a/preferences.d/ubuntu-pro-esm-apps b/preferences.d/ubuntu-pro-esm-apps index 5ded6f8f7a..ccdff4be92 100644 --- a/preferences.d/ubuntu-pro-esm-apps +++ b/preferences.d/ubuntu-pro-esm-apps @@ -1,4 +1,4 @@ -# This file is used by Ubuntu Pro and supplied by the ubuntu-advantage-tools +# This file is used by Ubuntu Pro and supplied by the ubuntu-pro-client # package. It has no effect if Ubuntu Pro services are not in use since no # other apt repositories are expected to match o=UbuntuESMApps. # diff --git a/preferences.d/ubuntu-pro-esm-infra b/preferences.d/ubuntu-pro-esm-infra index e956e0ae38..125b31d09f 100644 --- a/preferences.d/ubuntu-pro-esm-infra +++ b/preferences.d/ubuntu-pro-esm-infra @@ -1,4 +1,4 @@ -# This file is used by Ubuntu Pro and supplied by the ubuntu-advantage-tools +# This file is used by Ubuntu Pro and supplied by the ubuntu-pro-client # package. It has no effect if Ubuntu Pro services are not in use since no # other apt repositories are expected to match o=UbuntuESM. # diff --git a/setup.py b/setup.py index 2628f7b36a..e73bfcc2a5 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from uaclient import defaults -NAME = "ubuntu-advantage-tools" +NAME = "ubuntu-pro-client" INSTALL_REQUIRES = open("requirements.txt").read().rstrip("\n").split("\n") diff --git a/tools/ua.bash b/tools/ua.bash index c655a8333f..1576825424 100644 --- a/tools/ua.bash +++ b/tools/ua.bash @@ -1,4 +1,4 @@ -# bash completion for ubuntu-advantage-tools +# bash completion for ubuntu-pro-client . /etc/os-release # For VERSION_ID diff --git a/uaclient/apt.py b/uaclient/apt.py index 231d80bbe0..c6e002cb1b 100644 --- a/uaclient/apt.py +++ b/uaclient/apt.py @@ -17,16 +17,16 @@ from uaclient.defaults import ESM_APT_ROOTDIR APT_HELPER_TIMEOUT = 60.0 # 60 second timeout used for apt-helper call -APT_AUTH_COMMENT = " # ubuntu-advantage-tools" +APT_AUTH_COMMENT = " # ubuntu-pro-client" APT_CONFIG_AUTH_FILE = "Dir::Etc::netrc/" APT_CONFIG_AUTH_PARTS_DIR = "Dir::Etc::netrcparts/" APT_CONFIG_LISTS_DIR = "Dir::State::lists/" APT_PROXY_CONFIG_HEADER = """\ /* - * Autogenerated by ubuntu-advantage-tools + * Autogenerated by ubuntu-pro-client * Do not edit this file directly * - * To change what ubuntu-advantage-tools sets, use the `pro config set` + * To change what ubuntu-pro-client sets, use the `pro config set` * or the `pro config unset` commands to set/unset either: * global_apt_http_proxy and global_apt_https_proxy * for a global apt proxy @@ -54,7 +54,7 @@ SERIES_NOT_USING_DEB822 = ("xenial", "bionic", "focal", "jammy", "mantic") DEB822_REPO_FILE_CONTENT = """\ -# Written by ubuntu-advantage-tools +# Written by ubuntu-pro-client Types: deb{deb_src} URIs: {url} Suites: {suites} diff --git a/uaclient/messages/__init__.py b/uaclient/messages/__init__.py index 74516e6edf..6e6307b1bf 100644 --- a/uaclient/messages/__init__.py +++ b/uaclient/messages/__init__.py @@ -104,7 +104,7 @@ class TxtColor: """\ A new version is available: {version} Please run: - sudo apt install ubuntu-advantage-tools + sudo apt install ubuntu-pro-client to get the latest bug fixes and new features.""" ) ) diff --git a/uaclient/tests/test_apt.py b/uaclient/tests/test_apt.py index d611db9752..74a5064948 100644 --- a/uaclient/tests/test_apt.py +++ b/uaclient/tests/test_apt.py @@ -390,7 +390,7 @@ def test_add_auth_apt_repo_writes_sources_file( gpg_export_calls = [mock.call(src_keyfile, dest_keyfile)] else: expected_content = ( - "# Written by ubuntu-advantage-tools\n" + "# Written by ubuntu-pro-client\n" "Types: deb\n" "URIs: http://fakerepo\n" "Suites: {series}\n" @@ -459,7 +459,7 @@ def test_add_auth_apt_repo_ignores_suites_not_matching_series( else: expected_content = dedent( """\ - # Written by ubuntu-advantage-tools + # Written by ubuntu-pro-client Types: deb URIs: http://fakerepo Suites: {series}-one {series}-updates @@ -521,7 +521,7 @@ def test_add_auth_apt_repo_comments_updates_suites_on_non_update_machine( else: expected_content = dedent( """\ - # Written by ubuntu-advantage-tools + # Written by ubuntu-pro-client Types: deb URIs: http://fakerepo Suites: {series}-one diff --git a/uaclient/version.py b/uaclient/version.py index ee7f39dd89..c6a4b4d091 100644 --- a/uaclient/version.py +++ b/uaclient/version.py @@ -53,9 +53,7 @@ def get_last_known_candidate() -> Optional[str]: ): candidate_version = None try: - candidate_version = get_pkg_candidate_version( - "ubuntu-advantage-tools" - ) + candidate_version = get_pkg_candidate_version("ubuntu-pro-client") if candidate_version: os.makedirs(UAC_RUN_PATH, exist_ok=True) with open(CANDIDATE_CACHE_PATH, "w") as f: From d619b89023e8b4cee113fa28bb323f06b05c3547 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Tue, 12 Dec 2023 12:59:16 -0500 Subject: [PATCH 04/12] tests: update behave testing utils to use new packages --- features/install_uninstall.feature | 2 +- features/steps/ubuntu_advantage_tools.py | 167 ++++++++++++----------- features/util.py | 129 +++++++++++++---- tools/build.py | 2 +- tools/test-in-lxd.sh | 13 +- tools/test-in-multipass.sh | 17 +-- 6 files changed, 203 insertions(+), 127 deletions(-) diff --git a/features/install_uninstall.feature b/features/install_uninstall.feature index 40956ffdaf..5e1c9da683 100644 --- a/features/install_uninstall.feature +++ b/features/install_uninstall.feature @@ -24,7 +24,7 @@ Feature: Pro Install and Uninstall related tests And I verify that files exist matching `/etc/apt/trusted.gpg.d/ubuntu-pro-esm-infra.gpg` And I verify that files exist matching `/etc/apt/sources.list.d/ubuntu-esm-infra.list` And I verify that files exist matching `/etc/apt/preferences.d/ubuntu-esm-infra` - When I run `apt purge ubuntu-advantage-tools -y` with sudo, retrying exit [100] + When I run `apt purge ubuntu-pro-client -y` with sudo, retrying exit [100] Then stdout matches regexp: """ Purging configuration files for ubuntu-advantage-tools diff --git a/features/steps/ubuntu_advantage_tools.py b/features/steps/ubuntu_advantage_tools.py index 5312dd12c9..521b0e3685 100644 --- a/features/steps/ubuntu_advantage_tools.py +++ b/features/steps/ubuntu_advantage_tools.py @@ -7,6 +7,7 @@ from features.steps.packages import when_i_apt_install from features.steps.shell import when_i_run_command, when_i_run_shell_command from features.util import ( + ALL_BINARY_PACKAGE_NAMES, SUT, InstallationSource, build_debs, @@ -22,74 +23,83 @@ def when_i_install_uat(context, machine_name=SUT): if context.pro_config.install_from is InstallationSource.ARCHIVE: instance.execute("sudo apt update") when_i_apt_install( - context, "ubuntu-advantage-tools", machine_name=machine_name + context, "ubuntu-pro-client", machine_name=machine_name ) if is_pro: when_i_apt_install( - context, "ubuntu-advantage-pro", machine_name=machine_name + context, + "ubuntu-pro-image-auto-attach", + machine_name=machine_name, ) elif context.pro_config.install_from is InstallationSource.PREBUILT: - deb_paths = sorted( - get_debs_for_series(context.pro_config.debs_path, series) + debs = get_debs_for_series(context.pro_config.debs_path, series) + logging.info("using debs: {}".format(debs)) + to_install = [] + for deb_name, deb_path in debs.non_cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + if is_pro: + for deb_name, deb_path in debs.cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + when_i_apt_install( + context, " ".join(to_install), machine_name=machine_name ) - logging.info("using debs: {}".format(deb_paths)) - for deb_path in deb_paths: - if "advantage-pro" not in deb_path or is_pro: - instance.push_file(deb_path, "/tmp/behave_ua.deb") - when_i_apt_install( - context, "/tmp/behave_ua.deb", machine_name=machine_name - ) - instance.execute("sudo rm /tmp/behave_ua.deb") elif context.pro_config.install_from is InstallationSource.LOCAL: - ua_deb_path, pro_deb_path, l10n_deb_path = build_debs( + debs = build_debs( series, sbuild_output_to_terminal=context.pro_config.sbuild_output_to_terminal, # noqa: E501 ) - instance.push_file(ua_deb_path, "/tmp/behave_ua.deb") - when_i_apt_install( - context, "/tmp/behave_ua.deb", machine_name=machine_name - ) - instance.execute("sudo rm /tmp/behave_ua.deb") - instance.push_file(l10n_deb_path, "/tmp/behave_ua.deb") + to_install = [] + for deb_name, deb_path in debs.non_cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + if is_pro: + for deb_name, deb_path in debs.cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) when_i_apt_install( - context, "/tmp/behave_ua.deb", machine_name=machine_name + context, " ".join(to_install), machine_name=machine_name ) - instance.execute("sudo rm /tmp/behave_ua.deb") - if is_pro: - instance.push_file(pro_deb_path, "/tmp/behave_ua.deb") - when_i_apt_install( - context, "/tmp/behave_ua.deb", machine_name=machine_name - ) - instance.execute("sudo rm /tmp/behave_ua.deb") elif context.pro_config.install_from is InstallationSource.DAILY: instance.execute("sudo add-apt-repository ppa:ua-client/daily") instance.execute("sudo apt update") when_i_apt_install( - context, "ubuntu-advantage-tools", machine_name=machine_name + context, "ubuntu-pro-client", machine_name=machine_name ) if is_pro: when_i_apt_install( - context, "ubuntu-advantage-pro", machine_name=machine_name + context, + "ubuntu-pro-image-auto-attach", + machine_name=machine_name, ) elif context.pro_config.install_from is InstallationSource.STAGING: instance.execute("sudo add-apt-repository ppa:ua-client/staging") instance.execute("sudo apt update") when_i_apt_install( - context, "ubuntu-advantage-tools", machine_name=machine_name + context, "ubuntu-pro-client", machine_name=machine_name ) if is_pro: when_i_apt_install( - context, "ubuntu-advantage-pro", machine_name=machine_name + context, + "ubuntu-pro-image-auto-attach", + machine_name=machine_name, ) elif context.pro_config.install_from is InstallationSource.STABLE: instance.execute("sudo add-apt-repository ppa:ua-client/stable") instance.execute("sudo apt update") when_i_apt_install( - context, "ubuntu-advantage-tools", machine_name=machine_name + context, "ubuntu-pro-client", machine_name=machine_name ) if is_pro: when_i_apt_install( - context, "ubuntu-advantage-pro", machine_name=machine_name + context, + "ubuntu-pro-image-auto-attach", + machine_name=machine_name, ) elif context.pro_config.install_from is InstallationSource.PROPOSED: context.text = "deb http://archive.ubuntu.com/ubuntu/ {series}-proposed main\n".format( # noqa: E501 @@ -110,31 +120,26 @@ def when_i_install_uat(context, machine_name=SUT): machine_name=machine_name, ) - context.text = "Package: ubuntu-advantage-tools\nPin: release a={series}-proposed\nPin-Priority: 1001\n".format( # noqa: E501 - series=series - ) - when_i_create_file_with_content( - context, - "/etc/apt/preferences.d/uatools-proposed", - machine_name=machine_name, - ) - - context.text = "Package: ubuntu-advantage-pro\nPin: release a={series}-proposed\nPin-Priority: 1001\n".format( # noqa: E501 - series=series - ) - when_i_create_file_with_content( - context, - "/etc/apt/preferences.d/uapro-proposed", - machine_name=machine_name, - ) + for package in ALL_BINARY_PACKAGE_NAMES: + context.text = "Package: {package}\nPin: release a={series}-proposed\nPin-Priority: 1001\n".format( # noqa: E501 + package=package, + series=series, + ) + when_i_create_file_with_content( + context, + "/etc/apt/preferences.d/{}-proposed".format(package), + machine_name=machine_name, + ) instance.execute("sudo apt update") when_i_apt_install( - context, "ubuntu-advantage-tools", machine_name=machine_name + context, "ubuntu-pro-client", machine_name=machine_name ) if is_pro: when_i_apt_install( - context, "ubuntu-advantage-pro", machine_name=machine_name + context, + "ubuntu-pro-image-auto-attach", + machine_name=machine_name, ) elif context.pro_config.install_from is InstallationSource.CUSTOM: instance.execute( @@ -142,26 +147,28 @@ def when_i_install_uat(context, machine_name=SUT): ) instance.execute("sudo apt update") when_i_apt_install( - context, "ubuntu-advantage-tools", machine_name=machine_name + context, "ubuntu-pro-client", machine_name=machine_name ) if is_pro: when_i_apt_install( - context, "ubuntu-advantage-pro", machine_name=machine_name + context, + "ubuntu-pro-image-auto-attach", + machine_name=machine_name, ) @when("I have the `{series}` debs under test in `{dest}`") def when_i_have_the_debs_under_test(context, series, dest): if context.pro_config.install_from is InstallationSource.LOCAL: - deb_paths = build_debs( + debs = build_debs( series, sbuild_output_to_terminal=context.pro_config.sbuild_output_to_terminal, # noqa: E501 ) - for deb_path in deb_paths: - tools_or_pro = "tools" if "tools" in deb_path else "pro" - dest_path = "{}/ubuntu-advantage-{}.deb".format(dest, tools_or_pro) - context.machines[SUT].instance.push_file(deb_path, dest_path) + for deb_name, deb_path in debs.all_debs(): + context.machines[SUT].instance.push_file( + deb_path, "{}/{}.deb".format(dest, deb_name) + ) else: if context.pro_config.install_from is InstallationSource.PROPOSED: ppa_opts = "" @@ -193,16 +200,12 @@ def when_i_have_the_debs_under_test(context, series, dest): logging.info("Download command `{}`".format(download_cmd)) logging.info("stdout: {}".format(context.process.stdout)) logging.info("stderr: {}".format(context.process.stderr)) - when_i_run_shell_command( - context, - "cp ubuntu-advantage-tools*.deb ubuntu-advantage-tools.deb", - "with sudo", - ) - when_i_run_shell_command( - context, - "cp ubuntu-advantage-pro*.deb ubuntu-advantage-pro.deb", - "with sudo", - ) + for package in ALL_BINARY_PACKAGE_NAMES: + when_i_run_shell_command( + context, + "cp {package}*.deb {package}.deb".format(package=package), + "with sudo", + ) @when( @@ -250,9 +253,9 @@ def create_local_ppa(context, release): release, sbuild_output_to_terminal=context.pro_config.sbuild_output_to_terminal, ) - for deb in debs: - deb_destination = "/tmp/" + deb.split("/")[-1] - context.machines["ppa"].instance.push_file(deb, deb_destination) + for deb_name, deb_path in debs.all_debs(): + deb_destination = "/tmp/{}.deb".format(deb_name) + context.machines["ppa"].instance.push_file(deb_path, deb_destination) when_i_run_command( context, "aptly repo add repo-{} {}".format(release, deb_destination), @@ -271,19 +274,21 @@ def create_local_ppa(context, release): def when_i_install_pro(context, machine_name=SUT): if context.pro_config.install_from is InstallationSource.LOCAL: series = context.machines[machine_name].series - deb_paths = build_debs( + debs = build_debs( series, sbuild_output_to_terminal=context.pro_config.sbuild_output_to_terminal, # noqa: E501 ) - for deb_path in deb_paths: - if "advantage-pro" in deb_path: - context.machines[machine_name].instance.push_file( - deb_path, "/tmp/pro.deb" - ) - when_i_run_command( - context, "dpkg -i /tmp/pro.deb", "with sudo" - ) + to_install = [] + for deb_name, deb_path in debs.cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + context.machines[machine_name].instance.push_file( + deb_path, instance_tmp_path + ) + to_install.append(instance_tmp_path) + when_i_apt_install( + context, " ".join(to_install), machine_name=machine_name + ) else: when_i_run_command( context, "apt-get install ubuntu-advantage-pro", "with sudo" diff --git a/features/util.py b/features/util.py index d930ba2a33..cada5687b1 100644 --- a/features/util.py +++ b/features/util.py @@ -11,8 +11,9 @@ import tempfile import time from base64 import b64encode +from dataclasses import dataclass from enum import Enum -from typing import Callable, Iterable, List, Optional +from typing import Callable, Iterable, List, Optional, Tuple from urllib.parse import quote from urllib.request import Request, urlopen @@ -33,6 +34,43 @@ UA_DEB_BUILD_CACHE = os.path.join(UA_TMP_DIR, "deb-cache") +ALL_BINARY_PACKAGE_NAMES = [ + "ubuntu-pro-client", + "ubuntu-pro-client-l10n", + "ubuntu-pro-image-auto-attach", + "ubuntu-advantage-tools", + "ubuntu-advantage-pro", +] + + +@dataclass +class ProDebPaths: + ubuntu_pro_client: str + ubuntu_pro_image_auto_attach: str + ubuntu_pro_client_l10n: str + ubuntu_advantage_tools: str + ubuntu_advantage_pro: str + + def non_cloud_pro_image_debs(self) -> List[Tuple[str, str]]: + return [ + ("ubuntu-pro-client", self.ubuntu_pro_client), + ("ubuntu-advantage-tools", self.ubuntu_advantage_tools), + ("ubuntu-pro-client-l10n", self.ubuntu_pro_client_l10n), + ] + + def cloud_pro_image_debs(self) -> List[Tuple[str, str]]: + return [ + ( + "ubuntu-pro-image-auto-attach", + self.ubuntu_pro_image_auto_attach, + ), + ("ubuntu-advantage-pro", self.ubuntu_advantage_pro), + ] + + def all_debs(self) -> List[Tuple[str, str]]: + return self.non_cloud_pro_image_debs() + self.cloud_pro_image_debs() + + class InstallationSource(Enum): ARCHIVE = "archive" PREBUILT = "prebuilt" @@ -114,12 +152,36 @@ def repo_state_hash( return hashlib.md5(output_to_hash).hexdigest() -def get_debs_for_series(debs_path: str, series: str) -> List[str]: - return [ - os.path.join(debs_path, deb_file) - for deb_file in os.listdir(debs_path) - if series in deb_file - ] +def get_debs_for_series(debs_path: str, series: str) -> ProDebPaths: + ubuntu_pro_client = "" + ubuntu_pro_client_l10n = "" + ubuntu_pro_image_auto_attach = "" + ubuntu_advantage_tools = "" + ubuntu_advantage_pro = "" + for deb_file in os.listdir(debs_path): + if series in deb_file: + full_path = os.path.join(debs_path, deb_file) + if "ubuntu-pro-client-l10n" in deb_file: + ubuntu_pro_client_l10n = full_path + elif "ubuntu-pro-client" in deb_file: + ubuntu_pro_client = full_path + elif "ubuntu-pro-image-auto-attach" in deb_file: + ubuntu_pro_image_auto_attach = full_path + elif "ubuntu-advantage-tools" in deb_file: + ubuntu_advantage_tools = full_path + elif "ubuntu-advantage-pro" in deb_file: + ubuntu_advantage_pro = full_path + return ProDebPaths( + ubuntu_pro_client=ubuntu_pro_client, + ubuntu_pro_client_l10n=ubuntu_pro_client_l10n, + ubuntu_pro_image_auto_attach=ubuntu_pro_image_auto_attach, + ubuntu_advantage_tools=ubuntu_advantage_tools, + ubuntu_advantage_pro=ubuntu_advantage_pro, + ) + + +def _create_deb_path(prefix: str, name: str): + return os.path.join(UA_DEB_BUILD_CACHE, "{}{}.deb".format(prefix, name)) def build_debs( @@ -127,7 +189,7 @@ def build_debs( architecture: Optional[str] = None, chroot: Optional[str] = None, sbuild_output_to_terminal: bool = False, -) -> List[str]: +) -> ProDebPaths: """ Build the package through sbuild and store the debs into output_deb_dir @@ -141,25 +203,28 @@ def build_debs( architecture = get_dpkg_arch() deb_prefix = "{}-{}-{}-".format(series, architecture, repo_state_hash()) - tools_deb_name = "{}ubuntu-advantage-tools.deb".format(deb_prefix) - pro_deb_name = "{}ubuntu-advantage-pro.deb".format(deb_prefix) - l10n_deb_name = "{}ubuntu-pro-client-l10n.deb".format(deb_prefix) - tools_deb_cache_path = os.path.join(UA_DEB_BUILD_CACHE, tools_deb_name) - pro_deb_cache_path = os.path.join(UA_DEB_BUILD_CACHE, pro_deb_name) - l10n_deb_cache_path = os.path.join(UA_DEB_BUILD_CACHE, l10n_deb_name) + deb_paths = ProDebPaths( + ubuntu_pro_client=_create_deb_path(deb_prefix, "ubuntu-pro-client"), + ubuntu_pro_image_auto_attach=_create_deb_path( + deb_prefix, "ubuntu-pro-image-auto-attach" + ), + ubuntu_pro_client_l10n=_create_deb_path( + deb_prefix, "ubuntu-pro-client-l10n" + ), + ubuntu_advantage_tools=_create_deb_path( + deb_prefix, "ubuntu-advantage-tools" + ), + ubuntu_advantage_pro=_create_deb_path( + deb_prefix, "ubuntu-advantage-pro" + ), + ) if not os.path.exists(UA_DEB_BUILD_CACHE): os.makedirs(UA_DEB_BUILD_CACHE) - if os.path.exists(tools_deb_cache_path) and os.path.exists( - pro_deb_cache_path - ): - logging.info( - "--- Using debs in cache: {} and {} and {}".format( - tools_deb_cache_path, pro_deb_cache_path, l10n_deb_cache_path - ) - ) - return [tools_deb_cache_path, pro_deb_cache_path, l10n_deb_cache_path] + if os.path.exists(deb_paths.ubuntu_pro_client): + logging.info("--- Using debs in cache") + return deb_paths logging.info("--- Creating: {}".format(SOURCE_PR_TGZ)) @@ -248,17 +313,21 @@ def build_debs( for f in os.listdir(SBUILD_DIR): if f.endswith(".deb"): - if "l10n" in f: - dest = l10n_deb_cache_path - elif "pro" in f: - dest = pro_deb_cache_path - elif "tools" in f: - dest = tools_deb_cache_path + if "ubuntu-pro-client-l10n" in f: + dest = deb_paths.ubuntu_pro_client_l10n + elif "ubuntu-pro-client" in f: + dest = deb_paths.ubuntu_pro_client + elif "ubuntu-pro-image-auto-attach" in f: + dest = deb_paths.ubuntu_pro_image_auto_attach + elif "ubuntu-advantage-tools" in f: + dest = deb_paths.ubuntu_advantage_tools + elif "ubuntu-advantage-pro" in f: + dest = deb_paths.ubuntu_advantage_pro else: continue shutil.copy(os.path.join(SBUILD_DIR, f), dest) - return [tools_deb_cache_path, pro_deb_cache_path, l10n_deb_cache_path] + return deb_paths class SafeLoaderWithoutDatetime(yaml.SafeLoader): diff --git a/tools/build.py b/tools/build.py index c0d4aa098f..6f4a270824 100644 --- a/tools/build.py +++ b/tools/build.py @@ -39,7 +39,7 @@ def main(series=None, chroot=None, arch=None, quiet=False): chroot=chroot, sbuild_output_to_terminal=not quiet, architecture=arch, - ), + ).__dict__, } ) ) diff --git a/tools/test-in-lxd.sh b/tools/test-in-lxd.sh index b1e84b73b8..3ff732c521 100755 --- a/tools/test-in-lxd.sh +++ b/tools/test-in-lxd.sh @@ -13,8 +13,9 @@ SHELL_BEFORE=${SHELL_BEFORE:-0} series=${1:-jammy} build_out=$(./tools/build.sh "$series") hash=$(echo "$build_out" | jq -r .state_hash) -tools_deb=$(echo "$build_out" | jq -r '.debs[]' | grep tools) -l10n_deb=$(echo "$build_out" | jq -r '.debs[]' | grep l10n) +ubuntu_advantage_tools_deb=$(echo "$build_out" | jq -r '.debs.ubuntu_advantage_tools') +ubuntu_pro_client_deb=$(echo "$build_out" | jq -r '.debs.ubuntu_pro_client') +ubuntu_pro_client_l10n_deb=$(echo "$build_out" | jq -r '.debs.ubuntu_pro_client_l10n') name=ua-$series-$hash flags= @@ -29,8 +30,9 @@ if [[ "$VM" -ne 0 ]]; then echo "vms take a while before the agent is ready" sleep 30 fi -lxc file push "$tools_deb" "${name}/tmp/ua_tools.deb" -lxc file push "$l10n_deb" "${name}/tmp/ua_l10n.deb" +lxc file push "$ubuntu_advantage_tools_deb" "${name}/tmp/ua_tools.deb" +lxc file push "$ubuntu_pro_client_deb" "${name}/tmp/pro.deb" +lxc file push "$ubuntu_pro_client_l10n_deb" "${name}/tmp/pro_l10n.deb" if [[ "$SHELL_BEFORE" -ne 0 ]]; then set +x @@ -43,6 +45,5 @@ if [[ "$SHELL_BEFORE" -ne 0 ]]; then lxc exec "$name" bash fi -lxc exec "$name" -- dpkg -i /tmp/ua_tools.deb -lxc exec "$name" -- dpkg -i /tmp/ua_l10n.deb +lxc exec "$name" -- apt install /tmp/ua_tools.deb /tmp/pro.deb /tmp/pro_l10n.deb lxc shell "$name" diff --git a/tools/test-in-multipass.sh b/tools/test-in-multipass.sh index 18790d75c0..36dd315c27 100755 --- a/tools/test-in-multipass.sh +++ b/tools/test-in-multipass.sh @@ -11,18 +11,20 @@ SHELL_BEFORE=${SHELL_BEFORE:-0} series=${1:-jammy} build_out=$(./tools/build.sh "$series") hash=$(echo "$build_out" | jq -r .state_hash) -tools_deb=$(echo "$build_out" | jq -r '.debs[]' | grep tools) -l10n_deb=$(echo "$build_out" | jq -r '.debs[]' | grep l10n) +ubuntu_advantage_tools_deb=$(echo "$build_out" | jq -r '.debs.ubuntu_advantage_tools') +ubuntu_pro_client_deb=$(echo "$build_out" | jq -r '.debs.ubuntu_pro_client') +ubuntu_pro_client_l10n_deb=$(echo "$build_out" | jq -r '.debs.ubuntu_pro_client_l10n') name=ua-$series-$hash multipass delete "$name" --purge || true multipass launch "$series" --name "$name" -sleep 30 # Snaps won't access /tmp -cp "$tools_deb" ~/ua_tools.deb -cp "$l10n_deb" ~/ua_l10n.deb +cp "$ubuntu_advantage_tools_deb" ~/ua_tools.deb +cp "$ubuntu_pro_client_l10n_deb" ~/pro_l10n.deb +cp "$ubuntu_pro_client_deb" ~/pro.deb multipass transfer ~/ua_tools.deb "${name}:/tmp/ua_tools.deb" -multipass transfer ~/ua_l10n.deb "${name}:/tmp/ua_l10n.deb" +multipass transfer ~/pro_l10n.deb "${name}:/tmp/pro_l10n.deb" +multipass transfer ~/pro.deb "${name}:/tmp/pro.deb" rm -f ~/ua_tools.deb rm -f ~/ua_l10n.deb @@ -37,6 +39,5 @@ if [[ "$SHELL_BEFORE" -ne 0 ]]; then multipass exec "$name" bash fi -multipass exec "$name" -- sudo dpkg -i /tmp/ua_tools.deb -multipass exec "$name" -- sudo dpkg -i /tmp/ua_l10n.deb +multipass exec "$name" -- sudo apt install /tmp/ua_tools.deb /tmp/pro.deb /tmp/pro_l10n.deb multipass shell "$name" From 1572d10a4795001a60fe0b9ea3ce022ab52b8675 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Fri, 19 Jan 2024 16:55:55 -0500 Subject: [PATCH 05/12] update-pos --- debian/po/pt_BR.po | 6 +++--- debian/po/ubuntu-pro.pot | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po index b0e65bdd21..a35e9f3dc3 100644 --- a/debian/po/pt_BR.po +++ b/debian/po/pt_BR.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-17 16:08-0500\n" +"POT-Creation-Date: 2024-01-19 16:55-0500\n" "PO-Revision-Date: 2023-09-25 12:29-0400\n" "Last-Translator: Lucas Moura \n" "Language-Team: Brazilian Portuguese \n" "Language-Team: LANGUAGE \n" @@ -312,7 +312,7 @@ msgstr "" msgid "" " A new version is available: {version}\n" "Please run:\n" -" sudo apt install ubuntu-advantage-tools\n" +" sudo apt install ubuntu-pro-client\n" "to get the latest bug fixes and new features." msgstr "" From 5ff96f384b80ccf62222c0118add5bd0bd38f201 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Mon, 8 Jan 2024 12:45:09 -0500 Subject: [PATCH 06/12] fix package name in translations --- debian/po/pt_BR.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po index a35e9f3dc3..c7280ed142 100644 --- a/debian/po/pt_BR.po +++ b/debian/po/pt_BR.po @@ -365,7 +365,7 @@ msgstr "" "novamente." #: ../../uaclient/messages/__init__.py:104 -#, fuzzy, python-brace-format +#, python-brace-format msgid "" " A new version is available: {version}\n" "Please run:\n" @@ -374,7 +374,7 @@ msgid "" msgstr "" " Uma nova versão está disponível: {version}\n" "Por favor, execute:\n" -" sudo apt install ubuntu-advantage-tools\n" +" sudo apt install ubuntu-pro-client\n" "para obter as últimas correções de erros e novas funcionalidades." #. ############################################################################## From ce2aed6f72306bc821ae3088081d4cee414fd00b Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Tue, 9 Jan 2024 13:28:20 -0500 Subject: [PATCH 07/12] fixup: don't provide ubuntu-advantage-tools By removing "Provides: ubuntu-advantage-tools", we lower the chances of ubuntu-advantage-tools <31 being removed during an install of ubuntu-pro-client, becuase ubuntu-minimal (and ubuntu-cloud-minimal) Depend on ubuntu-advantage-tools. This removes the need for ubuntu-pro-client Depends: ubuntu-advantage-tools. --- debian/control | 5 +++-- debian/rules | 21 +-------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/debian/control b/debian/control index afad9ed428..ad445f6432 100644 --- a/debian/control +++ b/debian/control @@ -35,7 +35,7 @@ Vcs-Browser: https://github.com/canonical/ubuntu-pro-client Rules-Requires-Root: no Package: ubuntu-advantage-tools -Depends: ubuntu-pro-client, ${misc:Depends} +Depends: ubuntu-pro-client (= ${binary:Version}), ${misc:Depends} Architecture: all Priority: optional Section: oldlibs @@ -54,7 +54,8 @@ Depends: ${misc:Depends}, Recommends: ubuntu-pro-client-l10n Breaks: ubuntu-advantage-tools (<<31~) Replaces: ubuntu-advantage-tools (<<31~) -Provides: ubuntu-advantage-tools +# IMPORTANT: ubuntu-pro-client does not "Provide" ubuntu-advantage-tools +# TODO fill this in with rationale after testing. Description: Management tools for Ubuntu Pro Ubuntu Pro is a suite of additional services provided by Canonical on top of Ubuntu. Whether you're an enterprise customer deploying systems diff --git a/debian/rules b/debian/rules index 04fa018033..62fbdfc2e9 100755 --- a/debian/rules +++ b/debian/rules @@ -13,30 +13,11 @@ include /etc/os-release # versus Xenial to make those contraints applicable on each series. DISTRO_INFO_DEPS="distro-info (>= 0.18ubuntu0.18.04.1)," -# Xenial, Bionic, Focal, Jammy, and Mantic all began with only the -# ubuntu-advantage-tools. Even after the rename to ubuntu-pro-client, those -# releases need to keep ubuntu-advantage-tools installed, because the prerm -# script will break ESM access. In order to force ubuntu-advantage-tools to -# stay installed, we add ubuntu-advantage-tools to the Depends list for -# ubuntu-pro-client on those releases. -# On Noble onward, only ubuntu-pro-client needs to be installed, because it -# will have been there from the beginning of the release. ubuntu-advantage-tools -# still can be installed, but it will no longer cause any harm. -SELF_DEPS="" - ifeq (${VERSION_ID},"16.04") APT_PKG_DEPS="apt (>= 1.2.32), apt-transport-https (>= 1.2.32), apt-utils (>= 1.2.32), libapt-inst2.0 (>= 1.2.32), libapt-pkg5.0 (>= 1.2.32)," DISTRO_INFO_DEPS="distro-info (>= 0.14ubuntu0.2)," -SELF_DEPS="ubuntu-advantage-tools (>= 31~)," else ifeq (${VERSION_ID},"18.04") APT_PKG_DEPS="apt (>= 1.6.11), apt-utils (>= 1.6.11), libapt-inst2.0 (>= 1.6.11), libapt-pkg5.0 (>= 1.6.11)," -SELF_DEPS="ubuntu-advantage-tools (>= 31~)," -else ifeq (${VERSION_ID},"20.04") -SELF_DEPS="ubuntu-advantage-tools (>= 31~)," -else ifeq (${VERSION_ID},"22.04") -SELF_DEPS="ubuntu-advantage-tools (>= 31~)," -else ifeq (${VERSION_ID},"23.10") -SELF_DEPS="ubuntu-advantage-tools (>= 31~)," endif %: @@ -58,7 +39,7 @@ endif endif override_dh_gencontrol: - echo extra:Depends=$(APT_PKG_DEPS) $(DISTRO_INFO_DEPS) $(SELF_DEPS) >> debian/ubuntu-pro-client.substvars + echo extra:Depends=$(APT_PKG_DEPS) $(DISTRO_INFO_DEPS) >> debian/ubuntu-pro-client.substvars dh_gencontrol override_dh_systemd_enable: From 5e2821484930d5b5a43a1afef12f23bef9325b9f Mon Sep 17 00:00:00 2001 From: Lucas Moura Date: Wed, 10 Jan 2024 17:08:23 -0300 Subject: [PATCH 08/12] tests: add test for transition package Add integration test that install the ubuntu-advantage-tools transition package and checks that it also install the new ubuntu-pro-client package. We are also performing the same check for the ubuntu-advantage-pro package --- features/environment.py | 15 +++ features/install_uninstall.feature | 28 +++++ features/steps/packages.py | 11 +- features/steps/ubuntu_advantage_tools.py | 146 ++++++++++------------- 4 files changed, 116 insertions(+), 84 deletions(-) diff --git a/features/environment.py b/features/environment.py index 1927551688..d89c848c67 100644 --- a/features/environment.py +++ b/features/environment.py @@ -365,6 +365,21 @@ def before_scenario(context: Context, scenario: Scenario): ) return + install_from = context.pro_config.install_from + if install_from == InstallationSource.LOCAL: + if "skip_local_environment" in scenario.effective_tags: + scenario.skip( + reason="Scenario does not support install_from local" + ) + return + + if install_from == InstallationSource.PREBUILT: + if "skip_prebuilt_environment" in scenario.effective_tags: + scenario.skip( + reason="Scenario does not support install_from prebuilt" + ) + return + # before_step doesn't execute early enough to modify the step # so we perform step text surgery here # Also, logging capture is not set up when before_scenario is called, diff --git a/features/install_uninstall.feature b/features/install_uninstall.feature index 5e1c9da683..bf117c15ac 100644 --- a/features/install_uninstall.feature +++ b/features/install_uninstall.feature @@ -82,3 +82,31 @@ Feature: Pro Install and Uninstall related tests | bionic | lxd-container | | focal | lxd-container | | jammy | lxd-container | + + @skip_local_environment + @skip_prebuilt_environment + Scenario Outline: Package ubuntu-advantage-tools now install + Given a `` `` machine + When I install transition package ubuntu-advantage-tools + Then I verify that `ubuntu-pro-client` is installed + + Examples: ubuntu release + | release | machine_type | + | xenial | lxd-container | + | bionic | lxd-container | + | focal | lxd-container | + + @skip_local_environment + @skip_prebuilt_environment + Scenario Outline: Package ubuntu-advantage-tools now install + Given a `` `` machine + When I install transition package ubuntu-advantage-tools + Then I verify that `ubuntu-pro-image-auto-attach` is installed + + Examples: ubuntu release + | release | machine_type | + | xenial | aws.pro | + | bionic | aws.pro | + | focal | aws.pro | + | jammy | aws.pro | + | jammy | aws.pro | diff --git a/features/steps/packages.py b/features/steps/packages.py index d95dbf8882..ed8a5f70e7 100644 --- a/features/steps/packages.py +++ b/features/steps/packages.py @@ -1,7 +1,7 @@ import re from behave import then, when -from hamcrest import assert_that, contains_string, matches_regexp +from hamcrest import assert_that, contains_string, matches_regexp, not_ from features.steps.shell import when_i_retry_run_command, when_i_run_command from features.util import SUT @@ -161,6 +161,15 @@ def verify_package_not_installed(context, package): # then the package is neither installed nor known +@then("I verify that `{package}` is installed") +def verify_package_installed(context, package): + when_i_run_command(context, "dpkg -l {}".format(package), "as non-root") + assert_that( + context.process.stdout.strip(), + not_(contains_string("no packages found matching {}".format(package))), + ) + + @then("I verify that `{package}` is installed from apt source `{apt_source}`") def verify_package_is_installed_from_apt_source(context, package, apt_source): when_i_run_command( diff --git a/features/steps/ubuntu_advantage_tools.py b/features/steps/ubuntu_advantage_tools.py index 521b0e3685..2f46d6e9fd 100644 --- a/features/steps/ubuntu_advantage_tools.py +++ b/features/steps/ubuntu_advantage_tools.py @@ -15,93 +15,22 @@ ) -@when("I install ubuntu-advantage-tools") -def when_i_install_uat(context, machine_name=SUT): +def setup_pro_package_sources(context, machine_name=SUT): instance = context.machines[machine_name].instance - series = context.machines[machine_name].series - is_pro = "pro" in context.machines[machine_name].machine_type + if context.pro_config.install_from is InstallationSource.ARCHIVE: instance.execute("sudo apt update") - when_i_apt_install( - context, "ubuntu-pro-client", machine_name=machine_name - ) - if is_pro: - when_i_apt_install( - context, - "ubuntu-pro-image-auto-attach", - machine_name=machine_name, - ) - elif context.pro_config.install_from is InstallationSource.PREBUILT: - debs = get_debs_for_series(context.pro_config.debs_path, series) - logging.info("using debs: {}".format(debs)) - to_install = [] - for deb_name, deb_path in debs.non_cloud_pro_image_debs(): - instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) - instance.push_file(deb_path, instance_tmp_path) - to_install.append(instance_tmp_path) - if is_pro: - for deb_name, deb_path in debs.cloud_pro_image_debs(): - instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) - instance.push_file(deb_path, instance_tmp_path) - to_install.append(instance_tmp_path) - when_i_apt_install( - context, " ".join(to_install), machine_name=machine_name - ) - elif context.pro_config.install_from is InstallationSource.LOCAL: - debs = build_debs( - series, - sbuild_output_to_terminal=context.pro_config.sbuild_output_to_terminal, # noqa: E501 - ) - to_install = [] - for deb_name, deb_path in debs.non_cloud_pro_image_debs(): - instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) - instance.push_file(deb_path, instance_tmp_path) - to_install.append(instance_tmp_path) - if is_pro: - for deb_name, deb_path in debs.cloud_pro_image_debs(): - instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) - instance.push_file(deb_path, instance_tmp_path) - to_install.append(instance_tmp_path) - when_i_apt_install( - context, " ".join(to_install), machine_name=machine_name - ) elif context.pro_config.install_from is InstallationSource.DAILY: instance.execute("sudo add-apt-repository ppa:ua-client/daily") instance.execute("sudo apt update") - when_i_apt_install( - context, "ubuntu-pro-client", machine_name=machine_name - ) - if is_pro: - when_i_apt_install( - context, - "ubuntu-pro-image-auto-attach", - machine_name=machine_name, - ) elif context.pro_config.install_from is InstallationSource.STAGING: instance.execute("sudo add-apt-repository ppa:ua-client/staging") instance.execute("sudo apt update") - when_i_apt_install( - context, "ubuntu-pro-client", machine_name=machine_name - ) - if is_pro: - when_i_apt_install( - context, - "ubuntu-pro-image-auto-attach", - machine_name=machine_name, - ) elif context.pro_config.install_from is InstallationSource.STABLE: instance.execute("sudo add-apt-repository ppa:ua-client/stable") instance.execute("sudo apt update") - when_i_apt_install( - context, "ubuntu-pro-client", machine_name=machine_name - ) - if is_pro: - when_i_apt_install( - context, - "ubuntu-pro-image-auto-attach", - machine_name=machine_name, - ) elif context.pro_config.install_from is InstallationSource.PROPOSED: + series = context.machines[machine_name].series context.text = "deb http://archive.ubuntu.com/ubuntu/ {series}-proposed main\n".format( # noqa: E501 series=series ) @@ -132,20 +61,55 @@ def when_i_install_uat(context, machine_name=SUT): ) instance.execute("sudo apt update") - when_i_apt_install( - context, "ubuntu-pro-client", machine_name=machine_name - ) - if is_pro: - when_i_apt_install( - context, - "ubuntu-pro-image-auto-attach", - machine_name=machine_name, - ) elif context.pro_config.install_from is InstallationSource.CUSTOM: instance.execute( "sudo add-apt-repository {}".format(context.pro_config.custom_ppa) ) instance.execute("sudo apt update") + + +@when("I install ubuntu-advantage-tools") +def when_i_install_uat(context, machine_name=SUT): + instance = context.machines[machine_name].instance + series = context.machines[machine_name].series + is_pro = "pro" in context.machines[machine_name].machine_type + setup_pro_package_sources(context, machine_name) + + if context.pro_config.install_from is InstallationSource.PREBUILT: + debs = get_debs_for_series(context.pro_config.debs_path, series) + logging.info("using debs: {}".format(debs)) + to_install = [] + for deb_name, deb_path in debs.non_cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + if is_pro: + for deb_name, deb_path in debs.cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + when_i_apt_install( + context, " ".join(to_install), machine_name=machine_name + ) + elif context.pro_config.install_from is InstallationSource.LOCAL: + debs = build_debs( + series, + sbuild_output_to_terminal=context.pro_config.sbuild_output_to_terminal, # noqa: E501 + ) + to_install = [] + for deb_name, deb_path in debs.non_cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + if is_pro: + for deb_name, deb_path in debs.cloud_pro_image_debs(): + instance_tmp_path = "/tmp/behave_{}.deb".format(deb_name) + instance.push_file(deb_path, instance_tmp_path) + to_install.append(instance_tmp_path) + when_i_apt_install( + context, " ".join(to_install), machine_name=machine_name + ) + else: when_i_apt_install( context, "ubuntu-pro-client", machine_name=machine_name ) @@ -312,3 +276,19 @@ def when_i_check_apt_cache_policy(context): for step in context.scenario.steps: if step.name == APT_POLICY_IS: step.text = context.process.stdout + + +@when("I install transition package ubuntu-advantage-tools") +def when_i_install_transition_uat(context, machine_name=SUT): + is_pro = "pro" in context.machines[machine_name].machine_type + setup_pro_package_sources(context, machine_name) + + when_i_apt_install( + context, "ubuntu-advantage-tools", machine_name=machine_name + ) + if is_pro: + when_i_apt_install( + context, + "ubuntu-advantage-pro", + machine_name=machine_name, + ) From b07387447bff01fc9a0b7266ee73e7f4bf83ef9f Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Fri, 19 Jan 2024 16:45:12 -0500 Subject: [PATCH 09/12] lintian: fix or override errors and warnings --- debian/control | 12 +++++++----- debian/ubuntu-advantage-tools.lintian-overrides | 14 +++++++++----- debian/ubuntu-pro-client.lintian-overrides | 6 ++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/debian/control b/debian/control index ad445f6432..5fb8e9f8b3 100644 --- a/debian/control +++ b/debian/control @@ -35,12 +35,13 @@ Vcs-Browser: https://github.com/canonical/ubuntu-pro-client Rules-Requires-Root: no Package: ubuntu-advantage-tools -Depends: ubuntu-pro-client (= ${binary:Version}), ${misc:Depends} +Depends: ubuntu-pro-client (>= ${binary:Version}), ${misc:Depends} Architecture: all Priority: optional Section: oldlibs -Description: transitional package - This is a transitional package. It can safely be removed. +Description: transitional dummy package for ubuntu-pro-client + This is a transitional dummy package for ubuntu-pro-client. It can safely be + removed. Package: ubuntu-pro-client Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/ @@ -75,8 +76,9 @@ Depends: ubuntu-pro-image-auto-attach, ${misc:Depends} Architecture: all Priority: optional Section: oldlibs -Description: transitional package - This is a transitional package. It can safely be removed. +Description: transitional dummy package for ubuntu-pro-image-auto-attach + This is a transitional dummy package for ubuntu-pro-image-auto-attach. It can + safely be removed. Package: ubuntu-pro-image-auto-attach Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/en/latest/explanations/what_are_ubuntu_pro_cloud_instances/ diff --git a/debian/ubuntu-advantage-tools.lintian-overrides b/debian/ubuntu-advantage-tools.lintian-overrides index 0b09bcb121..47c96575ec 100644 --- a/debian/ubuntu-advantage-tools.lintian-overrides +++ b/debian/ubuntu-advantage-tools.lintian-overrides @@ -1,10 +1,14 @@ # We are silencing this issue because of this LP: #1930121 ubuntu-advantage-tools: command-with-path-in-maintainer-script -# Ubuntu doesn't support sysv init.d -ubuntu-advantage-tools: package-supports-alternative-init-but-no-init.d-script +ubuntu-advantage-tools: possible-bashism-in-maintainer-script -# We have made the decision of delivering those files -ubuntu-advantage-tools: package-installs-apt-preferences +# python3 is a transitive dependency via ubuntu-pro-client +ubuntu-advantage-tools: python3-script-but-no-python3-dep -ubuntu-advantage-tools: possible-bashism-in-maintainer-script +# This is only to cleanup an old tmp file +ubuntu-advantage-tools: possibly-insecure-handling-of-tmp-files-in-maintainer-script /tmp [postinst:61] + +# systemctl is the only way to do these calls, and we do the required check before calling it +ubuntu-advantage-tools: maintainer-script-calls-systemctl [postinst:260] +ubuntu-advantage-tools: maintainer-script-calls-systemctl [postinst:263] \ No newline at end of file diff --git a/debian/ubuntu-pro-client.lintian-overrides b/debian/ubuntu-pro-client.lintian-overrides index 6dc2905272..04514f3597 100644 --- a/debian/ubuntu-pro-client.lintian-overrides +++ b/debian/ubuntu-pro-client.lintian-overrides @@ -1,10 +1,8 @@ -# We are silencing this issue because of this LP: #1930121 -ubuntu-pro-client: command-with-path-in-maintainer-script - # Ubuntu doesn't support sysv init.d ubuntu-pro-client: package-supports-alternative-init-but-no-init.d-script # We have made the decision of delivering those files ubuntu-pro-client: package-installs-apt-preferences -ubuntu-pro-client: possible-bashism-in-maintainer-script +# This is intentional +ubuntu-pro-client: uses-dpkg-database-directly [usr/lib/ubuntu-advantage/apt-esm-json-hook] \ No newline at end of file From d331e068cd4d6356cd5204d1c9fd8de10cd34854 Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Fri, 19 Jan 2024 16:53:52 -0500 Subject: [PATCH 10/12] d/control: add explanation for the lack of Provides --- debian/control | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 5fb8e9f8b3..d226c28862 100644 --- a/debian/control +++ b/debian/control @@ -56,7 +56,21 @@ Recommends: ubuntu-pro-client-l10n Breaks: ubuntu-advantage-tools (<<31~) Replaces: ubuntu-advantage-tools (<<31~) # IMPORTANT: ubuntu-pro-client does not "Provide" ubuntu-advantage-tools -# TODO fill this in with rationale after testing. +# At the time of the rename, existing releases with ubuntu-advantage-tools +# include xenial, bionic, focal, jammy, and mantic. +# We cannot allow ubuntu-advantage-tools <<31 to be removed on those releases, +# because it could break ESM (remove sources.list entries in prerm). +# On those releases, ubuntu-minimal (and ubuntu-cloud-minimal) Depends on +# ubuntu-advantage-tools, which prevents it from being removed without also +# removing ubuntu-minimal or ubuntu-cloud-minimal. We consider that to be a +# sufficient warning to users that removing ubuntu-advantage-tools is not +# supported. +# If ubuntu-pro-client were to "Provide" ubuntu-advantage-tools, then that +# mechanism would not work, and users could remove ubuntu-advantage-tools +# accidentally. +# ubuntu-pro-client could "Provide" ubuntu-advantage-tools in releases in the +# future, but it would not add any value over having the ubuntu-advantage-tools +# transitional dummy package. Description: Management tools for Ubuntu Pro Ubuntu Pro is a suite of additional services provided by Canonical on top of Ubuntu. Whether you're an enterprise customer deploying systems From db62a10fe43ac4fdeb87281bde14ba6aaac86a9c Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Wed, 24 Jan 2024 13:17:46 -0500 Subject: [PATCH 11/12] rename: no need for 'image' in auto-attach package name --- debian/control | 8 ++++---- debian/rules | 8 ++++---- debian/ubuntu-pro-auto-attach.lintian-overrides | 3 +++ debian/ubuntu-pro-image-auto-attach.lintian-overrides | 3 --- features/install_uninstall.feature | 2 +- features/steps/ubuntu_advantage_tools.py | 2 +- features/util.py | 10 +++++----- 7 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 debian/ubuntu-pro-auto-attach.lintian-overrides delete mode 100644 debian/ubuntu-pro-image-auto-attach.lintian-overrides diff --git a/debian/control b/debian/control index d226c28862..aebd8f6e29 100644 --- a/debian/control +++ b/debian/control @@ -86,15 +86,15 @@ Description: Translations for Ubuntu Pro Client languages. Package: ubuntu-advantage-pro -Depends: ubuntu-pro-image-auto-attach, ${misc:Depends} +Depends: ubuntu-pro-auto-attach, ${misc:Depends} Architecture: all Priority: optional Section: oldlibs -Description: transitional dummy package for ubuntu-pro-image-auto-attach - This is a transitional dummy package for ubuntu-pro-image-auto-attach. It can +Description: transitional dummy package for ubuntu-pro-auto-attach + This is a transitional dummy package for ubuntu-pro-auto-attach. It can safely be removed. -Package: ubuntu-pro-image-auto-attach +Package: ubuntu-pro-auto-attach Homepage: https://canonical-ubuntu-pro-client.readthedocs-hosted.com/en/latest/explanations/what_are_ubuntu_pro_cloud_instances/ Architecture: all Depends: ${misc:Depends}, ubuntu-pro-client (>=31~) diff --git a/debian/rules b/debian/rules index 62fbdfc2e9..e2cf53c0c9 100755 --- a/debian/rules +++ b/debian/rules @@ -43,7 +43,7 @@ override_dh_gencontrol: dh_gencontrol override_dh_systemd_enable: - dh_systemd_enable -pubuntu-pro-image-auto-attach ua-auto-attach.service + dh_systemd_enable -pubuntu-pro-auto-attach ua-auto-attach.service dh_systemd_enable -pubuntu-pro-client ua-reboot-cmds.service dh_systemd_enable -pubuntu-pro-client ua-timer.timer dh_systemd_enable -pubuntu-pro-client ua-timer.service @@ -79,9 +79,9 @@ ifneq (${VERSION_ID},"16.04") rm $(CURDIR)/debian/ubuntu-pro-client/lib/systemd/system/ubuntu-advantage-cloud-id-shim.service endif - # Move ua-auto-attach.service out to ubuntu-pro-image-auto-attach - mkdir -p debian/ubuntu-pro-image-auto-attach/lib/systemd/system - mv debian/ubuntu-pro-client/lib/systemd/system/ua-auto-attach.* debian/ubuntu-pro-image-auto-attach/lib/systemd/system + # Move ua-auto-attach.service out to ubuntu-pro-auto-attach + mkdir -p debian/ubuntu-pro-auto-attach/lib/systemd/system + mv debian/ubuntu-pro-client/lib/systemd/system/ua-auto-attach.* debian/ubuntu-pro-auto-attach/lib/systemd/system # move migration scripts from before the package rename into ubuntu-advantage-tools mkdir -p debian/ubuntu-advantage-tools/usr/lib/ubuntu-advantage diff --git a/debian/ubuntu-pro-auto-attach.lintian-overrides b/debian/ubuntu-pro-auto-attach.lintian-overrides new file mode 100644 index 0000000000..be76d6e36d --- /dev/null +++ b/debian/ubuntu-pro-auto-attach.lintian-overrides @@ -0,0 +1,3 @@ +# Avoid warning on wanted-by-target + +ubuntu-pro-auto-attach: systemd-service-file-refers-to-unusual-wantedby-target diff --git a/debian/ubuntu-pro-image-auto-attach.lintian-overrides b/debian/ubuntu-pro-image-auto-attach.lintian-overrides deleted file mode 100644 index f3c0c7b087..0000000000 --- a/debian/ubuntu-pro-image-auto-attach.lintian-overrides +++ /dev/null @@ -1,3 +0,0 @@ -# Avoid warning on wanted-by-target - -ubuntu-pro-image-auto-attach: systemd-service-file-refers-to-unusual-wantedby-target diff --git a/features/install_uninstall.feature b/features/install_uninstall.feature index bf117c15ac..8b665012b0 100644 --- a/features/install_uninstall.feature +++ b/features/install_uninstall.feature @@ -101,7 +101,7 @@ Feature: Pro Install and Uninstall related tests Scenario Outline: Package ubuntu-advantage-tools now install Given a `` `` machine When I install transition package ubuntu-advantage-tools - Then I verify that `ubuntu-pro-image-auto-attach` is installed + Then I verify that `ubuntu-pro-auto-attach` is installed Examples: ubuntu release | release | machine_type | diff --git a/features/steps/ubuntu_advantage_tools.py b/features/steps/ubuntu_advantage_tools.py index 2f46d6e9fd..f32830c137 100644 --- a/features/steps/ubuntu_advantage_tools.py +++ b/features/steps/ubuntu_advantage_tools.py @@ -116,7 +116,7 @@ def when_i_install_uat(context, machine_name=SUT): if is_pro: when_i_apt_install( context, - "ubuntu-pro-image-auto-attach", + "ubuntu-pro-auto-attach", machine_name=machine_name, ) diff --git a/features/util.py b/features/util.py index cada5687b1..6519d3a6d4 100644 --- a/features/util.py +++ b/features/util.py @@ -37,7 +37,7 @@ ALL_BINARY_PACKAGE_NAMES = [ "ubuntu-pro-client", "ubuntu-pro-client-l10n", - "ubuntu-pro-image-auto-attach", + "ubuntu-pro-auto-attach", "ubuntu-advantage-tools", "ubuntu-advantage-pro", ] @@ -61,7 +61,7 @@ def non_cloud_pro_image_debs(self) -> List[Tuple[str, str]]: def cloud_pro_image_debs(self) -> List[Tuple[str, str]]: return [ ( - "ubuntu-pro-image-auto-attach", + "ubuntu-pro-auto-attach", self.ubuntu_pro_image_auto_attach, ), ("ubuntu-advantage-pro", self.ubuntu_advantage_pro), @@ -165,7 +165,7 @@ def get_debs_for_series(debs_path: str, series: str) -> ProDebPaths: ubuntu_pro_client_l10n = full_path elif "ubuntu-pro-client" in deb_file: ubuntu_pro_client = full_path - elif "ubuntu-pro-image-auto-attach" in deb_file: + elif "ubuntu-pro-auto-attach" in deb_file: ubuntu_pro_image_auto_attach = full_path elif "ubuntu-advantage-tools" in deb_file: ubuntu_advantage_tools = full_path @@ -206,7 +206,7 @@ def build_debs( deb_paths = ProDebPaths( ubuntu_pro_client=_create_deb_path(deb_prefix, "ubuntu-pro-client"), ubuntu_pro_image_auto_attach=_create_deb_path( - deb_prefix, "ubuntu-pro-image-auto-attach" + deb_prefix, "ubuntu-pro-auto-attach" ), ubuntu_pro_client_l10n=_create_deb_path( deb_prefix, "ubuntu-pro-client-l10n" @@ -317,7 +317,7 @@ def build_debs( dest = deb_paths.ubuntu_pro_client_l10n elif "ubuntu-pro-client" in f: dest = deb_paths.ubuntu_pro_client - elif "ubuntu-pro-image-auto-attach" in f: + elif "ubuntu-pro-auto-attach" in f: dest = deb_paths.ubuntu_pro_image_auto_attach elif "ubuntu-advantage-tools" in f: dest = deb_paths.ubuntu_advantage_tools From 5fc24b057a88c349110421fb8b27327c0b7e452a Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Tue, 6 Feb 2024 14:58:47 -0500 Subject: [PATCH 12/12] d/rules: fix quotes in echo command --- debian/rules | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/debian/rules b/debian/rules index e2cf53c0c9..bc32debc2f 100755 --- a/debian/rules +++ b/debian/rules @@ -11,13 +11,13 @@ include /etc/os-release # the flag --supported-esm. Those versions are 0.18 and 0.14build1, # respectively. So we set specific distro-info requirements for bionic and later # versus Xenial to make those contraints applicable on each series. -DISTRO_INFO_DEPS="distro-info (>= 0.18ubuntu0.18.04.1)," +DISTRO_INFO_DEPS=distro-info (>= 0.18ubuntu0.18.04.1), ifeq (${VERSION_ID},"16.04") -APT_PKG_DEPS="apt (>= 1.2.32), apt-transport-https (>= 1.2.32), apt-utils (>= 1.2.32), libapt-inst2.0 (>= 1.2.32), libapt-pkg5.0 (>= 1.2.32)," -DISTRO_INFO_DEPS="distro-info (>= 0.14ubuntu0.2)," +APT_PKG_DEPS=apt (>= 1.2.32), apt-transport-https (>= 1.2.32), apt-utils (>= 1.2.32), libapt-inst2.0 (>= 1.2.32), libapt-pkg5.0 (>= 1.2.32), +DISTRO_INFO_DEPS=distro-info (>= 0.14ubuntu0.2), else ifeq (${VERSION_ID},"18.04") -APT_PKG_DEPS="apt (>= 1.6.11), apt-utils (>= 1.6.11), libapt-inst2.0 (>= 1.6.11), libapt-pkg5.0 (>= 1.6.11)," +APT_PKG_DEPS=apt (>= 1.6.11), apt-utils (>= 1.6.11), libapt-inst2.0 (>= 1.6.11), libapt-pkg5.0 (>= 1.6.11), endif %: @@ -39,7 +39,7 @@ endif endif override_dh_gencontrol: - echo extra:Depends=$(APT_PKG_DEPS) $(DISTRO_INFO_DEPS) >> debian/ubuntu-pro-client.substvars + echo "extra:Depends=$(APT_PKG_DEPS) $(DISTRO_INFO_DEPS)" >> debian/ubuntu-pro-client.substvars dh_gencontrol override_dh_systemd_enable: