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