xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-networking/recipes-support/ntpsec/ntpsec_1.2.1.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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://LICENSE.adoc;md5=0520591566b6ed3a9ced8b15b4d4abf9 \
6                    file://libjsmn/LICENSE;md5=38118982429881235de8adf478a8e75d \
7                    file://docs/copyright.adoc;md5=9a1e3fce4b630078cb67ba2b619d2b13 \
8                    file://libaes_siv/COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
9
10DEPENDS += "bison-native \
11            openssl \
12            python3"
13
14SRC_URI = "https://ftp.ntpsec.org/pub/releases/ntpsec-${PV}.tar.gz \
15           file://0001-Update-to-OpenSSL-3.0.0-alpha15.patch \
16           file://0001-ntpd-ntp_sandbox.c-allow-clone3-for-glibc-2.34-in-se.patch \
17           file://0001-ntpd-ntp_sandbox.c-allow-newfstatat-on-all-archs-for.patch \
18           file://0002-ntpd-ntp_sandbox.c-match-riscv-to-aarch-in-seccomp-f.patch \
19           file://volatiles.ntpsec \
20           file://0001-wscript-Widen-the-search-for-tags.patch \
21           "
22
23SRC_URI[sha256sum] = "f2684835116c80b8f21782a5959a805ba3c44e3a681dd6c17c7cb00cc242c27a"
24
25inherit pkgconfig python3-dir python3targetconfig systemd update-alternatives update-rc.d useradd waf features_check
26
27# RDEPENDS on gnuplot with this restriction
28REQUIRED_DISTRO_FEATURES = "x11"
29
30PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'seccomp systemd', d)} \
31                 cap \
32                 leap-smear \
33                 mdns \
34                 mssntp \
35                 nts \
36                 refclocks"
37
38PACKAGECONFIG:remove:riscv32 = "seccomp"
39
40PACKAGECONFIG[cap] = ",,libcap"
41PACKAGECONFIG[docs] = "--enable-doc --enable-manpage,--disable-doc --disable-manpage,"
42PACKAGECONFIG[leap-smear] = "--enable-leap-smear"
43PACKAGECONFIG[mdns] = ",,mdns"
44PACKAGECONFIG[mssntp] = "--enable-mssntp"
45PACKAGECONFIG[nts] = ",--disable-nts"
46PACKAGECONFIG[refclocks] = "--refclock=all,,pps-tools"
47PACKAGECONFIG[seccomp] = "--enable-seccomp,,libseccomp"
48PACKAGECONFIG[systemd] = ",,systemd"
49
50CC[unexport] = "1"
51CFLAGS[unexport] = "1"
52LDFLAGS[unexport] = "1"
53
54export PYTHON_VERSION = "${PYTHON_BASEVERSION}"
55export PYTAG = "cpython${@ d.getVar('PYTHON_BASEVERSION').replace('.', '')}"
56export pyext_PATTERN = "%s.so"
57export PYTHON_LDFLAGS = "-lpthread -ldl"
58
59CFLAGS:append = " -I${PYTHON_INCLUDE_DIR} -D_GNU_SOURCE"
60
61EXTRA_OECONF = "--cross-compiler='${CC}' \
62                --cross-cflags='${CFLAGS}' \
63                --cross-ldflags='${LDFLAGS}' \
64                --pyshebang=${bindir}/python3 \
65                --pythondir=${PYTHON_SITEPACKAGES_DIR} \
66                --pythonarchdir=${PYTHON_SITEPACKAGES_DIR} \
67                --enable-debug \
68                --enable-debug-gdb \
69                --enable-early-droproot"
70
71EXTRA_OEWAF_BUILD ?= "-v"
72
73NTP_USER_HOME ?= "/var/lib/ntp"
74
75do_install:append() {
76	install -d ${D}${sysconfdir}/init.d
77	install -m 755 ${S}/etc/rc/ntpd ${D}${sysconfdir}/init.d
78	cp -r ${S}/etc/ntp.d ${D}${sysconfdir}
79
80	sed -e 's:@NTP_USER_HOME@:${NTP_USER_HOME}:g' ${WORKDIR}/volatiles.ntpsec >${T}/volatiles.ntpsec
81	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
82		cp ${B}/main/etc/* ${D}${systemd_system_unitdir}
83		awk '{print $1, $5, $4, $2, $3, "-"}' ${T}/volatiles.ntpsec >${T}/tmpfiles.ntpsec
84		install -D -m 0644 ${T}/tmpfiles.ntpsec ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
85	else
86		install -D -m 0644 ${T}/volatiles.ntpsec ${D}${sysconfdir}/default/volatiles/99_${BPN}
87	fi
88}
89
90PACKAGE_BEFORE_PN = "${PN}-python ${PN}-utils ${PN}-viz"
91
92FILES:${PN} += "${nonarch_libdir}/tmpfiles.d/ntpsec.conf"
93FILES:${PN}-python = "${PYTHON_SITEPACKAGES_DIR} \
94                      ${libdir}/libntpc.so.*"
95FILES:${PN}-utils = "${bindir}/ntpdig \
96                     ${bindir}/ntpkeygen \
97                     ${bindir}/ntpleapfetch \
98                     ${bindir}/ntpmon \
99                     ${bindir}/ntpq \
100                     ${bindir}/ntpsnmpd \
101                     ${bindir}/ntpsweep \
102                     ${bindir}/ntptrace \
103                     ${bindir}/ntpwait"
104FILES:${PN}-viz = "${bindir}/ntplogtemp \
105                   ${bindir}/ntpviz"
106
107RDEPENDS:${PN} += "libgcc"
108RDEPENDS:${PN}-utils += "${PN}-python python3-core"
109RDEPENDS:${PN}-viz += "gnuplot ${PN}-python python3-core python3-compression python3-ctypes python3-logging python3-shell"
110
111USERADD_PACKAGES = "${PN}"
112USERADD_PARAM:${PN} = "--system --home-dir ${NTP_USER_HOME} \
113                       --no-create-home \
114                       --shell /bin/false --user-group ntp"
115
116INITSCRIPT_NAME = "ntpd"
117
118SYSTEMD_PACKAGES = "${PN} ${PN}-viz"
119SYSTEMD_SERVICE:${PN} = "ntpd.service ntp-wait.service"
120SYSTEMD_SERVICE:${PN}-viz = "ntplogtemp.service ntpviz-weekly.timer ntpviz-weekly.service ntpviz-daily.timer ntpviz-daily.service ntplogtemp.timer"
121
122ALTERNATIVE_PRIORITY = "80"
123
124ALTERNATIVE:${PN} = "ntpd"
125ALTERNATIVE_LINK_NAME[ntpd] = "${sbindir}/ntpd"
126