Unique run-postinsts
cover Unique run-postinsts
This patchset removes the opkg/dpkg postinstalls that were creating their own run-postinsts script which, sometimes, confused people... Instead, use the already available run-postinsts recipe in order to create the run-postinsts init script. It will be used for both 'package-management'/no 'package-management' in DISTRO_FEATURES.
In my tests I tried to cover as much usecases as possible, in various combinations:
* rpm/ipk/deb;
* package-management/no package-management;
* delayed/no delayed postinstalls;
* sysvinit/systemd;
I hope I covered most of them. If there are any other 'dirty' usecases I should be aware of, don't be shy.
laurentiu
The following changes since commit a01af0202558e6ed9d16590b3a8d1dd1b95c0374:
recipes: bump PRs (2014-03-05 17:36:37 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib lpalcu/b5666_unique_run_postinsts
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=lpalcu/b5666_unique_run_postinsts
Laurentiu Palcu (2):
run-postinsts: use it for opkg/dpkg too
opkg/dpkg: remove the postinstalls
meta/recipes-devtools/dpkg/dpkg.inc | 24 +------- meta/recipes-devtools/opkg/opkg.inc | 28 +-------- .../run-postinsts/run-postinsts/run-postinsts | 63 +++++++++++++------- .../run-postinsts/run-postinsts_1.0.bb | 2 + 4 files changed, 44 insertions(+), 73 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 run-postinsts: use it for opkg/dpkg too
Currently, opkg/dpkg have their own postinstalls that create a run-postinsts script which is run at first boot.
This commit prepares the run-postinsts recipe/script to be used by opkg/dpkg when DISTRO_FEATURES includes package-management.
[YOCTO #5666]
--- .../run-postinsts/run-postinsts/run-postinsts | 63 +++++++++++++------- .../run-postinsts/run-postinsts_1.0.bb | 2 + 2 files changed, 42 insertions(+), 23 deletions(-)
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts +40 -23
@@ -8,13 +8,9 @@ # The following script will run all the scriptlets found in #SYSCONFDIR#/deb-postinsts, # #SYSCONFDIR#/ipk-postinsts or #SYSCONFDIR#/rpm-posinsts. -pi_dir="" -for pm in rpm deb ipk; do - if [ -d "#SYSCONFDIR#/${pm}-postinsts" ]; then - pi_dir=#SYSCONFDIR#/${pm}-postinsts - break - fi -done +pm=#IMAGE_PKGTYPE# +pm_installed=#PM_INSTALLED# +pi_dir=#SYSCONFDIR#/${pm}-postinsts remove_rcsd_link () { if [ -n "`which update-rc.d`" ]; then
@@ -29,24 +25,45 @@ 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..." - [ "$POSTINST_LOGGING" = "1" ] && echo "Running postinst $i..." >> $LOGFILE - if [ -x $i ]; then - if [ "$POSTINST_LOGGING" = "1" ]; then - sh -c $i >>$LOGFILE 2>&1 +if [ "$POSTINST_LOGGING" = "1" ]; then + rm -f $LOGFILE + append_log=">>$LOGFILE 2>&1" +fi + +exec_postinst_scriptlets() { + for i in `ls $pi_dir`; do + i=$pi_dir/$i + echo "Running postinst $i..." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log + if [ -x $i ]; then + eval sh -c $i $append_log + rm $i else - sh -c $i + echo "ERROR: postinst $i failed." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log + remove_pi_dir=0 fi - rm $i - else - echo "ERROR: postinst $i failed." - [ "$POSTINST_LOGGING" = "1" ] && echo "ERROR: postinst $i failed." >> $LOGFILE - remove_pi_dir=0 - fi -done + done +} + +remove_pi_dir=1 +if $pm_installed; then + case $pm in + "ipk") + eval opkg-cl configure $append_log + ;; + + "deb") + eval dpkg --configure -a $append_log + ;; + + "rpm") + exec_postinst_scriptlets + ;; + esac +else + exec_postinst_scriptlets +fi # since all postinstalls executed successfully, remove the postinstalls directory # and the rcS.d link
meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb +2 -0
@@ -37,6 +37,8 @@ do_install() { sed -i -e 's:#SYSCONFDIR#:${sysconfdir}:g' \ -e 's:#SBINDIR#:${sbindir}:g' \ -e 's:#BASE_BINDIR#:${base_bindir}:g' \ + -e 's:#IMAGE_PKGTYPE#:${IMAGE_PKGTYPE}:g' \ + -e 's:#PM_INSTALLED#:${@base_contains("IMAGE_FEATURES", "package-management", "true", "false", d)}:g' \ ${D}${sbindir}/run-postinsts \ ${D}${systemd_unitdir}/system/run-postinsts.service }
Signature · 1 line
1.7.9.5
PATCH 2/2 opkg/dpkg: remove the postinstalls
In reply to Laurentiu PalcuJust use the run-postinsts recipe for running first boot postinstalls.
[YOCTO #5666]
--- meta/recipes-devtools/dpkg/dpkg.inc | 24 +----------------------- meta/recipes-devtools/opkg/opkg.inc | 28 +--------------------------- 2 files changed, 2 insertions(+), 50 deletions(-)
meta/recipes-devtools/dpkg/dpkg.inc +1 -23
@@ -7,7 +7,7 @@ SRC_URI = "${DEBIAN_MIRROR}/main/d/dpkg/dpkg_${PV}.tar.xz \ DEPENDS = "zlib bzip2 perl ncurses" DEPENDS_class-native = "bzip2-replacement-native zlib-native virtual/update-alternatives-native gettext-native perl-native" -RDEPENDS_${PN} = "${VIRTUAL-RUNTIME_update-alternatives} xz" +RDEPENDS_${PN} = "${VIRTUAL-RUNTIME_update-alternatives} xz run-postinsts" RDEPENDS_${PN}_class-native = "xz-native" S = "${WORKDIR}/${BPN}-${PV}"
@@ -43,8 +43,6 @@ do_configure () { autotools_do_configure } -DPKG_INIT_POSITION ?= "98" - do_install_append () { if [ "${PN}" = "dpkg-native" ]; then # update-alternatives doesn't have an offline mode
@@ -66,26 +64,6 @@ do_install_append () { fi } -pkg_postinst_${PN} () { -#!/bin/sh -if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)} && \ - [ "x$D" != "x" ] && [ -f $D/var/lib/dpkg/status ]; then - install -d $D${sysconfdir}/rcS.d - - # this happens at S98 where our good 'ole packages script used to run - echo "#!/bin/sh -[ -e ${sysconfdir}/default/postinst ] && . ${sysconfdir}/default/postinst -if [ \"\$POSTINST_LOGGING\" = \"1\" ]; then - dpkg --configure -a >\$LOGFILE 2>&1 -else - dpkg --configure -a -fi -rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts -" > $D${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts - chmod 0755 $D${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts -fi -} - PROV = "virtual/update-alternatives" PROV_class-native = ""
meta/recipes-devtools/opkg/opkg.inc +1 -27
@@ -38,7 +38,7 @@ EXTRA_OECONF = "\ --with-opkglibdir=${OPKGLIBDIR} \ " -RDEPENDS_${PN} = "${VIRTUAL-RUNTIME_update-alternatives} opkg-config-base" +RDEPENDS_${PN} = "${VIRTUAL-RUNTIME_update-alternatives} opkg-config-base run-postinsts" RDEPENDS_${PN}_class-native = "" RDEPENDS_${PN}_class-nativesdk = "" RREPLACES_${PN} = "opkg-nogpg"
@@ -73,30 +73,4 @@ do_install_append() { rm ${D}${bindir}/update-alternatives } -pkg_postinst_${PN} () { -#!/bin/sh -if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)} && \ - [ "x$D" != "x" ] && [ -f $D${OPKGLIBDIR}/opkg/status ]; then - install -d $D${sysconfdir}/rcS.d - - # this happens at S98 where our good 'ole packages script used to run - echo "#!/bin/sh -[ -e ${sysconfdir}/default/postinst ] && . ${sysconfdir}/default/postinst -if [ \"\$POSTINST_LOGGING\" = \"1\" ]; then - opkg-cl configure >\$LOGFILE 2>&1 -else - opkg-cl configure -fi -rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts -" > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts - chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts -fi -} - BBCLASSEXTEND = "native nativesdk" - -# Define a variable to allow distros to run configure earlier. -# (for example, to enable loading of ethernet kernel modules before networking starts) -# note: modifying name or default value for POSTINSTALL_INITPOSITION requires -# changes in systemd-compat-units.bb -POSTINSTALL_INITPOSITION ?= "98"
Signature · 1 line
1.7.9.5