Patchwork [1/1] image.bbclass: uninstall package only if it's already installed

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Sept. 22, 2013, 9:34 a.m.
Message ID <943f0f04862b212f3641528f4c03385e092bc99b.1379842366.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/58481/
State Accepted
Commit b86dc63bc87763119fce8286f37f44361da824d0
Headers show

Comments

Qi.Chen@windriver.com - Sept. 22, 2013, 9:34 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Remove a package from rootfs only if it's already installed. Also,
if a package is uninstalled, remove it from installed_pkgs.txt.

[YOCTO #5169]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/image.bbclass |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 889547a..b4be509 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -510,7 +510,17 @@  rootfs_uninstall_unneeded () {
 			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
 				remove_run_postinsts=true
 			fi
-			rootfs_uninstall_packages update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}
+
+			# Remove package only if it's installed
+			pkgs_to_remove="update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
+			for pkg in $pkgs_to_remove; do
+			    # regexp for pkg, to be used in grep and sed
+			    pkg_regexp="^`echo $pkg | sed 's/\./\\\./'` "
+			    if grep -q "$pkg_regexp" ${WORKDIR}/installed_pkgs.txt; then
+				rootfs_uninstall_packages $pkg
+				sed -i "/$pkg_regexp/d" ${WORKDIR}/installed_pkgs.txt
+			    fi
+			done
 
 			# Need to remove rc.d files for run-postinsts by hand since opkg won't
 			# call postrm scripts in offline root mode.