← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:proposed-ignore-not-automatic into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:proposed-ignore-not-automatic into launchpad-buildd:master.

Commit message:
Ignore NotAutomatic flag for -proposed and -backports

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1016776 in launchpad-buildd: "Users are offered updates to packages in -proposed"
  https://bugs.launchpad.net/launchpad-buildd/+bug/1016776

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

This allows us to change the configuration of which upgrades are offered to users from -proposed without affecting how builds against -proposed behave; `Pin-Priority: 500` is the existing default, but without this change it would become priority 100 after we implement the remainder of https://bugs.launchpad.net/launchpad/+bug/1016776.

NotAutomatic was already ignored for -backports via livecd-rootfs (see https://bugs.launchpad.net/launchpad/+bug/888665), but I think doing it in launchpad-buildd is more flexible and transparent, not to mention significantly easier to deploy than having to land changes to livecd-rootfs and update all the chroots.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:proposed-ignore-not-automatic into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index a56c8da..28df0fc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+launchpad-buildd (205) UNRELEASED; urgency=medium
+
+  * Ignore NotAutomatic flag for -proposed and -backports (LP: #1016776).
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx>  Mon, 29 Nov 2021 16:20:37 +0000
+
 launchpad-buildd (204) bionic; urgency=medium
 
   * Configure apt to automatically retry downloads on failures
diff --git a/lpbuildd/target/apt.py b/lpbuildd/target/apt.py
index 01daca5..09d51dd 100644
--- a/lpbuildd/target/apt.py
+++ b/lpbuildd/target/apt.py
@@ -10,6 +10,7 @@ import os
 import subprocess
 import sys
 import tempfile
+from textwrap import dedent
 import time
 
 from lpbuildd.target.operation import Operation
@@ -65,6 +66,18 @@ class OverrideSourcesList(Operation):
                 os.fchmod(apt_proxy_conf.fileno(), 0o644)
                 self.backend.copy_in(
                     apt_proxy_conf.name, "/etc/apt/apt.conf.d/99proxy")
+        for pocket in ("proposed", "backports"):
+            with tempfile.NamedTemporaryFile(mode="w+") as preferences:
+                print(dedent("""\
+                    Package: *
+                    Pin: release a=*-{}
+                    Pin-Priority: 500
+                    """).format(pocket), file=preferences, end="")
+                preferences.flush()
+                os.fchmod(preferences.fileno(), 0o644)
+                self.backend.copy_in(
+                    preferences.name,
+                    "/etc/apt/preferences.d/{}.pref".format(pocket))
         return 0
 
 
diff --git a/lpbuildd/target/tests/test_apt.py b/lpbuildd/target/tests/test_apt.py
index cdefca4..4af3ac7 100644
--- a/lpbuildd/target/tests/test_apt.py
+++ b/lpbuildd/target/tests/test_apt.py
@@ -61,6 +61,16 @@ class TestOverrideSourcesList(TestCase):
              stat.S_IFREG | 0o644),
             override_sources_list.backend.backend_fs[
                 "/etc/apt/apt.conf.d/99phasing"])
+        self.assertEqual(
+            (b"Package: *\nPin: release a=*-proposed\nPin-Priority: 500\n",
+             stat.S_IFREG | 0o644),
+            override_sources_list.backend.backend_fs[
+                "/etc/apt/preferences.d/proposed.pref"])
+        self.assertEqual(
+            (b"Package: *\nPin: release a=*-backports\nPin-Priority: 500\n",
+             stat.S_IFREG | 0o644),
+            override_sources_list.backend.backend_fs[
+                "/etc/apt/preferences.d/backports.pref"])
 
     def test_apt_proxy(self):
         args = [