diff --git a/srcpkgs/clockspeed/files/NOTES b/srcpkgs/clockspeed/files/NOTES new file mode 100644 index 0000000000..194067a449 --- /dev/null +++ b/srcpkgs/clockspeed/files/NOTES @@ -0,0 +1,8 @@ +This clockspeed package includes two services, /etc/sv/clockspeed and +/etc/sv/clockspeed_adjust, which implement the methodology described +at http://thedjbway.b0llix.net. + +SEE ALSO: +http://thedjbway.b0llix.net/clockspeed.html +http://thedjbway.b0llix.net/clocksd.html + diff --git a/srcpkgs/clockspeed/files/clockctl b/srcpkgs/clockspeed/files/clockctl new file mode 100755 index 0000000000..e8631e5879 --- /dev/null +++ b/srcpkgs/clockspeed/files/clockctl @@ -0,0 +1,69 @@ +#!/bin/sh +# clockctl +# interface to djb clockspeed (0.62) +# === +# from http://thedjbway.b0llix.net/clockspeed/clockctl.html + +# read configuration: +if [ -r /etc/clockspeed/clockspeed.conf ] ; then + . /etc/clockspeed/clockspeed.conf +else + echo "$0: configuration error: unable to read clockspeed.conf" + exit 1 +fi + +# clock_pick function: +clock_pick() +{ + case ${CLOCK_TYPE} in + ntp|NTP) + ${CLOCKSPEED_BIN}/sntpclock "${CLOCK_IP}" + ;; + tai|TAI) + ${CLOCKSPEED_BIN}/taiclock "${CLOCK_IP}" + ;; + *) + echo "$0: configuration error: CLOCK_TYPE not recognized" + exit 1; + ;; + esac +} + + +# process command: +case $1 in +a|atto) + echo "Viewing current attoseconds in hardware tick:" + ${CLOCKSPEED_BIN}/clockview < ${CLOCKSPEED_HOME}/etc/atto + ;; +m|mark) + echo "Obtaining new calibration mark from master server at ${CLOCK_IP}:" + clock_pick | tee ${CLOCKSPEED_HOME}/adjust | ${CLOCKSPEED_BIN}/clockview + ;; +s|sync) + echo "Setting system clock with master server at ${CLOCK_IP}:" + clock_pick | ${CLOCKSPEED_BIN}/clockadd && \ + clock_pick | ${CLOCKSPEED_BIN}/clockview + ;; +v|view) + echo "Checking system clock against master server at ${CLOCK_IP} (clockview):" + clock_pick | ${CLOCKSPEED_BIN}/clockview + ;; +h|help) + cat <&1 +[ -d /var/lib/clockspeed/etc ] || mkdir -p /var/lib/clockspeed/etc +echo "*** Starting clockspeed..." +exec /usr/bin/clockspeed diff --git a/srcpkgs/clockspeed/files/clockspeed_adjust/clock_adjust.sh b/srcpkgs/clockspeed/files/clockspeed_adjust/clock_adjust.sh new file mode 100755 index 0000000000..7bad61838b --- /dev/null +++ b/srcpkgs/clockspeed/files/clockspeed_adjust/clock_adjust.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# from http://thedjbway.b0llix.net/clocksd/index.html +# +# clock_adjust.sh +# periodically get timing mark for clockspeed service + +# initialize WAIT, WAIT_MAX: +WAIT=541 +WAIT_MAX=2617923 + +# loop indefinitely +while : +do + # obtain timing mark for calibrating clockspeed adjust: + clockctl mark + # log current "attoseconds": + clockctl atto + echo "===" + echo "Waiting ${WAIT} seconds until next adjustment..." + sleep ${WAIT} + # increment $WAIT: + WAIT=`expr ${WAIT} + ${WAIT} + ${WAIT}` + if [ ${WAIT} -gt ${WAIT_MAX} ] ; then + WAIT=${WAIT_MAX} + fi +done diff --git a/srcpkgs/clockspeed/files/clockspeed_adjust/log/run b/srcpkgs/clockspeed/files/clockspeed_adjust/log/run new file mode 120000 index 0000000000..914853dd4f --- /dev/null +++ b/srcpkgs/clockspeed/files/clockspeed_adjust/log/run @@ -0,0 +1 @@ +/usr/bin/rsvlog \ No newline at end of file diff --git a/srcpkgs/clockspeed/files/clockspeed_adjust/run b/srcpkgs/clockspeed/files/clockspeed_adjust/run new file mode 100755 index 0000000000..7b606c102c --- /dev/null +++ b/srcpkgs/clockspeed/files/clockspeed_adjust/run @@ -0,0 +1,9 @@ +#!/bin/sh -e +# clockspeed_adjust/run +# "run" script for a clockspeed_adjust daemon +echo "*** Checking for clockspeed daemon..." +sv -w5 u clockspeed +exec 2>&1 +echo "*** Starting clockspeed_adjust..." +chown clocksd /var/lib/clockspeed/adjust +exec chpst -u clocksd:nogroup ./clock_adjust.sh diff --git a/srcpkgs/clockspeed/files/taiclockd/log/run b/srcpkgs/clockspeed/files/taiclockd/log/run new file mode 120000 index 0000000000..914853dd4f --- /dev/null +++ b/srcpkgs/clockspeed/files/taiclockd/log/run @@ -0,0 +1 @@ +/usr/bin/rsvlog \ No newline at end of file diff --git a/srcpkgs/clockspeed/files/taiclockd/run b/srcpkgs/clockspeed/files/taiclockd/run new file mode 100644 index 0000000000..ba356a163d --- /dev/null +++ b/srcpkgs/clockspeed/files/taiclockd/run @@ -0,0 +1,6 @@ +#!/bin/sh +# taiclockd/run +# "run" script for a taiclockd daemon +exec 2>&1 +echo "*** Starting taiclockd..." +exec chpst -u clocksd:nogroup /usr/bin/taiclockd diff --git a/srcpkgs/clockspeed/patches/clockspeed-0.62.cross.patch b/srcpkgs/clockspeed/patches/clockspeed-0.62.cross.patch new file mode 100644 index 0000000000..d6c15812bd --- /dev/null +++ b/srcpkgs/clockspeed/patches/clockspeed-0.62.cross.patch @@ -0,0 +1,16 @@ +diff -Naur clockspeed-0.62.orig/conf-cc clockspeed-0.62/conf-cc +--- clockspeed-0.62.orig/conf-cc 1998-10-13 12:37:49.000000000 -0500 ++++ clockspeed-0.62/conf-cc 2015-02-25 13:38:10.932118897 -0600 +@@ -1,3 +1,3 @@ +-gcc -O2 ++$CC -O2 + + This will be used to compile .c files. +diff -Naur clockspeed-0.62.orig/conf-ld clockspeed-0.62/conf-ld +--- clockspeed-0.62.orig/conf-ld 1998-10-13 12:37:49.000000000 -0500 ++++ clockspeed-0.62/conf-ld 2015-02-25 13:40:43.579122985 -0600 +@@ -1,3 +1,3 @@ +-gcc -s ++$CC -s $LDFLAGS + + This will be used to link .o files into an executable. diff --git a/srcpkgs/clockspeed/patches/clockspeed-0.62.errno.patch b/srcpkgs/clockspeed/patches/clockspeed-0.62.errno.patch new file mode 100644 index 0000000000..0280d067af --- /dev/null +++ b/srcpkgs/clockspeed/patches/clockspeed-0.62.errno.patch @@ -0,0 +1,33 @@ +diff -u clockspeed-0.62.old/clockview.c clockspeed-0.62/clockview.c +--- clockspeed-0.62.old/clockview.c 1998-10-13 12:37:49.000000000 -0500 ++++ clockspeed-0.62/clockview.c 2003-05-08 09:59:26.000000000 -0500 +@@ -1,5 +1,6 @@ + #include + #include ++#include + #include "substdio.h" + #include "readwrite.h" + #include "strerr.h" +diff -u clockspeed-0.62.old/error.h clockspeed-0.62/error.h +--- clockspeed-0.62.old/error.h 1998-10-13 12:37:49.000000000 -0500 ++++ clockspeed-0.62/error.h 2003-05-08 09:07:13.000000000 -0500 +@@ -1,7 +1,7 @@ + #ifndef ERROR_H + #define ERROR_H + +-extern int errno; ++#include + + extern int error_intr; + extern int error_nomem; +diff -u clockspeed-0.62.old/leapsecs_read.c clockspeed-0.62/leapsecs_read.c +--- clockspeed-0.62.old/leapsecs_read.c 1998-10-13 12:37:49.000000000 -0500 ++++ clockspeed-0.62/leapsecs_read.c 2003-05-08 09:07:13.000000000 -0500 +@@ -2,7 +2,6 @@ + #include + #include + #include +-extern int errno; + #include "tai.h" + #include "leapsecs.h" + diff --git a/srcpkgs/clockspeed/template b/srcpkgs/clockspeed/template new file mode 100644 index 0000000000..b4685f394f --- /dev/null +++ b/srcpkgs/clockspeed/template @@ -0,0 +1,43 @@ +# Template file for 'clockspeed' +pkgname="clockspeed" +version="0.62" +revision=1 +build_style="gnu-makefile" +makedepends="groff" +hostmakedepends="groff" +depends="sv-helper" +only_for_archs="i686 x86_64" +make_dirs="/etc/clockspeed 0755 root root" +short_desc="Dan Bernstein's clockspeed (network) timekeeping utility" +maintainer="bougyman " +license="Public Domain" +homepage="http://cr.yp.to/clockspeed.html" +distfiles="http://cr.yp.to/clockspeed/clockspeed-0.62.tar.gz " +checksum=43539964c4b554794b2da760d138c5975cbc850f1c8ec2ee96f5dba66e0d9eed + +system_accounts="clocksd" +clocksd_groups="nogroup" +clocksd_homedir="/var/lib/${pkgname}" +clocksd_descr="User for clockspeed adjustments" +conf_files="/etc/${pkgname}/${pkgname}.conf" +patch_args="-p1" + +pre_build() { + sed -i -e 's|/usr/local/clockspeed|/var/lib/clockspeed|' conf-home +} + +do_install() { + for binary in clockadd clockspeed clockview sntpclock taiclock taiclockd; + do + vbin $binary + done + vbin ${FILESDIR}/clockctl + vconf leapsecs.dat + vmkdir etc/clockspeed + vinstall ${FILESDIR}/clockspeed.conf 644 etc/clockspeed + vsv clockspeed + vsv clockspeed_adjust + vdoc README + vdoc INSTALL + vdoc ${FILESDIR}/NOTES +}