diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2015-09-15 22:41:29 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2015-09-15 22:41:29 +0300 |
commit | 21f9b84b4b729fbd7acbd465e7a3f726e4d20f91 (patch) | |
tree | eb2d091d427ca0813b445509d59cc8e27e8ad25f /yocto-poky/meta/recipes-devtools/run-postinsts | |
parent | 101cef31e2bf54c678501155cd2106251acbd076 (diff) | |
parent | c124f4f2e04dca16a428a76c89677328bc7bf908 (diff) | |
download | openbmc-21f9b84b4b729fbd7acbd465e7a3f726e4d20f91.tar.xz |
Merge commit 'c124f4f2e04dca16a428a76c89677328bc7bf908' as 'yocto-poky'
Diffstat (limited to 'yocto-poky/meta/recipes-devtools/run-postinsts')
4 files changed, 156 insertions, 0 deletions
diff --git a/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts new file mode 100755 index 000000000..53a8e1db0 --- /dev/null +++ b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts @@ -0,0 +1,92 @@ +#!/bin/sh +# +# Copyright 2007 Openedhand Ltd. +# +# Author: Richard Purdie <rpurdie@openedhand.com> +# + +# The following script will run all the scriptlets found in #SYSCONFDIR#/deb-postinsts, +# #SYSCONFDIR#/ipk-postinsts or #SYSCONFDIR#/rpm-posinsts. + +# the order of this list is important, do not change! +backend_list="rpm deb ipk" + +pm_installed=false + +for pm in $backend_list; do + pi_dir="#SYSCONFDIR#/$pm-postinsts" + + [ -d $pi_dir ] && break + + case $pm in + "deb") + if [ -s "#LOCALSTATEDIR#/lib/dpkg/status" ]; then + pm_installed=true + break + fi + ;; + + "ipk") + if [ -s "/var/lib/opkg/status" ]; then + pm_installed=true + break + fi + ;; + esac +done + +remove_rcsd_link () { + if [ -n "`which update-rc.d`" ]; then + update-rc.d -f run-postinsts remove + fi +} + +if [ -z "$pi_dir" ]; then + remove_rcsd_link + exit 0 +fi + +[ -e #SYSCONFDIR#/default/postinst ] && . #SYSCONFDIR#/default/postinst + +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 + echo "ERROR: postinst $i failed." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log + remove_pi_dir=0 + fi + done +} + +remove_pi_dir=1 +if $pm_installed; then + case $pm in + "ipk") + eval opkg configure $append_log + ;; + + "deb") + eval dpkg --configure -a $append_log + ;; + esac +else + exec_postinst_scriptlets +fi + +# since all postinstalls executed successfully, remove the postinstalls directory +# and the rcS.d link +if [ $remove_pi_dir = 1 ]; then + rm -rf $pi_dir + remove_rcsd_link +fi diff --git a/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.init b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.init new file mode 100644 index 000000000..473a1f7f6 --- /dev/null +++ b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.init @@ -0,0 +1,3 @@ +#!/bin/sh + +run-postinsts diff --git a/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.service b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.service new file mode 100644 index 000000000..85a043949 --- /dev/null +++ b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.service @@ -0,0 +1,16 @@ +[Unit] +Description=Run pending postinsts +DefaultDependencies=no +After=systemd-remount-fs.service systemd-tmpfiles-setup.service tmp.mount +Before=sysinit.target +ConditionPathExistsGlob=#SYSCONFDIR#/*-postinsts + +[Service] +Type=oneshot +ExecStart=#SBINDIR#/run-postinsts +ExecStartPost=#BASE_BINDIR#/systemctl disable run-postinsts.service +RemainAfterExit=No +TimeoutSec=0 + +[Install] +WantedBy=sysinit.target diff --git a/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb new file mode 100644 index 000000000..11c94e57d --- /dev/null +++ b/yocto-poky/meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb @@ -0,0 +1,45 @@ +SUMMARY = "Runs postinstall scripts on first boot of the target device" +SECTION = "devel" +PR = "r9" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ + file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +SRC_URI = "file://run-postinsts \ + file://run-postinsts.init \ + file://run-postinsts.service" + +S = "${WORKDIR}" + +inherit allarch systemd update-rc.d + +INITSCRIPT_NAME = "run-postinsts" +INITSCRIPT_PARAMS = "start 99 S ." + +SYSTEMD_SERVICE_${PN} = "run-postinsts.service" + +do_configure() { + : +} + +do_compile () { + : +} + +do_install() { + install -d ${D}${sbindir} + install -m 0755 ${WORKDIR}/run-postinsts ${D}${sbindir}/ + + install -d ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/run-postinsts.init ${D}${sysconfdir}/init.d/run-postinsts + + install -d ${D}${systemd_unitdir}/system/ + install -m 0644 ${WORKDIR}/run-postinsts.service ${D}${systemd_unitdir}/system/ + + sed -i -e 's:#SYSCONFDIR#:${sysconfdir}:g' \ + -e 's:#SBINDIR#:${sbindir}:g' \ + -e 's:#BASE_BINDIR#:${base_bindir}:g' \ + -e 's:#LOCALSTATEDIR#:${localstatedir}:g' \ + ${D}${sbindir}/run-postinsts \ + ${D}${systemd_unitdir}/system/run-postinsts.service +} |