summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/rootfs.py
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/oe/rootfs.py
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/oe/rootfs.py')
-rw-r--r--meta/lib/oe/rootfs.py36
1 files changed, 9 insertions, 27 deletions
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 """