1SUMMARY = "System and process monitoring utilities"
2DESCRIPTION = "Procps contains a set of system utilities that provide system information about processes using \
3the /proc filesystem. The package includes the programs ps, top, vmstat, w, kill, and skill."
4HOMEPAGE = "https://gitlab.com/procps-ng/procps"
5SECTION = "base"
6LICENSE = "GPL-2.0-or-later & LGPL-2.0-or-later"
7LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
8                    file://COPYING.LIB;md5=4cf66a4984120007c9881cc871cf49db \
9                    "
10
11DEPENDS = "ncurses"
12
13inherit autotools gettext pkgconfig update-alternatives
14
15SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https;branch=master \
16           file://sysctl.conf \
17           file://pidfd.patch \
18           "
19SRCREV = "4ddcef2fd843170c8e2d59a83042978f41037a2b"
20
21S = "${WORKDIR}/git"
22
23# Upstream has a custom autogen.sh which invokes po/update-potfiles as they
24# don't ship a po/POTFILES.in (which is silly).  Without that file gettext
25# doesn't believe po/ is a gettext directory and won't generate po/Makefile.
26do_configure:prepend() {
27    ( cd ${S} && po/update-potfiles )
28}
29
30EXTRA_OECONF = "--enable-skill --disable-modern-top"
31
32PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
33PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
34
35do_install:append () {
36	install -d ${D}${base_bindir}
37	[ "${bindir}" != "${base_bindir}" ] && for i in ${base_bindir_progs}; do mv ${D}${bindir}/$i ${D}${base_bindir}/$i; done
38	install -d ${D}${base_sbindir}
39	[ "${sbindir}" != "${base_sbindir}" ] && for i in ${base_sbindir_progs}; do mv ${D}${sbindir}/$i ${D}${base_sbindir}/$i; done
40        if [ "${base_sbindir}" != "${sbindir}" ]; then
41                rmdir ${D}${sbindir}
42        fi
43
44        install -d ${D}${sysconfdir}
45        install -m 0644 ${UNPACKDIR}/sysctl.conf ${D}${sysconfdir}/sysctl.conf
46        if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
47                install -d ${D}${sysconfdir}/sysctl.d
48                ln -sf ../sysctl.conf ${D}${sysconfdir}/sysctl.d/99-sysctl.conf
49        fi
50}
51
52CONFFILES:${PN} = "${sysconfdir}/sysctl.conf"
53
54bindir_progs = "free pkill pmap pgrep pwdx skill snice top uptime w"
55base_bindir_progs += "kill pidof ps watch"
56base_sbindir_progs += "sysctl"
57
58ALTERNATIVE_PRIORITY = "200"
59ALTERNATIVE_PRIORITY[pidof] = "150"
60
61ALTERNATIVE:${PN} = "${bindir_progs} ${base_bindir_progs} ${base_sbindir_progs}"
62
63ALTERNATIVE:${PN}-doc = "kill.1 uptime.1"
64ALTERNATIVE_LINK_NAME[kill.1] = "${mandir}/man1/kill.1"
65ALTERNATIVE_LINK_NAME[uptime.1] = "${mandir}/man1/uptime.1"
66
67python __anonymous() {
68    for prog in d.getVar('base_bindir_progs').split():
69        d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog))
70
71    for prog in d.getVar('base_sbindir_progs').split():
72        d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_sbindir'), prog))
73}
74
75PROCPS_PACKAGES = "${PN}-lib \
76                   ${PN}-ps \
77                   ${PN}-sysctl"
78
79PACKAGE_BEFORE_PN = "${PROCPS_PACKAGES}"
80RDEPENDS:${PN} += "${PROCPS_PACKAGES}"
81
82RDEPENDS:${PN}-ps += "${PN}-lib"
83RDEPENDS:${PN}-sysctl += "${PN}-lib"
84
85FILES:${PN}-lib = "${libdir}"
86FILES:${PN}-ps = "${base_bindir}/ps.${BPN}"
87FILES:${PN}-sysctl = "${base_sbindir}/sysctl.${BPN} ${sysconfdir}/sysctl.conf ${sysconfdir}/sysctl.d"
88
89ALTERNATIVE:${PN}:remove = "ps"
90ALTERNATIVE:${PN}:remove = "sysctl"
91
92ALTERNATIVE:${PN}-ps = "ps"
93ALTERNATIVE_TARGET[ps] = "${base_bindir}/ps"
94ALTERNATIVE_LINK_NAME[ps] = "${base_bindir}/ps"
95
96ALTERNATIVE:${PN}-sysctl = "sysctl"
97ALTERNATIVE_TARGET[sysctl] = "${base_sbindir}/sysctl"
98ALTERNATIVE_LINK_NAME[sysctl] = "${base_sbindir}/sysctl"
99