summaryrefslogtreecommitdiff
path: root/recipes/sysklogd/sysklogd.inc
blob: f25af532dc5a6f3ae07236269b4684abe70236d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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 \
           file://sysklogd"

# 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"

do_install () {
	install -d ${D}${mandir}/man8 \
		   ${D}${mandir}/man5 \
		   ${D}${base_sbindir}
	oe_runmake 'BINDIR=${D}${base_sbindir}' \
		   'MANDIR=${D}${mandir}' install
    mv ${D}${base_sbindir}/syslogd ${D}${base_sbindir}/syslogd.${PN}
    mv ${D}${base_sbindir}/klogd ${D}${base_sbindir}/klogd.${PN}
    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/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
}