Control: tags -1 + patch
Control: user de...@kali.org
Control: usertag -1 + kali-patch

On Wed, 29 Dec 2021, Raphaël Hertzog wrote:
> I noticed that /etc/apt/preferences.d/autopkgtest-default-release uses
> another syntax that seems to cover more cases:
> 
> Package: *
> Pin: release kali-rolling
> Pin-Priority: 990
> 
> However that syntax doesn't seem to be documented in apt_preferences.
> If it's correct and allows to check on either of the 3 fields, then
> we should likely use the same syntax in both files.

I got confirmation from David Kalnischkies that this syntax is supported
and means exactly this:

12:54 <DonKult> buxy: yeah, its supported and means "Archive/Suite: or
Codename is X". One example in the manpage actually includes it (release
unstable), but it is never explained it seems. It is also the backbone of
commandline flag -t X. Code is in apt-pkg/versionmatch.cc, but its not
much to see.

So I recommend to use this same syntax in files generated for
--pin-packages.

Suggested patch is attached.

Cheers,
-- 
  ⢀⣴⠾⠻⢶⣦⠀   Raphaël Hertzog <hert...@debian.org>
  ⣾⠁⢠⠒⠀⣿⡁
  ⢿⡄⠘⠷⠚⠋    The Debian Handbook: https://debian-handbook.info/get/
  ⠈⠳⣄⠀⠀⠀⠀   Debian Long Term Support: https://deb.li/LTS
>From 9946e61ed4821aa9c03d42393ea6887dc9337ea7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <raph...@offensive-security.com>
Date: Wed, 29 Dec 2021 13:23:27 +0100
Subject: [PATCH] Fix APT pinning for --pin-packages to also match on codenames
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

By using “Pin: release foo” instead of “Pin: release a=foo” we match
against all 3 relevant fields (Codename/Suite/Archive) whereas the
latter only matches against Suite and Archive.

Closes: #1002819
---
 lib/adt_testbed.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/adt_testbed.py b/lib/adt_testbed.py
index b37eef4..225eb1f 100644
--- a/lib/adt_testbed.py
+++ b/lib/adt_testbed.py
@@ -1235,10 +1235,10 @@ Description: satisfy autopkgtest test dependencies
 
         # prefer given packages from series, but make sure that other packages
         # are taken from default release as much as possible
-        script += 'printf "Package: $PKGS\\nPin: release a=%(release)s\\nPin-Priority: 995\\n" > /etc/apt/preferences.d/autopkgtest-%(release)s; ' % \
+        script += 'printf "Package: $PKGS\\nPin: release %(release)s\\nPin-Priority: 995\\n" > /etc/apt/preferences.d/autopkgtest-%(release)s; ' % \
             {'release': release}
         for default in default_releases:
-            script += 'printf "\nPackage: *\\nPin: release a=%(default)s\\nPin-Priority: 990\\n" >> /etc/apt/preferences.d/autopkgtest-%(release)s; ' % \
+            script += 'printf "\nPackage: *\\nPin: release %(default)s\\nPin-Priority: 990\\n" >> /etc/apt/preferences.d/autopkgtest-%(release)s; ' % \
                 {'release': release, 'default': default}
         self.check_exec(['sh', '-ec', script])
         self._set_default_release()
-- 
2.34.1

Reply via email to