1*4882a593SmuzhiyunDESCRIPTION = "netkit-rwho includes, ruptime rwho and rwhod (Daemon to maintain data for rwho/ruptime)"
2*4882a593SmuzhiyunHOMEPAGE = "ftp://ftp.uk.linux.org/pub/linux/Networking/netkit"
3*4882a593SmuzhiyunSECTION = "net"
4*4882a593SmuzhiyunLICENSE = "BSD-4-Clause"
5*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://rwho/rwho.c;beginline=2;endline=3;md5=5a85f13c0142d72fc378e00f15da5b9e"
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunSRC_URI = "${DEBIAN_MIRROR}/main/n/netkit-rwho/netkit-rwho_${PV}.orig.tar.gz;name=archive \
8*4882a593Smuzhiyun           ${DEBIAN_MIRROR}/main/n/netkit-rwho/netkit-rwho_${PV}-13.debian.tar.gz;subdir=${BP};name=patch13 \
9*4882a593Smuzhiyun           file://rwhod \
10*4882a593Smuzhiyun           file://rwhod.default \
11*4882a593Smuzhiyun           file://0001-Add-missing-include-path-to-I-options.patch \
12*4882a593Smuzhiyun           file://0002-Fix-build-issues-found-with-musl.patch \
13*4882a593Smuzhiyun           "
14*4882a593SmuzhiyunSRC_URI[archive.md5sum] = "0f71620d45d472f89134ba0d74242e75"
15*4882a593SmuzhiyunSRC_URI[archive.sha256sum] = "0409e2ce4bfdb2dacb2c193d0fedfc49bb975cb057c5c6b0ffcca603a1188da7"
16*4882a593SmuzhiyunSRC_URI[patch13.md5sum] = "82ed5a3c6b0bbf00b36508b9787963b9"
17*4882a593SmuzhiyunSRC_URI[patch13.sha256sum] = "53aefa27d98b565bf756db57120c03bd224a238e45699d92076420272a6eba8e"
18*4882a593Smuzhiyun
19*4882a593Smuzhiyuninherit autotools-brokensep useradd update-rc.d update-alternatives
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunCFLAGS += " -D_GNU_SOURCE"
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun# Unlike other Debian packages, net-tools *.diff.gz contains another series of
24*4882a593Smuzhiyun# patches maintained by quilt. So manually apply them before applying other local
25*4882a593Smuzhiyun# patches. Also remove all temp files before leaving, because do_patch() will pop
26*4882a593Smuzhiyun# up all previously applied patches in the start
27*4882a593Smuzhiyundo_patch[depends] += "quilt-native:do_populate_sysroot"
28*4882a593Smuzhiyunnetkit_do_patch() {
29*4882a593Smuzhiyun        cd ${S}
30*4882a593Smuzhiyun        # it's important that we only pop the existing patches when they've
31*4882a593Smuzhiyun        # been applied, otherwise quilt will climb the directory tree
32*4882a593Smuzhiyun        # and reverse out some completely different set of patches
33*4882a593Smuzhiyun        if [ -d ${S}/patches ]; then
34*4882a593Smuzhiyun                # whilst this is the default directory, doing it like this
35*4882a593Smuzhiyun                # defeats the directory climbing that quilt will otherwise
36*4882a593Smuzhiyun                # do; note the directory must exist to defeat this, hence
37*4882a593Smuzhiyun                # the test inside which we operate
38*4882a593Smuzhiyun                QUILT_PATCHES=${S}/patches quilt pop -a
39*4882a593Smuzhiyun        fi
40*4882a593Smuzhiyun        if [ -d ${S}/.pc-${BPN} ]; then
41*4882a593Smuzhiyun                rm -rf ${S}/.pc
42*4882a593Smuzhiyun                mv ${S}/.pc-${BPN} ${S}/.pc
43*4882a593Smuzhiyun                QUILT_PATCHES=${S}/debian/patches quilt pop -a
44*4882a593Smuzhiyun                rm -rf ${S}/.pc ${S}/debian
45*4882a593Smuzhiyun        fi
46*4882a593Smuzhiyun        QUILT_PATCHES=${S}/debian/patches quilt push -a
47*4882a593Smuzhiyun        mv ${S}/.pc ${S}/.pc-${BPN}
48*4882a593Smuzhiyun}
49*4882a593Smuzhiyun
50*4882a593Smuzhiyundo_unpack[cleandirs] += "${S}"
51*4882a593Smuzhiyun
52*4882a593Smuzhiyunpython do_patch() {
53*4882a593Smuzhiyun    bb.build.exec_func('netkit_do_patch', d)
54*4882a593Smuzhiyun    bb.build.exec_func('patch_do_patch', d)
55*4882a593Smuzhiyun}
56*4882a593Smuzhiyun
57*4882a593Smuzhiyundo_configure () {
58*4882a593Smuzhiyun    ./configure --prefix=${prefix}
59*4882a593Smuzhiyun    echo "LDFLAGS=${LDFLAGS}" >> MCONFIG
60*4882a593Smuzhiyun}
61*4882a593Smuzhiyun
62*4882a593Smuzhiyundo_install () {
63*4882a593Smuzhiyun    # rwho & ruptime
64*4882a593Smuzhiyun    install -d ${D}${bindir}
65*4882a593Smuzhiyun    install -d ${D}${mandir}/man1
66*4882a593Smuzhiyun    #rwhod
67*4882a593Smuzhiyun    install -d ${D}${sbindir}
68*4882a593Smuzhiyun    install -d ${D}${mandir}/man8
69*4882a593Smuzhiyun    install -d ${D}${sysconfdir}/init.d
70*4882a593Smuzhiyun    install -d ${D}${sysconfdir}/default
71*4882a593Smuzhiyun    sed -i 's/install -s/install/' rwho/Makefile
72*4882a593Smuzhiyun    sed -i 's/install -s/install/' ruptime/Makefile
73*4882a593Smuzhiyun    sed -i 's/install -s/install/' rwhod/Makefile
74*4882a593Smuzhiyun    oe_runmake 'INSTALLROOT=${D}' 'BINMODE=0755' \
75*4882a593Smuzhiyun    'DAEMONMODE=0755' 'MANMODE=0644' \
76*4882a593Smuzhiyun    'BINDIR=${bindir}' 'SBINDIR=${sbindir}' \
77*4882a593Smuzhiyun    'MANDIR=${mandir}' install
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun    install -m 0644 ${WORKDIR}/rwhod.default ${D}${sysconfdir}/default/rwhod
80*4882a593Smuzhiyun    install -m 755 ${WORKDIR}/rwhod ${D}${sysconfdir}/init.d
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun    mkdir -p -m 755 ${D}${localstatedir}/spool/rwho
83*4882a593Smuzhiyun    chown -R rwhod ${D}${localstatedir}/spool/rwho
84*4882a593Smuzhiyun}
85*4882a593Smuzhiyunpkg_postinst_ontarget:${PN}-server() {
86*4882a593Smuzhiyun    ${sysconfdir}/init.d/rwhod start
87*4882a593Smuzhiyun}
88*4882a593Smuzhiyun
89*4882a593Smuzhiyunpkg_postrm:${PN}-server() {
90*4882a593Smuzhiyun    ${sysconfdir}/init.d/rwhod stop
91*4882a593Smuzhiyun}
92*4882a593Smuzhiyun
93*4882a593SmuzhiyunINITSCRIPT_NAME = "rwhod"
94*4882a593SmuzhiyunINITSCRIPT_PARAM = "defaults 85 15"
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunUSERADD_PACKAGES = "${PN}-server"
97*4882a593SmuzhiyunGROUPADD_PARAM:${PN}-server = "--system rwhod"
98*4882a593SmuzhiyunUSERADD_PARAM:${PN}-server = "--system -g rwhod --home-dir  ${localstatedir}/spool/rwho \
99*4882a593Smuzhiyun        --no-create-home  --shell /bin/false rwhod"
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunINSANE_SKIP:${PN} = "already-stripped"
102*4882a593Smuzhiyun
103*4882a593SmuzhiyunPACKAGES = "${PN}-client ${PN}-server ${PN}-doc ${BPN}-dbg"
104*4882a593SmuzhiyunFILES:${PN}-client = "${bindir}/*"
105*4882a593SmuzhiyunFILES:${PN}-server = "${sbindir}/* ${localstatedir} ${sysconfdir}/default/* ${sysconfdir}/init.d/*"
106*4882a593SmuzhiyunFILES:${PN}-doc = "${mandir}"
107*4882a593SmuzhiyunFILES:${PN}-dbg = "${prefix}/src/debug \
108*4882a593Smuzhiyun            ${bindir}/.debug ${sbindir}/.debug"
109