[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5144/8267] rpm: add support for remote package feeds via PACKAGE_FEED_URIS variable
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 5144/8267] rpm: add support for remote package feeds via PACKAGE_FEED_URIS variable
- Date: Sun, 17 Dec 2017 03:01:38 +0000 (UTC)
commit 2b77735c72cb5100dbd850e79d4f639e82629842
Author: Alexander Kanavin <alexander kanavin linux intel com>
Date: Thu Mar 16 15:19:04 2017 +0200
rpm: add support for remote package feeds via PACKAGE_FEED_URIS variable
I've used a previous patch (which was never merged) by
Humberto Ibarra <humberto ibarra lopez intel com> as a model
for how to do runtime testing of this feature (e.g. we need to boot
an image, run dnf on it, and check that it is indeed able to
access the remote repo over http). Here's his original commit message:
=====
Testing that feeds specified with PACKAGE_FEED_URIS var are set
correctly has two parts. First a build with this var set is required,
and then smart update needs to be issued in the running taget.
The previous is not a common selftest practice because this is a
simple test, but requires building and running a specific image,
which takes a lot of time. testimage is not a good fit either,
since the images tested there do not have the PACKAGE_FEED_URIS
var set.
For this test, the runtime-test module is being used, which is a
selftest module but runs a testimage command. The var and test
environment were set in runtime-perf.py and the actual test is
done in a new testcase added to meta-selftest layer.
=====
[YOCTO #10872]
(From OE-Core rev: 3a9e2fdef9316e24b52ce99ac355fc2b09786c72)
Signed-off-by: Alexander Kanavin <alexander kanavin linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
meta-selftest/lib/oeqa/runtime/cases/selftest.py | 42 ++++++++++++++++++++++
meta/lib/oe/package_manager.py | 12 ++++++-
meta/lib/oeqa/selftest/runtime-test.py | 7 ++++
3 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/meta-selftest/lib/oeqa/runtime/cases/selftest.py
b/meta-selftest/lib/oeqa/runtime/cases/selftest.py
index 19de740..e4985a6 100644
--- a/meta-selftest/lib/oeqa/runtime/cases/selftest.py
+++ b/meta-selftest/lib/oeqa/runtime/cases/selftest.py
@@ -1,5 +1,7 @@
from oeqa.runtime.case import OERuntimeTestCase
from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.cases.dnf import DnfTest
+from oeqa.utils.httpserver import HTTPService
class Selftest(OERuntimeTestCase):
@@ -29,3 +31,43 @@ class Selftest(OERuntimeTestCase):
(status, output) = self.target.run("socat -V")
self.assertNotEqual(status, 0, msg="socat is still installed")
+
+
+class DnfSelftest(DnfTest):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-rootfs-repo'),
+ cls.tc.target.server_ip)
+ cls.repo_server.start()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.repo_server.stop()
+
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_verify_package_feeds(self):
+ """
+ Summary: Check correct setting of PACKAGE_FEED_URIS var
+ Expected: 1. Feeds were correctly set for dnf
+ 2. Update recovers packages from host's repo
+ Author: Humberto Ibarra <humberto ibarra lopez intel com>
+ Author: Alexander Kanavin <alexander kanavin intel com>
+ """
+ # When we created an image, we had to supply fake ip and port
+ # for the feeds. Now we can patch the real ones into the config file.
+ import tempfile
+ temp_file = tempfile.TemporaryDirectory(prefix="oeqa-remotefeeds-").name
+ self.tc.target.copyFrom("/etc/yum.repos.d/oe-remote-repo.repo", temp_file)
+ fixed_config = open(temp_file, "r").read().replace("bogus_ip",
self.tc.target.server_ip).replace("bogus_port", str(self.repo_server.port))
+ open(temp_file, "w").write(fixed_config)
+ self.tc.target.copyTo(temp_file, "/etc/yum.repos.d/oe-remote-repo.repo")
+
+ import re
+ output_makecache = self.dnf('makecache')
+ self.assertTrue(re.match(r".*Metadata cache created", output_makecache, re.DOTALL) is not None, msg
= "dnf makecache failed: %s" %(output_makecache))
+
+ output_repoinfo = self.dnf('repoinfo')
+ matchobj = re.match(r".*Repo-pkgs\s*:\s*(?P<n_pkgs>[0-9]+)", output_repoinfo, re.DOTALL)
+ self.assertTrue(matchobj is not None, msg = "Could not find the amount of packages in dnf repoinfo
output: %s" %(output_repoinfo))
+ self.assertTrue(int(matchobj.group('n_pkgs')) > 0, msg = "Amount of remote packages is not more than
zero: %s\n" %(output_repoinfo))
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index d516091..b016bc3 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -533,10 +533,20 @@ class RpmPM(PackageManager):
bb.utils.unlockfile(lf)
def insert_feeds_uris(self, feed_uris, feed_base_paths, feed_archs):
+ from urllib.parse import urlparse
+
if feed_uris == "":
return
- raise NotImplementedError("Adding remote dnf feeds not yet supported.")
+ bb.utils.mkdirhier(oe.path.join(self.target_rootfs, "etc", "yum.repos.d"))
+ remote_uris = self.construct_uris(feed_uris.split(), feed_base_paths.split())
+ for uri in remote_uris:
+ repo_name = "oe-remote-repo" + "-".join(urlparse(uri).path.split("/"))
+ if feed_archs is not None:
+ repo_uris = [uri + "/" + arch for arch in feed_archs]
+ else:
+ repo_uris = [uri]
+ open(oe.path.join(self.target_rootfs, "etc", "yum.repos.d", repo_name + ".repo"),
'w').write("[%s]\nbaseurl=%s\n" % (repo_name, " ".join(repo_uris)))
def _prepare_pkg_transaction(self):
os.environ['D'] = self.target_rootfs
diff --git a/meta/lib/oeqa/selftest/runtime-test.py b/meta/lib/oeqa/selftest/runtime-test.py
index e8b483d..171a373 100644
--- a/meta/lib/oeqa/selftest/runtime-test.py
+++ b/meta/lib/oeqa/selftest/runtime-test.py
@@ -108,14 +108,21 @@ class TestImage(oeSelfTest):
Summary: Check install packages functionality for testimage/testexport.
Expected: 1. Import tests from a directory other than meta.
2. Check install/uninstall of socat.
+ 3. Check that remote package feeds can be accessed
Product: oe-core
Author: Mariano Lopez <mariano lopez intel com>
+ Author: Alexander Kanavin <alexander kanavin intel com>
"""
if get_bb_var('DISTRO') == 'poky-tiny':
self.skipTest('core-image-full-cmdline not buildable for poky-tiny')
features = 'INHERIT += "testimage"\n'
features += 'TEST_SUITES = "ping ssh selftest"\n'
+ # We don't yet know what the server ip and port will be - they will be patched
+ # in at the start of the on-image test
+ features += 'PACKAGE_FEED_URIS = "http://bogus_ip:bogus_port"\n'
+ features += 'EXTRA_IMAGE_FEATURES += "package-management"\n'
+ features += 'PACKAGE_CLASSES = "package_rpm"'
self.write_config(features)
# Build core-image-sato and testimage
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]