3 # Copyright the NTPsec project contributors
5 # SPDX-License-Identifier: BSD-2-Clause
8 # buildprep - prepare your system for an NTPsec source build.
10 # Use the -n option to dry-run this command, showing what would be done
11 # without actually doing it
22 # Loop through option flags
28 $0 - prepare your system for an NTPsec source build
31 -h --help Show usage information and exit
32 -n --dry-run Only show what would be done instead of doing it
33 --ntpviz Install dependencies for ntpviz tool
34 --doc Install dependencies for building documentation
35 --update Update package repositories
36 -a --all Install all possible dependencies
57 echo "# WARNING: Unknown argument: $optflag"
63 # Some Python 2 packages (e.g python-devel, python-psutils) conventionally have
64 # Python 3 equivalents with a python3 prefix. Compute the correct value for the
65 # infix based on system Python. This eill start to be significant after Python 2
66 # EOLs at the beginning of 2020.
67 PYVERS
=$
(python
--version 2>&1 |
sed -n -e '/Python \([0-9]\).*/s//\1/p')
68 if [ "$PYVERS" = "2" ]
74 # Preparing your system for ntpsec source build...
75 # This script presently knows about:
76 # CentOS, Debian, Fedora, Gentoo, NetBSD, FreeBSD,
77 $ SLES, Ubuntu, and Alpine Linux
78 # If you are running something else, such as macOS or Solaris, please
79 # read the source for this buildprep script to get an idea of what packages
84 if [ "$DRYRUN" = "yes" ]
87 echo "# Run this without -n|--dry-run, as root, for actual installation."
91 if [ "$(id -u)" != 0 ]
93 echo "# ERROR: You must be running as root for your installer to do its thing."
94 echo "# ERROR: If you just wish to see what would be done, use the -n option."
99 if emerge
--version 2>/dev
/null
102 install="$do $installer -q y"
103 elif yum version
2>/dev
/null
106 install="$do $installer -y install"
107 elif dnf
--version >/dev
/null
2>&1
110 install="$do $installer -y install"
111 elif apt-get
--version >/dev
/null
2>&1
114 install="$do apt-get install -y"
115 elif zypper
-h >/dev
/null
2>&1
117 # OpenSUSE prefers zypper over yast
119 install="$do $installer install -y"
120 elif yast
-h >/dev
/null
2>&1
123 install="$do $installer --install"
124 elif apk
--version >/dev
/null
2>&1
126 # Alpine Linux, musl rather than glibc
128 install="$do $installer add"
129 elif test "$OS" = "NetBSD"
133 # NetBSD binary package installer
135 install="$do $installer install"
137 echo "## Looks like a NetBSD system"
138 echo "## You need to setup pkgin"
139 echo "## The last page of install disk has a check-box to do it"
140 echo "## But you don't get that option on a Raspberry Pi."
141 echo "## For the Pi, do something like:"
142 echo "## pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/earmv7hf/8.0/All/pkgin-0.9.4nb8.tgz"
143 echo "## Adjust the version and arch to match your setup."
146 elif test "$OS" = "FreeBSD"
150 # FreeBSD binary package installer
152 install="$do $installer install"
155 echo "# ERROR: Package manager unidentified - Unsupported operating system"
158 echo "# Your package installer is ${installer}."
161 # In order to have a single point of truth about prerequisite package names,
162 # these package name lists have been *removed* from INSTALL.
164 # Build time vs. run time:
165 # Build dependencies are marked. You'll need them all when building from a
166 # repository copy; the unmarked (run-time) dependencies are information for
167 # packagers. Under Gentoo, all dependencies are build dependencies.
169 # Notes on optional packages:
170 # libdnssd is optional for ntpd. Support for mDNS Service Discovery registration
171 # libcap (under Linux) enables dropping root and is not strictly required.
174 # Prerequisites to build the daemon: bison, pps-tools, service libraries
177 $install build-base python
# basic tools
178 $install bison
"python${PYVERS}-dev" linux-headers
179 $install openssl-dev libcap-dev libseccomp-dev
180 # probably needs more, but this builds
181 # can't find timepps.h: gpsd and chrony have their own ??
184 $install build-essential
# Build environment
185 $install bison libssl-dev
# build
186 $install libcap-dev libseccomp-dev
# build
187 $install libavahi-compat-libdnssd-dev
# optional build
189 $install python3-dev python-is-python3
192 # Build environment included!
193 $install sys-libs
/libcap sys-libs
/libseccomp
194 $install sys-devel
/bison net-misc
/pps-tools
198 # There is nothing magic about 3.7.
199 # In Dec 2018, 3.6 and 2.7 are also good candidates.
200 $install bison python37 py37-curses-3.7
201 # certificates for NTS
202 $install mozilla-rootcerts mozilla-rootcerts-openssl
203 # Also needs "nts ca /etc/openssl/certs/"
204 # setup "python" from command line
205 $do ln -s /usr
/pkg
/bin
/python3.7
/usr
/pkg
/bin
/python
206 $do ln -s /usr
/pkg
/bin
/python3.7
/usr
/pkg
/bin
/python3
207 # Add to Python search path
208 if [ "$DRYRUN" = "yes" ]
210 echo echo /usr
/local
/lib
/python3.7
/site-packages \
> \\
211 echo " " /usr
/pkg
/lib
/python3.7
/site-packages
/ntpsec.pth
213 echo /usr
/local
/lib
/python3.7
/site-packages
> \
214 /usr
/pkg
/lib
/python3.7
/site-packages
/ntpsec.pth
219 $install bison python3
220 $do ln -s /usr
/local
/bin
/python3
/usr
/local
/bin
/python
221 # certificates for NTS
225 $do $installer groupinstall
"Development Tools" # Build environment
226 $install bison openssl-devel
# build
227 $install libcap-devel libseccomp-devel
# build
228 $install pps-tools-devel
# build
229 $install avahi-compat-libdns_sd-devel
# optional build
230 $install libcap openssl-libs pps-tools
233 echo "# SLES versions 12 and earlier do not have pps-tools"
234 $install basis-devel
# Build environment
235 $install libcap-devel libseccomp-devel
# build
236 $install openssl-devel
# build
237 $install libcap2 openssl-libs
238 $install "python${PYVERS}-curses"
241 $install -t pattern devel_basis
# Build environment
242 $install bison
# build
243 $install libcap-devel libseccomp-devel
# build
244 $install openssl-devel
# build
245 echo "# SLES versions 12 and earlier do not have pps-tools"
246 $install pps-tools-devel
# build
248 $install libcap2 openssl-libs
249 $install "python${PYVERS}-curses"
255 # Prerequisites for the client Python tools: python extensions
258 $install "python${PYVERS}-dev"
261 $install "python${PYVERS}-devel"
267 # Prerequisites to use ntpviz: gnuplot and liberation fonts
270 $install gnuplot ||
echo "# You need to enable the community repository"
271 $install ttf-liberation
274 distro
=$
(lsb_release
-i -s)
275 if [ "$distro" = "Ubuntu" ]
277 echo "# Looks like an Ubuntu system"
280 echo "# Looks like a generic Debian system"
283 $install fonts-liberation
"python${PYVERS}-psutil"
286 $install sci-visualization
/gnuplot
287 $install media-fonts
/liberation-fonts
291 $install liberation-fonts-common.noarch
292 $install liberation-mono-fonts.noarch
293 $install liberation-narrow-fonts.noarch
294 $install liberation-sans-fonts.noarch
295 $install liberation-serif-fonts.noarch
298 $install gnuplot liberation-fonts
304 # prerequisites to build documentation
313 $install app-text
/asciidoc
316 echo "# Please check that your asciidoc is at least 8.6.0"
317 echo "# You may need to enable EPEL repositories"
333 # prerequisites to build documentation
336 $do $installer --sync
339 $do $installer update
342 $do $installer distro-sync
345 $do $installer-get update
348 $do $installer-get refresh
353 if [ "$UPDATE" = "yes" ]
358 echo "# Skipping update of package repositories [-u] [--update]"
365 if [ "$NTPVIZ" = "yes" ]
370 echo "# Skipping ntpviz dependencies [--ntpviz]"
373 if [ "$DOC" = "yes" ]
378 echo "# Skipping documentation dependencies [--doc]"