diff options
author | Ferry Toth <ftoth@exalondelft.nl> | 2022-04-13 22:37:41 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-04-19 14:14:11 +0100 |
commit | 4a3f3f2c3491fe4ef65557be7d298b8a5adb47a4 (patch) | |
tree | e8dd2855d4107f45ef74d470e2c03c43f9cb9d9f /meta/lib | |
parent | b550a21a6659adec8dc226baaaa0372e319b7eda (diff) | |
download | poky-4a3f3f2c3491fe4ef65557be7d298b8a5adb47a4.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: 3ec30490d09d6639eea2638cf12a323948f221cc)
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>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/apt.py | 38 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/runtime_test.py | 38 |
2 files changed, 69 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() | ||
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py index 2ad89490fc..3ece617cb0 100644 --- a/meta/lib/oeqa/selftest/cases/runtime_test.py +++ b/meta/lib/oeqa/selftest/cases/runtime_test.py | |||
@@ -162,6 +162,44 @@ class TestImage(OESelftestTestCase): | |||
162 | bitbake('core-image-full-cmdline socat') | 162 | bitbake('core-image-full-cmdline socat') |
163 | bitbake('-c testimage core-image-full-cmdline') | 163 | bitbake('-c testimage core-image-full-cmdline') |
164 | 164 | ||
165 | def test_testimage_apt(self): | ||
166 | """ | ||
167 | Summary: Check package feeds functionality for apt | ||
168 | Expected: 1. Check that remote package feeds can be accessed | ||
169 | Product: oe-core | ||
170 | Author: Ferry Toth <fntoth@gmail.com> | ||
171 | """ | ||
172 | if get_bb_var('DISTRO') == 'poky-tiny': | ||
173 | self.skipTest('core-image-full-cmdline not buildable for poky-tiny') | ||
174 | |||
175 | features = 'INHERIT += "testimage"\n' | ||
176 | features += 'TEST_SUITES = "ping ssh apt.AptRepoTest.test_apt_install_from_repo"\n' | ||
177 | # We don't yet know what the server ip and port will be - they will be patched | ||
178 | # in at the start of the on-image test | ||
179 | features += 'PACKAGE_FEED_URIS = "http://bogus_ip:bogus_port"\n' | ||
180 | features += 'EXTRA_IMAGE_FEATURES += "package-management"\n' | ||
181 | features += 'PACKAGE_CLASSES = "package_deb"\n' | ||
182 | # We need gnupg on the target to install keys | ||
183 | features += 'IMAGE_INSTALL:append:pn-core-image-full-cmdline = " gnupg"\n' | ||
184 | |||
185 | bitbake('gnupg-native -c addto_recipe_sysroot') | ||
186 | |||
187 | # Enable package feed signing | ||
188 | self.gpg_home = tempfile.mkdtemp(prefix="oeqa-feed-sign-") | ||
189 | self.track_for_cleanup(self.gpg_home) | ||
190 | signing_key_dir = os.path.join(self.testlayer_path, 'files', 'signing') | ||
191 | runCmd('gpgconf --list-dirs --homedir %s; gpg -v --batch --homedir %s --import %s' % (self.gpg_home, self.gpg_home, os.path.join(signing_key_dir, 'key.secret')), native_sysroot=get_bb_var("RECIPE_SYSROOT_NATIVE", "gnupg-native"), shell=True) | ||
192 | features += 'INHERIT += "sign_package_feed"\n' | ||
193 | features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n' | ||
194 | features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase') | ||
195 | features += 'GPG_PATH = "%s"\n' % self.gpg_home | ||
196 | features += 'PSEUDO_IGNORE_PATHS .= ",%s"\n' % self.gpg_home | ||
197 | self.write_config(features) | ||
198 | |||
199 | # Build core-image-sato and testimage | ||
200 | bitbake('core-image-full-cmdline socat') | ||
201 | bitbake('-c testimage core-image-full-cmdline') | ||
202 | |||
165 | def test_testimage_virgl_gtk_sdl(self): | 203 | def test_testimage_virgl_gtk_sdl(self): |
166 | """ | 204 | """ |
167 | Summary: Check host-assisted accelerate OpenGL functionality in qemu with gtk and SDL frontends | 205 | Summary: Check host-assisted accelerate OpenGL functionality in qemu with gtk and SDL frontends |