Dimitri John Ledkov has proposed merging ~xnox/launchpad-buildd:channels-snapd 
into launchpad-buildd:master.

Commit message:
buildsnap: add support to refresh snapd

Sometimes, a broken snapd snap in a given channel can prevent building new 
snaps, in such cases overriding snapd channel may be required. Whilst channels 
options are passed to the builder in such cases, it doesn't actually act upon 
them. It is more convenient to do this, then specifying `build-snap: 
[snapd/latest/edge]` in snapcraft.yaml.

Requested reviews:
  William Grant (wgrant)
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~xnox/launchpad-buildd/+git/launchpad-buildd/+merge/438474
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~xnox/launchpad-buildd:channels-snapd into launchpad-buildd:master.
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index 44dcc1c..5f91e96 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -59,7 +59,7 @@ class BuildSnap(
             default={},
             help=(
                 f"install SNAP from CHANNEL (supported snaps: "
-                f"{', '.join(cls.core_snap_names)}, snapcraft)"
+                f"{', '.join(cls.core_snap_names)}, snapcraft, snapd)"
             ),
         )
         parser.add_argument(
@@ -174,6 +174,26 @@ class BuildSnap(
                     "snapcraft",
                 ]
             )
+        # Depending on series, snapd snap may already be installed
+        # In that case, one needs to refresh to change channel
+        # Both operations exit 0 if there is nothing to do
+        if "snapd" in self.args.channels:
+            self.backend.run(
+                [
+                    "snap",
+                    "install",
+                    "--channel=%s" % self.args.channels["snapd"],
+                    "snapd",
+                ]
+            )
+            self.backend.run(
+                [
+                    "snap",
+                    "refresh",
+                    "--channel=%s" % self.args.channels["snapd"],
+                    "snapd",
+                ]
+            )
         if self.args.proxy_url:
             self.install_svn_servers()
 
diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py
index 95bf948..42b2970 100644
--- a/lpbuildd/target/tests/test_build_snap.py
+++ b/lpbuildd/target/tests/test_build_snap.py
@@ -204,6 +204,7 @@ class TestBuildSnap(TestCase):
             "--channel=core=candidate",
             "--channel=core18=beta",
             "--channel=snapcraft=edge",
+            "--channel=snapd=edge",
             "--branch",
             "lp:foo",
             "test-snap",
@@ -220,6 +221,8 @@ class TestBuildSnap(TestCase):
                     RanSnap(
                         "install", "--classic", "--channel=edge", "snapcraft"
                     ),
+                    RanSnap("install", "--channel=edge", "snapd"),
+                    RanSnap("refresh", "--channel=edge", "snapd"),
                 ]
             ),
         )
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to