[PATCH] Use apt pinning instead of APT::Default-Release
- Subject: [PATCH] Use apt pinning instead of APT::Default-Release
- From: Iain Lane <iain.lane@canonical.com>
- Date: Thu, 22 Mar 2018 10:34:56 +0000
apt verifies that the value of APT::Default-Release exists in
sources.list, and this breaks assumptions in certain tests which expect
to be able to construct arbitrary sources.lists and work with them.
pin files aren't subject to this validation, but are otherwise
equivalent - let's use one of those.
---
lib/adt_testbed.py | 5 ++---
tests/autopkgtest | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/lib/adt_testbed.py b/lib/adt_testbed.py
index 0848f72..4e0d16c 100644
--- a/lib/adt_testbed.py
+++ b/lib/adt_testbed.py
@@ -613,7 +613,7 @@ Description: satisfy autopkgtest test dependencies
'Retrying with using all packages from %s' % release)
self.check_exec(['/bin/sh', '-ec', 'rm /etc/apt/preferences.d/autopkgtest-' + release])
if not self.apt_pin_for_releases:
- self.check_exec(['/bin/sh', '-ec', 'rm -f /etc/apt/apt.conf.d/autopkgtest-default-release'])
+ self.check_exec(['/bin/sh', '-ec', 'rm -f /etc/apt/apt.preferences.d/autopkgtest-default-release'])
continue
if shell_on_failure:
@@ -1272,8 +1272,7 @@ fi
def _set_default_release(self):
'''Set APT::Default-Release to enable pinning to do it's job.'''
- script = 'mkdir -p /etc/apt/apt.conf.d; '
- script += 'printf "APT::Default-Release \\"%(default)s\\";\\n" > /etc/apt/apt.conf.d/autopkgtest-default-release; ' % \
+ script = 'printf "\nPackage: *\\nPin: release %(default)s\\nPin-Priority: 990\\n" > /etc/apt/preferences.d/autopkgtest-default-release' % \
{'default': self._get_default_release()}
self.check_exec(['sh', '-ec', script])
diff --git a/tests/autopkgtest b/tests/autopkgtest
index 8201665..afee411 100755
--- a/tests/autopkgtest
+++ b/tests/autopkgtest
@@ -1960,7 +1960,7 @@ deb [trusted=yes arch=6510] http://foo.ubuntu.com/ fluffy-proposed main 6510
# should set up apt pinning
self.assertEqual(os.listdir(os.path.join(apt_dir, 'preferences.d')),
- ['autopkgtest-fluffy-proposed'])
+ ['autopkgtest-fluffy-proposed', 'autopkgtest-default-release'])
with open(os.path.join(apt_dir, 'preferences.d', 'autopkgtest-fluffy-proposed')) as f:
self.assertEqual(f.read(), '''Package: foo bar
Pin: release a=fluffy-proposed
@@ -1969,13 +1969,13 @@ Pin-Priority: 995
Package: *
Pin: release a=fluffy-updates
Pin-Priority: 990
+''')
+ with open(os.path.join(apt_dir, 'preferences.d', 'autopkgtest-fluffy-proposed')) as f:
+ self.assertEqual(f.read(), '''Package: *
+Pin: release fluffy
+Pin-Priority: 990
''')
- # should set up APT::Default-Release
- self.assertEqual(os.listdir(os.path.join(apt_dir, 'apt.conf.d')),
- ['autopkgtest-default-release'])
- with open(os.path.join(apt_dir, 'apt.conf.d', 'autopkgtest-default-release')) as f:
- self.assertEqual(f.read(), 'APT::Default-Release "fluffy";\n')
def test_apt_default_release(self):
'''--apt-default-release'''
--
2.15.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/autopkgtest-devel/attachments/20180322/83781fea/attachment.sig>
Reply to: