Skip to contentSkip to conversation

sysklogd: fix update-rc.d handling

PATCH Applied Andy Ross 2 participants 2 messages Oct 11, 2012 – Oct 18, 2012

lore
Share & tools
lore

Andy Ross

author
#0 lore raw

PATCH 1/1 sysklogd: fix update-rc.d handling

The sysklogd recipe had a cut-n-paste version of the update-rc.d.bbclass code which didn't work, but this was hidden because all images contain the busybox version which does. Building a busybox-free image unmasked the issue and syslogd wouldn't start on first boot.

The comments seem to be wrong/stale. AFAICT update-rc.d and update-alternatives work fine with each other, though there is an ordering constraint (alternatives must be specified last, so it "wraps" update-rc.d). This version builds and works both with and without busybox.

---
 meta/recipes-extended/sysklogd/sysklogd.inc | 43 +----------------------------
 1 file changed, 1 insertion(+), 42 deletions(-)
meta/recipes-extended/sysklogd/sysklogd.inc +1 -42
index 151babb..1167328 100644
@@ -11,10 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
                     file://klogd.c;beginline=2;endline=19;md5=7e87ed0ae6142de079bce738c10c899d \
                    "
 
-# syslog initscript is handled explicitly because order of
-# update-rc.d and update-alternatives is important (see below)
-DEPENDS_append = " update-rc.d update-rc.d-native"
-RDEPENDS_${PN}_append = " update-rc.d"
+inherit update-rc.d update-alternatives
 
 SRC_URI = "http://www.infodrom.org/projects/sysklogd/download/sysklogd-${PV}.tar.gz \
            file://no-strip-install.patch \
@@ -41,22 +38,6 @@ do_install () {
 	install -m 755 ${WORKDIR}/sysklogd ${D}${sysconfdir}/init.d/syslog
 }
 
-pkg_preinst_${PN} () {
-	# all this is needed to avoid sysmlink errors,
-	# because update-rc.d runs before pkg_postinst
-	ETC=$D${sysconfdir}
-
-	if [ -e $ETC/init.d/syslog -a ! -L $ETC/init.d/syslog ]; then
-		echo "WARNING:" "non symlink ${sysconfdir}/init.d/syslog exist -> backup to ${sysconfdir}/init.d/syslog.old"
-		mv $ETC/init.d/syslog $ETC/init.d/syslog.old
-	fi
-	if [ ! -e $ETC/init.d/syslog ]; then
-		ln -s dummy $ETC/init.d/syslog
-	fi
-}
-
-inherit update-alternatives
-
 ALTERNATIVE_PRIORITY = "100"
 
 ALTERNATIVE_${PN} = "syslogd klogd syslog-init syslog-conf"
@@ -66,15 +47,6 @@ ALTERNATIVE_LINK_NAME[klogd] = "${base_sbindir}/klogd"
 ALTERNATIVE_LINK_NAME[syslog-init] = "${sysconfdir}/init.d/syslog"
 ALTERNATIVE_LINK_NAME[syslog-conf] = "${sysconfdir}/syslog.conf"
 
-pkg_postinst_${PN} () {
-	if test "x$D" != "x"; then
-	OPT="-r $D"
-	else
-	OPT="-s"
-	fi
-	update-rc.d $OPT syslog defaults
-}
-
 pkg_prerm_${PN} () {
 	if test "x$D" = "x"; then
 	if test "$1" = "upgrade" -o "$1" = "remove"; then
@@ -82,16 +54,3 @@ pkg_prerm_${PN} () {
 	fi
 	fi
 }
-
-pkg_postrm_${PN} () {
-	if test "x$D" != "x"; then
-	OPT="-r $D"
-	else
-	OPT=""
-	fi
-	if test "$1" = "remove" -o "$1" = "purge"; then
-	if ! test -e "/etc/init.d/syslog"; then
-	    update-rc.d $OPT syslog remove
-	fi
-	fi
-}
Signature · 1 line
1.7.11.4
Applied
#1 lore raw
Quoted 86 lines · Andy Ross

The sysklogd recipe had a cut-n-paste version of the update-rc.d.bbclass code which didn't work, but this was hidden because all images contain the busybox version which does. Building a busybox-free image unmasked the issue and syslogd wouldn't start on first boot.

The comments seem to be wrong/stale. AFAICT update-rc.d and update-alternatives work fine with each other, though there is an ordering constraint (alternatives must be specified last, so it "wraps" update-rc.d). This version builds and works both with and without busybox.

---
  meta/recipes-extended/sysklogd/sysklogd.inc | 43 +----------------------------
  1 file changed, 1 insertion(+), 42 deletions(-)
meta/recipes-extended/sysklogd/sysklogd.inc +1 -29
index 151babb..1167328 100644
@@ -11,10 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
                      file://klogd.c;beginline=2;endline=19;md5=7e87ed0ae6142de079bce738c10c899d \
                     "
 
-# syslog initscript is handled explicitly because order of
-# update-rc.d and update-alternatives is important (see below)
-DEPENDS_append = " update-rc.d update-rc.d-native"
-RDEPENDS_${PN}_append = " update-rc.d"
+inherit update-rc.d update-alternatives
 
  SRC_URI = "http://www.infodrom.org/projects/sysklogd/download/sysklogd-${PV}.tar.gz \
             file://no-strip-install.patch \
@@ -41,22 +38,6 @@ do_install () {
  	install -m 755 ${WORKDIR}/sysklogd ${D}${sysconfdir}/init.d/syslog
  }
 
