← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Configure apt to always include phased updates

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1949769 in launchpad-buildd: "Disable apt phased-updates in build environments"
  https://bugs.launchpad.net/launchpad-buildd/+bug/1949769

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

Versions of APT that support phased updates do this automatically if running in a chroot, but builds may be running in a LXD container instead.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:apt-phasing into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 8c8872b..4d495dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ launchpad-buildd (204) UNRELEASED; urgency=medium
 
   * Configure apt to automatically retry downloads on failures
     (LP: #1949473).
+  * Configure apt to always include phased updates, even if running in LXD
+    containers (LP: #1949769).
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Tue, 02 Nov 2021 13:42:13 +0000
 
diff --git a/lpbuildd/target/apt.py b/lpbuildd/target/apt.py
index 49b1650..01daca5 100644
--- a/lpbuildd/target/apt.py
+++ b/lpbuildd/target/apt.py
@@ -45,6 +45,16 @@ class OverrideSourcesList(Operation):
             os.fchmod(apt_retries_conf.fileno(), 0o644)
             self.backend.copy_in(
                 apt_retries_conf.name, "/etc/apt/apt.conf.d/99retries")
+        # Versions of APT that support phased updates do this automatically
+        # if running in a chroot, but builds may be running in a LXD
+        # container instead.
+        with tempfile.NamedTemporaryFile(mode="w+") as apt_phasing_conf:
+            print('APT::Get::Always-Include-Phased-Updates "true";',
+                  file=apt_phasing_conf)
+            apt_phasing_conf.flush()
+            os.fchmod(apt_phasing_conf.fileno(), 0o644)
+            self.backend.copy_in(
+                apt_phasing_conf.name, "/etc/apt/apt.conf.d/99phasing")
         if self.args.apt_proxy_url is not None:
             with tempfile.NamedTemporaryFile(mode="w+") as apt_proxy_conf:
                 print(
diff --git a/lpbuildd/target/tests/test_apt.py b/lpbuildd/target/tests/test_apt.py
index a946e38..cdefca4 100644
--- a/lpbuildd/target/tests/test_apt.py
+++ b/lpbuildd/target/tests/test_apt.py
@@ -56,6 +56,11 @@ class TestOverrideSourcesList(TestCase):
             (b'Acquire::Retries "3";\n', stat.S_IFREG | 0o644),
             override_sources_list.backend.backend_fs[
                 "/etc/apt/apt.conf.d/99retries"])
+        self.assertEqual(
+            (b'APT::Get::Always-Include-Phased-Updates "true";\n',
+             stat.S_IFREG | 0o644),
+            override_sources_list.backend.backend_fs[
+                "/etc/apt/apt.conf.d/99phasing"])
 
     def test_apt_proxy(self):
         args = [
@@ -76,6 +81,11 @@ class TestOverrideSourcesList(TestCase):
             override_sources_list.backend.backend_fs[
                 "/etc/apt/apt.conf.d/99retries"])
         self.assertEqual(
+            (b'APT::Get::Always-Include-Phased-Updates "true";\n',
+             stat.S_IFREG | 0o644),
+            override_sources_list.backend.backend_fs[
+                "/etc/apt/apt.conf.d/99phasing"])
+        self.assertEqual(
             (dedent("""\
                 Acquire::http::Proxy "http://apt-proxy.example:3128/";;
                 """).encode("UTF-8"), stat.S_IFREG | 0o644),

Follow ups