Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | SUMMARY = "Network Time Protocol daemon and utilities" |
| 2 | DESCRIPTION = "The Network Time Protocol (NTP) is used to \ |
| 3 | synchronize the time of a computer client or server to \ |
| 4 | another server or reference time source, such as a radio \ |
| 5 | or satellite receiver or modem." |
| 6 | HOMEPAGE = "http://support.ntp.org" |
| 7 | SECTION = "net" |
| 8 | LICENSE = "NTP" |
| 9 | LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=e877a1d567a6a58996d2b66e3e387003" |
| 10 | |
| 11 | DEPENDS = "libevent" |
| 12 | |
| 13 | SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.gz \ |
| 14 | file://ntp-4.2.4_p6-nano.patch \ |
| 15 | file://reproducibility-fixed-path-to-posix-shell.patch \ |
| 16 | file://reproducibility-respect-source-date-epoch.patch \ |
| 17 | file://ntpd \ |
| 18 | file://ntp.conf \ |
| 19 | file://ntpdate \ |
| 20 | file://ntpdate.default \ |
| 21 | file://ntpdate.service \ |
| 22 | file://ntpd.service \ |
| 23 | file://sntp.service \ |
| 24 | file://sntp \ |
| 25 | file://ntpd.list \ |
| 26 | " |
| 27 | |
| 28 | SRC_URI[md5sum] = "1522d66574bae14abb2622746dad2bdc" |
| 29 | SRC_URI[sha256sum] = "709b222b5013d77d26bfff532b5ea470a8039497ef29d09363931c036cb30454" |
| 30 | |
| 31 | inherit autotools update-rc.d useradd systemd pkgconfig |
| 32 | |
| 33 | # The ac_cv_header_readline_history is to stop ntpdc depending on either |
| 34 | # readline or curses |
| 35 | EXTRA_OECONF += "--with-net-snmp-config=no \ |
| 36 | --without-ntpsnmpd \ |
| 37 | ac_cv_header_readline_history_h=no \ |
| 38 | --with-yielding_select=yes \ |
| 39 | --with-locfile=redhat \ |
| 40 | --without-rpath \ |
| 41 | " |
| 42 | CFLAGS_append = " -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED" |
| 43 | |
| 44 | USERADD_PACKAGES = "${PN}" |
| 45 | NTP_USER_HOME ?= "/var/lib/ntp" |
| 46 | USERADD_PARAM_${PN} = "--system --home-dir ${NTP_USER_HOME} \ |
| 47 | --no-create-home \ |
| 48 | --shell /bin/false --user-group ntp" |
| 49 | |
| 50 | # NB: debug is default-enabled by NTP; keep it default-enabled here. |
| 51 | PACKAGECONFIG ??= "cap debug refclocks openssl \ |
| 52 | ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \ |
| 53 | " |
| 54 | PACKAGECONFIG[openssl] = "--with-openssl-libdir=${STAGING_LIBDIR} \ |
| 55 | --with-openssl-incdir=${STAGING_INCDIR} \ |
| 56 | --with-crypto, \ |
| 57 | --without-openssl --without-crypto, \ |
| 58 | openssl" |
| 59 | PACKAGECONFIG[cap] = "--enable-linuxcaps,--disable-linuxcaps,libcap" |
| 60 | PACKAGECONFIG[readline] = "--with-lineeditlibs,--without-lineeditlibs,readline" |
| 61 | PACKAGECONFIG[refclocks] = "--enable-all-clocks,--disable-all-clocks,pps-tools" |
| 62 | PACKAGECONFIG[debug] = "--enable-debugging,--disable-debugging" |
| 63 | PACKAGECONFIG[mdns] = "ac_cv_header_dns_sd_h=yes,ac_cv_header_dns_sd_h=no,mdns" |
| 64 | PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6," |
| 65 | |
| 66 | do_install_append() { |
| 67 | install -d ${D}${sysconfdir}/init.d |
| 68 | install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir} |
| 69 | install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d |
| 70 | install -d ${D}${bindir} |
| 71 | install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync |
| 72 | |
| 73 | install -m 755 -d ${D}${NTP_USER_HOME} |
| 74 | chown ntp:ntp ${D}${NTP_USER_HOME} |
| 75 | |
| 76 | # Fix hardcoded paths in scripts |
| 77 | sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 78 | sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 79 | sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 80 | sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 81 | sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync |
| 82 | sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace |
| 83 | sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace |
| 84 | sed -i '1s,#!.*perl,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait |
| 85 | sed -i '/use/i use warnings;' ${D}${sbindir}/ntp-wait |
| 86 | sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/calc_tickadj |
| 87 | sed -i '/use/i use warnings;' ${D}${sbindir}/calc_tickadj |
| 88 | |
| 89 | install -d ${D}/${sysconfdir}/default |
| 90 | install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate |
| 91 | install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/ |
| 92 | |
| 93 | install -d ${D}/${sysconfdir}/network/if-up.d |
| 94 | ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d |
| 95 | |
| 96 | install -d ${D}${systemd_unitdir}/system |
| 97 | install -m 0644 ${WORKDIR}/ntpdate.service ${D}${systemd_unitdir}/system/ |
| 98 | install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/ |
| 99 | install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/ |
| 100 | |
| 101 | install -d ${D}${systemd_unitdir}/ntp-units.d |
| 102 | install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list |
| 103 | |
| 104 | # Remove an empty libexecdir. |
| 105 | rmdir --ignore-fail-on-non-empty ${D}${libexecdir} |
| 106 | } |
| 107 | |
| 108 | PACKAGES += "ntpdate sntp ${PN}-tickadj ${PN}-utils" |
| 109 | # NOTE: you don't need ntpdate, use "ntpd -q -g -x" |
| 110 | |
| 111 | # ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms |
| 112 | # with wonky clocks (e.g. OpenSlug) |
| 113 | RDEPENDS_${PN} = "${PN}-tickadj" |
| 114 | # ntpd require libgcc for execution |
| 115 | RDEPENDS_${PN} += "libgcc" |
| 116 | # Handle move from bin to utils package |
| 117 | RPROVIDES_${PN}-utils = "${PN}-bin" |
| 118 | RREPLACES_${PN}-utils = "${PN}-bin" |
| 119 | RCONFLICTS_${PN}-utils = "${PN}-bin" |
| 120 | |
| 121 | SYSTEMD_PACKAGES = "${PN} ntpdate sntp" |
| 122 | SYSTEMD_SERVICE_${PN} = "ntpd.service" |
| 123 | SYSTEMD_SERVICE_ntpdate = "ntpdate.service" |
| 124 | SYSTEMD_SERVICE_sntp = "sntp.service" |
| 125 | SYSTEMD_AUTO_ENABLE_sntp = "disable" |
| 126 | |
| 127 | RPROVIDES_${PN} += "${PN}-systemd" |
| 128 | RREPLACES_${PN} += "${PN}-systemd" |
| 129 | RCONFLICTS_${PN} += "${PN}-systemd" |
| 130 | |
| 131 | RPROVIDES_ntpdate += "ntpdate-systemd" |
| 132 | RREPLACES_ntpdate += "ntpdate-systemd" |
| 133 | RCONFLICTS_ntpdate += "ntpdate-systemd" |
| 134 | |
| 135 | RSUGGESTS_${PN} = "iana-etc" |
| 136 | |
| 137 | FILES_${PN} = "${sbindir}/ntpd.ntp ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd ${libdir} \ |
| 138 | ${NTP_USER_HOME} \ |
| 139 | ${systemd_unitdir}/ntp-units.d/60-ntpd.list ${libexecdir}\ |
| 140 | " |
| 141 | FILES_${PN}-tickadj = "${sbindir}/tickadj" |
| 142 | FILES_${PN}-utils = "${sbindir} ${datadir}/ntp/lib" |
| 143 | RDEPENDS_${PN}-utils += "perl" |
| 144 | FILES_ntpdate = "${sbindir}/ntpdate \ |
| 145 | ${sysconfdir}/network/if-up.d/ntpdate-sync \ |
| 146 | ${bindir}/ntpdate-sync \ |
| 147 | ${sysconfdir}/default/ntpdate \ |
| 148 | ${systemd_unitdir}/system/ntpdate.service \ |
| 149 | " |
| 150 | FILES_sntp = "${sbindir}/sntp \ |
| 151 | ${sysconfdir}/default/sntp \ |
| 152 | ${systemd_unitdir}/system/sntp.service \ |
| 153 | " |
| 154 | |
| 155 | CONFFILES_${PN} = "${sysconfdir}/ntp.conf" |
| 156 | CONFFILES_ntpdate = "${sysconfdir}/default/ntpdate" |
| 157 | |
| 158 | INITSCRIPT_NAME = "ntpd" |
| 159 | # No dependencies, so just go in at the standard level (20) |
| 160 | INITSCRIPT_PARAMS = "defaults" |
| 161 | |
| 162 | pkg_postinst_ntpdate() { |
| 163 | if ! grep -q -s ntpdate $D/var/spool/cron/root; then |
| 164 | echo "adding crontab" |
| 165 | test -d $D/var/spool/cron || mkdir -p $D/var/spool/cron |
| 166 | echo "30 * * * * ${bindir}/ntpdate-sync silent" >> $D/var/spool/cron/root |
| 167 | fi |
| 168 | } |
| 169 | |
| 170 | inherit update-alternatives |
| 171 | |
| 172 | ALTERNATIVE_PRIORITY = "100" |
| 173 | |
| 174 | ALTERNATIVE_${PN} = "ntpd" |
| 175 | ALTERNATIVE_LINK_NAME[ntpd] = "${sbindir}/ntpd" |