Re: compilation error clockspeed

Bennett Todd <[email protected]> Tue, 19 Nov 2002 09:16:10 -0500
Newsgroups gmane.comp.lib.libtai
Message-ID <[email protected]>
2002-11-19-01:24:13 np rpr:
> I am using clockspeed for the very first time.

Congratulations! One big heads-up --- it caught me by surprise.

Clockspeed manages the Unix system clock as a TAI clock. What this
means, in practice, is that the clock advances one second every real
second, always. Sounds reasonable, doesn't it?

Reasonable means you've got troubles from POSIX:-). POSIX, at least
as interpreted by the implementors of the timezone library and of
NTP, calls for stalling the Unix clock, so that it does not advance
during leap seconds; POSIX's notion is that every day always has
86,400 seconds, and leap seconds don't exist.

The upshot of all this is that when you use clockspeed to keep your
clock stable and sntpclock to synchronize, your clock runs very
nicely, 22 seconds faster than the rest of the world. Next time a
leap second happens (won't be before the middle of next year at the
earliest) that will be 23 seconds. You can make things work out
right, get the right time displayed by date(1) and everything else,
if you change your timezone. You can probably just prepend "right/"
to the timezone you're using. I'm using US/Eastern, so I changed it
to right/US/Eastern. I also copied
/usr/share/zoneinfo/right/US/Eastern to /etc/localtime and updated
copies in chroot jails.

> First of all does it work on Linux?

Magnificently.

> I am trying to compile it on RH7.2 (2.4.7-4).

You need the attached patch, which as Daniel Biddle indicated, adds
a #include of <time.h> where it's needed.

I also attach an init script I wrote, and a spec file for building
an rpm.

Under djb's licensing, it is as far as I know fine for me to
distribute these files, but, since I had to patch the clockspeed
source code to get it to compile, and since I adjusted conf-home as
well to get the adjust file under /var/run, a binary rpm built from
these bits cannot be redistributed.

I'm still uncertain whether a src.rpm, which is just a concatenation
of the original clockspeed-0.62.tar.gz with these attached files,
would be legal to distribute or not.

If you're not hip to building rpms and would like a quick tutorial,
please email me off-list.

Enjoy,

-Bennett
clockspeed-0.62-redhat-7.2.patch (text/plain, 319 B)
diff -ru clockspeed-0.62.orig/clockview.c clockspeed-0.62/clockview.c
--- clockspeed-0.62.orig/clockview.c	Tue Oct 13 13:37:49 1998
+++ clockspeed-0.62/clockview.c	Fri May 17 09:10:57 2002
@@ -14,7 +14,7 @@
 time_t when;
 unsigned long nano;
 unsigned long atto;
-
+#include <time.h>
 void print()
 {
   struct tm *tm;
clockspeed.init (text/plain, 469 B)
#!/bin/sh -e
# chkconfig: 2345 99 01
# description: start/stop clockspeed daemon

# Source function library.
. /etc/rc.d/init.d/functions

case "$1" in
 start)	echo -n starting clockspeed
	/usr/bin/clockspeed &
	echo $! >/var/run/clockspeed.pid
	echo_success;echo ''
	;;

  stop)	echo -n stopping clockspeed
	kill `cat /var/run/clockspeed.pid`
	echo_success;echo ''
	;;

restart) $0 stop; $0 start;;
 *) echo "syntax: `basename $0` start|stop|restart">&2;exit 1;;
esac
clockspeed.spec (text/plain, 1.3 KB)
Summary: clock timing adjuster
Name: clockspeed
Version: 0.62
Release: 2
Source0: http://cr.yp.to/%{name}/%{name}-%{PACKAGE_VERSION}.tar.gz
Source1: clockspeed.init
Patch0: clockspeed-0.62-redhat-7.2.patch
URL: http://cr.yp.to/%{name}.html
License: http://cr.yp.to/dnscache/dist.html
Group: System Environment/Daemons
BuildRoot: /var/tmp/%{name}-rpmroot
%description

%{name} allows setting the system clock, and adjusting it to correct
for persistent drift.

%changelog
* Fri May 17 2002 Bennett Todd <[email protected]>
  - 0.62-2: redhat-7.2.patch
* Mon Jul 10 2000 Bennett Todd <[email protected]>
  - 0.62-1: Initial wrap

%prep
%setup
%patch0 -p1
echo /var/run/clockspeed >conf-home

%build
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/{etc,usr/{bin,man/man1},var/run/clockspeed}
rm install instcheck auto_home.[co]
echo $RPM_BUILD_ROOT/usr >conf-home
perl -pi -e 's#c\("/",#c\("'$RPM_BUILD_ROOT/'",#' hier.c

make install instcheck
./install
./instcheck

mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
cp $RPM_SOURCE_DIR/clockspeed.init $RPM_BUILD_ROOT/etc/rc.d/init.d/clockspeed
chmod 755 $RPM_BUILD_ROOT/etc/rc.d/init.d/clockspeed

%files
%defattr(-,root,root)
%config /etc/leapsecs.dat
/etc/rc.d/init.d/clockspeed
/usr/bin/*
%dir /var/run/clockspeed
%doc [A-Z]*
%doc /usr/man/man*/*
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE92keqHZWg9mCTffwRAir3AJ9jLP47DgD5rHsf0CIusTlsHGpw2wCg1MBO
ssp7SawuqHDy4fuFLDg9fbI=
=VyQk
-----END PGP SIGNATURE-----