-pkg_preinst_${PN} () {
-	# all this is needed to avoid sysmlink errors,
-	# because update-rc.d runs before pkg_postinst
-	ETC=$D${sysconfdir}
-
-	if [ -e $ETC/init.d/syslog -a ! -L $ETC/init.d/syslog ]; then
-		echo "WARNING:" "non symlink ${sysconfdir}/init.d/syslog exist -> backup to ${sysconfdir}/init.d/syslog.old"
-		mv $ETC/init.d/syslog $ETC/init.d/syslog.old
-	fi
-	if [ ! -e $ETC/init.d/syslog ]; then
-		ln -s dummy $ETC/init.d/syslog
-	fi
-}
-
-inherit update-alternatives
-
  ALTERNATIVE_PRIORITY = "100"
 
  ALTERNATIVE_${PN} = "syslogd klogd syslog-init syslog-conf"
@@ -66,15 +47,6 @@ ALTERNATIVE_LINK_NAME[klogd] = "${base_sbindir}/klogd"
  ALTERNATIVE_LINK_NAME[syslog-init] = "${sysconfdir}/init.d/syslog"
  ALTERNATIVE_LINK_NAME[syslog-conf] = "${sysconfdir}/syslog.conf"
 
-pkg_postinst_${PN} () {
-	if test "x$D" != "x"; then
-	OPT="-r $D"
-	else
-	OPT="-s"
-	fi
-	update-rc.d $OPT syslog defaults
-}
-
  pkg_prerm_${PN} () {
  	if test "x$D" = "x"; then
  	if test "$1" = "upgrade" -o "$1" = "remove"; then
@@ -82,16 +54,3 @@ pkg_prerm_${PN} () {
  	fi
  	fiOn 10/11/2012 09:22 AM, Andy Ross wrote:> The sysklogd recipe had a cut-n-paste version of the

update-rc.d.bbclass code which didn't work, but this was hidden because all images contain the busybox version which does. Building a busybox-free image unmasked the issue and syslogd wouldn't start on first boot.

The comments seem to be wrong/stale. AFAICT update-rc.d and update-alternatives work fine with each other, though there is an ordering constraint (alternatives must be specified last, so it "wraps" update-rc.d). This version builds and works both with and without busybox.

Quoted 5 lines
---
  meta/recipes-extended/sysklogd/sysklogd.inc | 43 +----------------------------
  1 file changed, 1 insertion(+), 42 deletions(-)

Merged into OE-Core

Thanks
Sau!

Quoted 88 lines
meta/recipes-extended/sysklogd/sysklogd.inc +1 -42
index 151babb..1167328 100644
@@ -11,10 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
                      file://klogd.c;beginline=2;endline=19;md5=7e87ed0ae6142de079bce738c10c899d \
                     "
 
-# syslog initscript is handled explicitly because order of
-# update-rc.d and update-alternatives is important (see below)
-DEPENDS_append = " update-rc.d update-rc.d-native"
-RDEPENDS_${PN}_append = " update-rc.d"
+inherit update-rc.d update-alternatives
 
  SRC_URI = "http://www.infodrom.org/projects/sysklogd/download/sysklogd-${PV}.tar.gz \
             file://no-strip-install.patch \
@@ -41,22 +38,6 @@ do_install () {
  	install -m 755 ${WORKDIR}/sysklogd ${D}${sysconfdir}/init.d/syslog
  }
 
-pkg_preinst_${PN} () {
-	# all this is needed to avoid sysmlink errors,
-	# because update-rc.d runs before pkg_postinst
-	ETC=$D${sysconfdir}
-
-	if [ -e $ETC/init.d/syslog -a ! -L $ETC/init.d/syslog ]; then
-		echo "WARNING:" "non symlink ${sysconfdir}/init.d/syslog exist -> backup to ${sysconfdir}/init.d/syslog.old"
-		mv $ETC/init.d/syslog $ETC/init.d/syslog.old
-	fi
-	if [ ! -e $ETC/init.d/syslog ]; then
-		ln -s dummy $ETC/init.d/syslog
-	fi
-}
-
-inherit update-alternatives
-
  ALTERNATIVE_PRIORITY = "100"
 
  ALTERNATIVE_${PN} = "syslogd klogd syslog-init syslog-conf"
@@ -66,15 +47,6 @@ ALTERNATIVE_LINK_NAME[klogd] = "${base_sbindir}/klogd"
  ALTERNATIVE_LINK_NAME[syslog-init] = "${sysconfdir}/init.d/syslog"
  ALTERNATIVE_LINK_NAME[syslog-conf] = "${sysconfdir}/syslog.conf"
 
-pkg_postinst_${PN} () {
-	if test "x$D" != "x"; then
-	OPT="-r $D"
-	else
-	OPT="-s"
-	fi
-	update-rc.d $OPT syslog defaults
-}
-
  pkg_prerm_${PN} () {
  	if test "x$D" = "x"; then
  	if test "$1" = "upgrade" -o "$1" = "remove"; then
@@ -82,16 +54,3 @@ pkg_prerm_${PN} () {
  	fi
  	fi
  }
-
-pkg_postrm_${PN} () {
-	if test "x$D" != "x"; then
-	OPT="-r $D"
-	else
-	OPT=""
-	fi
-	if test "$1" = "remove" -o "$1" = "purge"; then
-	if ! test -e "/etc/init.d/syslog"; then
-	    update-rc.d $OPT syslog remove
-	fi
-	fi
-}
  }
meta/recipes-extended/sysklogd/sysklogd.inc +0 -13
-
-pkg_postrm_${PN} () {
-	if test "x$D" != "x"; then
-	OPT="-r $D"
-	else
-	OPT=""
-	fi
-	if test "$1" = "remove" -o "$1" = "purge"; then
-	if ! test -e "/etc/init.d/syslog"; then
-	    update-rc.d $OPT syslog remove
-	fi
-	fi
-}