← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:charmcraft-pack into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:charmcraft-pack into launchpad-buildd:master.

Commit message:
Switch to "charmcraft pack --destructive-mode"

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This is safe now that Charmcraft 1.2 is in the stable channel.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:charmcraft-pack into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 5195400..84bcf3c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 launchpad-buildd (201) UNRELEASED; urgency=medium
 
   * Sanitize non-user-bound macaroons in build logs.
+  * Switch to "charmcraft pack --destructive-mode", now that Charmcraft 1.2
+    is in the stable channel.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Fri, 20 Aug 2021 17:53:12 +0100
 
diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py
index a6c6278..f37c638 100644
--- a/lpbuildd/target/build_charm.py
+++ b/lpbuildd/target/build_charm.py
@@ -51,7 +51,7 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin,
         self.bin = os.path.dirname(sys.argv[0])
         self.buildd_path = os.path.join("/home/buildd", self.args.name)
 
-    def run_build_command(self, args, env=None, build_path=None, **kwargs):
+    def run_build_command(self, args, env=None, **kwargs):
         """Run a build command in the target.
 
         :param args: the command and arguments to run.
@@ -120,17 +120,12 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin,
             self.args.build_path)
         check_path_escape(self.buildd_path, build_context_path)
         env = OrderedDict()
-        env["CHARMCRAFT_MANAGED_MODE"] = "1"
         if self.args.proxy_url:
             env["http_proxy"] = self.args.proxy_url
             env["https_proxy"] = self.args.proxy_url
             env["GIT_PROXY_COMMAND"] = "/usr/local/bin/lpbuildd-git-proxy"
-        args = [
-            "charmcraft", "build", "-v",
-            "-p", build_context_path,
-            "-f", build_context_path,
-            ]
-        self.run_build_command(args, env=env)
+        args = ["charmcraft", "pack", "-v", "--destructive-mode"]
+        self.run_build_command(args, env=env, cwd=build_context_path)
 
     def run(self):
         try:
diff --git a/lpbuildd/target/tests/test_build_charm.py b/lpbuildd/target/tests/test_build_charm.py
index 61e8602..d695a37 100644
--- a/lpbuildd/target/tests/test_build_charm.py
+++ b/lpbuildd/target/tests/test_build_charm.py
@@ -358,10 +358,8 @@ class TestBuildCharm(TestCase):
         build_charm.build()
         self.assertThat(build_charm.backend.run.calls, MatchesListwise([
             RanBuildCommand(
-                ["charmcraft", "build", "-v",
-                 "-p", "/home/buildd/test-image/.",
-                 "-f", "/home/buildd/test-image/."],
-                cwd="/home/buildd/test-image", CHARMCRAFT_MANAGED_MODE="1"),
+                ["charmcraft", "pack", "-v", "--destructive-mode"],
+                cwd="/home/buildd/test-image/."),
             ]))
 
     def test_build_with_path(self):
@@ -376,10 +374,8 @@ class TestBuildCharm(TestCase):
         build_charm.build()
         self.assertThat(build_charm.backend.run.calls, MatchesListwise([
             RanBuildCommand(
-                ["charmcraft", "build", "-v",
-                 "-p", "/home/buildd/test-image/build-aux/",
-                 "-f", "/home/buildd/test-image/build-aux/"],
-                cwd="/home/buildd/test-image", CHARMCRAFT_MANAGED_MODE="1"),
+                ["charmcraft", "pack", "-v", "--destructive-mode"],
+                cwd="/home/buildd/test-image/build-aux/"),
             ]))
 
     def test_build_proxy(self):
@@ -392,17 +388,14 @@ class TestBuildCharm(TestCase):
         build_charm = parse_args(args=args).operation
         build_charm.build()
         env = {
-            "CHARMCRAFT_MANAGED_MODE": "1",
             "http_proxy": "http://proxy.example:3128/";,
             "https_proxy": "http://proxy.example:3128/";,
             "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy",
             }
         self.assertThat(build_charm.backend.run.calls, MatchesListwise([
             RanBuildCommand(
-                ["charmcraft", "build", "-v",
-                 "-p", "/home/buildd/test-image/.",
-                 "-f", "/home/buildd/test-image/."],
-                cwd="/home/buildd/test-image", **env),
+                ["charmcraft", "pack", "-v", "--destructive-mode"],
+                cwd="/home/buildd/test-image/.", **env),
             ]))
 
     def test_run_succeeds(self):
@@ -422,10 +415,8 @@ class TestBuildCharm(TestCase):
                 ["bzr", "branch", "lp:foo", "test-image"],
                 cwd="/home/buildd")),
             AnyMatch(RanBuildCommand(
-                ["charmcraft", "build", "-v",
-                 "-p", "/home/buildd/test-image/.",
-                 "-f", "/home/buildd/test-image/."],
-                cwd="/home/buildd/test-image", CHARMCRAFT_MANAGED_MODE="1")),
+                ["charmcraft", "pack", "-v", "--destructive-mode"],
+                cwd="/home/buildd/test-image/.")),
             ))
 
     def test_run_install_fails(self):