summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/cases
diff options
context:
space:
mode:
authorFerry Toth <ftoth@exalondelft.nl>2022-04-13 22:37:41 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-28 17:07:18 +0100
commit15d0cc7db5c30f4a277006b6d7ad200cc352a775 (patch)
treeee1386e28f24bad5808adb64db912429d9ba224c /meta/lib/oeqa/runtime/cases
parent3bc9b46bd9efe112137026d6cad294d6469dec54 (diff)
downloadpoky-15d0cc7db5c30f4a277006b6d7ad200cc352a775.tar.gz
apt: add apt selftest to test signed package feeds
Since Gatesgarth apt (1.8.2) has become more strict and doesn’t allow unsigned repositories by default. Currently when building images this requirement is worked around by using [allow-insecure=yes] and equivalently when performing selftest. Patches "gpg-sign: Add parameters to gpg signature function" and "package_manager: sign DEB package feeds" enable signed DEB package feeds. This patch adds a runtime test for apt derived from the test_testimage_dnf test. It creates a signed deb package feed, runs a qemu image to install the key and performs some package management. To be able to install the key the gnupg package is added to the testimage. (From OE-Core rev: 10fd76e6dfd97b57a9e2f592677c7e47b622e6b5) Signed-off-by: Ferry Toth <ftoth@exalondelft.nl> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 3ec30490d09d6639eea2638cf12a323948f221cc) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime/cases')
-rw-r--r--meta/lib/oeqa/runtime/cases/apt.py38
1 files changed, 31 insertions, 7 deletions
diff --git a/meta/lib/oeqa/runtime/cases/apt.py b/meta/lib/oeqa/runtime/cases/apt.py
index 53745df93f..574a34f148 100644
--- a/meta/lib/oeqa/runtime/cases/apt.py
+++ b/meta/lib/oeqa/runtime/cases/apt.py
@@ -21,7 +21,7 @@ class AptRepoTest(AptTest):
21 21
22 @classmethod 22 @classmethod
23 def setUpClass(cls): 23 def setUpClass(cls):
24 service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_DEB'], 'all') 24 service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_DEB'], '')
25 cls.repo_server = HTTPService(service_repo, 25 cls.repo_server = HTTPService(service_repo,
26 '0.0.0.0', port=cls.tc.target.server_port, 26 '0.0.0.0', port=cls.tc.target.server_port,
27 logger=cls.tc.logger) 27 logger=cls.tc.logger)
@@ -34,20 +34,44 @@ class AptRepoTest(AptTest):
34 def setup_source_config_for_package_install(self): 34 def setup_source_config_for_package_install(self):
35 apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port) 35 apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
36 apt_get_sourceslist_dir = '/etc/apt/' 36 apt_get_sourceslist_dir = '/etc/apt/'
37 self.target.run('cd %s; echo deb [ allow-insecure=yes ] %s ./ > sources.list' % (apt_get_sourceslist_dir, apt_get_source_server)) 37 self.target.run('cd %s; echo deb [ allow-insecure=yes ] %s/all ./ > sources.list' % (apt_get_sourceslist_dir, apt_get_source_server))
38
39 def setup_source_config_for_package_install_signed(self):
40 apt_get_source_server = 'http:\/\/%s:%s' % (self.tc.target.server_ip, self.repo_server.port)
41 apt_get_sourceslist_dir = '/etc/apt/'
42 self.target.run("cd %s; cp sources.list sources.list.bak; sed -i 's/\[trusted=yes\] http:\/\/bogus_ip:bogus_port/%s/g' sources.list" % (apt_get_sourceslist_dir, apt_get_source_server))
38 43
39 def cleanup_source_config_for_package_install(self): 44 def cleanup_source_config_for_package_install(self):
40 apt_get_sourceslist_dir = '/etc/apt/' 45 apt_get_sourceslist_dir = '/etc/apt/'
41 self.target.run('cd %s; rm sources.list' % (apt_get_sourceslist_dir)) 46 self.target.run('cd %s; rm sources.list' % (apt_get_sourceslist_dir))
42 47
48 def cleanup_source_config_for_package_install_signed(self):
49 apt_get_sourceslist_dir = '/etc/apt/'
50 self.target.run('cd %s; mv sources.list.bak sources.list' % (apt_get_sourceslist_dir))
51
52 def setup_key(self):
53 # the key is found on the target /etc/pki/packagefeed-gpg/
54 # named PACKAGEFEED-GPG-KEY-poky-branch
55 self.target.run('cd %s; apt-key add P*' % ('/etc/pki/packagefeed-gpg'))
56
43 @skipIfNotFeature('package-management', 57 @skipIfNotFeature('package-management',
44 'Test requires package-management to be in IMAGE_FEATURES') 58 'Test requires package-management to be in IMAGE_FEATURES')
45 @skipIfNotDataVar('IMAGE_PKGTYPE', 'deb', 59 @skipIfNotDataVar('IMAGE_PKGTYPE', 'deb',
46 'DEB is not the primary package manager') 60 'DEB is not the primary package manager')
47 @OEHasPackage(['apt']) 61 @OEHasPackage(['apt'])
48 def test_apt_install_from_repo(self): 62 def test_apt_install_from_repo(self):
49 self.setup_source_config_for_package_install() 63 if not self.tc.td.get('PACKAGE_FEED_GPG_NAME'):
50 self.pkg('update') 64 self.setup_source_config_for_package_install()
51 self.pkg('remove --yes run-postinsts-dev') 65 self.pkg('update')
52 self.pkg('install --yes --allow-unauthenticated run-postinsts-dev') 66 self.pkg('remove --yes run-postinsts-dev')
53 self.cleanup_source_config_for_package_install() 67 self.pkg('install --yes --allow-unauthenticated run-postinsts-dev')
68 self.cleanup_source_config_for_package_install()
69 else:
70 # when we are here a key has been set to sign the package feed and
71 # public key and gnupg installed on the image by test_testimage_apt
72 self.setup_source_config_for_package_install_signed()
73 self.setup_key()
74 self.pkg('update')
75 self.pkg('install --yes run-postinsts-dev')
76 self.pkg('remove --yes run-postinsts-dev')
77 self.cleanup_source_config_for_package_install_signed()