1SUMMARY = "The Network Time Protocol suite, refactored"
2HOMEPAGE = "https://www.ntpsec.org/"
3
4LICENSE = "CC-BY-4.0 & BSD-2-Clause & NTP & BSD-3-Clause & MIT"
5LIC_FILES_CHKSUM = "file://LICENSES/BSD-2;md5=653830da7b770a32f6f50f6107e0b186 \
6                    file://LICENSES/BSD-3;md5=55e9dcf6a625a2dcfcda4ef6a647fbfd \
7                    file://LICENSES/CC-BY-4.0;md5=2ab724713fdaf49e4523c4503bfd068d \
8                    file://LICENSES/MIT;md5=5a9dfc801af3eb49df2055c9b07918b2 \
9                    file://LICENSES/NTP;md5=cb56b7747f86157c78ca81f224806694"
10
11DEPENDS += "bison-native \
12            openssl \
13            python3"
14
15SRC_URI = "https://ftp.ntpsec.org/pub/releases/ntpsec-${PV}.tar.gz \
16           file://volatiles.ntpsec \
17           file://0001-wscript-Add-BISONFLAGS-support.patch \
18           "
19
20SRC_URI[sha256sum] = "e0ce93af222a0a9860e6f5a51aadba9bb5ca601d80b2aea118a62f0a3226950e"
21
22UPSTREAM_CHECK_URI = "ftp://ftp.ntpsec.org/pub/releases/"
23
24inherit pkgconfig python3-dir python3targetconfig systemd update-alternatives update-rc.d useradd waf features_check
25
26# RDEPENDS on gnuplot with this restriction
27REQUIRED_DISTRO_FEATURES = "x11"
28
29PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'seccomp systemd', d)} \
30                 cap \
31                 leap-smear \
32                 mdns \
33                 mssntp \
34                 nts \
35                 refclocks"
36
37PACKAGECONFIG:remove:riscv32 = "seccomp"
38
39PACKAGECONFIG[cap] = ",,libcap"
40PACKAGECONFIG[docs] = "--enable-doc --enable-manpage,--disable-doc --disable-manpage,"
41PACKAGECONFIG[leap-smear] = "--enable-leap-smear"
42PACKAGECONFIG[mdns] = ",,mdns"
43PACKAGECONFIG[mssntp] = "--enable-mssntp"
44PACKAGECONFIG[nts] = ",--disable-nts"
45PACKAGECONFIG[refclocks] = "--refclock=all,,pps-tools"
46PACKAGECONFIG[seccomp] = "--enable-seccomp,,libseccomp"
47PACKAGECONFIG[systemd] = ",,systemd"
48
49CC[unexport] = "1"
50CFLAGS[unexport] = "1"
51LDFLAGS[unexport] = "1"
52
53export PYTHON_VERSION = "${PYTHON_BASEVERSION}"
54export PYTAG = "cpython${@ d.getVar('PYTHON_BASEVERSION').replace('.', '')}"
55export pyext_PATTERN = "%s.so"
56export PYTHON_LDFLAGS = "-lpthread -ldl"
57
58CFLAGS:append = " -I${PYTHON_INCLUDE_DIR} -D_GNU_SOURCE"
59
60EXTRA_OECONF = "--cross-compiler='${CC}' \
61                --cross-cflags='${CFLAGS}' \
62                --cross-ldflags='${LDFLAGS}' \
63                --pyshebang=${bindir}/python3 \
64                --pythondir=${PYTHON_SITEPACKAGES_DIR} \
65                --pythonarchdir=${PYTHON_SITEPACKAGES_DIR} \
66                --enable-debug-gdb \
67                --enable-early-droproot"
68
69EXTRA_OEWAF_BUILD ?= "-v"
70
71NTP_USER_HOME ?= "/var/lib/ntp"
72
73BISONFLAGS = "--file-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR}"
74
75do_configure:prepend() {
76	export BISONFLAGS="${BISONFLAGS}"
77}
78
79do_install:append() {
80	install -d ${D}${sysconfdir}/init.d
81	install -m 755 ${S}/etc/rc/ntpd ${D}${sysconfdir}/init.d
82	cp -r ${S}/etc/ntp.d ${D}${sysconfdir}
83
84	sed -e 's:@NTP_USER_HOME@:${NTP_USER_HOME}:g' ${WORKDIR}/volatiles.ntpsec >${T}/volatiles.ntpsec
85	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
86		cp ${B}/main/etc/* ${D}${systemd_system_unitdir}
87		awk '{print $1, $5, $4, $2, $3, "-"}' ${T}/volatiles.ntpsec >${T}/tmpfiles.ntpsec
88		install -D -m 0644 ${T}/tmpfiles.ntpsec ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
89	else
90		install -D -m 0644 ${T}/volatiles.ntpsec ${D}${sysconfdir}/default/volatiles/99_${BPN}
91	fi
92}
93
94PACKAGE_BEFORE_PN = "${PN}-python ${PN}-utils ${PN}-viz"
95
96FILES:${PN} += "${nonarch_libdir}/tmpfiles.d/ntpsec.conf"
97FILES:${PN}-python = "${PYTHON_SITEPACKAGES_DIR} \
98                      ${libdir}/libntpc.so.*"
99FILES:${PN}-utils = "${bindir}/ntpdig \
100                     ${bindir}/ntpkeygen \
101                     ${bindir}/ntpleapfetch \
102                     ${bindir}/ntpmon \
103                     ${bindir}/ntpq \
104                     ${bindir}/ntpsnmpd \
105                     ${bindir}/ntpsweep \
106                     ${bindir}/ntptrace \
107                     ${bindir}/ntpwait"
108FILES:${PN}-viz = "${bindir}/ntplogtemp \
109                   ${bindir}/ntpviz"
110
111RDEPENDS:${PN} += "libgcc"
112RDEPENDS:${PN}-utils += "${PN}-python python3-core"
113RDEPENDS:${PN}-viz += "gnuplot ${PN}-python python3-core python3-compression python3-ctypes python3-logging python3-shell"
114
115USERADD_PACKAGES = "${PN}"
116USERADD_PARAM:${PN} = "--system --home-dir ${NTP_USER_HOME} \
117                       --no-create-home \
118                       --shell /bin/false --user-group ntp"
119
120INITSCRIPT_NAME = "ntpd"
121
122SYSTEMD_PACKAGES = "${PN} ${PN}-viz"
123SYSTEMD_SERVICE:${PN} = "ntpd.service ntp-wait.service"
124SYSTEMD_SERVICE:${PN}-viz = "ntplogtemp.service ntpviz-weekly.timer ntpviz-weekly.service ntpviz-daily.timer ntpviz-daily.service ntplogtemp.timer"
125
126ALTERNATIVE_PRIORITY = "80"
127
128ALTERNATIVE:${PN} = "ntpd"
129ALTERNATIVE_LINK_NAME[ntpd] = "${sbindir}/ntpd"
130