summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorFredrik Gustafsson <fredrik.gustafsson@axis.com>2020-09-08 12:53:07 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-11-24 15:53:07 +0000
commite51345b50784572602a09a233b9d6f4847fe1f16 (patch)
treed65d4d5d4e06f3d0a014a634c03ced594d6c1dc7 /meta/lib
parent8c28435258ea28dadbbbe9506beae700c226c379 (diff)
downloadpoky-e51345b50784572602a09a233b9d6f4847fe1f16.tar.gz
package management: Allow dynamic loading of PM
Dynamic loading of package managers will allow other layers to simply add their package manager code in package_manager/ and have bitbake find it according to the package manager configuration. This is useful for adding new (faster) package managers to Open Embedded while not increasing the test scope or require Open Embedded to support more package managers. How this is tested: * Build core-image-minimal with all three package managers * Build the sdk with all three package managers. dpkg fails, but it fails on master as well. * Run the complete test suite, all tests passed except 16 * Run those 16 tests on master and verify that they fail there as well * Fix errors making tests works on master but not with this patch. (From OE-Core rev: 02670501dea192879ddf9f8048eea57a94719fc1) Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/manifest.py10
-rw-r--r--meta/lib/oe/package_manager/deb/__init__.py4
-rw-r--r--meta/lib/oe/package_manager/deb/manifest.py2
-rw-r--r--meta/lib/oe/package_manager/deb/rootfs.py8
-rw-r--r--meta/lib/oe/package_manager/deb/sdk.py10
-rw-r--r--meta/lib/oe/package_manager/ipk/__init__.py9
-rw-r--r--meta/lib/oe/package_manager/ipk/manifest.py2
-rw-r--r--meta/lib/oe/package_manager/ipk/rootfs.py8
-rw-r--r--meta/lib/oe/package_manager/ipk/sdk.py10
-rw-r--r--meta/lib/oe/package_manager/rpm/__init__.py2
-rw-r--r--meta/lib/oe/package_manager/rpm/manifest.py2
-rw-r--r--meta/lib/oe/package_manager/rpm/rootfs.py8
-rw-r--r--meta/lib/oe/package_manager/rpm/sdk.py10
-rw-r--r--meta/lib/oe/rootfs.py36
-rw-r--r--meta/lib/oe/sdk.py27
15 files changed, 55 insertions, 93 deletions
diff --git a/meta/lib/oe/manifest.py b/meta/lib/oe/manifest.py
index 47bd622412..1a058dcd73 100644
--- a/meta/lib/oe/manifest.py
+++ b/meta/lib/oe/manifest.py
@@ -191,14 +191,8 @@ class Manifest(object, metaclass=ABCMeta):
191 191
192def create_manifest(d, final_manifest=False, manifest_dir=None, 192def create_manifest(d, final_manifest=False, manifest_dir=None,
193 manifest_type=Manifest.MANIFEST_TYPE_IMAGE): 193 manifest_type=Manifest.MANIFEST_TYPE_IMAGE):
194 from oe.package_manager.rpm.manifest import RpmManifest 194 import importlib
195 from oe.package_manager.ipk.manifest import OpkgManifest 195 manifest = importlib.import_module('oe.package_manager.' + d.getVar('IMAGE_PKGTYPE') + '.manifest').PkgManifest(d, manifest_dir, manifest_type)
196 from oe.package_manager.deb.manifest import DpkgManifest
197 manifest_map = {'rpm': RpmManifest,
198 'ipk': OpkgManifest,
199 'deb': DpkgManifest}
200
201 manifest = manifest_map[d.getVar('IMAGE_PKGTYPE')](d, manifest_dir, manifest_type)
202 196
203 if final_manifest: 197 if final_manifest:
204 manifest.create_final() 198 manifest.create_final()
diff --git a/meta/lib/oe/package_manager/deb/__init__.py b/meta/lib/oe/package_manager/deb/__init__.py
index 5120920e70..10ad707c23 100644
--- a/meta/lib/oe/package_manager/deb/__init__.py
+++ b/meta/lib/oe/package_manager/deb/__init__.py
@@ -79,7 +79,7 @@ class DpkgIndexer(Indexer):
79 if self.d.getVar('PACKAGE_FEED_SIGN') == '1': 79 if self.d.getVar('PACKAGE_FEED_SIGN') == '1':
80 raise NotImplementedError('Package feed signing not implementd for dpkg') 80 raise NotImplementedError('Package feed signing not implementd for dpkg')
81 81
82class DpkgPkgsList(PkgsList): 82class PMPkgsList(PkgsList):
83 83
84 def list_pkgs(self): 84 def list_pkgs(self):
85 cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"), 85 cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"),
@@ -461,7 +461,7 @@ class DpkgPM(OpkgDpkgPM):
461 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8"))) 461 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
462 462
463 def list_installed(self): 463 def list_installed(self):
464 return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs() 464 return PMPkgsList(self.d, self.target_rootfs).list_pkgs()
465 465
466 def package_info(self, pkg): 466 def package_info(self, pkg):
467 """ 467 """
diff --git a/meta/lib/oe/package_manager/deb/manifest.py b/meta/lib/oe/package_manager/deb/manifest.py
index 0b12036644..d8eab24a06 100644
--- a/meta/lib/oe/package_manager/deb/manifest.py
+++ b/meta/lib/oe/package_manager/deb/manifest.py
@@ -4,7 +4,7 @@
4 4
5from oe.manifest import Manifest 5from oe.manifest import Manifest
6 6
7class DpkgManifest(Manifest): 7class PkgManifest(Manifest):
8 def create_initial(self): 8 def create_initial(self):
9 with open(self.initial_manifest, "w+") as manifest: 9 with open(self.initial_manifest, "w+") as manifest:
10 manifest.write(self.initial_manifest_file_header) 10 manifest.write(self.initial_manifest_file_header)
diff --git a/meta/lib/oe/package_manager/deb/rootfs.py b/meta/lib/oe/package_manager/deb/rootfs.py
index 819f67eda5..8fbaca11d6 100644
--- a/meta/lib/oe/package_manager/deb/rootfs.py
+++ b/meta/lib/oe/package_manager/deb/rootfs.py
@@ -7,7 +7,7 @@ import shutil
7from oe.rootfs import Rootfs 7from oe.rootfs import Rootfs
8from oe.manifest import Manifest 8from oe.manifest import Manifest
9from oe.utils import execute_pre_post_process 9from oe.utils import execute_pre_post_process
10from oe.package_manager.deb.manifest import DpkgManifest 10from oe.package_manager.deb.manifest import PkgManifest
11from oe.package_manager.deb import DpkgPM 11from oe.package_manager.deb import DpkgPM
12 12
13class DpkgOpkgRootfs(Rootfs): 13class DpkgOpkgRootfs(Rootfs):
@@ -120,9 +120,9 @@ class DpkgOpkgRootfs(Rootfs):
120 120
121 num += 1 121 num += 1
122 122
123class DpkgRootfs(DpkgOpkgRootfs): 123class PkgRootfs(DpkgOpkgRootfs):
124 def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None): 124 def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None):
125 super(DpkgRootfs, self).__init__(d, progress_reporter, logcatcher) 125 super(PkgRootfs, self).__init__(d, progress_reporter, logcatcher)
126 self.log_check_regex = '^E:' 126 self.log_check_regex = '^E:'
127 self.log_check_expected_regexes = \ 127 self.log_check_expected_regexes = \
128 [ 128 [
@@ -131,7 +131,7 @@ class DpkgRootfs(DpkgOpkgRootfs):
131 131
132 bb.utils.remove(self.image_rootfs, True) 132 bb.utils.remove(self.image_rootfs, True)
133 bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS'), True) 133 bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS'), True)
134 self.manifest = DpkgManifest(d, manifest_dir) 134 self.manifest = PkgManifest(d, manifest_dir)
135 self.pm = DpkgPM(d, d.getVar('IMAGE_ROOTFS'), 135 self.pm = DpkgPM(d, d.getVar('IMAGE_ROOTFS'),
136 d.getVar('PACKAGE_ARCHS'), 136 d.getVar('PACKAGE_ARCHS'),
137 d.getVar('DPKG_ARCH')) 137 d.getVar('DPKG_ARCH'))
diff --git a/meta/lib/oe/package_manager/deb/sdk.py b/meta/lib/oe/package_manager/deb/sdk.py
index b25eb70b00..9859d8f32d 100644
--- a/meta/lib/oe/package_manager/deb/sdk.py
+++ b/meta/lib/oe/package_manager/deb/sdk.py
@@ -8,19 +8,19 @@ from oe.utils import execute_pre_post_process
8from oe.sdk import Sdk 8from oe.sdk import Sdk
9from oe.manifest import Manifest 9from oe.manifest import Manifest
10from oe.package_manager.deb import DpkgPM 10from oe.package_manager.deb import DpkgPM
11from oe.package_manager.deb.manifest import PkgManifest
11 12
12class DpkgSdk(Sdk): 13class PkgSdk(Sdk):
13 def __init__(self, d, manifest_dir=None): 14 def __init__(self, d, manifest_dir=None):
14 super(DpkgSdk, self).__init__(d, manifest_dir) 15 super(PkgSdk, self).__init__(d, manifest_dir)
15 16
16 self.target_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt") 17 self.target_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt")
17 self.host_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt-sdk") 18 self.host_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt-sdk")
18 19
19 from oe.package_manager.deb.manifest import DpkgManifest
20 20
21 self.target_manifest = DpkgManifest(d, self.manifest_dir, 21 self.target_manifest = PkgManifest(d, self.manifest_dir,
22 Manifest.MANIFEST_TYPE_SDK_TARGET) 22 Manifest.MANIFEST_TYPE_SDK_TARGET)
23 self.host_manifest = DpkgManifest(d, self.manifest_dir, 23 self.host_manifest = PkgManifest(d, self.manifest_dir,
24 Manifest.MANIFEST_TYPE_SDK_HOST) 24 Manifest.MANIFEST_TYPE_SDK_HOST)
25 25
26 deb_repo_workdir = "oe-sdk-repo" 26 deb_repo_workdir = "oe-sdk-repo"
diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py
index 9603993a59..416ed23d47 100644
--- a/meta/lib/oe/package_manager/ipk/__init__.py
+++ b/meta/lib/oe/package_manager/ipk/__init__.py
@@ -59,9 +59,10 @@ class OpkgIndexer(Indexer):
59 self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE'), 59 self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE'),
60 armor=is_ascii_sig) 60 armor=is_ascii_sig)
61 61
62class OpkgPkgsList(PkgsList): 62class PMPkgsList(PkgsList):
63 def __init__(self, d, rootfs_dir, config_file): 63 def __init__(self, d, rootfs_dir):
64 super(OpkgPkgsList, self).__init__(d, rootfs_dir) 64 super(PMPkgsList, self).__init__(d, rootfs_dir)
65 config_file = d.getVar("IPKGCONF_TARGET")
65 66
66 self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg") 67 self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg")
67 self.opkg_args = "-f %s -o %s " % (config_file, rootfs_dir) 68 self.opkg_args = "-f %s -o %s " % (config_file, rootfs_dir)
@@ -416,7 +417,7 @@ class OpkgPM(OpkgDpkgPM):
416 bb.utils.remove(os.path.join(self.opkg_dir, "lists"), True) 417 bb.utils.remove(os.path.join(self.opkg_dir, "lists"), True)
417 418
418 def list_installed(self): 419 def list_installed(self):
419 return OpkgPkgsList(self.d, self.target_rootfs, self.config_file).list_pkgs() 420 return PMPkgsList(self.d, self.target_rootfs).list_pkgs()
420 421
421 def dummy_install(self, pkgs): 422 def dummy_install(self, pkgs):
422 """ 423 """
diff --git a/meta/lib/oe/package_manager/ipk/manifest.py b/meta/lib/oe/package_manager/ipk/manifest.py
index 69676903ab..ee4b57bcb0 100644
--- a/meta/lib/oe/package_manager/ipk/manifest.py
+++ b/meta/lib/oe/package_manager/ipk/manifest.py
@@ -4,7 +4,7 @@
4 4
5from oe.manifest import Manifest 5from oe.manifest import Manifest
6 6
7class OpkgManifest(Manifest): 7class PkgManifest(Manifest):
8 """ 8 """
9 Returns a dictionary object with mip and mlp packages. 9 Returns a dictionary object with mip and mlp packages.
10 """ 10 """
diff --git a/meta/lib/oe/package_manager/ipk/rootfs.py b/meta/lib/oe/package_manager/ipk/rootfs.py
index 63b4a59c40..26dbee6f6a 100644
--- a/meta/lib/oe/package_manager/ipk/rootfs.py
+++ b/meta/lib/oe/package_manager/ipk/rootfs.py
@@ -8,7 +8,7 @@ import shutil
8from oe.rootfs import Rootfs 8from oe.rootfs import Rootfs
9from oe.manifest import Manifest 9from oe.manifest import Manifest
10from oe.utils import execute_pre_post_process 10from oe.utils import execute_pre_post_process
11from oe.package_manager.ipk.manifest import OpkgManifest 11from oe.package_manager.ipk.manifest import PkgManifest
12from oe.package_manager.ipk import OpkgPM 12from oe.package_manager.ipk import OpkgPM
13 13
14class DpkgOpkgRootfs(Rootfs): 14class DpkgOpkgRootfs(Rootfs):
@@ -121,12 +121,12 @@ class DpkgOpkgRootfs(Rootfs):
121 121
122 num += 1 122 num += 1
123 123
124class OpkgRootfs(DpkgOpkgRootfs): 124class PkgRootfs(DpkgOpkgRootfs):
125 def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None): 125 def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None):
126 super(OpkgRootfs, self).__init__(d, progress_reporter, logcatcher) 126 super(PkgRootfs, self).__init__(d, progress_reporter, logcatcher)
127 self.log_check_regex = '(exit 1|Collected errors)' 127 self.log_check_regex = '(exit 1|Collected errors)'
128 128
129 self.manifest = OpkgManifest(d, manifest_dir) 129 self.manifest = PkgManifest(d, manifest_dir)
130 self.opkg_conf = self.d.getVar("IPKGCONF_TARGET") 130 self.opkg_conf = self.d.getVar("IPKGCONF_TARGET")
131 self.pkg_archs = self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS") 131 self.pkg_archs = self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS")
132 132
diff --git a/meta/lib/oe/package_manager/ipk/sdk.py b/meta/lib/oe/package_manager/ipk/sdk.py
index 47c0a92c1b..37af0344eb 100644
--- a/meta/lib/oe/package_manager/ipk/sdk.py
+++ b/meta/lib/oe/package_manager/ipk/sdk.py
@@ -6,20 +6,20 @@ import glob
6import shutil 6import shutil
7from oe.utils import execute_pre_post_process 7from oe.utils import execute_pre_post_process
8from oe.sdk import Sdk 8from oe.sdk import Sdk
9from oe.package_manager.ipk.manifest import PkgManifest
9from oe.manifest import Manifest 10from oe.manifest import Manifest
10from oe.package_manager.ipk import OpkgPM 11from oe.package_manager.ipk import OpkgPM
11 12
12class OpkgSdk(Sdk): 13class PkgSdk(Sdk):
13 def __init__(self, d, manifest_dir=None): 14 def __init__(self, d, manifest_dir=None):
14 super(OpkgSdk, self).__init__(d, manifest_dir) 15 super(PkgSdk, self).__init__(d, manifest_dir)
15 16
16 self.target_conf = self.d.getVar("IPKGCONF_TARGET") 17 self.target_conf = self.d.getVar("IPKGCONF_TARGET")
17 self.host_conf = self.d.getVar("IPKGCONF_SDK") 18 self.host_conf = self.d.getVar("IPKGCONF_SDK")
18 19
19 from oe.package_manager.ipk.manifest import OpkgManifest 20 self.target_manifest = PkgManifest(d, self.manifest_dir,
20 self.target_manifest = OpkgManifest(d, self.manifest_dir,
21 Manifest.MANIFEST_TYPE_SDK_TARGET) 21 Manifest.MANIFEST_TYPE_SDK_TARGET)
22 self.host_manifest = OpkgManifest(d, self.manifest_dir, 22 self.host_manifest = PkgManifest(d, self.manifest_dir,
23 Manifest.MANIFEST_TYPE_SDK_HOST) 23 Manifest.MANIFEST_TYPE_SDK_HOST)
24 24
25 ipk_repo_workdir = "oe-sdk-repo" 25 ipk_repo_workdir = "oe-sdk-repo"
diff --git a/meta/lib/oe/package_manager/rpm/__init__.py b/meta/lib/oe/package_manager/rpm/__init__.py
index c91f61ae5c..898184442f 100644
--- a/meta/lib/oe/package_manager/rpm/__init__.py
+++ b/meta/lib/oe/package_manager/rpm/__init__.py
@@ -43,7 +43,7 @@ class RpmSubdirIndexer(RpmIndexer):
43 self.do_write_index(dir_path) 43 self.do_write_index(dir_path)
44 44
45 45
46class RpmPkgsList(PkgsList): 46class PMPkgsList(PkgsList):
47 def list_pkgs(self): 47 def list_pkgs(self):
48 return RpmPM(self.d, self.rootfs_dir, self.d.getVar('TARGET_VENDOR'), needfeed=False).list_installed() 48 return RpmPM(self.d, self.rootfs_dir, self.d.getVar('TARGET_VENDOR'), needfeed=False).list_installed()
49 49
diff --git a/meta/lib/oe/package_manager/rpm/manifest.py b/meta/lib/oe/package_manager/rpm/manifest.py
index a75f6bdabf..e6604b301f 100644
--- a/meta/lib/oe/package_manager/rpm/manifest.py
+++ b/meta/lib/oe/package_manager/rpm/manifest.py
@@ -4,7 +4,7 @@
4 4
5from oe.manifest import Manifest 5from oe.manifest import Manifest
6 6
7class RpmManifest(Manifest): 7class PkgManifest(Manifest):
8 """ 8 """
9 Returns a dictionary object with mip and mlp packages. 9 Returns a dictionary object with mip and mlp packages.
10 """ 10 """
diff --git a/meta/lib/oe/package_manager/rpm/rootfs.py b/meta/lib/oe/package_manager/rpm/rootfs.py
index 2de5752b91..00d07cd9cc 100644
--- a/meta/lib/oe/package_manager/rpm/rootfs.py
+++ b/meta/lib/oe/package_manager/rpm/rootfs.py
@@ -5,17 +5,17 @@
5from oe.rootfs import Rootfs 5from oe.rootfs import Rootfs
6from oe.manifest import Manifest 6from oe.manifest import Manifest
7from oe.utils import execute_pre_post_process 7from oe.utils import execute_pre_post_process
8from oe.package_manager.rpm.manifest import RpmManifest 8from oe.package_manager.rpm.manifest import PkgManifest
9from oe.package_manager.rpm import RpmPM 9from oe.package_manager.rpm import RpmPM
10 10
11class RpmRootfs(Rootfs): 11class PkgRootfs(Rootfs):
12 def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None): 12 def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None):
13 super(RpmRootfs, self).__init__(d, progress_reporter, logcatcher) 13 super(PkgRootfs, self).__init__(d, progress_reporter, logcatcher)
14 self.log_check_regex = r'(unpacking of archive failed|Cannot find package'\ 14 self.log_check_regex = r'(unpacking of archive failed|Cannot find package'\
15 r'|exit 1|ERROR: |Error: |Error |ERROR '\ 15 r'|exit 1|ERROR: |Error: |Error |ERROR '\
16 r'|Failed |Failed: |Failed$|Failed\(\d+\):)' 16 r'|Failed |Failed: |Failed$|Failed\(\d+\):)'
17 17
18 self.manifest = RpmManifest(d, manifest_dir) 18 self.manifest = PkgManifest(d, manifest_dir)
19 19
20 self.pm = RpmPM(d, 20 self.pm = RpmPM(d,
21 d.getVar('IMAGE_ROOTFS'), 21 d.getVar('IMAGE_ROOTFS'),
diff --git a/meta/lib/oe/package_manager/rpm/sdk.py b/meta/lib/oe/package_manager/rpm/sdk.py
index b14b155a85..c5f232431f 100644
--- a/meta/lib/oe/package_manager/rpm/sdk.py
+++ b/meta/lib/oe/package_manager/rpm/sdk.py
@@ -6,16 +6,16 @@ import glob
6from oe.utils import execute_pre_post_process 6from oe.utils import execute_pre_post_process
7from oe.sdk import Sdk 7from oe.sdk import Sdk
8from oe.manifest import Manifest 8from oe.manifest import Manifest
9from oe.package_manager.rpm.manifest import PkgManifest
9from oe.package_manager.rpm import RpmPM 10from oe.package_manager.rpm import RpmPM
10 11
11class RpmSdk(Sdk): 12class PkgSdk(Sdk):
12 def __init__(self, d, manifest_dir=None, rpm_workdir="oe-sdk-repo"): 13 def __init__(self, d, manifest_dir=None, rpm_workdir="oe-sdk-repo"):
13 super(RpmSdk, self).__init__(d, manifest_dir) 14 super(PkgSdk, self).__init__(d, manifest_dir)
14 15
15 from oe.package_manager.rpm.manifest import RpmManifest 16 self.target_manifest = PkgManifest(d, self.manifest_dir,
16 self.target_manifest = RpmManifest(d, self.manifest_dir,
17 Manifest.MANIFEST_TYPE_SDK_TARGET) 17 Manifest.MANIFEST_TYPE_SDK_TARGET)
18 self.host_manifest = RpmManifest(d, self.manifest_dir, 18 self.host_manifest = PkgManifest(d, self.manifest_dir,
19 Manifest.MANIFEST_TYPE_SDK_HOST) 19 Manifest.MANIFEST_TYPE_SDK_HOST)
20 20
21 rpm_repo_workdir = "oe-sdk-repo" 21 rpm_repo_workdir = "oe-sdk-repo"
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index 4e09eae6b9..4b747dd0f4 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -10,12 +10,6 @@ import shutil
10import os 10import os
11import subprocess 11import subprocess
12import re 12import re
13from oe.package_manager.rpm.manifest import RpmManifest
14from oe.package_manager.ipk.manifest import OpkgManifest
15from oe.package_manager.deb.manifest import DpkgManifest
16from oe.package_manager.rpm import RpmPkgsList
17from oe.package_manager.ipk import OpkgPkgsList
18from oe.package_manager.deb import DpkgPkgsList
19 13
20class Rootfs(object, metaclass=ABCMeta): 14class Rootfs(object, metaclass=ABCMeta):
21 """ 15 """
@@ -360,12 +354,9 @@ class Rootfs(object, metaclass=ABCMeta):
360 354
361 355
362def get_class_for_type(imgtype): 356def get_class_for_type(imgtype):
363 from oe.package_manager.rpm.rootfs import RpmRootfs 357 import importlib
364 from oe.package_manager.ipk.rootfs import OpkgRootfs 358 mod = importlib.import_module('oe.package_manager.' + imgtype + '.rootfs')
365 from oe.package_manager.deb.rootfs import DpkgRootfs 359 return mod.PkgRootfs
366 return {"rpm": RpmRootfs,
367 "ipk": OpkgRootfs,
368 "deb": DpkgRootfs}[imgtype]
369 360
370def variable_depends(d, manifest_dir=None): 361def variable_depends(d, manifest_dir=None):
371 img_type = d.getVar('IMAGE_PKGTYPE') 362 img_type = d.getVar('IMAGE_PKGTYPE')
@@ -375,17 +366,10 @@ def variable_depends(d, manifest_dir=None):
375def create_rootfs(d, manifest_dir=None, progress_reporter=None, logcatcher=None): 366def create_rootfs(d, manifest_dir=None, progress_reporter=None, logcatcher=None):
376 env_bkp = os.environ.copy() 367 env_bkp = os.environ.copy()
377 368
378 from oe.package_manager.rpm.rootfs import RpmRootfs
379 from oe.package_manager.ipk.rootfs import OpkgRootfs
380 from oe.package_manager.deb.rootfs import DpkgRootfs
381 img_type = d.getVar('IMAGE_PKGTYPE') 369 img_type = d.getVar('IMAGE_PKGTYPE')
382 if img_type == "rpm":
383 RpmRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
384 elif img_type == "ipk":
385 OpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
386 elif img_type == "deb":
387 DpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
388 370
371 cls = get_class_for_type(img_type)
372 cls(d, manifest_dir, progress_reporter, logcatcher).create()
389 os.environ.clear() 373 os.environ.clear()
390 os.environ.update(env_bkp) 374 os.environ.update(env_bkp)
391 375
@@ -395,12 +379,10 @@ def image_list_installed_packages(d, rootfs_dir=None):
395 rootfs_dir = d.getVar('IMAGE_ROOTFS') 379 rootfs_dir = d.getVar('IMAGE_ROOTFS')
396 380
397 img_type = d.getVar('IMAGE_PKGTYPE') 381 img_type = d.getVar('IMAGE_PKGTYPE')
398 if img_type == "rpm": 382
399 return RpmPkgsList(d, rootfs_dir).list_pkgs() 383 import importlib
400 elif img_type == "ipk": 384 cls = importlib.import_module('oe.package_manager.' + img_type)
401 return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET")).list_pkgs() 385 return cls.PMPkgsList(d, rootfs_dir).list_pkgs()
402 elif img_type == "deb":
403 return DpkgPkgsList(d, rootfs_dir).list_pkgs()
404 386
405if __name__ == "__main__": 387if __name__ == "__main__":
406 """ 388 """
diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py
index fdcadcb8de..37b59afd1a 100644
--- a/meta/lib/oe/sdk.py
+++ b/meta/lib/oe/sdk.py
@@ -115,33 +115,18 @@ def sdk_list_installed_packages(d, target, rootfs_dir=None):
115 115
116 rootfs_dir = [sdk_output, os.path.join(sdk_output, target_path)][target is True] 116 rootfs_dir = [sdk_output, os.path.join(sdk_output, target_path)][target is True]
117 117
118 from oe.package_manager.rpm import RpmPkgsList
119 from oe.package_manager.ipk import OpkgPkgsList
120 from oe.package_manager.deb import DpkgPkgsList
121 img_type = d.getVar('IMAGE_PKGTYPE') 118 img_type = d.getVar('IMAGE_PKGTYPE')
122 if img_type == "rpm": 119 import importlib
123 arch_var = ["SDK_PACKAGE_ARCHS", None][target is True] 120 cls = importlib.import_module('oe.package_manager.' + img_type)
124 os_var = ["SDK_OS", None][target is True] 121 return cls.PMPkgsList(d, rootfs_dir).list_pkgs()
125 return RpmPkgsList(d, rootfs_dir).list_pkgs()
126 elif img_type == "ipk":
127 conf_file_var = ["IPKGCONF_SDK", "IPKGCONF_TARGET"][target is True]
128 return OpkgPkgsList(d, rootfs_dir, d.getVar(conf_file_var)).list_pkgs()
129 elif img_type == "deb":
130 return DpkgPkgsList(d, rootfs_dir).list_pkgs()
131 122
132def populate_sdk(d, manifest_dir=None): 123def populate_sdk(d, manifest_dir=None):
133 env_bkp = os.environ.copy() 124 env_bkp = os.environ.copy()
134 125
135 img_type = d.getVar('IMAGE_PKGTYPE') 126 img_type = d.getVar('IMAGE_PKGTYPE')
136 from oe.package_manager.rpm.sdk import RpmSdk 127 import importlib
137 from oe.package_manager.ipk.sdk import OpkgSdk 128 cls = importlib.import_module('oe.package_manager.' + img_type + '.sdk')
138 from oe.package_manager.deb.sdk import DpkgSdk 129 cls.PkgSdk(d, manifest_dir).populate()
139 if img_type == "rpm":
140 RpmSdk(d, manifest_dir).populate()
141 elif img_type == "ipk":
142 OpkgSdk(d, manifest_dir).populate()
143 elif img_type == "deb":
144 DpkgSdk(d, manifest_dir).populate()
145 130
146 os.environ.clear() 131 os.environ.clear()
147 os.environ.update(env_bkp) 132 os.environ.update(env_bkp)