← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:oci-default-arch-build-args into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:oci-default-arch-build-args into launchpad:master.

Commit message:
Add LAUNCHPAD_BUILD_ARCH as a default BUILD_ARG

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1929183 in Launchpad itself: "Add posibility to build multi architecture OCI base images"
  https://bugs.launchpad.net/launchpad/+bug/1929183

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/403194

Using the LAUNCHPAD_ prefix to avoid any potential collisions with enabling BUILDKIT or similar in future.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-default-arch-build-args into launchpad:master.
diff --git a/lib/lp/oci/model/ocirecipebuildbehaviour.py b/lib/lp/oci/model/ocirecipebuildbehaviour.py
index 0ca766d..a8737f2 100644
--- a/lib/lp/oci/model/ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/model/ocirecipebuildbehaviour.py
@@ -141,10 +141,16 @@ class OCIRecipeBuildBehaviour(SnapProxyMixin, BuildFarmJobBehaviourBase):
                 logger=logger))
 
         args['build_file'] = build.recipe.build_file
+
+        # Do our work on a new dict, so we don't try to update the
+        # copy on the model
+        build_args = {
+            "LAUNCHPAD_BUILD_ARCH": build.distro_arch_series.architecturetag}
         # We have to remove the security proxy that Zope applies to this
         # dict, since otherwise we'll be unable to serialise it to
         # XML-RPC.
-        args['build_args'] = removeSecurityProxy(build.recipe.build_args)
+        build_args.update(removeSecurityProxy(build.recipe.build_args))
+        args['build_args'] = build_args
         args['build_path'] = build.recipe.build_path
         args['metadata'] = self._getBuildInfoArgs()
 
diff --git a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
index ad4f625..21fc34e 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
@@ -389,12 +389,15 @@ class TestAsyncOCIRecipeBuildBehaviour(
         # Asserts that nothing here is a zope proxy, to avoid errors when
         # serializing it for XML-RPC call.
         self.assertHasNoZopeSecurityProxy(args)
+        arch_tag = job.build.distro_arch_series.architecturetag
         self.assertThat(args, MatchesDict({
             "archive_private": Is(False),
             "archives": Equals(expected_archives),
             "arch_tag": Equals("i386"),
             "build_file": Equals(job.build.recipe.build_file),
-            "build_args": Equals({"BUILD_VAR": "123"}),
+            "build_args": Equals({
+                "BUILD_VAR": "123",
+                "LAUNCHPAD_BUILD_ARCH": arch_tag}),
             "build_path": Equals(job.build.recipe.build_path),
             "build_url": Equals(canonical_url(job.build)),
             "fast_cleanup": Is(True),
@@ -440,12 +443,15 @@ class TestAsyncOCIRecipeBuildBehaviour(
         # serializing it for XML-RPC call.
         self.assertHasNoZopeSecurityProxy(args)
         split_browse_root = urlsplit(config.codehosting.git_browse_root)
+        arch_tag = job.build.distro_arch_series.architecturetag
         self.assertThat(args, MatchesDict({
             "archive_private": Is(False),
             "archives": Equals(expected_archives),
             "arch_tag": Equals("i386"),
             "build_file": Equals(job.build.recipe.build_file),
-            "build_args": Equals({"BUILD_VAR": "123"}),
+            "build_args": Equals({
+                "BUILD_VAR": "123",
+                "LAUNCHPAD_BUILD_ARCH": arch_tag}),
             "build_path": Equals(job.build.recipe.build_path),
             "build_url": Equals(canonical_url(job.build)),
             "fast_cleanup": Is(True),
@@ -493,12 +499,15 @@ class TestAsyncOCIRecipeBuildBehaviour(
         with dbuser(config.builddmaster.dbuser):
             args = yield job.extraBuildArgs()
         self.assertHasNoZopeSecurityProxy(args)
+        arch_tag = job.build.distro_arch_series.architecturetag
         self.assertThat(args, MatchesDict({
             "archive_private": Is(False),
             "archives": Equals(expected_archives),
             "arch_tag": Equals("i386"),
             "build_file": Equals(job.build.recipe.build_file),
-            "build_args": Equals({"BUILD_VAR": "123"}),
+            "build_args": Equals({
+                "BUILD_VAR": "123",
+                "LAUNCHPAD_BUILD_ARCH": arch_tag}),
             "build_path": Equals(job.build.recipe.build_path),
             "build_url": Equals(canonical_url(job.build)),
             "fast_cleanup": Is(True),