diff options
author | Steffen Sledz <sledz@dresearch.de> | 2010-05-07 16:15:57 +0200 |
---|---|---|
committer | Steffen Sledz <sledz@dresearch.de> | 2010-05-17 14:08:13 +0200 |
commit | 543d057b7dc9290130a89226b567f2b2140aae0c (patch) | |
tree | 926ecfbca3a7f1b687285de2ad7645bfb2b3824f | |
parent | 98bed2876d7dd88cc25f1c70929f1d632b8f95ee (diff) |
busybox/syslogs: use update-alternatives for syslog selection
* u-a for init scripts of busybox-syslog, sysklogd, and rsyslog
* syslog-ng needs to be integrated too!
Signed-off-by: Steffen Sledz <sledz@dresearch.de>
Acked-by: Martin Jansa <Martin.Jansa@gmail.com>
-rw-r--r-- | recipes/busybox/busybox.inc | 44 | ||||
-rw-r--r-- | recipes/rsyslog/rsyslog.inc | 50 | ||||
-rw-r--r-- | recipes/sysklogd/sysklogd.inc | 55 | ||||
-rw-r--r-- | recipes/sysklogd/sysklogd_1.4.1.bb | 2 | ||||
-rw-r--r-- | recipes/sysklogd/sysklogd_1.5.bb | 2 |
5 files changed, 132 insertions, 21 deletions
diff --git a/recipes/busybox/busybox.inc b/recipes/busybox/busybox.inc index fbcd8ea95f..c6b6422fc1 100644 --- a/recipes/busybox/busybox.inc +++ b/recipes/busybox/busybox.inc @@ -11,7 +11,7 @@ LICENSE = "GPLv2" SECTION = "base" PRIORITY = "required" -INC_PR = "r28" +INC_PR = "r29" SRC_URI = "\ file://busybox-cron \ @@ -46,12 +46,14 @@ RDEPENDS_${PN} += "${PN}-mountall" RRECOMMENDS_${PN} += "libgcc ${PN}-syslog" FILES_${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www" -FILES_${PN}-syslog = "${sysconfdir}/init.d/syslog ${sysconfdir}/syslog.conf" +FILES_${PN}-syslog = "${sysconfdir}/init.d/syslog.${PN} ${sysconfdir}/syslog.conf" FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd" FILES_${PN} += "${datadir}/udhcpc" -INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd" +# syslog initscript is handled explicitly because order of +# update-rc.d and update-alternatives is important (see below) +INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-udhcpd" INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd" INITSCRIPT_NAME_${PN}-syslog = "syslog" INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd" @@ -107,7 +109,7 @@ do_install () { ln -sf busybox ${D}${base_bindir}/sh if grep -q "CONFIG_SYSLOGD=y" ${WORKDIR}/defconfig; then - install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/syslog.${PN} install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/ fi if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then @@ -157,6 +159,40 @@ pkg_prerm_${PN}-mountall () { update-alternatives --remove default_mountall mountall.${PN} } +pkg_postinst_${PN}-syslog () { + update-alternatives --install ${sysconfdir}/init.d/syslog syslog-init syslog.${PN} 50 + + if test "x$D" != "x"; then + OPT="-r $D" + else + OPT="-s" + fi + update-rc.d $OPT syslog defaults +} + +pkg_prerm_${PN}-syslog () { + if test "x$D" = "x"; then + if test "$1" = "upgrade" -o "$1" = "remove"; then + /etc/init.d/syslog stop + fi + fi + + update-alternatives --remove syslog-init syslog.${PN} +} + +pkg_postrm_${PN}-syslog () { + 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 +} + pkg_prerm_${PN} () { # This is so you can make busybox commit suicide - removing busybox with no other packages # providing its files, this will make update-alternatives work, but the update-rc.d part diff --git a/recipes/rsyslog/rsyslog.inc b/recipes/rsyslog/rsyslog.inc index 3e39ba0a04..d94ab34d3b 100644 --- a/recipes/rsyslog/rsyslog.inc +++ b/recipes/rsyslog/rsyslog.inc @@ -2,31 +2,61 @@ DESCRIPTION = "Rsyslog is an enhanced multi-threaded syslogd" DEPENDS = "zlib" HOMEPAGE = "http://www.rsyslog.com/" LICENSE = "GPLv3" -INC_PR = "r0" +INC_PR = "r1" SRC_URI = "http://download.rsyslog.com/rsyslog/${PN}-${PV}.tar.gz \ file://rsyslog.conf \ file://initscript" -inherit autotools update-rc.d + +inherit autotools do_install_append() { install -d ${D}/${sysconfdir}/${PN} install ${WORKDIR}/rsyslog.conf ${D}${sysconfdir}/rsyslog.conf install -d ${D}/${sysconfdir}/init.d - install -m 755 ${WORKDIR}/initscript ${D}/${sysconfdir}/init.d/rsyslog + install -m 755 ${WORKDIR}/initscript ${D}/${sysconfdir}/init.d/syslog.${PN} +} + +# syslog initscript is handled explicitly because order of +# update-rc.d and update-alternatives is important +DEPENDS_append = " update-rc.d update-rc.d-native" +RDEPENDS_${PN}_append = " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "update-rc.d", d)}" + +pkg_postinst_${PN} () { + update-alternatives --install ${sysconfdir}/init.d/syslog syslog-init syslog.${PN} 300 + + if test "x$D" != "x"; then + OPT="-r $D" + else + OPT="-s" + fi + update-rc.d $OPT syslog defaults } -pkg_postinst() { - update-rc.d -f syslog remove +pkg_prerm_${PN} () { + if test "x$D" = "x"; then + if test "$1" = "upgrade" -o "$1" = "remove"; then + /etc/init.d/syslog stop + fi + fi + + update-alternatives --remove syslog-init syslog.${PN} } -pkg_postrm() { - update-rc.d syslog add 5 +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 } CONFFILES_${PN} = "${sysconfdir}/rsyslog.conf" -INITSCRIPT_NAME = "rsyslog" -#INITSCRIPT_PARAMS = "defaults 05" -INITSCRIPT_PARAMS = "remove" +INITSCRIPT_NAME = "syslog" diff --git a/recipes/sysklogd/sysklogd.inc b/recipes/sysklogd/sysklogd.inc index 65da86d835..40177361c8 100644 --- a/recipes/sysklogd/sysklogd.inc +++ b/recipes/sysklogd/sysklogd.inc @@ -1,16 +1,20 @@ LICENSE = "GPL" SECTION = "base" DESCRIPTION = "The sysklogd package implements two system log daemons." +INC_PR = "r3" SRC_URI = "http://www.ibiblio.org/pub/Linux/system/daemons/sysklogd-${PV}.tar.gz \ file://nonrootinstall.patch;patch=1 \ file://sysklogd" -inherit update-rc.d -INITSCRIPT_NAME = "sysklogd" -INITSCRIPT_PARAMS = "start 39 S 1 2 3 . stop 99 0 6 ." +# 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 = " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "update-rc.d", d)}" + +INITSCRIPT_NAME = "syslog" + CFLAGS_append = " -DSYSV" -RCONFLICTS = "busybox-syslog" do_install () { install -d ${D}${mandir}/man8 \ @@ -23,14 +27,55 @@ do_install () { install -d ${D}${sysconfdir} install -m 644 ${S}/syslog.conf ${D}${sysconfdir}/syslog.conf install -d ${D}${sysconfdir}/init.d - install -m 755 ${WORKDIR}/sysklogd ${D}${sysconfdir}/init.d/sysklogd + install -m 755 ${WORKDIR}/sysklogd ${D}${sysconfdir}/init.d/syslog.${PN} } + +pkg_preinst_${PN} () { + # all this is needed to avoid sysmlink errors, + # because update-rc.d runs before pkg_postinst :( + if [ -e ${sysconfdir}/init.d/syslog -a ! -L ${sysconfdir}/init.d/syslog ]; then + echo "WARNING:" "non symlink ${sysconfdir}/init.d/syslog exist -> backup to ${sysconfdir}/init.d/syslog.old" + mv ${sysconfdir}/init.d/syslog ${sysconfdir}/init.d/syslog.old + fi + if [ ! -e ${sysconfdir}/init.d/syslog ]; then + ln -s dummy ${sysconfdir}/init.d/syslog + fi +} + pkg_postinst_${PN} () { update-alternatives --install ${base_sbindir}/syslogd syslogd syslogd.${PN} 100 update-alternatives --install ${base_sbindir}/klogd klogd klogd.${PN} 100 + update-alternatives --install ${sysconfdir}/init.d/syslog syslog-init syslog.${PN} 100 + + if test "x$D" != "x"; then + OPT="-r $D" + else + OPT="-s" + fi + update-rc.d $OPT syslog defaults } + pkg_prerm_${PN} () { update-alternatives --remove syslogd syslogd.${PN} update-alternatives --remove klogd klogd.${PN} + + if test "x$D" = "x"; then + if test "$1" = "upgrade" -o "$1" = "remove"; then + /etc/init.d/syslog stop + fi + fi + update-alternatives --remove syslog-init syslog.${PN} } +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 +} diff --git a/recipes/sysklogd/sysklogd_1.4.1.bb b/recipes/sysklogd/sysklogd_1.4.1.bb index 3d938f5316..e02dd3e876 100644 --- a/recipes/sysklogd/sysklogd_1.4.1.bb +++ b/recipes/sysklogd/sysklogd_1.4.1.bb @@ -1,5 +1,5 @@ require sysklogd.inc -PR = "r1" +PR = "${INC_PR}.1" SRC_URI[md5sum] = "d214aa40beabf7bdb0c9b3c64432c774" diff --git a/recipes/sysklogd/sysklogd_1.5.bb b/recipes/sysklogd/sysklogd_1.5.bb index 70e55c3eea..a01576897c 100644 --- a/recipes/sysklogd/sysklogd_1.5.bb +++ b/recipes/sysklogd/sysklogd_1.5.bb @@ -1,5 +1,5 @@ require sysklogd.inc -PR = "r2" +PR = "${INC_PR}.2" SRC_URI += "file://no-strip-install.patch;patch=1" |