ntp.scm 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
  3. ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
  5. ;;; Copyright © 2015, 2018 Ludovic Courtès <ludo@gnu.org>
  6. ;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
  7. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (gnu packages ntp)
  24. #:use-module (gnu packages)
  25. #:use-module (gnu packages base)
  26. #:use-module (gnu packages linux)
  27. #:use-module (gnu packages autotools)
  28. #:use-module (gnu packages pkg-config)
  29. #:use-module (gnu packages tls)
  30. #:use-module (gnu packages libevent)
  31. #:use-module ((guix licenses) #:prefix l:)
  32. #:use-module (guix packages)
  33. #:use-module (guix utils)
  34. #:use-module (guix download)
  35. #:use-module (guix git-download)
  36. #:use-module (guix build-system gnu)
  37. #:use-module (srfi srfi-1))
  38. (define-public ntp
  39. (package
  40. (name "ntp")
  41. (version "4.2.8p12")
  42. (source
  43. (origin
  44. (method url-fetch)
  45. (uri (list (string-append
  46. "http://archive.ntp.org/ntp4/ntp-"
  47. (version-major+minor version)
  48. "/ntp-" version ".tar.gz")
  49. (string-append
  50. "https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-"
  51. (version-major+minor version)
  52. "/ntp-" version ".tar.gz")))
  53. (sha256
  54. (base32
  55. "0m04ndn0674kcf9x0aggjya07a3hlig2nlzzpwk7vmqka0mj56vh"))
  56. (modules '((guix build utils)))
  57. (snippet
  58. '(begin
  59. ;; Remove the bundled copy of libevent, but we must keep
  60. ;; sntp/libevent/build-aux since configure.ac contains
  61. ;; AC_CONFIG_AUX_DIR([sntp/libevent/build-aux])
  62. (rename-file "sntp/libevent/build-aux"
  63. "sntp/libevent:build-aux")
  64. (delete-file-recursively "sntp/libevent")
  65. (mkdir "sntp/libevent")
  66. (rename-file "sntp/libevent:build-aux"
  67. "sntp/libevent/build-aux")
  68. #t))))
  69. (native-inputs `(("which" ,which)
  70. ("pkg-config" ,pkg-config)))
  71. (inputs
  72. `(("openssl" ,openssl)
  73. ("libevent" ,libevent)
  74. ;; Build with POSIX capabilities support on GNU/Linux. This allows 'ntpd'
  75. ;; to run as non-root (when invoked with '-u'.)
  76. ,@(if (string-suffix? "-linux"
  77. (or (%current-target-system) (%current-system)))
  78. `(("libcap" ,libcap))
  79. '())))
  80. (arguments
  81. `(#:phases
  82. (modify-phases %standard-phases
  83. (add-after 'unpack 'disable-network-test
  84. (lambda _
  85. (substitute* "tests/libntp/Makefile.in"
  86. (("test-decodenetnum\\$\\(EXEEXT\\) ") ""))
  87. #t)))))
  88. (build-system gnu-build-system)
  89. (synopsis "Real time clock synchronization system")
  90. (description "NTP is a system designed to synchronize the clocks of
  91. computers over a network.")
  92. (license (l:x11-style
  93. "http://www.eecis.udel.edu/~mills/ntp/html/copyright.html"
  94. "A non-copyleft free licence from the University of Delaware"))
  95. (home-page "http://www.ntp.org")))
  96. (define-public openntpd
  97. (package
  98. (name "openntpd")
  99. (version "6.2p3")
  100. (source (origin
  101. (method url-fetch)
  102. (uri (string-append
  103. "mirror://openbsd/OpenNTPD/" name "-" version ".tar.gz"))
  104. (sha256
  105. (base32
  106. "0fn12i4kzsi0zkr4qp3dp9bycmirnfapajqvdfx02zhr4hanj0kv"))))
  107. (build-system gnu-build-system)
  108. (arguments
  109. '(#:configure-flags '("--with-privsep-user=ntpd"
  110. "--localstatedir=/var")
  111. #:phases
  112. (modify-phases %standard-phases
  113. (add-after 'unpack 'modify-install-locations
  114. (lambda _
  115. ;; Don't try to create /var/run or /var/db
  116. (substitute* "src/Makefile.in"
  117. (("DESTDIR\\)\\$\\(localstatedir") "TMPDIR"))
  118. #t)))))
  119. (inputs
  120. `(("libressl" ,libressl))) ; enable TLS time constraints. See ntpd.conf(5).
  121. (home-page "http://www.openntpd.org/")
  122. (synopsis "NTP client and server by the OpenBSD Project")
  123. (description "OpenNTPD is the OpenBSD Project's implementation of a client
  124. and server for the Network Time Protocol. Its design goals include being
  125. secure, easy to configure, and accurate enough for most purposes, so it's more
  126. minimalist than ntpd.")
  127. ;; A few of the source files are under bsd-3.
  128. (license (list l:isc l:bsd-3))))
  129. (define-public tlsdate
  130. (package
  131. (name "tlsdate")
  132. (version "0.0.13")
  133. (home-page "https://github.com/ioerror/tlsdate")
  134. (source (origin
  135. (method git-fetch)
  136. (uri (git-reference
  137. (commit (string-append "tlsdate-" version))
  138. (url home-page)))
  139. (sha256
  140. (base32
  141. "0w3v63qmbhpqlxjsvf4k3zp90k6mdzi8cdpgshan9iphy1f44xgl"))
  142. (file-name (string-append name "-" version "-checkout"))))
  143. (build-system gnu-build-system)
  144. (arguments
  145. `(;; Disable seccomp when it's not supported--e.g., on aarch64. See
  146. ;; 'src/seccomp.c' for the list of supported systems.
  147. #:configure-flags ,(if (any (lambda (system)
  148. (string-contains (or
  149. (%current-target-system)
  150. (%current-system))
  151. system))
  152. '("x86_64" "i686" "arm"))
  153. ''()
  154. ''("--disable-seccomp-filter"))
  155. #:phases (modify-phases %standard-phases
  156. (add-after 'unpack 'autogen
  157. (lambda _
  158. ;; The ancestor of 'SOURCE_DATE_EPOCH'; it contains the
  159. ;; date that is recorded in binaries. It must be a
  160. ;; "recent date" since it is used to detect bogus dates
  161. ;; received from servers.
  162. (setenv "COMPILE_DATE" (number->string 1530144000))
  163. (invoke "sh" "autogen.sh"))))))
  164. (inputs `(("openssl" ,openssl)
  165. ("libevent" ,libevent)))
  166. (native-inputs `(("pkg-config" ,pkg-config)
  167. ("autoconf" ,autoconf)
  168. ("automake" ,automake)
  169. ("libtool" ,libtool)))
  170. (synopsis "Extract remote time from TLS handshakes")
  171. (description
  172. "@command{tlsdate} sets the local clock by securely connecting with TLS
  173. to remote servers and extracting the remote time out of the secure handshake.
  174. Unlike ntpdate, @command{tlsdate} uses TCP, for instance connecting to a
  175. remote HTTPS or TLS enabled service, and provides some protection against
  176. adversaries that try to feed you malicious time information.")
  177. (license l:bsd-3)))