Patchwork [2/5] image.bbclass:support incremental deb image generation

login
register
mail settings
Submitter Hongxu Jia
Date Feb. 4, 2013, 9:34 a.m.
Message ID <732ebfb266b8f815cc29d12347aac3cbc924c6bb.1359968242.git.hongxu.jia@windriver.com>
Download mbox | patch
Permalink /patch/43965/
State New
Headers show

Comments

Hongxu Jia - Feb. 4, 2013, 9:34 a.m.
When use the incremental image generation, and the type of previous image
has no change, don't remove the rootfs

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes/image.bbclass |   37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 9b4dec8..b607f90 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -203,16 +203,37 @@  run_intercept_scriptlets () {
 
 fakeroot do_rootfs () {
 	#set -x
-	# When use the rpm incremental image generation, don't remove the rootfs
-	if [ "${INC_RPM_IMAGE_GEN}" != "1" -o "${IMAGE_PKGTYPE}" != "rpm" ]; then
-		rm -rf ${IMAGE_ROOTFS}
-	elif [ -d ${T}/saved_rpmlib/var/lib/rpm ]; then
-		# Move the rpmlib back
-		if [ ! -d ${IMAGE_ROOTFS}/var/lib/rpm ]; then
-			mkdir -p ${IMAGE_ROOTFS}/var/lib/
-			mv ${T}/saved_rpmlib/var/lib/rpm ${IMAGE_ROOTFS}/var/lib/
+	local is_remove_rootfs=1
+
+	# When use the incremental image generation, and the type
+	# of previous image has no change, don't remove the rootfs
+	if [ "${INC_RPM_IMAGE_GEN}" = "1" ]; then
+		if [ "${IMAGE_PKGTYPE}" = "rpm"	]; then
+			if [ -d ${T}/saved_rpmlib/var/lib/rpm ]; then
+				is_remove_rootfs=0
+				echo "NOTE: Start rpm incremental image generation"
+
+				# Move the rpmlib back
+				if [ ! -d ${IMAGE_ROOTFS}/var/lib/rpm ]; then
+					mkdir -p ${IMAGE_ROOTFS}/var/lib/
+					mv ${T}/saved_rpmlib/var/lib/rpm ${IMAGE_ROOTFS}/var/lib/
+				fi
+			fi
+		fi
+	elif [ "${INC_DEB_IMAGE_GEN}" = "1" ]; then
+		if [ "${IMAGE_PKGTYPE}" = "deb" ]; then
+			if [ -e ${IMAGE_ROOTFS}/var/lib/dpkg/status ]; then
+				is_remove_rootfs=0
+				echo "NOTE: Start deb incremental image generation"
+			fi
 		fi
 	fi
+
+	if [ $is_remove_rootfs -eq 1 ]; then
+		rm -rf ${IMAGE_ROOTFS}
+		rm -rf ${T}/saved_rpmlib
+	fi
+
 	rm -rf ${MULTILIB_TEMP_ROOTFS}
 	mkdir -p ${IMAGE_ROOTFS}
 	mkdir -p ${DEPLOY_DIR_IMAGE}