Debian Codegraph @

buildprep

raw symbols SCIP
1 #!/bin/sh
2 #
3 # buildprep - prepare your system for a cvs-fast-export source build.
4 #
5 # Use the -n option to dry-run this command, showing what would be done
6 # without actually doing it
7 #
8 # This script swiped from NTPsec.
9
10 # Set the defaults
11 DRYRUN="no"
12 DOC="no"
13
14 OS=$(uname -s)
15
16 # Loop through option flags
17 for optflag in "$@"
18 do
19 case "$optflag" in
20 -h|--help)
21 cat <<EOF
22 $0 - prepare your system for a cvs-fast-export source build
23
24 Options:
25 -h --help Show usage information and exit
26 -n --dry-run Only show what would be done instead of doing it
27 --doc Install dependencies for building documentation
28 -a --all Install all possible dependencies
29 EOF
30 exit 0
31 ;;
32 -n|--dry-run)
33 DRYRUN="yes"
34 ;;
35 --doc)
36 DOC="yes"
37 ;;
38 -a|--all)
39 DOC="yes"
40 ;;
41 *)
42 echo "# WARNING: Unknown argument: $optflag"
43 echo "#"
44 ;;
45 esac
46 done
47
48 cat <<EOF
49 # Preparing your system for cvs-fast-export source build...
50 # This script presently knows about:
51 # Ubuntu (and POP_OS), Fedora using yum, Fedora using dnf, Gentoo.
52 #
53 # It has some stub code for other systems; please fill that in if you
54 # can and send us an MR.
55 #
56 # If you are running something else, such as macOS or Solaris, please
57 # read the source for this buildprep script to get an idea of what packages
58 # are required.
59 #
60 EOF
61
62 if [ "$DRYRUN" = "yes" ]
63 then
64 do='echo'
65 echo "# Run this without -n|--dry-run, as root, for actual installation."
66 echo " #You may want to run an update from your package inddex first."
67 echo "#"
68 else
69 do=""
70 if [ "$(id -u)" != 0 ]
71 then
72 echo "# ERROR: You must be running as root for your installer to do its thing."
73 echo "# ERROR: If you just wish to see what would be done, use the -n option."
74 exit 1
75 fi
76 fi
77
78 if emerge --version 2>/dev/null
79 then
80 installer=emerge
81 install="$do $installer -q y"
82 elif yum version 2>/dev/null
83 then
84 installer=yum
85 install="$do $installer -y install"
86 elif dnf --version >/dev/null 2>&1
87 then
88 installer=dnf
89 install="$do $installer -y install"
90 elif apt-get --version >/dev/null 2>&1
91 then
92 installer=apt
93 install="$do apt-get install -qy"
94 elif zypper -h >/dev/null 2>&1
95 then
96 # OpenSUSE prefers zypper over yast
97 installer=zypper
98 install="$do $installer install -y"
99 elif yast -h >/dev/null 2>&1
100 then
101 installer=yast
102 install="$do $installer --install"
103 elif apk --version >/dev/null 2>&1
104 then
105 # Alpine Linux, musl rather than glibc
106 installer=apk
107 install="$do $installer add"
108 elif command -v pacman
109 then
110 # Arch Linux
111 installer=pacman
112 install="$do $installer -S --needed --noconfirm"
113 elif [ "$OS" = "NetBSD" ]
114 then
115 if pkgin -v
116 then
117 # NetBSD binary package installer
118 installer=pkgin
119 install="$do $installer install"
120 else
121 echo "## Looks like a NetBSD system"
122 echo "## You need to setup pkgin"
123 echo "## The last page of install disk has a check-box to do it"
124 echo "## But you don't get that option on a Raspberry Pi."
125 echo "## For the Pi, do something like:"
126 echo "## pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/earmv7hf/8.0/All/pkgin-0.9.4nb8.tgz"
127 echo "## Adjust the version and arch to match your setup."
128 exit 1
129 fi
130 elif [ "$OS" = "FreeBSD" ]
131 then
132 if pkg -v
133 then
134 # FreeBSD binary package installer
135 installer=pkg
136 install="$do $installer install"
137 fi
138 else
139 echo "# ERROR: Package manager unidentified - Unsupported operating system"
140 exit 1
141 fi
142 echo "# Your package installer is ${installer}."
143 echo ""
144
145 main () {
146 # Prerequisites to build the daemon: bison, pps-tools, service libraries
147 case $installer in
148 apk)
149 echo "Not yet supported" >&2
150 exit 1
151 ;;
152 apt)
153 # tzdata needs to be installed explicitly so it won't try an interactive
154 # configuration when pulled as a dependency. This package doesn't care
155 # whether your Python is 2.x or 3.x.
156 $install tzdata
157 $install make grep sed gcc bison flex python3 git rcs cvs pylint cppcheck shellcheck
158 ;;
159 emerge)
160 echo "Not yet supported" >&2
161 exit 1
162 ;;
163 pacman)
164 $install tzdata
165 $install make grep sed gcc bison flex python git rcs cvs \
166 python-pylint cppcheck shellcheck
167 ;;
168 pkgin)
169 echo "Not yet supported" >&2
170 exit 1
171 ;;
172 pkg)
173 echo "Not yet supported" >&2
174 exit 1
175 ;;
176 yum)
177 echo "Not yet supported" >&2
178 exit 1
179 ;;
180 dnf)
181 $install tzdata
182 $install make grep sed gcc bison flex rcs cvs pylint cppcheck ShellCheck
183 ;;
184 yast)
185 echo "Not yet supported" >&2
186 exit 1
187 ;;
188 zypper)
189 echo "Not yet supported" >&2
190 exit 1
191 ;;
192 esac
193 }
194
195 doc () {
196 # prerequisites to build documentation
197 case $installer in
198 apk)
199 echo "Not yet supported" >&2
200 exit 1
201 ;;
202 apt)
203 $install asciidoc
204 ;;
205 emerge)
206 echo "Not yet supported" >&2
207 exit 1
208 ;;
209 pacman)
210 $install asciidoc
211 ;;
212 pkgin)
213 echo "Not yet supported" >&2
214 exit 1
215 ;;
216 pkg)
217 echo "Not yet supported" >&2
218 exit 1
219 ;;
220 yum)
221 echo "Not yet supported" >&2
222 exit 1
223 ;;
224 dnf)
225 $install asciidoc
226 ;;
227 yast|zypper)
228 echo "Not yet supported" >&2
229 exit 1
230 ;;
231 esac
232 }
233
234 # Main sequence
235 main
236
237 if [ "$DOC" = "yes" ]
238 then
239 doc
240 else
241 echo ""
242 echo "# Skipping documentation dependencies [--doc]"
243 fi
244
245 echo ""
246 echo "# Done."
247
248 # end