Skip to contentSkip to conversation

run-postinsts refactoring

PATCH Superseded Laurentiu Palcu 4 participants 15 messages May 23, 2013 – Jun 6, 2013

lore
Share & tools
lore
#0 lore raw

cover run-postinsts refactoring

Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed postinstalls on target when the PM is not part of the image;
* opkg removes the meta-data and some uneeded packages whilst deb/rpm remove only the meta-data;
* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

Thanks,
Laurentiu

The following changes since commit f7b639e527a65f9ce77aef07651ac5ec1e094e52:

rpm-postinsts.bb: enable postinst logging (2013-05-23 10:28:05 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
systemd: add udev-utils dependency for udev-hwdb rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclas: switch to using run-postinsts
rpm: replace rpm-postinsts dependency with run-postinsts

 meta/classes/image.bbclass                         |   33 +++++++++++
 meta/classes/rootfs_deb.bbclass                    |   23 +++++++-
 meta/classes/rootfs_ipk.bbclass                    |   39 ++++++-------
 meta/classes/rootfs_rpm.bbclass                    |   25 ++++++++-
 meta/recipes-core/images/core-image-minimal.bb     |    2 -
 meta/recipes-core/systemd/systemd_199.bb           |    2 +
 .../dpkg/run-postinsts/run-postinsts               |   59 ++++++++++++--------
 .../dpkg/run-postinsts/run-postinsts.awk           |   30 ----------
 meta/recipes-devtools/dpkg/run-postinsts_1.0.bb    |    7 +--
 meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
 10 files changed, 135 insertions(+), 87 deletions(-)
 delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/7 systemd: add udev-utils dependency for udev-hwdb

udev-hwdb needs udevadm tool to compile the hardware index.

---
 meta/recipes-core/systemd/systemd_199.bb |    2 ++
 1 file changed, 2 insertions(+)
meta/recipes-core/systemd/systemd_199.bb +2 -0
index b1cc046..09e2171 100644
@@ -212,6 +212,8 @@ RDEPENDS_udev += "udev-utils"
 RPROVIDES_udev = "hotplug"
 RRECOMMENDS_udev += "udev-hwdb"
 
+RDEPENDS_udev-hwdb += "udev-utils"
+
 FILES_udev += "${base_sbindir}/udevd \
                ${rootlibexecdir}/systemd/systemd-udevd \
                ${rootlibexecdir}/udev/accelerometer \
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/7 rootfs_*.bbclass: add some helper functions

In reply to Laurentiu Palcu

This patch adds the following helper functions:
* delayed_postinsts - outputs the list of delayed postinstalls;
* save_postinsts - this will save the delayed postinstalls for ipk/deb in /etc/(ipk|deb)_postinsts;
* rootfs_remove_packages - removes packages from an image;

Additionaly, this patch will remove a piece of code in rootfs_ipk_do_rootfs which will be moved to image.bbclass and used for all backends;

[YOCTO #4484]

---
 meta/classes/rootfs_deb.bbclass |   23 +++++++++++++++++++++--
 meta/classes/rootfs_ipk.bbclass |   39 ++++++++++++++++++---------------------
 meta/classes/rootfs_rpm.bbclass |   23 +++++++++++++++++++++--
 3 files changed, 60 insertions(+), 25 deletions(-)
meta/classes/rootfs_deb.bbclass +21 -2
index e642cf3..edd1037 100644
@@ -85,7 +85,7 @@ fakeroot rootfs_deb_do_rootfs () {
 	${ROOTFS_POSTPROCESS_COMMAND}
 
 	if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
-		if grep Status:.install.ok.unpacked ${IMAGE_ROOTFS}/var/lib/dpkg/status; then
+		if [ -n "$(delayed_postinsts)" ]; then
 			bberror "Some packages could not be configured offline and rootfs is read-only."
 			exit 1
 		fi
@@ -94,9 +94,22 @@ fakeroot rootfs_deb_do_rootfs () {
 	log_check rootfs
 }
 
+rootfs_deb_do_rootfs[vardeps] += "delayed_postinsts"
+
+delayed_postinsts () {
+	cat ${IMAGE_ROOTFS}/var/lib/dpkg/status|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
+}
+
+save_postinsts () {
+	for p in $(delayed_postinsts); do
+		install -d ${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts
+		cp ${IMAGE_ROOTFS}/var/lib/dpkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts/$p
+	done
+}
+
 remove_packaging_data_files() {
 	rm -rf ${IMAGE_ROOTFS}${opkglibdir}
-	rm -rf ${IMAGE_ROOTFS}/usr/dpkg/
+	rm -rf ${IMAGE_ROOTFS}/var/lib/dpkg/
 }
 
 rootfs_install_packages() {
@@ -105,3 +118,9 @@ rootfs_install_packages() {
 	# Mark all packages installed
 	sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" $INSTALL_ROOTFS_DEB/var/lib/dpkg/status
 }
+
+rootfs_remove_packages() {
+	# for some reason, --root doesn't really work here... We use --admindir&--instdir instead.
+	${STAGING_BINDIR_NATIVE}/dpkg --admindir=${IMAGE_ROOTFS}/var/lib/dpkg --instdir=${IMAGE_ROOTFS} -r --force-depends $@
+}
+
meta/classes/rootfs_ipk.bbclass +18 -21
index 3e1f959..1403422 100644
@@ -91,36 +91,29 @@ fakeroot rootfs_ipk_do_rootfs () {
 	${ROOTFS_POSTPROCESS_COMMAND}
 
 	if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
-		if grep Status:.install.ok.unpacked ${STATUS}; then
+		if [ -n "$(delayed_postinsts)" ]; then
 			bberror "Some packages could not be configured offline and rootfs is read-only."
 			exit 1
 		fi
 	fi
 
 	rm -f ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/lists/*
-	if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
-		if ! grep Status:.install.ok.unpacked ${STATUS}; then
-			# All packages were successfully configured.
-			# update-rc.d, base-passwd, run-postinsts are no further use, remove them now
-			remove_run_postinsts=false
-			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
-				remove_run_postinsts=true
-			fi
-			opkg-cl ${OPKG_ARGS} --force-depends remove update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL} || true
-
-			# Need to remove rc.d files for run-postinsts by hand since opkg won't
-			# call postrm scripts in offline root mode.
-			if $remove_run_postinsts; then
-				update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
-			fi
-
-			# Also delete the status files
-			remove_packaging_data_files
-		fi
-	fi
 	log_check rootfs
 }
 
+rootfs_ipk_do_rootfs[vardeps] += "delayed_postinsts"
+
+delayed_postinsts () {
+	cat ${STATUS}|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
+}
+
+save_postinsts () {
+	for p in $(delayed_postinsts); do
+		install -d ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts
+		cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts/$p
+	done
+}
+
 rootfs_ipk_write_manifest() {
 	manifest=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest
 	cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status $manifest
@@ -145,6 +138,10 @@ rootfs_install_packages() {
 	opkg-cl ${OPKG_ARGS} install `cat $1`
 }
 
+rootfs_remove_packages() {
+	opkg-cl ${OPKG_ARGS} --force-depends remove $@
+}
+
 ipk_insert_feed_uris () {
 
 	echo "Building from feeds activated!"
meta/classes/rootfs_rpm.bbclass +21 -2
index d373dab..d1d6eff 100644
@@ -114,8 +114,8 @@ fakeroot rootfs_rpm_do_rootfs () {
 	${ROOTFS_POSTPROCESS_COMMAND}
 
 	if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
-		if [ -d ${IMAGE_ROOTFS}/etc/rpm-postinsts ] ; then
-			if [ "`ls -A ${IMAGE_ROOTFS}/etc/rpm-postinsts`" != "" ] ; then
+		if [ -d ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts ] ; then
+			if [ "`ls -A ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts`" != "" ] ; then
 				bberror "Some packages could not be configured offline and rootfs is read-only."
 				exit 1
 			fi
@@ -135,6 +135,20 @@ fakeroot rootfs_rpm_do_rootfs () {
 	log_check rootfs
 }
 
+rootfs_rpm_do_rootfs[vardeps] += "delayed_postinsts"
+
+delayed_postinsts() {
+	if [ -d ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts ]; then
+		ls ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts
+	fi
+}
+
+save_postinsts() {
+	# this is just a stub. For RPM, the failed postinstalls are already saved in
+	# /etc/rpm-postinsts
+	true
+}
+
 remove_packaging_data_files() {
 	# Save the rpmlib for increment rpm image generation
 	t="${T}/saved_rpmlib/var/lib"
@@ -165,6 +179,11 @@ rootfs_install_packages() {
 	package_install_internal_rpm
 }
 
+rootfs_remove_packages() {
+	echo rpm -e --nodeps --root=${IMAGE_ROOTFS} --dbpath=/var/lib/rpm $@
+	rpm -e --nodeps --root=${IMAGE_ROOTFS} --dbpath=/var/lib/rpm $@
+}
+
 python () {
     if d.getVar('BUILD_IMAGES_FROM_FEEDS', True):
         flags = d.getVarFlag('do_rootfs', 'recrdeptask')
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/7 image.bbclass: remove unneeded files from the image

In reply to Laurentiu Palcu

This patch creates a new function, rootfs_remove_unneeded(), that will be called after rootfs_*_do_rootfs is called and which will handle delayed postinstalls in a generic fashion, for all backends in the same way.

---
 meta/classes/image.bbclass |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
meta/classes/image.bbclass +33 -0
index 04db533..380ed8e 100644
@@ -303,6 +303,9 @@ fakeroot do_rootfs () {
 
 	rootfs_${IMAGE_PKGTYPE}_do_rootfs
 
+	# remove unneeded packages/files from the final image
+	rootfs_remove_unneeded
+
 	insert_feed_uris
 
 	if [ "x${LDCONFIGDEPEND}" != "x" ]; then
@@ -463,6 +466,36 @@ rootfs_install_complementary() {
     fi
 }
 
+rootfs_remove_unneeded () {
+	if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
+		if [ -z "$(delayed_postinsts)" ]; then
+			# All packages were successfully configured.
+			# update-rc.d, base-passwd, run-postinsts are no further use, remove them now
+			remove_run_postinsts=false
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				remove_run_postinsts=true
+			fi
+			rootfs_remove_packages update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}
+
+			# Need to remove rc.d files for run-postinsts by hand since opkg won't
+			# call postrm scripts in offline root mode.
+			if $remove_run_postinsts; then
+				update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
+			fi
+		else
+			# Some packages were not successfully configured, save them only
+			# if we have run-postinsts script present. Otherwise, they're
+			# useless
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				save_postinsts
+			fi
+		fi
+
+		# Since no package manager is present in the image the metadata is not needed
+		remove_packaging_data_files
+	fi
+}
+
 # set '*' as the root password so the images
 # can decide if they want it or not
 zap_root_password () {
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/7 core-image-minimal: do not remove packaging files in the rootfs postprocess

In reply to Laurentiu Palcu

Since the removal of PM's meta-data was moved in image.bbclass, after rootfs_*_do_rootfs() runs, there's no need to remove the files in rootfs postprocess stage. Also, if the meta-data is removed then there's no way we can save the postinstalls to /etc/(deb|ipk)-postinsts later.

For RPM, it doesn't really matter since the postinstalls are saved to /etc/rpm-postinsts as soon as the postinstall fails.

[YOCTO #4484]

---
 meta/recipes-core/images/core-image-minimal.bb |    2 --
 1 file changed, 2 deletions(-)
meta/recipes-core/images/core-image-minimal.bb +0 -2
index 0d2613e..0b56cc8 100644
@@ -10,5 +10,3 @@ inherit core-image
 
 IMAGE_ROOTFS_SIZE = "8192"
 
-# remove not needed ipkg informations
-ROOTFS_POSTPROCESS_COMMAND += "remove_packaging_data_files ; "
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/7 run-postinsts: make it generic

In reply to Laurentiu Palcu

This recipe is used only when the package manager is not deployed on target and there still are delayed postinstalls that need to be run on target. At the moment, run-postinsts is targeted to dpkg/opkg. RPM uses another recipe, called rpm-postinsts which, in turn, is used even when the rpm package is deployed.

This patch intends to make run-postinsts generic and deprecate rpm-postinsts. Here's why:
* when opkg/dpkg are not deplyed, the meta-data files are useless. Hence, the awk script is not needed. The postinstall files are already saved in /etc/(deb|ipk)-postinsts directory and we can use the same procedure as in rpm's case;

---
 .../dpkg/run-postinsts/run-postinsts               |   59 ++++++++++++--------
 .../dpkg/run-postinsts/run-postinsts.awk           |   30 ----------
 meta/recipes-devtools/dpkg/run-postinsts_1.0.bb    |    7 +--
 3 files changed, 38 insertions(+), 58 deletions(-)
 delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk
meta/recipes-devtools/dpkg/run-postinsts/run-postinsts +35 -24
index 5f6442c..2593066 100755
@@ -5,32 +5,43 @@
 # Author: Richard Purdie <[email protected]>
 #
 
-PKGSYSTEM=/var/lib/dpkg
+# The following script will run all the scriptlets found in #SYSCONFDIR#/deb-postinsts or
+# #SYSCONFDIR#/ipk-postinsts
 
-if [ ! -e $PKGSYSTEM/status ]; then
-  if [ -e /var/lib/opkg/status ]; then
-    PKGSYSTEM=/var/lib/opkg
-  else
-    echo "No package system found"
-    exit 1
-  fi
-fi
+pi_dir=""
+for pm in rpm deb ipk; do
+	if [ -d "#SYSCONFDIR#/${pm}-postinsts" ]; then
+		pi_dir=#SYSCONFDIR#/${pm}-postinsts
+		break
+	fi
+done
 
-STAMP=$PKGSYSTEM/postinsts-done
-STATFILE=$PKGSYSTEM/status
-STATFILE2=$PKGSYSTEM/status2
+[ -z "$pi_dir" ] && exit 0
 
-if [ -e $STAMP ]; then
-  exit 0
-fi
+[ -e #SYSCONFDIR#/default/postinst ] && . #SYSCONFDIR#/default/postinst
+
+remove_pi_dir=1
+for i in `ls $pi_dir`; do
+	i=$pi_dir/$i
+	echo "Running postinst $i..."
+	if [ -x $i ]; then
+		if [ "$POSTINST_LOGGING" = "1" ]; then
+			sh -c $i >>$LOGFILE 2&>1
+		else
+			sh -c $i
+		fi
+		rm $i
+	else
+		echo "ERROR: postinst $i failed."
+		remove_pi_dir=0
+	fi
+done
 
-awk -f /usr/share/run-postinsts/run-postinsts.awk $STATFILE > $STATFILE2
-if [ $? = 0 ]; then
-  mv $STATFILE2 $STATFILE
-  touch $STAMP
-  exit 0
-else
-  rm -f $STATFILE2
-  rm -f $STAMP
-  exit 1
+# since all postinstalls executed successfully, remove the postinstalls directory
+# and the rcS.d link
+if [ $remove_pi_dir = 1 ]; then
+	rm -rf $pi_dir
+	if [ -n "`which update-rc.d`" ]; then
+		update-rc.d -f run-postinsts remove
+	fi
 fi
meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk deleted +0 -30
deleted file mode 100644
index cbc8d1a..0000000
@@ -1,30 +0,0 @@
-#
-# Copyright 2007 Openedhand Ltd.
-#
-# Author: Richard Purdie <[email protected]>
-#
-# Rather hacky proof of concept
-#
-
-BEGIN {
-  rc=system("test -d /var/lib/dpkg/info/")
-  if (rc==0)
-    pkgdir="/var/lib/dpkg/info"
-  else
-    pkgdir="/var/lib/opkg/info"
-  package=""
-}
-/Package:.*/ {
-  package = substr($0, 10)
-}
-/Status:.*unpacked.*/ {
-  print "Configuring: " package > "/dev/stderr"
-  ret = system(pkgdir "/" package ".postinst 1>&2")
-  if (ret == 0)
-    $0 = gensub("unpacked", "installed", 1)
-  else
-    print "Postinstall failed for " package > "/dev/stderr"
-}
-{
-  print $0
-}
meta/recipes-devtools/dpkg/run-postinsts_1.0.bb +3 -4
index 4c9b2fd..5dd1709 100644
@@ -1,11 +1,11 @@
-DESCRIPTION = "Run postinstall scripts on device using awk"
+DESCRIPTION = "Run postinstall scripts on device"
 SECTION = "devel"
 PR = "r9"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
                     file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 
-SRC_URI = "file://run-postinsts file://run-postinsts.awk"
+SRC_URI = "file://run-postinsts"
 
 INITSCRIPT_NAME = "run-postinsts"
 INITSCRIPT_PARAMS = "start 98 S ."
@@ -24,6 +24,5 @@ do_install() {
 	install -d ${D}${sysconfdir}/init.d/
 	install -m 0755 ${WORKDIR}/run-postinsts ${D}${sysconfdir}/init.d/
 
-	install -d ${D}${datadir}/${BPN}/
-	install -m 0644 ${WORKDIR}/run-postinsts.awk ${D}${datadir}/${BPN}/
+	sed -i -e 's:#SYSCONFDIR#:${sysconfdir}:g' ${D}${sysconfdir}/init.d/run-postinsts
 }
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH 5/7] run-postinsts: make it generic

Quoted 2 lines · Laurentiu Palcu

This patch intends to make run-postinsts generic and deprecate rpm-postinsts. Here's why:

If it's generic, please move it out of the dpkg/ directory in oe-core.

Ross

#7 lore raw

PATCH 6/7 rootfs_rpm.bbclas: switch to using run-postinsts

In reply to Laurentiu Palcu

Since run-postinsts was made generic, use it for RPM too.

---
 meta/classes/rootfs_rpm.bbclass |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/rootfs_rpm.bbclass +1 -1
index d1d6eff..5027cee 100644
@@ -3,7 +3,7 @@
 #
 
 ROOTFS_PKGMANAGE = "rpm smartpm"
-ROOTFS_PKGMANAGE_BOOTSTRAP = "rpm-postinsts"
+ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
 
 # Add 50Meg of extra space for Smart
 IMAGE_ROOTFS_EXTRA_SPACE_append = "${@base_contains("PACKAGE_INSTALL", "smartpm", " + 51200", "" ,d)}"
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH 7/7 rpm: replace rpm-postinsts dependency with run-postinsts

In reply to Laurentiu Palcu

run-postinsts is generic and will handle rpm delayed postinsts just fine. No need to use another recipe.

---
 meta/recipes-devtools/rpm/rpm_5.4.9.bb |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rpm/rpm_5.4.9.bb +1 -1
index 2dbdca6..0e3a883 100644
@@ -310,7 +310,7 @@ FILES_${PN}-build = "${prefix}/src/rpm \
 		${libdir}/rpm/vpkg-provides2.sh \
 		${libdir}/rpm/perfile_rpmdeps.sh \
 		"
-RDEPENDS_${PN} = "base-files ${PN}-postinsts"
+RDEPENDS_${PN} = "base-files run-postinsts"
 RDEPENDS_${PN}_class-native = ""
 RDEPENDS_${PN}-build = "file"
 
Signature · 1 line
1.7.9.5
#9 lore raw
In reply to Laurentiu Palcu
Quoted 16 lines · Laurentiu Palcu

Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed

    postinstalls on target when the PM is not part of the image;
  * opkg removes the meta-data and some uneeded packages whilst deb/rpm remove
    only the meta-data;

* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

Quoted 7 lines

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

This seems to have a problem building on the auto builder, most of the failures are due to the following:

/usr/sbin/update-rc.d: /bin/sh: bad interpreter: No such file or directory

Details here:

Quoted 8 lines
| log_check: Using /srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/work/qemuppc-poky-linux/core-image-minimal-dev/1.0-r0/temp/log.do_rootfs.32640 as logfile
| Logfile is clean
| rpm -e --nodeps --root=/srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/work/qemuppc-poky-linux/core-image-minimal-dev/1.0-r0/rootfs --dbpath=/var/lib/rpm update-rc.d base-passwd run-postinsts
| /srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/sysroots/x86_64-linux/var/tmp/rpm-tmp.67450: /usr/sbin/update-rc.d: /bin/sh: bad interpreter: No such file or directory
| error: %postun(run-postinsts-1.0-r9.ppc603e) scriptlet failed, exit status 126
| ERROR: Function failed: do_rootfs (see /srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/work/qemuppc-poky-linux/core-image-minimal-dev/1.0-r0/temp/log.do_rootfs.32640 for further information)

NOTE: recipe core-image-minimal-dev-1.0-r0: task do_rootfs: Failed
ERROR: Task 71 (/srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/bu

Sau!

Quoted 35 lines

Thanks,
Laurentiu

The following changes since commit f7b639e527a65f9ce77aef07651ac5ec1e094e52:

   rpm-postinsts.bb: enable postinst logging (2013-05-23 10:28:05 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
systemd: add udev-utils dependency for udev-hwdb rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclas: switch to using run-postinsts
rpm: replace rpm-postinsts dependency with run-postinsts

  meta/classes/image.bbclass                         |   33 +++++++++++
  meta/classes/rootfs_deb.bbclass                    |   23 +++++++-
  meta/classes/rootfs_ipk.bbclass                    |   39 ++++++-------
  meta/classes/rootfs_rpm.bbclass                    |   25 ++++++++-
  meta/recipes-core/images/core-image-minimal.bb     |    2 -
  meta/recipes-core/systemd/systemd_199.bb           |    2 +
  .../dpkg/run-postinsts/run-postinsts               |   59 ++++++++++++--------
  .../dpkg/run-postinsts/run-postinsts.awk           |   30 ----------
  meta/recipes-devtools/dpkg/run-postinsts_1.0.bb    |    7 +--
  meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
  10 files changed, 135 insertions(+), 87 deletions(-)

delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk

#10 lore raw
Quoted 21 lines · Saul Wold
Quoted 20 lines · Laurentiu Palcu

Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed

    postinstalls on target when the PM is not part of the image;
  * opkg removes the meta-data and some uneeded packages whilst deb/rpm remove
    only the meta-data;

* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

Quoted 7 lines
Quoted 3 lines

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

This seems to have a problem building on the auto builder, most of the failures are due to the following:

/usr/sbin/update-rc.d: /bin/sh: bad interpreter: No such file or directory

I gave it a run on our local AB and saw no issues. However, from the log you sent, it appears to be a problem in run-postinsts postrm scriptlet when it's being removed from the image at do_rootfs time. The update-rc.d in the native sysroot is called, which uses /bin/sh.

I'm pretty sure that you'll get the same failure, without my patches, if you set AB to create ipk images (because the code I made generic for all backends was taken from the current rootfs_ipk.bbclass). Currently, if I'm not mistaken, the AB images default to using RPM as the backend.

This is my first hunch... since it works an a local AB we have here, with Ubuntu server (/bin/sh -> dash).

Thanks,
Laurentiu

Quoted 51 lines

Details here:

Quoted 8 lines
| log_check: Using /srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/work/qemuppc-poky-linux/core-image-minimal-dev/1.0-r0/temp/log.do_rootfs.32640 as logfile
| Logfile is clean
| rpm -e --nodeps --root=/srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/work/qemuppc-poky-linux/core-image-minimal-dev/1.0-r0/rootfs --dbpath=/var/lib/rpm update-rc.d base-passwd run-postinsts
| /srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/sysroots/x86_64-linux/var/tmp/rpm-tmp.67450: /usr/sbin/update-rc.d: /bin/sh: bad interpreter: No such file or directory
| error: %postun(run-postinsts-1.0-r9.ppc603e) scriptlet failed, exit status 126
| ERROR: Function failed: do_rootfs (see /srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/build/build/tmp/work/qemuppc-poky-linux/core-image-minimal-dev/1.0-r0/temp/log.do_rootfs.32640 for further information)

NOTE: recipe core-image-minimal-dev-1.0-r0: task do_rootfs: Failed
ERROR: Task 71 (/srv/home/pokybuild/yocto-autobuilder-new/yocto-slave/nightly-ppc/bu

Sau!

Quoted 35 lines

Thanks,
Laurentiu

The following changes since commit f7b639e527a65f9ce77aef07651ac5ec1e094e52:

   rpm-postinsts.bb: enable postinst logging (2013-05-23 10:28:05 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
systemd: add udev-utils dependency for udev-hwdb rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclas: switch to using run-postinsts
rpm: replace rpm-postinsts dependency with run-postinsts

  meta/classes/image.bbclass                         |   33 +++++++++++
  meta/classes/rootfs_deb.bbclass                    |   23 +++++++-
  meta/classes/rootfs_ipk.bbclass                    |   39 ++++++-------
  meta/classes/rootfs_rpm.bbclass                    |   25 ++++++++-
  meta/recipes-core/images/core-image-minimal.bb     |    2 -
  meta/recipes-core/systemd/systemd_199.bb           |    2 +
  .../dpkg/run-postinsts/run-postinsts               |   59 ++++++++++++--------
  .../dpkg/run-postinsts/run-postinsts.awk           |   30 ----------
  meta/recipes-devtools/dpkg/run-postinsts_1.0.bb    |    7 +--
  meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
  10 files changed, 135 insertions(+), 87 deletions(-)

delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk

#11 lore raw

v2 cover run-postinsts refactoring

In reply to Laurentiu Palcu

(cover letter only)

Changes in v2:
* addressed an RPM issue that happened on AB. Interestingly, it happened only on certain distros. Our internal AB (running on Ubuntu server 12.04), didn't show any issues. So, what was the problem? We use a scriptlet wrapper to run the pre/post install scriptlets. What I missed in the previous patchset was that I didn't use the scriptlet wrapper when running the pre/post remove scriptlets and the context in which they ran was not correct. Hence, the update-rc.d used was the host's...
* addresses Ross's request to move run-postinsts recipe out of dpkg directory, since it's generic now;

Paul, Mark would you please review the RPM changes please?

Thanks,
Laurentiu

Changes in v1:
Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed postinstalls on target when the PM is not part of the image;
* opkg removes the meta-data and some uneeded packages whilst deb/rpm remove only the meta-data;
* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

Thanks,
Laurentiu

The following changes since commit a62aed41f2d8f874f7ae24d0e5be5dbc66ea2199:

lrzsz: check locale.h in configure (2013-06-04 15:55:46 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclass: switch to using run-postinsts package_rpm.bbclass: handle pre/post remove scriptlets
rpm: replace rpm-postinsts dependency with run-postinsts

 meta/classes/image.bbclass                         |   33 ++++++++++++++
 meta/classes/package_rpm.bbclass                   |   16 ++++---
 meta/classes/rootfs_deb.bbclass                    |   23 +++++++++-
 meta/classes/rootfs_ipk.bbclass                    |   39 ++++++++--------
 meta/classes/rootfs_rpm.bbclass                    |   29 ++++++++++--
 meta/recipes-core/images/core-image-minimal.bb     |    2 -
 .../dpkg/run-postinsts/run-postinsts               |   36 ---------------
 .../dpkg/run-postinsts/run-postinsts.awk           |   30 -------------
 meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
 .../run-postinsts/run-postinsts/run-postinsts      |   47 ++++++++++++++++++++
 .../{dpkg => run-postinsts}/run-postinsts_1.0.bb   |    7 ++-
 11 files changed, 159 insertions(+), 105 deletions(-)
 delete mode 100755 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts
 delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk
 create mode 100755 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
 rename meta/recipes-devtools/{dpkg => run-postinsts}/run-postinsts_1.0.bb (68%)
Signature · 1 line
1.7.9.5
Reviewed-by on the v2 series
#12 lore raw

Comments below....

Quoted 88 lines · Laurentiu Palcu

(cover letter only)

Changes in v2:
* addressed an RPM issue that happened on AB. Interestingly, it happened only on certain distros. Our internal AB (running on Ubuntu server 12.04), didn't show any issues. So, what was the problem? We use a scriptlet wrapper to run the pre/post install scriptlets. What I missed in the previous patchset was that I didn't use the scriptlet wrapper when running the pre/post remove scriptlets and the context in which they ran was not correct. Hence, the update-rc.d used was the host's...
* addresses Ross's request to move run-postinsts recipe out of dpkg directory,

    since it's generic now;

Paul, Mark would you please review the RPM changes please?

Thanks,
Laurentiu

Changes in v1:
Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed

    postinstalls on target when the PM is not part of the image;
  * opkg removes the meta-data and some uneeded packages whilst deb/rpm remove
    only the meta-data;

* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

Thanks,
Laurentiu

The following changes since commit a62aed41f2d8f874f7ae24d0e5be5dbc66ea2199:

   lrzsz: check locale.h in configure (2013-06-04 15:55:46 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclass: switch to using run-postinsts package_rpm.bbclass: handle pre/post remove scriptlets
rpm: replace rpm-postinsts dependency with run-postinsts

  meta/classes/image.bbclass                         |   33 ++++++++++++++
  meta/classes/package_rpm.bbclass                   |   16 ++++---
  meta/classes/rootfs_deb.bbclass                    |   23 +++++++++-
  meta/classes/rootfs_ipk.bbclass                    |   39 ++++++++--------
  meta/classes/rootfs_rpm.bbclass                    |   29 ++++++++++--
  meta/recipes-core/images/core-image-minimal.bb     |    2 -
  .../dpkg/run-postinsts/run-postinsts               |   36 ---------------
  .../dpkg/run-postinsts/run-postinsts.awk           |   30 -------------
  meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
  .../run-postinsts/run-postinsts/run-postinsts      |   47 ++++++++++++++++++++
  .../{dpkg => run-postinsts}/run-postinsts_1.0.bb   |    7 ++-
  11 files changed, 159 insertions(+), 105 deletions(-)

delete mode 100755 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk create mode 100755 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts rename meta/recipes-devtools/{dpkg => run-postinsts}/run-postinsts_1.0.bb (68%)

(quoted diff) +6 -0
+rootfs_remove_unneeded () {
+	if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
+		if [ -z "$(delayed_postinsts)" ]; then
+			# All packages were successfully configured.
+			# update-rc.d, base-passwd, run-postinsts are no further use, remove them now
+			remove_run_postinsts=false

Review

Quoted 10 lines
(quoted diff) +10 -0
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				remove_run_postinsts=true
+			fi
+			rootfs_remove_packages update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}
+
+			# Need to remove rc.d files for run-postinsts by hand since opkg won't
+			# call postrm scripts in offline root mode.
+			if $remove_run_postinsts; then
+				update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
+			fi

The above runs unconditionally for all package types. Will this cause an issue w/ RPM or deb? (I don't think it will, but I'm slightly worried about RPM and it's removal scripts.)

Quoted 4 lines
(quoted diff) +4 -0
+		else
+			# Some packages were not successfully configured, save them only
+			# if we have run-postinsts script present. Otherwise, they're
+			# useless

Review

Quoted 10 lines
(quoted diff) +10 -0
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				save_postinsts
+			fi
+		fi
+
+		# Since no package manager is present in the image the metadata is not needed
+		remove_packaging_data_files
+	fi
+}
+

Everything else looks fine.

#13 lore raw
Quoted 97 lines · Mark Hatle

Comments below....

Quoted 94 lines · Laurentiu Palcu

(cover letter only)

Changes in v2:
* addressed an RPM issue that happened on AB. Interestingly, it happened only on certain distros. Our internal AB (running on Ubuntu server 12.04), didn't show any issues. So, what was the problem? We use a scriptlet wrapper to run the pre/post install scriptlets. What I missed in the previous patchset was that I didn't use the scriptlet wrapper when running the pre/post remove scriptlets and the context in which they ran was not correct. Hence, the update-rc.d used was the host's...
* addresses Ross's request to move run-postinsts recipe out of dpkg directory,

    since it's generic now;

Paul, Mark would you please review the RPM changes please?

Thanks,
Laurentiu

Changes in v1:
Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed

    postinstalls on target when the PM is not part of the image;
  * opkg removes the meta-data and some uneeded packages whilst deb/rpm remove
    only the meta-data;

* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

Thanks,
Laurentiu

The following changes since commit a62aed41f2d8f874f7ae24d0e5be5dbc66ea2199:

   lrzsz: check locale.h in configure (2013-06-04 15:55:46 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclass: switch to using run-postinsts package_rpm.bbclass: handle pre/post remove scriptlets
rpm: replace rpm-postinsts dependency with run-postinsts

  meta/classes/image.bbclass                         |   33 ++++++++++++++
  meta/classes/package_rpm.bbclass                   |   16 ++++---
  meta/classes/rootfs_deb.bbclass                    |   23 +++++++++-
  meta/classes/rootfs_ipk.bbclass                    |   39 ++++++++--------
  meta/classes/rootfs_rpm.bbclass                    |   29 ++++++++++--
  meta/recipes-core/images/core-image-minimal.bb     |    2 -
  .../dpkg/run-postinsts/run-postinsts               |   36 ---------------
  .../dpkg/run-postinsts/run-postinsts.awk           |   30 -------------
  meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
  .../run-postinsts/run-postinsts/run-postinsts      |   47 ++++++++++++++++++++
  .../{dpkg => run-postinsts}/run-postinsts_1.0.bb   |    7 ++-
  11 files changed, 159 insertions(+), 105 deletions(-)

delete mode 100755 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk create mode 100755 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts rename meta/recipes-devtools/{dpkg => run-postinsts}/run-postinsts_1.0.bb (68%)

(quoted diff) +12 -0
+rootfs_remove_unneeded () {
+	if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
+		if [ -z "$(delayed_postinsts)" ]; then
+			# All packages were successfully configured.
+			# update-rc.d, base-passwd, run-postinsts are no further use, remove them now
+			remove_run_postinsts=false
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				remove_run_postinsts=true
+			fi
+			rootfs_remove_packages update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}
+
+			# Need to remove rc.d files for run-postinsts by hand since opkg won't
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+			# call postrm scripts in offline root mode.
+			if $remove_run_postinsts; then
+				update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
+			fi

The above runs unconditionally for all package types. Will this cause an issue w/ RPM or deb? (I don't think it will, but I'm slightly worried about RPM and it's removal scripts.)

I believe I missed to remove the opkg from the comment since I pasted this piece of code from rootfs_ipk.bbclass. However, during my tests, I saw no issues with rpm/deb. Is there anything in particular you think I should check for RPM to rule out your concerns?

Thanks,
Laurentiu

Quoted 20 lines
Quoted 5 lines
(quoted diff) +4 -0
+		else
+			# Some packages were not successfully configured, save them only
+			# if we have run-postinsts script present. Otherwise, they're
+			# useless

Review

Quoted 10 lines
(quoted diff) +10 -0
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				save_postinsts
+			fi
+		fi
+
+		# Since no package manager is present in the image the metadata is not needed
+		remove_packaging_data_files
+	fi
+}
+

Everything else looks fine.

#14 lore raw
Quoted 108 lines · Laurentiu Palcu
Quoted 97 lines · Mark Hatle

Comments below....

Quoted 94 lines · Laurentiu Palcu

(cover letter only)

Changes in v2:
* addressed an RPM issue that happened on AB. Interestingly, it happened only on certain distros. Our internal AB (running on Ubuntu server 12.04), didn't show any issues. So, what was the problem? We use a scriptlet wrapper to run the pre/post install scriptlets. What I missed in the previous patchset was that I didn't use the scriptlet wrapper when running the pre/post remove scriptlets and the context in which they ran was not correct. Hence, the update-rc.d used was the host's...
* addresses Ross's request to move run-postinsts recipe out of dpkg directory,

     since it's generic now;

Paul, Mark would you please review the RPM changes please?

Thanks,
Laurentiu

Changes in v1:
Hi all,

My work at #4484 revealed that the package managers deb/ipk/rpm handle removal of PM meta-data (when the PM is not deployed) and the delayed postinstalls execution in their own way. Currently we have:
* run-postinsts (for deb/ipk) and rpm-postinsts (for rpm) for running the delayed

     postinstalls on target when the PM is not part of the image;
   * opkg removes the meta-data and some uneeded packages whilst deb/rpm remove
     only the meta-data;

* both opkg and deb have no way of running the delayed postinstalls on target, if package-management is not part of IMAGE_FEATURES, because the meta-data was deleted (and it would have been useless anyway since the PM is not installed);

That being said, this patchset tries to create a more unified solution for all PM backends.

rpm-postinsts recipe is replaced by run-postinsts but I'll keep it in oe-core for a while (a couple of weeks maybe), just in case the current solution does not satisfy the RPM users (I doubt it though).

I did tests with core-image-minimal using sysvinit/systemd and with/without delayed postinstalls. The results are as expected.

Thanks,
Laurentiu

The following changes since commit a62aed41f2d8f874f7ae24d0e5be5dbc66ea2199:

    lrzsz: check locale.h in configure (2013-06-04 15:55:46 +0100)

are available in the git repository at:

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

Laurentiu Palcu (7):
rootfs_*.bbclass: add some helper functions image.bbclass: remove unneeded files from the image
core-image-minimal: do not remove packaging files in the rootfs
postprocess
run-postinsts: make it generic
rootfs_rpm.bbclass: switch to using run-postinsts package_rpm.bbclass: handle pre/post remove scriptlets
rpm: replace rpm-postinsts dependency with run-postinsts

   meta/classes/image.bbclass                         |   33 ++++++++++++++
   meta/classes/package_rpm.bbclass                   |   16 ++++---
   meta/classes/rootfs_deb.bbclass                    |   23 +++++++++-
   meta/classes/rootfs_ipk.bbclass                    |   39 ++++++++--------
   meta/classes/rootfs_rpm.bbclass                    |   29 ++++++++++--
   meta/recipes-core/images/core-image-minimal.bb     |    2 -
   .../dpkg/run-postinsts/run-postinsts               |   36 ---------------
   .../dpkg/run-postinsts/run-postinsts.awk           |   30 -------------
   meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    2 +-
   .../run-postinsts/run-postinsts/run-postinsts      |   47 ++++++++++++++++++++
   .../{dpkg => run-postinsts}/run-postinsts_1.0.bb   |    7 ++-
   11 files changed, 159 insertions(+), 105 deletions(-)

delete mode 100755 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts delete mode 100644 meta/recipes-devtools/dpkg/run-postinsts/run-postinsts.awk create mode 100755 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts rename meta/recipes-devtools/{dpkg => run-postinsts}/run-postinsts_1.0.bb (68%)

(quoted diff) +12 -0
+rootfs_remove_unneeded () {
+	if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
+		if [ -z "$(delayed_postinsts)" ]; then
+			# All packages were successfully configured.
+			# update-rc.d, base-passwd, run-postinsts are no further use, remove them now
+			remove_run_postinsts=false
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				remove_run_postinsts=true
+			fi
+			rootfs_remove_packages update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}
+
+			# Need to remove rc.d files for run-postinsts by hand since opkg won't
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+			# call postrm scripts in offline root mode.
+			if $remove_run_postinsts; then
+				update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
+			fi

The above runs unconditionally for all package types. Will this cause an issue w/ RPM or deb? (I don't think it will, but I'm slightly worried about RPM and it's removal scripts.)

Quoted 4 lines

I believe I missed to remove the opkg from the comment since I pasted this piece of code from rootfs_ipk.bbclass. However, during my tests, I saw no issues with rpm/deb. Is there anything in particular you think I should check for RPM to rule out your concerns?

Simply that the update-rc.d will be run by the RPM rule, and rerun in the above.

As long as that doesn't cause a problem, I'm fine with the change.

--Mark

Quoted 22 lines

Thanks,
Laurentiu

Quoted 20 lines
Quoted 5 lines
(quoted diff) +4 -0
+		else
+			# Some packages were not successfully configured, save them only
+			# if we have run-postinsts script present. Otherwise, they're
+			# useless

Review

Quoted 10 lines
(quoted diff) +10 -0
+			if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
+				save_postinsts
+			fi
+		fi
+
+		# Since no package manager is present in the image the metadata is not needed
+		remove_packaging_data_files
+	fi
+}
+

Everything else looks fine.