← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad-buildd/livefs-debug into lp:launchpad-buildd

 

Colin Watson has proposed merging lp:~cjwatson/launchpad-buildd/livefs-debug into lp:launchpad-buildd.

Commit message:
Accept a "debug" entry in livefs arguments, which enables detailed live-build debugging.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/livefs-debug/+merge/330662
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad-buildd/livefs-debug into lp:launchpad-buildd.
=== modified file 'debian/changelog'
--- debian/changelog	2017-09-08 00:42:04 +0000
+++ debian/changelog	2017-09-13 09:33:08 +0000
@@ -1,3 +1,10 @@
+launchpad-buildd (151) UNRELEASED; urgency=medium
+
+  * Accept a "debug" entry in livefs arguments, which enables detailed
+    live-build debugging.
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx>  Tue, 12 Sep 2017 18:31:48 +0100
+
 launchpad-buildd (151) xenial; urgency=medium
 
   * Run snapd with SNAPPY_STORE_NO_CDN=1, since the buildd network isn't

=== modified file 'lpbuildd/livefs.py'
--- lpbuildd/livefs.py	2017-08-26 09:51:15 +0000
+++ lpbuildd/livefs.py	2017-09-13 09:33:08 +0000
@@ -36,6 +36,7 @@
         self.image_format = extra_args.get("image_format")
         self.locale = extra_args.get("locale")
         self.extra_ppas = extra_args.get("extra_ppas", [])
+        self.debug = extra_args.get("debug", False)
 
         super(LiveFilesystemBuildManager, self).initiate(
             files, chroot, extra_args)
@@ -58,6 +59,8 @@
             args.extend(["--locale", self.locale])
         for ppa in self.extra_ppas:
             args.extend(["--extra-ppa", ppa])
+        if self.debug:
+            args.append("--debug")
         self.runTargetSubProcess("buildlivefs", *args)
 
     def iterate_BUILD_LIVEFS(self, retcode):

=== modified file 'lpbuildd/target/build_livefs.py'
--- lpbuildd/target/build_livefs.py	2017-08-29 08:53:24 +0000
+++ lpbuildd/target/build_livefs.py	2017-09-13 09:33:08 +0000
@@ -58,6 +58,9 @@
         parser.add_argument(
             "--extra-ppa", dest="extra_ppas", default=[], action="append",
             help="use this additional PPA")
+        parser.add_argument(
+            "--debug", default=False, action="store_true",
+            help="enable detailed live-build debugging")
 
     def run_build_command(self, args, env=None, echo=False):
         """Run a build command in the chroot.
@@ -106,12 +109,16 @@
                 "--release", self.args.series,
                 ])
         else:
-            self.run_build_command(["rm", "-rf", "auto"])
+            self.run_build_command(["rm", "-rf", "auto", "local"])
             self.run_build_command(["mkdir", "-p", "auto"])
             for lb_script in ("config", "build", "clean"):
                 lb_script_path = os.path.join(
                     "/usr/share/livecd-rootfs/live-build/auto", lb_script)
                 self.run_build_command(["ln", "-s", lb_script_path, "auto/"])
+            if self.args.debug:
+                self.run_build_command(["mkdir", "-p", "local/functions"])
+                self.run_build_command(
+                    ["sh", "-c", "echo 'set -x' >local/functions/debug.sh"])
             self.run_build_command(["lb", "clean", "--purge"])
 
             base_lb_env = OrderedDict()

=== modified file 'lpbuildd/target/tests/test_build_livefs.py'
--- lpbuildd/target/tests/test_build_livefs.py	2017-08-22 16:37:25 +0000
+++ lpbuildd/target/tests/test_build_livefs.py	2017-09-13 09:33:08 +0000
@@ -120,7 +120,7 @@
         build_livefs = parse_args(args=args).operation
         build_livefs.build()
         self.assertThat(build_livefs.backend.run.calls, MatchesListwise([
-            RanBuildCommand("rm -rf auto"),
+            RanBuildCommand("rm -rf auto local"),
             RanBuildCommand("mkdir -p auto"),
             RanBuildCommand(
                 "ln -s /usr/share/livecd-rootfs/live-build/auto/config auto/"),
@@ -148,6 +148,32 @@
                 "--release xenial"),
             ]))
 
+    def test_build_debug(self):
+        args = [
+            "buildlivefs",
+            "--backend=fake", "--series=xenial", "--arch=amd64", "1",
+            "--project=ubuntu", "--debug",
+            ]
+        build_livefs = parse_args(args=args).operation
+        build_livefs.build()
+        self.assertThat(build_livefs.backend.run.calls, MatchesListwise([
+            RanBuildCommand("rm -rf auto local"),
+            RanBuildCommand("mkdir -p auto"),
+            RanBuildCommand(
+                "ln -s /usr/share/livecd-rootfs/live-build/auto/config auto/"),
+            RanBuildCommand(
+                "ln -s /usr/share/livecd-rootfs/live-build/auto/build auto/"),
+            RanBuildCommand(
+                "ln -s /usr/share/livecd-rootfs/live-build/auto/clean auto/"),
+            RanBuildCommand("mkdir -p local/functions"),
+            RanBuildCommand(
+                "sh -c 'echo '\\''set -x'\\'' >local/functions/debug.sh'"),
+            RanBuildCommand("lb clean --purge"),
+            RanBuildCommand(
+                "env PROJECT=ubuntu ARCH=amd64 SUITE=xenial lb config"),
+            RanBuildCommand("env PROJECT=ubuntu ARCH=amd64 lb build"),
+            ]))
+
     def test_run_succeeds(self):
         args = [
             "buildlivefs",