Merge ~cjwatson/launchpad-buildd:remove-core-snaps-restrictions into launchpad-buildd:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 5a90fe7db3f5d67907ed268dfd0b545cfd7bc64c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad-buildd:remove-core-snaps-restrictions
Merge into: launchpad-buildd:master
Diff against target: 103 lines (+12/-28)
3 files modified
debian/changelog (+2/-0)
lpbuildd/target/build_charm.py (+5/-14)
lpbuildd/target/build_snap.py (+5/-14)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+411629@code.launchpad.net

Commit message

Remove restrictions on core snap names

Description of the change

We now install snaps corresponding to whatever Launchpad sends. Having to do launchpad-buildd rollouts every time we wanted to add new core snap names was introducing unnecessary delays to the process, and it meant more places in which we were hardcoding the list of valid core snap names.

This shouldn't land until https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/411626 is on production.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

LGTM, just a minor comment

review: Approve
5a90fe7... by Colin Watson

Add note about separate --classic installation

Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 905f523..4fe4e13 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,6 +1,8 @@
6 launchpad-buildd (234) UNRELEASED; urgency=medium
7
8 * Add basic documentation of malware scanning for CI builds.
9+ * Remove restrictions on core snap names; we now install snaps
10+ corresponding to whatever Launchpad sends.
11
12 -- Colin Watson <cjwatson@ubuntu.com> Tue, 06 Jun 2023 11:42:23 +0100
13
14diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py
15index b64bbcc..1bcbd1e 100644
16--- a/lpbuildd/target/build_charm.py
17+++ b/lpbuildd/target/build_charm.py
18@@ -26,8 +26,6 @@ class BuildCharm(
19 ):
20 description = "Build a charm."
21
22- core_snap_names = ["core", "core16", "core18", "core20", "core22"]
23-
24 @classmethod
25 def add_arguments(cls, parser):
26 super().add_arguments(parser)
27@@ -37,10 +35,7 @@ class BuildCharm(
28 metavar="SNAP=CHANNEL",
29 dest="channels",
30 default={},
31- help=(
32- f"install SNAP from CHANNEL (supported snaps: "
33- f"{', '.join(cls.core_snap_names)}, charmcraft)"
34- ),
35+ help="install SNAP from CHANNEL",
36 )
37 parser.add_argument(
38 "--build-path", default=".", help="location of charm to build."
39@@ -74,15 +69,11 @@ class BuildCharm(
40 self.backend.run(["apt-get", "-y", "install"] + deps)
41 if self.backend.supports_snapd:
42 self.snap_store_set_proxy()
43- for snap_name in self.core_snap_names:
44- if snap_name in self.args.channels:
45+ for snap_name, channel in sorted(self.args.channels.items()):
46+ # charmcraft is handled separately, since it requires --classic.
47+ if snap_name != "charmcraft":
48 self.backend.run(
49- [
50- "snap",
51- "install",
52- "--channel=%s" % self.args.channels[snap_name],
53- snap_name,
54- ]
55+ ["snap", "install", "--channel=%s" % channel, snap_name]
56 )
57 if "charmcraft" in self.args.channels:
58 self.backend.run(
59diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
60index 44dcc1c..68f491e 100644
61--- a/lpbuildd/target/build_snap.py
62+++ b/lpbuildd/target/build_snap.py
63@@ -46,8 +46,6 @@ class BuildSnap(
64 ):
65 description = "Build a snap."
66
67- core_snap_names = ["core", "core16", "core18", "core20", "core22"]
68-
69 @classmethod
70 def add_arguments(cls, parser):
71 super().add_arguments(parser)
72@@ -57,10 +55,7 @@ class BuildSnap(
73 metavar="SNAP=CHANNEL",
74 dest="channels",
75 default={},
76- help=(
77- f"install SNAP from CHANNEL (supported snaps: "
78- f"{', '.join(cls.core_snap_names)}, snapcraft)"
79- ),
80+ help="install SNAP from CHANNEL",
81 )
82 parser.add_argument(
83 "--build-request-id",
84@@ -154,15 +149,11 @@ class BuildSnap(
85 self.backend.run(["apt-get", "-y", "install"] + deps)
86 if self.backend.supports_snapd:
87 self.snap_store_set_proxy()
88- for snap_name in self.core_snap_names:
89- if snap_name in self.args.channels:
90+ for snap_name, channel in sorted(self.args.channels.items()):
91+ # snapcraft is handled separately, since it requires --classic.
92+ if snap_name != "snapcraft":
93 self.backend.run(
94- [
95- "snap",
96- "install",
97- "--channel=%s" % self.args.channels[snap_name],
98- snap_name,
99- ]
100+ ["snap", "install", "--channel=%s" % channel, snap_name]
101 )
102 if "snapcraft" in self.args.channels:
103 self.backend.run(

Subscribers

People subscribed via source and target branches