Skip to contentSkip to conversation

rootfs.py: allow removal of support packages

PATCH Superseded Stephano Cetola 2 participants 5 messages Jul 11, 2016 – Jul 19, 2016

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 rootfs.py: allow removal of support packages

I've updated the list to be extened by getVar().split() as requested.

Stephano Cetola (1):
rootfs.py: allow removal of support packages

 meta/lib/oe/rootfs.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.0
#1 lore raw

PATCH v3 1/1 rootfs.py: allow removal of support packages

For images not containing a package manager, this allows the removal of support packages based on the REMOVE_PKG_SUPPORT variable. Packages that will be uninstalled include: update-rc.d, base-passwd, shadow, run-postinsts, and update-alternatives.

---
 meta/lib/oe/rootfs.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
meta/lib/oe/rootfs.py +18 -2
index ed0bab1..6939dce 100644
@@ -253,6 +253,24 @@ class Rootfs(object, metaclass=ABCMeta):
 
         image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs",
                                         True, False, self.d)
+        runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management",
+                                        True, False, self.d)
+
+        if (not runtime_pkgmanage and self.d.getVar('REMOVE_PKG_SUPPORT', True) == "1"
+                and delayed_postinsts is None):
+            # Remove components that we don't need if we're not going to install
+            # additional packages at runtime
+            pkgs_installed = image_list_installed_packages(self.d)
+            unneeded_pkgs = ["update-rc.d", "base-passwd", "shadow",
+                    "update-alternatives", "run-postinsts"]
+            unneeded_pkgs.extend(self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL",
+                True).split(","))
+            pkgs_to_remove = [pkg for pkg in pkgs_installed if pkg in unneeded_pkgs]
+
+            if len(pkgs_to_remove) > 0:
+                bb.warn("removing packages")
+                self.pm.remove(pkgs_to_remove, False)
+
         if image_rorfs:
             # Remove components that we don't need if it's a read-only rootfs
             unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED", True).split()
@@ -271,8 +289,6 @@ class Rootfs(object, metaclass=ABCMeta):
         post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND", True)
         execute_pre_post_process(self.d, post_uninstall_cmds)
 
-        runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management",
-                                              True, False, self.d)
         if not runtime_pkgmanage:
             # Remove the package manager data files
             self.pm.remove_packaging_data()
Signature · 1 line
2.9.0
#2 lore raw

meta/lib/oe/rootfs.py class Rootfs(object, metaclass=ABCMeta): · line 267

Quoted 3 lines · Stephano Cetola
meta/lib/oe/rootfs.py +2 -0
+            unneeded_pkgs.extend(self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL",
+                True).split(","))

Sorry for not getting around to reviewing this...

That variable is whitespace separated, not comma.

Ross

#3 lore raw
Quoted 7 lines · Ross

meta/lib/oe/rootfs.py class Rootfs(object, metaclass=ABCMeta): · line 267

Quoted 3 lines · Stephano Cetola
meta/lib/oe/rootfs.py +2 -0
+            unneeded_pkgs.extend(self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL",
+                True).split(","))
Quoted 5 lines

Sorry for not getting around to reviewing this...

That variable is whitespace separated, not comma.

Ross

There should be a V4 out there already that splits off space. Not sure what I was thinking here, but I realized pretty quickly my mistake :)

https://patchwork.openembedded.org/patch/126893/

Cheers,
Stephano

#4 lore raw
Quoted 4 lines · Stephano Cetola

There should be a V4 out there already that splits off space. Not sure what I
was thinking here, but I realized pretty quickly my mistake :)

Somehow missed that, thanks!

Ross