From adf587e55c0f9bc74f0bef415273c937401baebb Mon Sep 17 00:00:00 2001 From: Hongxu Jia Date: Fri, 21 Feb 2014 14:20:40 +0800 Subject: rootfs.py: support ipk incremental image generation The incremental image generation is based on the previous existing image, adds new packages, upgrades existing packages, and removes unused packages. [YOCTO #1894] Signed-off-by: Hongxu Jia --- meta/lib/oe/rootfs.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'meta') diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index 3bcb812e5f..e0f6cd8582 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py @@ -438,13 +438,25 @@ class OpkgRootfs(Rootfs): def __init__(self, d, manifest_dir): super(OpkgRootfs, self).__init__(d) - bb.utils.remove(self.image_rootfs, True) - bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True) self.manifest = OpkgManifest(d, manifest_dir) self.opkg_conf = self.d.getVar("IPKGCONF_TARGET", True) self.pkg_archs = self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS", True) - self.pm = OpkgPM(d, self.image_rootfs, self.opkg_conf, self.pkg_archs) + self.inc_opkg_image_gen = self.d.getVar('INC_IPK_IMAGE_GEN', True) or "" + if self.inc_opkg_image_gen != "1": + bb.utils.remove(self.image_rootfs, True) + self.pm = OpkgPM(d, + self.image_rootfs, + self.opkg_conf, + self.pkg_archs) + else: + self.pm = OpkgPM(d, + self.image_rootfs, + self.opkg_conf, + self.pkg_archs) + self.pm.recover_packaging_data() + + bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True) """ This function was reused from the old implementation. @@ -508,6 +520,32 @@ class OpkgRootfs(Rootfs): self._multilib_sanity_test(dirs) + ''' + While ipk incremental image generation is enabled, it will remove the + unneeded pkgs by comparing the old full manifest in previous existing + image and the new full manifest in the current image. + ''' + def _remove_extra_packages(self, pkgs_initial_install): + if self.inc_opkg_image_gen == "1": + # Parse full manifest in previous existing image creation session + old_full_manifest = self.manifest.parse_full_manifest() + + # Create full manifest for the current image session, the old one + # will be replaced by the new one. + self.manifest.create_full(self.pm) + + # Parse full manifest in current image creation session + new_full_manifest = self.manifest.parse_full_manifest() + + pkg_to_remove = list() + for pkg in old_full_manifest: + if pkg not in new_full_manifest: + pkg_to_remove.append(pkg) + + if pkg_to_remove != []: + bb.note('decremental removed: %s' % ' '.join(pkg_to_remove)) + self.pm.remove(pkg_to_remove) + def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS', True) @@ -524,6 +562,9 @@ class OpkgRootfs(Rootfs): self.pm.handle_bad_recommendations() + if self.inc_opkg_image_gen == "1": + self._remove_extra_packages(pkgs_to_install) + for pkg_type in self.install_order: if pkg_type in pkgs_to_install: # For multilib, we perform a sanity test before final install @@ -540,6 +581,9 @@ class OpkgRootfs(Rootfs): execute_pre_post_process(self.d, opkg_post_process_cmds) execute_pre_post_process(self.d, rootfs_post_install_cmds) + if self.inc_opkg_image_gen == "1": + self.pm.backup_packaging_data() + def _get_delayed_postinsts(self): pkg_list = [] status_file = os.path.join(self.image_rootfs, -- cgit v1.2.3