def create_manifest(d, final_manifest=False, manifest_dir=None,
manifest_type=Manifest.MANIFEST_TYPE_IMAGE):
- from oe.package_manager.rpm.manifest import RpmManifest
- from oe.package_manager.ipk.manifest import OpkgManifest
- from oe.package_manager.deb.manifest import DpkgManifest
- manifest_map = {'rpm': RpmManifest,
- 'ipk': OpkgManifest,
- 'deb': DpkgManifest}
-
- manifest = manifest_map[d.getVar('IMAGE_PKGTYPE')](d, manifest_dir, manifest_type)
+ import importlib
+ manifest = importlib.import_module('oe.package_manager.' + d.getVar('IMAGE_PKGTYPE') + '.manifest').PkgManifest(d, manifest_dir, manifest_type)
if final_manifest:
manifest.create_final()
if self.d.getVar('PACKAGE_FEED_SIGN') == '1':
raise NotImplementedError('Package feed signing not implementd for dpkg')
-class DpkgPkgsList(PkgsList):
+class PMPkgsList(PkgsList):
def list_pkgs(self):
cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"),
"returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
def list_installed(self):
- return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs()
+ return PMPkgsList(self.d, self.target_rootfs).list_pkgs()
def package_info(self, pkg):
"""
from oe.manifest import Manifest
-class DpkgManifest(Manifest):
+class PkgManifest(Manifest):
def create_initial(self):
with open(self.initial_manifest, "w+") as manifest:
manifest.write(self.initial_manifest_file_header)
from oe.rootfs import Rootfs
from oe.manifest import Manifest
from oe.utils import execute_pre_post_process
-from oe.package_manager.deb.manifest import DpkgManifest
+from oe.package_manager.deb.manifest import PkgManifest
from oe.package_manager.deb import DpkgPM
class DpkgOpkgRootfs(Rootfs):
num += 1
-class DpkgRootfs(DpkgOpkgRootfs):
+class PkgRootfs(DpkgOpkgRootfs):
def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None):
- super(DpkgRootfs, self).__init__(d, progress_reporter, logcatcher)
+ super(PkgRootfs, self).__init__(d, progress_reporter, logcatcher)
self.log_check_regex = '^E:'
self.log_check_expected_regexes = \
[
bb.utils.remove(self.image_rootfs, True)
bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS'), True)
- self.manifest = DpkgManifest(d, manifest_dir)
+ self.manifest = PkgManifest(d, manifest_dir)
self.pm = DpkgPM(d, d.getVar('IMAGE_ROOTFS'),
d.getVar('PACKAGE_ARCHS'),
d.getVar('DPKG_ARCH'))
from oe.sdk import Sdk
from oe.manifest import Manifest
from oe.package_manager.deb import DpkgPM
+from oe.package_manager.deb.manifest import PkgManifest
-class DpkgSdk(Sdk):
+class PkgSdk(Sdk):
def __init__(self, d, manifest_dir=None):
- super(DpkgSdk, self).__init__(d, manifest_dir)
+ super(PkgSdk, self).__init__(d, manifest_dir)
self.target_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt")
self.host_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt-sdk")
- from oe.package_manager.deb.manifest import DpkgManifest
- self.target_manifest = DpkgManifest(d, self.manifest_dir,
+ self.target_manifest = PkgManifest(d, self.manifest_dir,
Manifest.MANIFEST_TYPE_SDK_TARGET)
- self.host_manifest = DpkgManifest(d, self.manifest_dir,
+ self.host_manifest = PkgManifest(d, self.manifest_dir,
Manifest.MANIFEST_TYPE_SDK_HOST)
deb_repo_workdir = "oe-sdk-repo"
self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE'),
armor=is_ascii_sig)
-class OpkgPkgsList(PkgsList):
- def __init__(self, d, rootfs_dir, config_file):
- super(OpkgPkgsList, self).__init__(d, rootfs_dir)
+class PMPkgsList(PkgsList):
+ def __init__(self, d, rootfs_dir):
+ super(PMPkgsList, self).__init__(d, rootfs_dir)
+ config_file = d.getVar("IPKGCONF_TARGET")
self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg")
self.opkg_args = "-f %s -o %s " % (config_file, rootfs_dir)
bb.utils.remove(os.path.join(self.opkg_dir, "lists"), True)
def list_installed(self):
- return OpkgPkgsList(self.d, self.target_rootfs, self.config_file).list_pkgs()
+ return PMPkgsList(self.d, self.target_rootfs).list_pkgs()
def dummy_install(self, pkgs):
"""
from oe.manifest import Manifest
-class OpkgManifest(Manifest):
+class PkgManifest(Manifest):
"""
Returns a dictionary object with mip and mlp packages.
"""
from oe.rootfs import Rootfs
from oe.manifest import Manifest
from oe.utils import execute_pre_post_process
-from oe.package_manager.ipk.manifest import OpkgManifest
+from oe.package_manager.ipk.manifest import PkgManifest
from oe.package_manager.ipk import OpkgPM
class DpkgOpkgRootfs(Rootfs):
num += 1
-class OpkgRootfs(DpkgOpkgRootfs):
+class PkgRootfs(DpkgOpkgRootfs):
def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None):
- super(OpkgRootfs, self).__init__(d, progress_reporter, logcatcher)
+ super(PkgRootfs, self).__init__(d, progress_reporter, logcatcher)
self.log_check_regex = '(exit 1|Collected errors)'
- self.manifest = OpkgManifest(d, manifest_dir)
+ self.manifest = PkgManifest(d, manifest_dir)
self.opkg_conf = self.d.getVar("IPKGCONF_TARGET")
self.pkg_archs = self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS")
import shutil
from oe.utils import execute_pre_post_process
from oe.sdk import Sdk
+from oe.package_manager.ipk.manifest import PkgManifest
from oe.manifest import Manifest
from oe.package_manager.ipk import OpkgPM
-class OpkgSdk(Sdk):
+class PkgSdk(Sdk):
def __init__(self, d, manifest_dir=None):
- super(OpkgSdk, self).__init__(d, manifest_dir)
+ super(PkgSdk, self).__init__(d, manifest_dir)
self.target_conf = self.d.getVar("IPKGCONF_TARGET")
self.host_conf = self.d.getVar("IPKGCONF_SDK")
- from oe.package_manager.ipk.manifest import OpkgManifest
- self.target_manifest = OpkgManifest(d, self.manifest_dir,
+ self.target_manifest = PkgManifest(d, self.manifest_dir,
Manifest.MANIFEST_TYPE_SDK_TARGET)
- self.host_manifest = OpkgManifest(d, self.manifest_dir,
+ self.host_manifest = PkgManifest(d, self.manifest_dir,
Manifest.MANIFEST_TYPE_SDK_HOST)
ipk_repo_workdir = "oe-sdk-repo"
self.do_write_index(dir_path)
-class RpmPkgsList(PkgsList):
+class PMPkgsList(PkgsList):
def list_pkgs(self):
return RpmPM(self.d, self.rootfs_dir, self.d.getVar('TARGET_VENDOR'), needfeed=False).list_installed()
from oe.manifest import Manifest
-class RpmManifest(Manifest):
+class PkgManifest(Manifest):
"""
Returns a dictionary object with mip and mlp packages.
"""
from oe.rootfs import Rootfs
from oe.manifest import Manifest
from oe.utils import execute_pre_post_process
-from oe.package_manager.rpm.manifest import RpmManifest
+from oe.package_manager.rpm.manifest import PkgManifest
from oe.package_manager.rpm import RpmPM
-class RpmRootfs(Rootfs):
+class PkgRootfs(Rootfs):
def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None):
- super(RpmRootfs, self).__init__(d, progress_reporter, logcatcher)
+ super(PkgRootfs, self).__init__(d, progress_reporter, logcatcher)
self.log_check_regex = r'(unpacking of archive failed|Cannot find package'\
r'|exit 1|ERROR: |Error: |Error |ERROR '\
r'|Failed |Failed: |Failed$|Failed\(\d+\):)'
- self.manifest = RpmManifest(d, manifest_dir)
+ self.manifest = PkgManifest(d, manifest_dir)
self.pm = RpmPM(d,
d.getVar('IMAGE_ROOTFS'),
from oe.utils import execute_pre_post_process
from oe.sdk import Sdk
from oe.manifest import Manifest
+from oe.package_manager.rpm.manifest import PkgManifest
from oe.package_manager.rpm import RpmPM
-class RpmSdk(Sdk):
+class PkgSdk(Sdk):
def __init__(self, d, manifest_dir=None, rpm_workdir="oe-sdk-repo"):
- super(RpmSdk, self).__init__(d, manifest_dir)
+ super(PkgSdk, self).__init__(d, manifest_dir)
- from oe.package_manager.rpm.manifest import RpmManifest
- self.target_manifest = RpmManifest(d, self.manifest_dir,
+ self.target_manifest = PkgManifest(d, self.manifest_dir,
Manifest.MANIFEST_TYPE_SDK_TARGET)
- self.host_manifest = RpmManifest(d, self.manifest_dir,
+ self.host_manifest = PkgManifest(d, self.manifest_dir,
Manifest.MANIFEST_TYPE_SDK_HOST)
rpm_repo_workdir = "oe-sdk-repo"
import os
import subprocess
import re
-from oe.package_manager.rpm.manifest import RpmManifest
-from oe.package_manager.ipk.manifest import OpkgManifest
-from oe.package_manager.deb.manifest import DpkgManifest
-from oe.package_manager.rpm import RpmPkgsList
-from oe.package_manager.ipk import OpkgPkgsList
-from oe.package_manager.deb import DpkgPkgsList
class Rootfs(object, metaclass=ABCMeta):
"""
def get_class_for_type(imgtype):
- from oe.package_manager.rpm.rootfs import RpmRootfs
- from oe.package_manager.ipk.rootfs import OpkgRootfs
- from oe.package_manager.deb.rootfs import DpkgRootfs
- return {"rpm": RpmRootfs,
- "ipk": OpkgRootfs,
- "deb": DpkgRootfs}[imgtype]
+ import importlib
+ mod = importlib.import_module('oe.package_manager.' + imgtype + '.rootfs')
+ return mod.PkgRootfs
def variable_depends(d, manifest_dir=None):
img_type = d.getVar('IMAGE_PKGTYPE')
def create_rootfs(d, manifest_dir=None, progress_reporter=None, logcatcher=None):
env_bkp = os.environ.copy()
- from oe.package_manager.rpm.rootfs import RpmRootfs
- from oe.package_manager.ipk.rootfs import OpkgRootfs
- from oe.package_manager.deb.rootfs import DpkgRootfs
img_type = d.getVar('IMAGE_PKGTYPE')
- if img_type == "rpm":
- RpmRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
- elif img_type == "ipk":
- OpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
- elif img_type == "deb":
- DpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
+ cls = get_class_for_type(img_type)
+ cls(d, manifest_dir, progress_reporter, logcatcher).create()
os.environ.clear()
os.environ.update(env_bkp)
rootfs_dir = d.getVar('IMAGE_ROOTFS')
img_type = d.getVar('IMAGE_PKGTYPE')
- if img_type == "rpm":
- return RpmPkgsList(d, rootfs_dir).list_pkgs()
- elif img_type == "ipk":
- return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET")).list_pkgs()
- elif img_type == "deb":
- return DpkgPkgsList(d, rootfs_dir).list_pkgs()
+
+ import importlib
+ cls = importlib.import_module('oe.package_manager.' + img_type)
+ return cls.PMPkgsList(d, rootfs_dir).list_pkgs()
if __name__ == "__main__":
"""
rootfs_dir = [sdk_output, os.path.join(sdk_output, target_path)][target is True]
- from oe.package_manager.rpm import RpmPkgsList
- from oe.package_manager.ipk import OpkgPkgsList
- from oe.package_manager.deb import DpkgPkgsList
img_type = d.getVar('IMAGE_PKGTYPE')
- if img_type == "rpm":
- arch_var = ["SDK_PACKAGE_ARCHS", None][target is True]
- os_var = ["SDK_OS", None][target is True]
- return RpmPkgsList(d, rootfs_dir).list_pkgs()
- elif img_type == "ipk":
- conf_file_var = ["IPKGCONF_SDK", "IPKGCONF_TARGET"][target is True]
- return OpkgPkgsList(d, rootfs_dir, d.getVar(conf_file_var)).list_pkgs()
- elif img_type == "deb":
- return DpkgPkgsList(d, rootfs_dir).list_pkgs()
+ import importlib
+ cls = importlib.import_module('oe.package_manager.' + img_type)
+ return cls.PMPkgsList(d, rootfs_dir).list_pkgs()
def populate_sdk(d, manifest_dir=None):
env_bkp = os.environ.copy()
img_type = d.getVar('IMAGE_PKGTYPE')
- from oe.package_manager.rpm.sdk import RpmSdk
- from oe.package_manager.ipk.sdk import OpkgSdk
- from oe.package_manager.deb.sdk import DpkgSdk
- if img_type == "rpm":
- RpmSdk(d, manifest_dir).populate()
- elif img_type == "ipk":
- OpkgSdk(d, manifest_dir).populate()
- elif img_type == "deb":
- DpkgSdk(d, manifest_dir).populate()
+ import importlib
+ cls = importlib.import_module('oe.package_manager.' + img_type + '.sdk')
+ cls.PkgSdk(d, manifest_dir).populate()
os.environ.clear()
os.environ.update(env_bkp)