← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:ci-chown-build-tree into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:ci-chown-build-tree into launchpad-buildd:master.

Commit message:
In CI jobs, chown the VCS tree to buildd:buildd after fetching it

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Otherwise lpcraft running as the buildd user can't read its .git directory.  For example, this broke Launchpad's own CI jobs.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:ci-chown-build-tree into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index bb87638..e48d607 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+launchpad-buildd (228) UNRELEASED; urgency=medium
+
+  * In CI jobs, chown the VCS tree to buildd:buildd after fetching it, since
+    otherwise lpcraft running as the buildd user can't read its .git
+    directory.
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx>  Thu, 26 Jan 2023 11:30:11 +0000
+
 launchpad-buildd (227) focal; urgency=medium
 
   * Tolerate receiving "builder_constraints": None.
diff --git a/lpbuildd/target/run_ci.py b/lpbuildd/target/run_ci.py
index 62757e2..c0e8703 100644
--- a/lpbuildd/target/run_ci.py
+++ b/lpbuildd/target/run_ci.py
@@ -95,6 +95,7 @@ class RunCIPrepare(BuilderProxyOperationMixin, VCSOperationMixin,
         env = self.build_proxy_environment(proxy_url=self.args.proxy_url)
         self.vcs_fetch("tree", cwd="/build", env=env)
         self.vcs_update_status(self.buildd_path)
+        self.backend.run(["chown", "-R", "buildd:buildd", "/build/tree"])
 
     def run(self):
         try:
diff --git a/lpbuildd/target/tests/test_run_ci.py b/lpbuildd/target/tests/test_run_ci.py
index 3eac5fc..08c4d95 100644
--- a/lpbuildd/target/tests/test_run_ci.py
+++ b/lpbuildd/target/tests/test_run_ci.py
@@ -233,6 +233,7 @@ class TestRunCIPrepare(TestCase):
             RanBuildCommand(
                 ["git", "rev-parse", "HEAD^{}"],
                 cwd="/build/tree", get_output=True, universal_newlines=True),
+            RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
             ]))
         status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
         with open(status_path) as status:
@@ -259,6 +260,7 @@ class TestRunCIPrepare(TestCase):
             RanBuildCommand(
                 ["git", "rev-parse", "next^{}"],
                 cwd="/build/tree", get_output=True, universal_newlines=True),
+            RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
             ]))
         status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
         with open(status_path) as status:
@@ -285,6 +287,7 @@ class TestRunCIPrepare(TestCase):
             RanBuildCommand(
                 ["git", "rev-parse", "refs/tags/1.0^{}"],
                 cwd="/build/tree", get_output=True, universal_newlines=True),
+            RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
             ]))
         status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
         with open(status_path) as status:
@@ -318,6 +321,7 @@ class TestRunCIPrepare(TestCase):
             RanBuildCommand(
                 ["git", "rev-parse", "HEAD^{}"],
                 cwd="/build/tree", get_output=True, universal_newlines=True),
+            RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
             ]))
         status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
         with open(status_path) as status: