Fixes for run-postinsts
cover Fixes for run-postinsts
This patchset is target to making run-postinsts work on systemd based images no matter 'package-management' is in IMAGE_FEATURES or not.
//Chen Qi
The following changes since commit 24d5b449e5f4d91119f0d8e13c457618811aadfc:
libtool-cross/native: Force usage of bash due to sstate inconsistencies (2014-01-23 12:14:34 +0000)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib ChenQi/postinsts-fixes
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=ChenQi/postinsts-fixes
Chen Qi (2):
run-postinsts: remove the init script after a clean start-up
dpkg: use systemd service for first boot configuration
Ross Burton (3):
run-postinsts: Add systemd service file
systemd-compat-units: remove run-postints service image.bbclass: fix paths to run-postinsts
meta/classes/image.bbclass | 4 ++--
meta/recipes-core/systemd/systemd-compat-units.bb | 19 +----------------
meta/recipes-devtools/dpkg/dpkg.inc | 21 +++++++++++++++++--
.../dpkg/dpkg/dpkg-configure.service | 17 +++++++++++++++
meta/recipes-devtools/dpkg/dpkg_1.17.4.bb | 1 +
.../run-postinsts/run-postinsts/run-postinsts | 15 +++++++++----
.../run-postinsts/run-postinsts/run-postinsts.init | 3 +++
.../run-postinsts}/run-postinsts.service | 8 +++----
.../run-postinsts/run-postinsts_1.0.bb | 22 ++++++++++++++++----
9 files changed, 76 insertions(+), 34 deletions(-)
create mode 100644 meta/recipes-devtools/dpkg/dpkg/dpkg-configure.service
create mode 100644 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.init
rename meta/{recipes-core/systemd/systemd-compat-units => recipes-devtools/run-postinsts/run-postinsts}/run-postinsts.service (63%)Signature · 1 line
1.7.9.5
PATCH 1/5 run-postinsts: remove the init script after a clean start-up
If we enable ipk/deb package back-end, and we have 'package-management' in our IMAGE_FEATURES, then the /etc/rcS.d/S99run-postinsts would still exist in our system after a clean start-up.
The initial design for run-postinsts requires the related init script to be removed if there's no more post-install script left in the system.
This patch fixes this problem.
[YOCTO #5718]
--- .../run-postinsts/run-postinsts/run-postinsts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts +11 -4
@@ -16,7 +16,16 @@ for pm in rpm deb ipk; do fi done -[ -z "$pi_dir" ] && exit 0 +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
@@ -43,7 +52,5 @@ done # 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 + remove_rcsd_link fi
Signature · 1 line
1.7.9.5
PATCH 2/5 run-postinsts: Add systemd service file
In reply to Chen QiFrom: Ross Burton <[email protected]>
This patch mainly adds a systmd service file for run-postinsts, which is started at first boot to run the post-install scripts.
Apart from this, this patch also modifies the installation location of run-postinsts to ${sbindir}. This is because this script would be used by both sysvinit and systemd based images. So it's more reasonable to make it locate under ${sbindir}.
[YOCTO #5719]
--- .../run-postinsts/run-postinsts/run-postinsts.init | 3 +++ .../run-postinsts/run-postinsts.service | 17 +++++++++++++++ .../run-postinsts/run-postinsts_1.0.bb | 22 ++++++++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.init create mode 100644 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.service
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.init new file +3 -0
@@ -0,0 +1,3 @@ +#!/bin/sh + +run-postinsts
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts.service new file +17 -0
@@ -0,0 +1,17 @@ +[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=basic.target +WantedBy=sysinit.target
meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb +18 -4
@@ -5,12 +5,16 @@ LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" -SRC_URI = "file://run-postinsts" +SRC_URI = "file://run-postinsts \ + file://run-postinsts.init \ + file://run-postinsts.service" + +inherit allarch systemd update-rc.d INITSCRIPT_NAME = "run-postinsts" INITSCRIPT_PARAMS = "start 99 S ." -inherit update-rc.d +SYSTEMD_SERVICE_${PN} = "run-postinsts.service" do_configure() { :
@@ -21,8 +25,18 @@ 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 ${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' ${D}${sysconfdir}/init.d/run-postinsts + sed -i -e 's:#SYSCONFDIR#:${sysconfdir}:g' \ + -e 's:#SBINDIR#:${sbindir}:g' \ + -e 's:#BASE_BINDIR#:${base_bindir}:g' \ + ${D}${sbindir}/run-postinsts \ + ${D}${systemd_unitdir}/system/run-postinsts.service }
Signature · 1 line
1.7.9.5
PATCH 3/5 systemd-compat-units: remove run-postints service
In reply to Chen QiFrom: Ross Burton <[email protected]>
Remove this service as it's moved to the run-postinsts recipe.
[YOCTO #5719]
--- meta/recipes-core/systemd/systemd-compat-units.bb | 19 +------------------ .../systemd-compat-units/run-postinsts.service | 17 ----------------- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 meta/recipes-core/systemd/systemd-compat-units/run-postinsts.service
meta/recipes-core/systemd/systemd-compat-units.bb +1 -18
@@ -9,17 +9,7 @@ DEPENDS = "systemd-systemctl-native" inherit allarch -SRC_URI = "file://*.service" - -do_install() { - install -d ${D}${systemd_unitdir}/system/basic.target.wants - install -d ${D}${systemd_unitdir}/system/sysinit.target.wants/ - sed -i -e 's,@POSTINSTALL_INITPOSITION@,${POSTINSTALL_INITPOSITION},g' \ - ${WORKDIR}/run-postinsts.service - install -m 0644 ${WORKDIR}/run-postinsts.service ${D}${systemd_unitdir}/system - ln -sf ../run-postinsts.service ${D}${systemd_unitdir}/system/basic.target.wants/ - ln -sf ../run-postinsts.service ${D}${systemd_unitdir}/system/sysinit.target.wants/ -} +ALLOW_EMPTY_${PN} = "1" SYSTEMD_DISABLED_SYSV_SERVICES = " \ busybox-udhcpc \
@@ -47,11 +37,4 @@ pkg_postinst_${PN} () { done ; echo } -FILES_${PN} = "${systemd_unitdir}/system ${bindir}" RDPEPENDS_${PN} = "systemd" - -# 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 opkg.inc -POSTINSTALL_INITPOSITION ?= "98"
meta/recipes-core/systemd/systemd-compat-units/run-postinsts.service deleted +0 -17
@@ -1,17 +0,0 @@ -[Unit] -Description=Run pending postinsts -DefaultDependencies=no -ConditionPathExists=|/etc/rcS.d/S@POSTINSTALL_INITPOSITION@run-postinsts -After=systemd-remount-fs.service systemd-tmpfiles-setup.service tmp.mount -Before=sysinit.target - -[Service] -ExecStart=/etc/rcS.d/S@POSTINSTALL_INITPOSITION@run-postinsts -RemainAfterExit=No -Type=oneshot -StandardOutput=syslog -TimeoutSec=0 - -[Install] -WantedBy=basic.target -WantedBy=sysinit.target
Signature · 1 line
1.7.9.5
PATCH 4/5 image.bbclass: fix paths to run-postinsts
In reply to Chen QiFrom: Ross Burton <[email protected]>
The run-postinsts script has been moved to ${sbindir}.
[YOCTO #5719]
--- meta/classes/image.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/image.bbclass +2 -2
@@ -531,7 +531,7 @@ rootfs_uninstall_unneeded () { # 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 + if [ -e ${IMAGE_ROOTFS}${sbindir}/run-postinsts ]; then remove_run_postinsts=true fi
@@ -555,7 +555,7 @@ rootfs_uninstall_unneeded () { # 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 + if [ -e ${IMAGE_ROOTFS}${sbindir}/run-postinsts ]; then save_postinsts fi fi
Signature · 1 line
1.7.9.5
PATCH 5/5 dpkg: use systemd service for first boot configuration
In reply to Chen QiUse a systemd service file for first boot configuration for dpkg based images which has 'package-management' in its IMAGE_FEATURES.
[YOCTO #5719]
--- meta/recipes-devtools/dpkg/dpkg.inc | 21 ++++++++++++++++++-- .../dpkg/dpkg/dpkg-configure.service | 17 ++++++++++++++++ meta/recipes-devtools/dpkg/dpkg_1.17.4.bb | 1 + 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/dpkg/dpkg/dpkg-configure.service
meta/recipes-devtools/dpkg/dpkg.inc +19 -2
@@ -14,7 +14,13 @@ S = "${WORKDIR}/${BPN}-${PV}" PARALLEL_MAKE = "" -inherit autotools gettext perlnative pkgconfig +inherit autotools gettext perlnative pkgconfig systemd + +python () { + if not oe.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): + pn = d.getVar('PN', True) + d.setVar('SYSTEMD_SERVICE_%s' % (pn), 'dpkg-configure.service') +} export PERL = "${bindir}/perl" PERL_class-native = "${STAGING_BINDIR_NATIVE}/perl-native/perl"
@@ -48,11 +54,22 @@ do_install_append () { mv ${D}${bindir}/update-alternatives ${D}${sbindir} sed -i -e 's|^#!.*${bindir}/perl-native.*/perl|#!/usr/bin/env perl|' ${D}${bindir}/dpkg-* fi + + if ${@base_contains('DISTRO_FEATURES','sysvinit','false','true',d)};then + install -d ${D}${systemd_unitdir}/system + install -m 0644 ${WORKDIR}/dpkg-configure.service ${D}${systemd_unitdir}/system/ + sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ + -e 's,@SYSCONFDIR@,${sysconfdir},g' \ + -e 's,@BINDIR@,${bindir},g' \ + -e 's,@SYSTEMD_UNITDIR@,${systemd_unitdir},g' \ + ${D}${systemd_unitdir}/system/dpkg-configure.service + fi } pkg_postinst_${PN} () { #!/bin/sh -if [ "x$D" != "x" ] && [ -f $D/var/lib/dpkg/status ]; then +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
meta/recipes-devtools/dpkg/dpkg/dpkg-configure.service new file +17 -0
@@ -0,0 +1,17 @@ +[Unit] +Description=dpkg first boot configure +DefaultDependencies=no +After=systemd-remount-fs.service systemd-tmpfiles-setup.service tmp.mount +Before=sysinit.target + +[Service] +Type=oneshot +EnvironmentFile=-@SYSCONFDIR@/default/postinst +ExecStart=-@BASE_BINDIR@/sh -c " if [ $POSTINST_LOGGING = '1' ]; then @BINDIR@/dpkg --configure -a > $LOGFILE 2>&1; else @BINDIR@/dpkg --configure -a; fi" +ExecStartPost=@BASE_BINDIR@/systemctl disable dpkg-configure.service +StandardOutput=syslog +RemainAfterExit=No + +[Install] +WantedBy=basic.target +WantedBy=sysinit.target
meta/recipes-devtools/dpkg/dpkg_1.17.4.bb +1 -0
@@ -9,6 +9,7 @@ SRC_URI += "file://noman.patch \ file://remove-tar-no-timestamp.patch \ file://fix-abs-redefine.patch \ file://arch_pm.patch \ + file://dpkg-configure.service \ " SRC_URI[md5sum] = "cc25086e1e3bd9512a95f14cfe9002e1"
Signature · 1 line
1.7.9.5