Skip to content

Commit

Permalink
debian: rename binary packages
Browse files Browse the repository at this point in the history
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 ubuntu-pro-client "Breaks" ubuntu-advantage-tools <<31~, existing
instances will need to upgrade to ubuntu-advantage-tools 31 (the
transitional package) in order to install the new ubuntu-pro-client
package. 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}.
  • Loading branch information
orndorffgrant committed Dec 11, 2023
1 parent 73195ff commit 7a17d46
Show file tree
Hide file tree
Showing 23 changed files with 206 additions and 76 deletions.
28 changes: 24 additions & 4 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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},
Expand All @@ -41,6 +49,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
Expand All @@ -50,17 +61,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 (>=31~)
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
Expand Down
39 changes: 21 additions & 18 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,47 @@ 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) >> 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
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
cd debian/ubuntu-pro-client

# TODO move patch status json to ubuntu-advantage-tools
# TODO anything else only needed for old migrations?


override_dh_auto_clean:
Expand Down
4 changes: 2 additions & 2 deletions debian/source/lintian-overrides
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Lintian doesn't see dh-systemd alternative when building on xenial
ubuntu-advantage-tools: missing-build-dependency-for-dh_-command dh_systemd_start => dh-systemd
ubuntu-pro-client: missing-build-dependency-for-dh_-command dh_systemd_start => dh-systemd

# Lintian can't handle the multiline debhelper/dh-systemd dependencies explained in debian/control
ubuntu-advantage-tools: missing-build-dependency-for-dh-addon *systemd*
ubuntu-pro-client: missing-build-dependency-for-dh-addon *systemd*
3 changes: 0 additions & 3 deletions debian/ubuntu-advantage-pro.lintian-overrides

This file was deleted.

10 changes: 0 additions & 10 deletions debian/ubuntu-advantage-tools.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
26 changes: 0 additions & 26 deletions debian/ubuntu-advantage-tools.postrm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions debian/ubuntu-pro-client.lintian-overrides
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
98 changes: 98 additions & 0 deletions debian/ubuntu-pro-client.postinst
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions debian/ubuntu-pro-client.postrm
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
3 changes: 3 additions & 0 deletions debian/ubuntu-pro-image-auto-attach.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Avoid warning on wanted-by-target

ubuntu-pro-image-auto-attach: systemd-service-file-refers-to-unusual-wantedby-target
2 changes: 1 addition & 1 deletion preferences.d/ubuntu-pro-esm-apps
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion preferences.d/ubuntu-pro-esm-infra
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tools/ua.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bash completion for ubuntu-advantage-tools
# bash completion for ubuntu-pro-client

. /etc/os-release # For VERSION_ID

Expand Down
8 changes: 4 additions & 4 deletions uaclient/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,7 +53,7 @@


ESM_REPO_FILE_CONTENT = """\
# Written by ubuntu-advantage-tools
# Written by ubuntu-pro-client
deb https://esm.ubuntu.com/{name}/ubuntu {series}-{name}-security main
# deb-src https://esm.ubuntu.com/{name}/ubuntu {series}-{name}-security main
Expand Down
Loading

0 comments on commit 7a17d46

Please sign in to comment.