← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:remove-core-snaps-restrictions into launchpad-buildd:master.

Commit message:
Remove restrictions on core snap names

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/411629

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:remove-core-snaps-restrictions into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 4d495dc..bc05b5b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ launchpad-buildd (204) UNRELEASED; urgency=medium
     (LP: #1949473).
   * Configure apt to always include phased updates, even if running in LXD
     containers (LP: #1949769).
+  * Remove restrictions on core snap names; we now install snaps
+    corresponding to whatever Launchpad sends.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Tue, 02 Nov 2021 13:42:13 +0000
 
diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py
index d5ade71..048710c 100644
--- a/lpbuildd/target/build_charm.py
+++ b/lpbuildd/target/build_charm.py
@@ -30,17 +30,12 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin,
 
     description = "Build a charm."
 
-    core_snap_names = ["core", "core16", "core18", "core20", "core22"]
-
     @classmethod
     def add_arguments(cls, parser):
         super(BuildCharm, cls).add_arguments(parser)
         parser.add_argument(
             "--channel", action=SnapChannelsAction, metavar="SNAP=CHANNEL",
-            dest="channels", default={}, help=(
-                "install SNAP from CHANNEL "
-                "(supported snaps: {}, charmcraft)".format(
-                    ", ".join(cls.core_snap_names))))
+            dest="channels", default={}, help="install SNAP from CHANNEL")
         parser.add_argument(
             "--build-path", default=".",
             help="location of charm to build.")
@@ -88,12 +83,10 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin,
         self.backend.run(["apt-get", "-y", "install"] + deps)
         if self.args.backend in ("lxd", "fake"):
             self.snap_store_set_proxy()
-        for snap_name in self.core_snap_names:
-            if snap_name in self.args.channels:
+        for snap_name, channel in sorted(self.args.channels.items()):
+            if snap_name != "charmcraft":
                 self.backend.run(
-                    ["snap", "install",
-                     "--channel=%s" % self.args.channels[snap_name],
-                     snap_name])
+                    ["snap", "install", "--channel=%s" % channel, snap_name])
         if "charmcraft" in self.args.channels:
             self.backend.run(
                 ["snap", "install", "--classic",
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index 7ec133b..79cc161 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -52,17 +52,12 @@ class BuildSnap(BuilderProxyOperationMixin, VCSOperationMixin,
 
     description = "Build a snap."
 
-    core_snap_names = ["core", "core16", "core18", "core20", "core22"]
-
     @classmethod
     def add_arguments(cls, parser):
         super(BuildSnap, cls).add_arguments(parser)
         parser.add_argument(
             "--channel", action=SnapChannelsAction, metavar="SNAP=CHANNEL",
-            dest="channels", default={}, help=(
-                "install SNAP from CHANNEL "
-                "(supported snaps: {}, snapcraft)".format(
-                    ", ".join(cls.core_snap_names))))
+            dest="channels", default={}, help="install SNAP from CHANNEL")
         parser.add_argument(
             "--build-request-id",
             help="ID of the request triggering this build on Launchpad")
@@ -143,12 +138,10 @@ class BuildSnap(BuilderProxyOperationMixin, VCSOperationMixin,
         self.backend.run(["apt-get", "-y", "install"] + deps)
         if self.args.backend in ("lxd", "fake"):
             self.snap_store_set_proxy()
-        for snap_name in self.core_snap_names:
-            if snap_name in self.args.channels:
+        for snap_name, channel in sorted(self.args.channels.items()):
+            if snap_name != "snapcraft":
                 self.backend.run(
-                    ["snap", "install",
-                     "--channel=%s" % self.args.channels[snap_name],
-                     snap_name])
+                    ["snap", "install", "--channel=%s" % channel, snap_name])
         if "snapcraft" in self.args.channels:
             self.backend.run(
                 ["snap", "install", "--classic",