Pull postinst-intercepts from BBPATH
v2 cover Pull postinst-intercepts from BBPATH
From: Christopher Larson <[email protected]>
These are the bits to allow us to pull intercepts from BBPATH. This is kept as a separate class, as it's needed by both image construction and sdk construction, the latter to support meta-toolchain & similar recipes.
The following changes since commit 364449251ffe4ff2c11acaa258edcec244c38818:
classes/package: fix variable name in comment (2018-07-26 16:55:21 +0100)
are available in the git repository at:
[email protected]:kergoth/openembedded-core.git bbpath-intercepts
for you to fetch changes up to fc32ec263034818cd182e093685d776b8d50a3a2:
populate_sdk_base.bbclass: inherit and use image-postinst-intercepts (2018-07-27 22:04:40 +0500)
----------------------------------------------------------------
v2 changes:
- rebased
- renamed bbpath-intercepts.bbclass to image-postinst-intercepts.bbclass, as requested by Richard
Christopher Larson (4):
oe.package_manager: support loading intercepts from multiple paths image-postinst-intercepts.bbclass: add class image.bbclass: inherit and use image-postinst-intercepts populate_sdk_base.bbclass: inherit and use image-postinst-intercepts
meta/classes/image-postinst-intercepts.bbclass | 23 +++++++++++++++++++++++ meta/classes/image.bbclass | 2 ++ meta/classes/populate_sdk_base.bbclass | 3 ++- meta/lib/oe/package_manager.py | 19 +++++++++++++------ 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 meta/classes/image-postinst-intercepts.bbclass
Signature · 1 line
2.11.1
PATCH v2 1/4 oe.package_manager: support loading intercepts from multiple paths
From: Christopher Larson <[email protected]>
- if POSTINST_INTERCEPTS is set, use the listed intercept files, or
- if POSTINST_INTERCEPTS_PATH is set, load from the listed paths, or
- if POSTINST_INTERCEPTS_DIR is set, load from it (for compatibility), or
- load from ${COREBASE}/meta/postinst-intercepts
--- meta/lib/oe/package_manager.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
meta/lib/oe/package_manager.py +13 -6
@@ -335,17 +335,24 @@ class PackageManager(object, metaclass=ABCMeta): def _initialize_intercepts(self): bb.note("Initializing intercept dir for %s" % self.target_rootfs) - postinst_intercepts_dir = self.d.getVar("POSTINST_INTERCEPTS_DIR") - if not postinst_intercepts_dir: - postinst_intercepts_dir = self.d.expand("${COREBASE}/scripts/postinst-intercepts") # As there might be more than one instance of PackageManager operating at the same time # we need to isolate the intercept_scripts directories from each other, # hence the ugly hash digest in dir name. - self.intercepts_dir = os.path.join(self.d.getVar('WORKDIR'), - "intercept_scripts-%s" %(hashlib.sha256(self.target_rootfs.encode()).hexdigest()) ) + self.intercepts_dir = os.path.join(self.d.getVar('WORKDIR'), "intercept_scripts-%s" % + (hashlib.sha256(self.target_rootfs.encode()).hexdigest())) + postinst_intercepts = (self.d.getVar("POSTINST_INTERCEPTS") or "").split() + if not postinst_intercepts: + postinst_intercepts_path = self.d.getVar("POSTINST_INTERCEPTS_PATH") + if not postinst_intercepts_path: + postinst_intercepts_path = self.d.getVar("POSTINST_INTERCEPTS_DIR") or self.d.expand("${COREBASE}/scripts/postinst-intercepts") + postinst_intercepts = oe.path.which_wild('*', postinst_intercepts_path) + + bb.debug(1, 'Collected intercepts:\n%s' % ''.join(' %s\n' % i for i in postinst_intercepts)) bb.utils.remove(self.intercepts_dir, True) - shutil.copytree(postinst_intercepts_dir, self.intercepts_dir) + bb.utils.mkdirhier(self.intercepts_dir) + for intercept in postinst_intercepts: + bb.utils.copyfile(intercept, os.path.join(self.intercepts_dir, os.path.basename(intercept))) @abstractmethod def _handle_intercept_failure(self, failed_script):
Signature · 1 line
2.11.1
PATCH v2 2/4 image-postinst-intercepts.bbclass: add class
In reply to Christopher LarsonFrom: Christopher Larson <[email protected]>
This class sets POSTINST_INTERCEPTS and POSTINST_INTERCEPTS_CHECKSUMS, to allow us to pull intercepts from BBPATH. This is kept as a separate class, as it's needed by both image construction and sdk construction, the latter to support meta-toolchain & similar recipes.
--- meta/classes/image-postinst-intercepts.bbclass | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 meta/classes/image-postinst-intercepts.bbclass
meta/classes/image-postinst-intercepts.bbclass new file +23 -0
@@ -0,0 +1,23 @@ +# Gather existing and candidate postinst intercepts from BBPATH +POSTINST_INTERCEPTS_DIR ?= "${COREBASE}/scripts/postinst-intercepts" +POSTINST_INTERCEPTS_PATHS ?= "${@':'.join('%s/postinst-intercepts' % p for p in '${BBPATH}'.split(':'))}:${POSTINST_INTERCEPTS_DIR}" + +python find_intercepts() { + intercepts = {} + search_paths = [] + paths = d.getVar('POSTINST_INTERCEPTS_PATHS').split(':') + overrides = (':' + d.getVar('FILESOVERRIDES')).split(':') + [''] + search_paths = [os.path.join(p, op) for p in paths for op in overrides] + searched = oe.path.which_wild('*', ':'.join(search_paths), candidates=True) + files, chksums = [], [] + for pathname, candidates in searched: + if os.path.isfile(pathname): + files.append(pathname) + chksums.append('%s:True' % pathname) + chksums.extend('%s:False' % c for c in candidates[:-1]) + + d.setVar('POSTINST_INTERCEPT_CHECKSUMS', ' '.join(chksums)) + d.setVar('POSTINST_INTERCEPTS', ' '.join(files)) +} +find_intercepts[eventmask] += "bb.event.RecipePreFinalise" +addhandler find_intercepts
Signature · 1 line
2.11.1
PATCH v2 3/4 image.bbclass: inherit and use image-postinst-intercepts
In reply to Christopher LarsonFrom: Christopher Larson <[email protected]>
--- meta/classes/image.bbclass | 2 ++ 1 file changed, 2 insertions(+)
meta/classes/image.bbclass +2 -0
@@ -14,6 +14,7 @@ IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'ima IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}" IMGCLASSES += "image_types_wic" IMGCLASSES += "rootfs-postcommands" +IMGCLASSES += "image-postinst-intercepts" inherit ${IMGCLASSES} TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
@@ -246,6 +247,7 @@ fakeroot python do_rootfs () { do_rootfs[dirs] = "${TOPDIR}" do_rootfs[cleandirs] += "${S} ${IMGDEPLOYDIR}" do_rootfs[umask] = "022" +do_rootfs[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}" addtask rootfs after do_prepare_recipe_sysroot fakeroot python do_image () {
Signature · 1 line
2.11.1
PATCH v2 4/4 populate_sdk_base.bbclass: inherit and use image-postinst-intercepts
In reply to Christopher LarsonFrom: Christopher Larson <[email protected]>
--- meta/classes/populate_sdk_base.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/populate_sdk_base.bbclass +2 -1
@@ -1,4 +1,4 @@ -inherit meta +inherit meta image-postinst-intercepts # Wildcards specifying complementary packages to install for every package that has been explicitly # installed into the rootfs
@@ -307,4 +307,5 @@ do_populate_sdk[dirs] = "${PKGDATA_DIR} ${TOPDIR}" do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS').split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}" do_populate_sdk[rdepends] = "${@' '.join([x + ':do_package_write_${IMAGE_PKGTYPE} ' + x + ':do_packagedata' for x in d.getVar('SDK_RDEPENDS').split()])}" do_populate_sdk[recrdeptask] += "do_packagedata do_package_write_rpm do_package_write_ipk do_package_write_deb" +do_populate_sdk[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}" addtask populate_sdk
Signature · 1 line
2.11.1
Quoted 7 lines · Christopher Larson
From: Christopher Larson <[email protected]>
These are the bits to allow us to pull intercepts from BBPATH. This is kept
as a separate class, as it's needed by both image construction and sdk construction, the latter to support meta-toolchain & similar recipes.
Ping. v2 renamed bbpath-intercepts to image-postinst-intercepts and rebased. Let me know if there are any other concerns. Not urgent, just want to make sure it doesn't fall through the cracks :)
Signature · 4 lines
Christopher Larson kergoth at gmail dot com Founder - BitBake, OpenEmbedded, OpenZaurus Senior Software Engineer, Mentor Graphics