-
Notifications
You must be signed in to change notification settings - Fork 10
/
build-linux.sh
executable file
·71 lines (59 loc) · 1.67 KB
/
build-linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/bash
# Copyright 2015-2020 Peter Williams <[email protected]>
# Licensed under the MIT License.
# Just Do It script: rebuild a package or packages on Linux. We use a
# persistent builder container for efficiency.
set -e
img_name=forge-builder
cont_name=forgebuilder
recipe_topdir=$(cd $(dirname $0) && pwd)
builder_args=("--python=3.9.* *_cpython")
uid="$(id -u):$(id -g)"
# Make sure container is up and running
set +e
is_running=$(docker inspect --format="{{ .State.Running }}" $cont_name 2>/dev/null)
ec=$?
set -e
if [ $ec -eq 1 ] ; then
# Most likely, the container doesn't exist at all.
echo "Starting container ..."
mkdir -p "$recipe_topdir/artifacts"
docker run \
-dit \
-v "$recipe_topdir":/work:rw,z \
-v "$recipe_topdir/artifacts":/conda/conda-bld:rw,z \
-u $uid \
-e NJOBS \
--net=host \
--name $cont_name \
$img_name bash
is_running=true
fi
if [ "$is_running" != "true" ] ; then
# Container is stopped.
docker start $cont_name
fi
# Ready to go.
while [ $# -gt 0 ] ; do
pkg="$1"
shift
if [ ! -d "$recipe_topdir/recipes/$pkg" ] ; then
echo >&2 "error: no such package $pkg"
exit 1
fi
log="$recipe_topdir/recipes/$pkg/linux-64-py3.log"
echo "Building with logs to $log ..."
set +e
stdbuf -oL -eL \
docker exec \
-e NJOBS \
$cont_name /entrypoint.sh \
build "$pkg" "${builder_args[@]}" >"$log" 2>&1
ec=$?
set -e
echo "========================================"
tail -n8 "$log"
echo "========================================"
[ "$ec" -ne 0 ] && exit $ec
done
exit 0