Merge ~paride/autopkgtest-cloud:clean-alien-packages into autopkgtest-cloud:master

Proposed by Paride Legovini
Status: Merged
Approved by: Brian Murray
Approved revision: f63bcbeeb8edb934753bcbf5dcb58797a9ff5e64
Merged at revision: 0656e75829c2e28d572c046a7a17d2d9f82e4ded
Proposed branch: ~paride/autopkgtest-cloud:clean-alien-packages
Merge into: autopkgtest-cloud:master
Diff against target: 59 lines (+50/-0)
1 file modified
charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh (+50/-0)
Reviewer Review Type Date Requested Status
Paride Legovini Needs Fixing
Julian Andres Klode (community) Approve
Tim Andersson Pending
Ubuntu Release Team Pending
Review via email: mp+442340@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paride Legovini (paride) wrote :

To reviewers: note the usage of -o Dpkg::Options::="--force-confnew". My idea is that if we *downgrade* a package we want the "new" config files (i.e. those from the *older* package, the one being installed), as the already installed conf files may not be supported by the older package version.

Revision history for this message
Paride Legovini (paride) :
Revision history for this message
Julian Andres Klode (juliank) wrote :

Some comment but overall this should work.

review: Approve
Revision history for this message
Brian Murray (brian-murray) wrote :

One comment.

Revision history for this message
Paride Legovini (paride) :
Revision history for this message
Paride Legovini (paride) wrote :

Ready for another review.

Revision history for this message
Paride Legovini (paride) wrote :

I found a bug: we need DEBIAN_FRONTEND=noninteractive even when purging '?obsolete' packages, as debconf questions may also appear in that stage. Actually hit this in staging. The script was trying to remove a running kernel.

review: Needs Fixing
Revision history for this message
Paride Legovini (paride) wrote :

I updated the MP, the only change wrt the previous version is that I added

  DEBIAN_FRONTEND=noninteractive

to the line where we purge '?obsolete' packages. I tested this in staging by removing the mantic image and manually running the script, simulating what we do when opening a new series.

Revision history for this message
Paride Legovini (paride) wrote :

As discussed, added a comment on '?obsolete' removal possibly removing the running kernel.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh
index c6d401c..92c2d70 100644
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh
@@ -1,5 +1,55 @@
1# Canonical/Ubuntu specific testbed setup1# Canonical/Ubuntu specific testbed setup
22
3RELEASE=$(lsb_release --codename --short 2>/dev/null)
4
5# Make the installed package versions match what is available from the configured
6# repositories, even if a downgrade is required.
7#
8# We may end up with images with packages newer than those available from the
9# repositories when opening a new release (images are created using the
10# previous release dailies as a base, which may include 0-day SRUs, or
11# Launchpad may fail to copy packages, see openssl 3.0.8-1ubuntu2), or when
12# package versions are pulled from the archive.
13#
14# Note: 'release a=' matches the Suite field in the repository Release file.
15cat >/etc/apt/preferences.d/force-downgrade-to-release.pref <<EOF
16Package: *
17Pin: release a=$RELEASE
18Pin-Priority: 1001
19
20Package: *
21Pin: release a=$RELEASE-updates
22Pin-Priority: 1001
23
24Package: *
25Pin: release n=$RELEASE-security
26Pin-Priority: 1001
27EOF
28# This is going to be a downgrade-only (or no-op) dist-upgrade, as setup-testbed
29# already dist-upgraded the system. Force the usage of the conf files of the
30# package being installed (--force-confnew), as conf files "from the future"
31# may not be supported by the older package version we're downgrading to.
32DEBIAN_FRONTEND=noninteractive eatmydata apt-get -y --allow-downgrades -o Dpkg::Options::="--force-confnew" dist-upgrade
33rm /etc/apt/preferences.d/force-downgrade-to-release.pref
34
35# Remove packages not available from any configured repository, e.g.
36# packages fully removed from the archive. This requires the analyze-pattern
37# feature, which has been introduced in apt 2.0.1 (>= Focal).
38#
39# Note: autoremove/--autoremove always runs on the entire set of installed
40# packages. Together with --autopurge/purge each removal becomes a purge.
41#
42# Removing '?obsolete' packages may remove the running kernel. This is not
43# expected to be an issue.
44if /usr/lib/apt/apt-helper analyze-pattern '?true' >/dev/null 2>&1; then
45 DEBIAN_FRONTEND=noninteractive eatmydata apt-get -y purge --autoremove '?obsolete'
46else
47 # We're on an older release (analyze-pattern is not available).
48 # Still do an autopurge to get rid of packages that got orphaned
49 # by downgrades.
50 eatmydata apt-get -y autoremove --purge
51fi
52
3# compatibility with old Jenkins testbeds for trusty53# compatibility with old Jenkins testbeds for trusty
4if grep -q trusty /etc/lsb-release; then apt-get update || (sleep 10; apt-get update); apt-get install -y build-essential; fi54if grep -q trusty /etc/lsb-release; then apt-get update || (sleep 10; apt-get update); apt-get install -y build-essential; fi
555

Subscribers

People subscribed via source and target branches