Skip to contentSkip to conversation

Postinstall fixes

PATCH New Laurentiu Palcu 1 participant 5 messages Apr 22, 2013

lore
Share & tools
lore
#0 lore raw

cover Postinstall fixes

Hi all,

Because RPM saves the postinstalls in /etc/rpm-postinsts only if the postinstall fails, the intercept hooks machanism was implemented so that the postinstalls always return 1, in order for the rpm to save the scriptlet. Unfortunately, this is not such a good idea when a recipe needs to install more than one hook.

This patchset changes the logic in order to allow installing multiple hooks in the same postinstall. The postinstall is extracted after the package is installed and some sed magic is needed in order to extract the postinstall scriptlets from rpm.

Thanks,
Laurentiu

The following changes since commit 3b2d8e52ee4391802cff7baf3f343700499859ce:

build-appliance: Update to latest dylan revision for release (2013-04-18 22:02:43 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib lpalcu/postinsts_issue_fix
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=lpalcu/postinsts_issue_fix

Laurentiu Palcu (4):
fontcache.bbclass: do not exit with 1 after installing intercept hook gtk-icon-cache.bbclass: do not exit 1 after installing intercept hook pixbufcache.bbclass: do not exit 1 after installing intercept hook image.bbclass: change the logic when intercepts fail

 meta/classes/fontcache.bbclass      |   10 ++------
 meta/classes/gtk-icon-cache.bbclass |   47 +++++++++++++++--------------------
 meta/classes/image.bbclass          |   32 ++++++++++++++++--------
 meta/classes/pixbufcache.bbclass    |   29 +++++++++------------
 4 files changed, 56 insertions(+), 62 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/4 fontcache.bbclass: do not exit with 1 after installing intercept hook

This will allow to register, in a single postinstall, multiple hooks.

---
 meta/classes/fontcache.bbclass |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
meta/classes/fontcache.bbclass +2 -8
index 0bc309a..9136c5a 100644
@@ -8,19 +8,13 @@ inherit qemu
 
 FONT_PACKAGES ??= "${PN}"
 
-#
-# On host, the postinstall MUST return 1 because we do not know if the intercept
-# hook will succeed. If it does succeed, than the packages will be marked as
-# installed.
-#
 fontcache_common() {
 if [ "x$D" != "x" ] ; then
 	$INTERCEPT_DIR/postinst_intercept update_font_cache ${PKG} bindir=${bindir} \
 		libdir=${libdir} base_libdir=${base_libdir}
-	exit 1
+else
+	fc-cache
 fi
-
-fc-cache
 }
 
 python populate_packages_append() {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 gtk-icon-cache.bbclass: do not exit 1 after installing intercept hook

In reply to Laurentiu Palcu

This will allow to register, in a single postinstall, multiple hooks.

---
 meta/classes/gtk-icon-cache.bbclass |   47 +++++++++++++++--------------------
 1 file changed, 20 insertions(+), 27 deletions(-)
meta/classes/gtk-icon-cache.bbclass +20 -27
index b53c0bc..7f24d49 100644
@@ -2,41 +2,34 @@ FILES_${PN} += "${datadir}/icons/hicolor"
 
 DEPENDS += "${@['hicolor-icon-theme', '']['${BPN}' == 'hicolor-icon-theme']} gtk-update-icon-cache-native"
 
-#
-# On host, the postinstall MUST return 1 because we do not know if the intercept
-# hook will succeed. If it does succeed, than the packages will be marked as
-# installed.
-#
 gtk_icon_cache_postinst() {
 if [ "x$D" != "x" ]; then
-    $INTERCEPT_DIR/postinst_intercept update_icon_cache ${PKG} libdir=${libdir} \
-        base_libdir=${base_libdir}
-    exit 1
+	$INTERCEPT_DIR/postinst_intercept update_icon_cache ${PKG} libdir=${libdir} \
+		base_libdir=${base_libdir}
+else
+
+	# Update the pixbuf loaders in case they haven't been registered yet
+	GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
+
+	for icondir in /usr/share/icons/* ; do
+		if [ -d $icondir ] ; then
+			gtk-update-icon-cache -fqt  $icondir
+		fi
+	done
 fi
-
-# Update the pixbuf loaders in case they haven't been registered yet
-GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
-
-for icondir in /usr/share/icons/* ; do
-    if [ -d $icondir ] ; then
-        gtk-update-icon-cache -fqt  $icondir
-    fi
-done
 }
 
 gtk_icon_cache_postrm() {
 if [ "x$D" != "x" ]; then
-    $INTERCEPT_DIR/postinst_intercept update_icon_cache ${PKG} libdir=${libdir} \
-        base_libdir=${base_libdir}
-
-    exit 1
+	$INTERCEPT_DIR/postinst_intercept update_icon_cache ${PKG} libdir=${libdir} \
+		base_libdir=${base_libdir}
+else
+	for icondir in /usr/share/icons/* ; do
+		if [ -d $icondir ] ; then
+			gtk-update-icon-cache -qt  $icondir
+		fi
+	done
 fi
-
-for icondir in /usr/share/icons/* ; do
-    if [ -d $icondir ] ; then
-        gtk-update-icon-cache -qt  $icondir
-    fi
-done
 }
 
 python populate_packages_append () {
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/4 pixbufcache.bbclass: do not exit 1 after installing intercept hook

In reply to Laurentiu Palcu

This will allow to register, in a single postinstall, multiple hooks.

---
 meta/classes/pixbufcache.bbclass |   29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
meta/classes/pixbufcache.bbclass +12 -17
index 3c34557..4e0f577 100644
@@ -8,27 +8,22 @@ inherit qemu
 
 PIXBUF_PACKAGES ??= "${PN}"
 
-#
-# On host, the postinstall MUST return 1 because we do not know if the intercept
-# hook will succeed. If it does succeed, than the packages will be marked as
-# installed.
-#
 pixbufcache_common() {
 if [ "x$D" != "x" ]; then
 	$INTERCEPT_DIR/postinst_intercept update_pixbuf_cache ${PKG} libdir=${libdir} \
 		bindir=${bindir} base_libdir=${base_libdir}
-	exit 1
-fi
-
-# Update the pixbuf loaders in case they haven't been registered yet
-GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
-
-if [ -x ${bindir}/gtk-update-icon-cache ] && [ -d ${datadir}/icons ]; then
-    for icondir in /usr/share/icons/*; do
-        if [ -d ${icondir} ]; then
-            gtk-update-icon-cache -t -q ${icondir}
-        fi
-    done
+else
+
+	# Update the pixbuf loaders in case they haven't been registered yet
+	GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
+
+	if [ -x ${bindir}/gtk-update-icon-cache ] && [ -d ${datadir}/icons ]; then
+		for icondir in /usr/share/icons/*; do
+			if [ -d ${icondir} ]; then
+				gtk-update-icon-cache -t -q ${icondir}
+			fi
+		done
+	fi
 fi
 }
 
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/4 image.bbclass: change the logic when intercepts fail

In reply to Laurentiu Palcu

Due to some issues with postinstalls that register hooks, we changed the logic a bit. Now, all postinstalls that register hooks will return successfully and only after, if hooks fail, mark the package as unpacked.

---
 meta/classes/image.bbclass |   32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
meta/classes/image.bbclass +22 -10
index 4e9c29c..ffb372a 100644
@@ -187,21 +187,32 @@ run_intercept_scriptlets () {
 			[ "$script" = "*" ] && break
 			[ "$script" = "postinst_intercept" ] || [ ! -x "$script" ] && continue
 			echo "> Executing $script"
-			./$script || { echo "WARNING: intercept script \"$script\" failed, falling back to running postinstalls at first boot" && continue; };
+			./$script && continue
+			echo "WARNING: intercept script \"$script\" failed, falling back to running postinstalls at first boot"
 			#
-			# If we got here, than the intercept was successful. Next, we must
-			# mark the postinstalls as "installed". For rpm is a little bit
-			# different, we just have to delete the saved postinstalls from
+			# If we got here, than the intercept has failed. Next, we must
+			# mark the postinstalls as "unpacked". For rpm is a little bit
+			# different, we just have to save the package postinstalls in
 			# /etc/rpm-postinsts
 			#
 			pkgs="$(cat ./$script|grep "^##PKGS"|cut -d':' -f2)" || continue
 			case ${IMAGE_PKGTYPE} in
 				"rpm")
-					for pi in ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/*; do
-						pkg_name="$(cat $pi|sed -n -e "s/^.*postinst_intercept $script \([^ ]*\).*/\1/p")"
-						if [ -n "$pkg_name" -a -n "$(echo "$pkgs"|grep " $pkg_name ")" ]; then
-							rm $pi
-						fi
+					[ -d ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/ ] || mkdir ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/
+					v_expr=$(echo ${MULTILIB_GLOBAL_VARIANTS}|tr ' ' '|')
+					for p in $pkgs; do
+						# remove any multilib prefix from the package name (RPM 
+						# does not use it like this)
+						new_p=$(echo $p | sed -r "s/^($v_expr)-//")
+
+						# extract the postinstall scriptlet from rpm package and
+						# save it in /etc/rpm-postinsts
+						echo "  * postponing $new_p"
+						rpm -q --scripts --root=${IMAGE_ROOTFS} --dbpath=/var/lib/rpm $new_p |\
+						sed -n -e '/^postinstall scriptlet (using .*):$/,/^.* scriptlet (using .*):$/ {/.*/p}' |\
+						sed -e 's/postinstall scriptlet (using \(.*\)):$/#!\1/' -e '/^.* scriptlet (using .*):$/d'\
+							> ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/$new_p
+						chmod +x ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/$new_p
 					done
 					# move to the next intercept script
 					continue
@@ -216,7 +227,8 @@ run_intercept_scriptlets () {
 			# the next piece of code is run only for ipk/dpkg
 			sed_expr=""
 			for p in $pkgs; do
-				sed_expr="$sed_expr -e \"/^Package: ${p}$/,/^Status: install.* unpacked$/ {s/unpacked/installed/}\""
+				echo "  * postponing $p"
+				sed_expr="$sed_expr -e \"/^Package: ${p}$/,/^Status: install.* installed$/ {s/installed/unpacked/}\""
 			done
 			eval sed -i $sed_expr $status_file
 		done
Signature · 1 line
1.7.9.5