Skip to contentSkip to conversation

package_rpm: Only rebuild the indexes if the packages have changed

PATCH In review Richard Purdie 2 participants 2 messages Apr 27, 2012 – Apr 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package_rpm: Only rebuild the indexes if the packages have changed

This change farms the solvedb creation out to a separate script which handles creation of the index, only if mtime of any of the packages has changed.

For a core-image-minimal set of rpm's this saves ~20s of a 45s rootfs build. For core-image-sato it saves 1 minute of a 5 minute rootfs build. The more packages in the system, the bigger the saving will be.

---

meta/classes/package_rpm.bbclass +4 -14
index 2476c16..cf66a51 100644
@@ -40,12 +40,13 @@ package_update_index_rpm_common () {
 	rpmconf_base="$1"
 	shift
 
+        createdirs=""
 	for archvar in "$@"; do
 		eval archs=\${${archvar}}
 		packagedirs=""
 		for arch in $archs; do
 			packagedirs="${DEPLOY_DIR_RPM}/$arch $packagedirs"
-			rm -rf ${DEPLOY_DIR_RPM}/$arch/solvedb
+			rm -rf ${DEPLOY_DIR_RPM}/$arch/solvedb.done
 		done
 
 		cat /dev/null > ${rpmconf_base}-${archvar}.conf
@@ -53,22 +54,11 @@ package_update_index_rpm_common () {
 			if [ -e $pkgdir/ ]; then
 				echo "Generating solve db for $pkgdir..."
 				echo $pkgdir/solvedb >> ${rpmconf_base}-${archvar}.conf
-				if [ -d $pkgdir/solvedb ]; then
-					# We've already processed this and it's a duplicate
-					continue
-				fi
-				mkdir -p $pkgdir/solvedb
-				echo "# Dynamically generated solve manifest" >> $pkgdir/solvedb/manifest
-				find $pkgdir -maxdepth 1 -type f >> $pkgdir/solvedb/manifest
-				${RPM} -i --replacepkgs --replacefiles --oldpackage \
-					-D "_dbpath $pkgdir/solvedb" --justdb \
-					--noaid --nodeps --noorder --noscripts --notriggers --noparentdirs --nolinktos --stats \
-					--ignoresize --nosignature --nodigest \
-					-D "__dbi_txn create nofsync" \
-					$pkgdir/solvedb/manifest
+                                createdirs="$createdirs $pkgdir"
 			fi
 		done
 	done
+	rpm-createsolvedb.py "${RPM}" $createdirs
 }
 
 #
scripts/rpm-createsolvedb.py renamed from dev/null +63 -0

63 lines not on this page · raw message

#1 lore raw
Quoted 6 lines

+    if os.path.exists(path + "/solvedb.checksum") and open(path + "/solvedb.checksum", "r").read() == checksum:
+        open(path + "/solvedb.done", "w")
+        continue
+
+    if os.path.exists(path + "/solvedb"):
+        os.system("rm -rf %s" % (path + "/solvedb"))

to be pythonic may be use shutils.rmtree() here

Quoted 4 lines

+    os.mkdir(path + "/solvedb")
+    m = open(path + "/solvedb/manifest", "w")
+    m.write("# Dynamically generated solve manifest\n")
+    for f in manifest: