Skip to contentSkip to conversation

Fixes for run-postinsts in sysvinit and systemd

PATCH In review Chen Qi 2 participants 7 messages Jan 13, 2014 – Jan 23, 2014

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

cover Fixes for run-postinsts in sysvinit and systemd

The following changes since commit 1b636173ca88e5ccca1992f9a12367a1189fa674:

bitbake: toaster: Toaster GUI, generic search, filter and order (2014-01-10 15:20:26 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/run-postinsts-fixes
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/run-postinsts-fixes

Chen Qi (2):
run-postinsts: remove the init script after a clean start-up
systemd-compat-units: make run-postinsts.service work correctly on
target

 meta/recipes-core/systemd/systemd-compat-units.bb  |    8 --------
 .../systemd-compat-units/run-postinsts.service     |    4 ++--
 .../run-postinsts/run-postinsts/run-postinsts      |   15 +++++++++++----
 3 files changed, 13 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/2 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
index c94c3e9..11141ec 100755
@@ -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
author
#2 lore raw

PATCH 2/2 systemd-compat-units: make run-postinsts.service work correctly on target

In reply to Chen Qi

If we are using systemd as the init manager and rpm as the package back-end, then the post-install script would not run at system start-up.

The problem is that we now have two init scripts to deal with post-install scripts in our system. They are installed as /etc/rcS.d/S98run-postinsts and /etc/rcS.d/S99run-postinsts respectively, however, the run-postinsts.service in systemd only deals with the former one.

This patch fixes this problem to make run-postinsts.service work correctly for the three package back-ends with/without 'package-management' in the IMAGE_FEATURES.

This patch also hardcodes 98 and 99 instead of using POSTINSTALL_INITPOSITION because using that variable doesn't bring anything useful.

[YOCTO #5719]

---
 meta/recipes-core/systemd/systemd-compat-units.bb  |    8 --------
 .../systemd-compat-units/run-postinsts.service     |    4 ++--
 2 files changed, 2 insertions(+), 10 deletions(-)
meta/recipes-core/systemd/systemd-compat-units.bb +0 -8
index 9f28283..5a6adb2 100644
@@ -14,8 +14,6 @@ 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/
@@ -50,9 +48,3 @@ pkg_postinst_${PN} () {
 
 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 +2 -2
index 35cf3d3..1dc7b1a 100644
@@ -1,12 +1,12 @@
 [Unit]
 Description=Run pending postinsts
 DefaultDependencies=no
-ConditionPathExists=|/etc/rcS.d/S@POSTINSTALL_INITPOSITION@run-postinsts
+ConditionPathExistsGlob=/etc/rcS.d/S*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
+ExecStart=-/etc/rcS.d/S98run-postinsts ; -/etc/rcS.d/S99run-postinsts
 RemainAfterExit=No
 Type=oneshot
 StandardOutput=syslog
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH 2/2] systemd-compat-units: make run-postinsts.service work correctly on target

Quoted 1 line · Chen Qi

+ExecStart=-/etc/rcS.d/S98run-postinsts ; -/etc/rcS.d/S99run-postinsts

Can we just make opkg and run-postinsts write that file using the same number?

Also, that service file needs to move directly into run-postinsts. There's a start in poky-contrib:ross/postinsts if you want to finish it off. :)

Ross

author
#4 lore raw

Re: [PATCH 2/2] systemd-compat-units: make run-postinsts.service work correctly on target

Quoted 11 lines · Ross
Quoted 1 line · Chen Qi

+ExecStart=-/etc/rcS.d/S98run-postinsts ; -/etc/rcS.d/S99run-postinsts

Can we just make opkg and run-postinsts write that file using the same number?

Also, that service file needs to move directly into run-postinsts. There's a start in poky-contrib:ross/postinsts if you want to finish it off. :)

Ross

Hi Ross,

As you have started working on this problem, I think I'll just drop this patch.

After looking at your branch, I think there's only one thing to look out for. When we're using ipk/dpkg as the package back-end, and 'package-management' is in IMAGE_FEATURES, there would be no /etc/*-postinsts.

Best Regards,
Chen Qi

#5 lore raw

Re: [PATCH 2/2] systemd-compat-units: make run-postinsts.service work correctly on target

Quoted 7 lines · ChenQi

As you have started working on this problem, I think I'll just drop this patch.

After looking at your branch, I think there's only one thing to look out for. When we're using ipk/dpkg as the package back-end, and 'package-management' is in IMAGE_FEATURES, there would be no /etc/*-postinsts.

I started but didn't finish - as you've taken the systemd bugs could you finish this off? Pretty sure I filed a bug to go with it.

Ross

author
#6 lore raw

Re: [PATCH 2/2] systemd-compat-units: make run-postinsts.service work correctly on target

Quoted 4 lines · Ross
Quoted 3 lines · ChenQi

As you have started working on this problem, I think I'll just drop this patch.

Quoted 10 lines
Quoted 4 lines

After looking at your branch, I think there's only one thing to look out for. When we're using ipk/dpkg as the package back-end, and 'package-management' is in IMAGE_FEATURES, there would be no /etc/*-postinsts.

I started but didn't finish - as you've taken the systemd bugs could you finish this off? Pretty sure I filed a bug to go with it.

Ross

OK.

Best Regards,
Chen Qi