← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:missing-apt-indextargets into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:missing-apt-indextargets into launchpad-buildd:master.

Commit message:
Tolerate missing "apt-get indextargets" on trusty

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

On trusty, it seems that /usr/lib/apt/apt-helper exists but "apt-get indextargets" doesn't, which broke dep-wait analysis in some cases.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:missing-apt-indextargets into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 52b6dfe..a49b1e9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 launchpad-buildd (195) UNRELEASED; urgency=medium
 
   * sbuild-package: Temporarily remove lxd group membership (LP: #1820348).
+  * Tolerate missing "apt-get indextargets" on trusty.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Fri, 05 Mar 2021 13:39:19 +0000
 
diff --git a/lpbuildd/binarypackage.py b/lpbuildd/binarypackage.py
index 19daca7..17af204 100644
--- a/lpbuildd/binarypackage.py
+++ b/lpbuildd/binarypackage.py
@@ -180,12 +180,22 @@ class BinaryPackageBuildManager(DebianBuildManager):
     def getAptLists(self):
         """Yield each of apt's Packages files in turn as a file object."""
         apt_helper = "/usr/lib/apt/apt-helper"
-        if os.path.exists(os.path.join(self.chroot_path, apt_helper[1:])):
-            paths = subprocess.check_output(
-                ["sudo", "chroot", self.chroot_path,
-                 "apt-get", "indextargets", "--format", "$(FILENAME)",
-                 "Created-By: Packages"],
-                universal_newlines=True).splitlines()
+        apt_helper_exists = os.path.exists(
+            os.path.join(self.chroot_path, apt_helper[1:]))
+        paths = None
+        if apt_helper_exists:
+            try:
+                paths = subprocess.check_output(
+                    ["sudo", "chroot", self.chroot_path,
+                     "apt-get", "indextargets", "--format", "$(FILENAME)",
+                     "Created-By: Packages"],
+                    universal_newlines=True).splitlines()
+            except subprocess.CalledProcessError:
+                # This might be e.g. Ubuntu 14.04, where
+                # /usr/lib/apt/apt-helper exists but "apt-get indextargets"
+                # doesn't.  Fall back to reading Packages files directly.
+                pass
+        if paths is not None:
             for path in paths:
                 helper = subprocess.Popen(
                     ["sudo", "chroot", self.chroot_path,