OILS / deps / from-apt.sh View on Github | oilshell.org

412 lines, 205 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# deps/from-apt.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10# These are needed for bootstrapping pip in Python 3.10
11# (Also used by build/py.sh ubuntu-deps)
12#
13# For building Python 3.10 with working 'pip install'
14# libssl-dev: to download packages
15# libffi-dev: for working setuptools
16# zlib1g-dev: needed for 'import zlib'
17declare -a PY3_BUILD_DEPS=(libssl-dev libffi-dev zlib1g-dev)
18
19# for deps/from-R.sh
20declare -a R_BUILD_DEPS=(
21 r-base-core # R interpreter
22
23 # ICU for the R stringi package. This makes compilation faster; otherwise
24 # it tries to compile it from source.
25 # https://stringi.gagolewski.com/install.html
26 libicu-dev
27)
28
29install-R() {
30 ### For manual use OUTSIDE container
31 apt-install "${R_BUILD_DEPS[@]}"
32}
33
34# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#run---mounttypecache
35
36# TODO: Use this for ALL images
37apt-install() {
38 ### Helper to slim down images
39
40 apt-get install -y --no-install-recommends "$@"
41}
42
43init-deb-cache() {
44 rm -f /etc/apt/apt.conf.d/docker-clean
45 echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
46}
47
48layer-wedge-bootstrap-debian() {
49 local -a packages=(
50 # xz-utils # do we need this for extraction?
51
52 gcc
53 g++ # re2c is C++
54 make # to build re2c
55
56 # for cmark
57 cmake
58
59 # cmake -G Ninja can be used
60 ninja-build
61
62 # For 'deps/wedge.sh unboxed-install'
63 sudo
64
65 # uftrace configure uses pkg-config to find python3 flags
66 pkg-config
67 # uftrace configure detects with #include "Python.h"
68 python3-dev
69 # shared library for uftrace to do dlopen()
70 # requires path in uftrace source
71 libpython3.7
72
73 # for USDT probes
74 systemtap-sdt-dev
75
76 # Dependencies for building our own Python3 wedge. Otherwise 'pip install'
77 # won't work.
78 # TODO: We should move 'pip install' to build time.
79 "${PY3_BUILD_DEPS[@]}"
80
81 # For installing R packages
82 "${R_BUILD_DEPS[@]}"
83 )
84
85 apt-get update
86
87 apt-install "${packages[@]}"
88}
89
90layer-python-symlink() {
91 ### A special layer for building CPython; done as root
92 ln -s -f -v /usr/bin/python2 /usr/bin/python
93}
94
95layer-debian-10() {
96 # Can't install packages in Debian without this
97 apt-get update # uses /var/lib/apt
98
99 # uses /var/cache/apt
100 apt-install git python2
101}
102
103layer-debian-12() {
104 # Can't install packages in Debian without this
105 apt-get update # uses /var/lib/apt
106
107 # uses /var/cache/apt
108 # Soil's time-tsv3 can run under python3 too
109 apt-install git python3
110}
111
112layer-locales() {
113 apt-install locales
114 # uncomment in a file
115 sed -i 's/# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
116 locale-gen --purge en_US.UTF-8
117}
118
119test-image() {
120 ### For testing builds, not run on CI
121
122 apt-install build-essential "${PY3_BUILD_DEPS[@]}"
123}
124
125wild() {
126 # for build/py.sh all
127 local -a packages=(
128 gcc # 'cc' for compiling Python extensions
129 g++ # for C++ tarball
130
131 python2-dev
132 libreadline-dev
133 curl # wait for cpp-tarball
134 )
135
136 apt-install "${packages[@]}"
137}
138
139dev-minimal() {
140 local -a packages=(
141 # TODO: remove
142 python2-dev # for building Python extensions
143 python-setuptools # Python 2, for flake8
144 python-pip # flake8 typing
145
146 gcc # for building Python extensions
147 libreadline-dev
148
149 python3-setuptools # mypy
150 python3-pip
151 # 2023-07: somehow this became necessary to pip3 install typed_ast, a MyPy
152 # dep, which recently updated to version 1.5.5
153 python3-dev
154
155 # Note: osh-minimal task needs shells; testing WITHOUT spec-bin shells
156 busybox-static mksh zsh
157
158 gawk
159
160 # 'ps' used by spec tests
161 procps
162 # for oil-spec task
163 jq
164 )
165
166 apt-install "${packages[@]}"
167}
168
169pea() {
170 # For installing MyPy
171 # apt-install python3-pip
172
173 echo 'None'
174}
175
176other-tests() {
177 local -a packages=(
178 libreadline-dev
179 python2-dev # osh2oil needs build/py.sh minimal
180
181 # Compilers for R. TODO: try removing after wedge
182 gcc g++
183
184 make # to build py27.grammar.marshal, ugh
185
186 r-base-core
187 )
188
189 apt-install "${packages[@]}"
190}
191
192cpp-small() {
193 local -a packages=(
194 # for build/py.sh all
195 libreadline-dev
196 python2-dev
197
198 # To compile Oil
199 g++
200 ninja-build
201
202 # For 32-bit binaries with -m32
203 gcc-multilib
204 g++-multilib
205
206 # For some tests
207 gawk
208
209 # for MyPy git clone https://. TODO: remove when the build is hermetic
210 ca-certificates
211
212 # for test/ltrace
213 ltrace
214
215 # for USDT probes
216 systemtap-sdt-dev
217 )
218
219 apt-install "${packages[@]}"
220}
221
222benchmarks() {
223 ### For benchmarks
224
225 local -a packages=(
226 # for build/py.sh all
227 libreadline-dev
228 python2-dev
229
230 # To build Oils
231 g++
232 ninja-build
233 make # to build R packages
234
235 # to create _test/index.html
236 gawk
237
238 # for stable benchmarks. TODO: could move osh-parser cachegrind to benchmarks2
239 valgrind
240
241 # benchmarks compare system shells -- they don't use our spec-bin? In case
242 # there are perf bugs caused by the build
243 busybox-static mksh zsh
244
245 # retrieving deps like benchmarks/osh-runtime -- TODO: move to build time
246 wget
247 bzip2 # extracting benchmarks/osh-runtime
248 xz-utils
249
250 # For analyzing benchmarks.
251 r-base-core
252
253 # pgrep used by test/stateful in interactive task
254 # TODO: Could move both Python and C++ to their own image
255 # That will be a good use case once we have
256 procps
257 )
258
259 apt-install "${packages[@]}"
260}
261
262bloaty() {
263 local -a packages=(
264 g++ # for C++ tarball
265 curl # wait for cpp-tarball
266 )
267
268 apt-install "${packages[@]}"
269}
270
271benchmarks2() {
272 ### uftrace needs a Python plugin
273
274 local -a packages=(
275 curl # fetch C++ tarball
276 g++ # build it
277
278 # uftrace needs a Python 3 plugin
279 # Technically we don't need 'python3' or 'python3.7' -- only the shared
280 # lib?
281 libpython3.7
282
283 # for stable benchmarks.
284 valgrind
285
286 # Analyze uftrace
287 r-base-core
288
289 # for MyPy git clone https://. TODO: remove when the build is hermetic
290 ca-certificates
291 )
292
293 apt-install "${packages[@]}"
294}
295
296cpp-spec() {
297 ### For cpp-spec
298
299 local -a packages=(
300 # for build/py.sh all
301 libreadline-dev
302 python2-dev
303
304 # To build Oil
305 g++
306 ninja-build
307
308 # to create _test/index.html
309 gawk
310
311 # spec tests use these
312 procps
313 jq
314
315 # for MyPy git clone https://. TODO: remove when the build is hermetic
316 ca-certificates
317 )
318
319 apt-install "${packages[@]}"
320}
321
322clang() {
323 ### For cpp-coverage
324
325 local -a packages=(
326 # For build/py.sh minimal
327 libreadline-dev
328 python2-dev
329
330 # Compile Oils
331 g++
332 ninja-build
333
334 xz-utils # to extract Clang
335
336 # for MyPy git clone https://. TODO: remove when the build is hermetic
337 ca-certificates
338 )
339
340 apt-install "${packages[@]}"
341}
342
343ovm-tarball() {
344 local -a packages=(
345 # build/py.sh all
346 libreadline-dev
347 python2-dev
348
349 # retrieving spec-bin -- TODO: move to build time
350 wget
351 # for wget https://. TODO: remove when the build is hermetic
352 ca-certificates
353
354 # when spec tests use 'time', dash falls back on 'time' command
355 'time'
356
357 # TODO: probably can remove C++ compiler now that re2c is a wedge
358 gcc
359 g++
360
361 # for cmark
362 cmake
363 # to build Python-2.7.13 (could be a wedge)
364 make
365
366 xz-utils # extract e.g. zsh/yash tarballs
367 bzip2 # extract e.g. busybox tarball
368
369 # for syscall measurements
370 strace
371
372 # used by test/spec-runner.sh
373 gawk
374 )
375
376 apt-install "${packages[@]}"
377}
378
379app-tests() {
380 local -a packages=(
381 # build/py.sh all
382 libreadline-dev
383 python2-dev
384
385 # retrieving spec-bin -- TODO: move to build time
386 wget
387 # for wget https://. TODO: remove when the build is hermetic
388 ca-certificates
389
390 curl # wait for cpp-tarball
391
392 gcc
393 g++ # for C++ tarball
394
395 # to build ble.sh
396 make
397 # used by ble.sh
398 gawk
399 procps
400
401 # for ble.sh contra
402 libx11-dev
403 libxft-dev
404 libncursesw5-dev
405 )
406
407 apt-install "${packages[@]}"
408}
409
410if test $(basename $0) = 'from-apt.sh'; then
411 "$@"
412fi