-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-local
executable file
·79 lines (68 loc) · 1.63 KB
/
build-local
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
72
73
74
75
76
77
78
79
#!/bin/bash
script="$(realpath "$0")"
dir="$(dirname $0)/ocaml"
prefix="$(realpath $(dirname "$0"))"/local
if [[ ! -d $dir ]]; then
echo "Expect OCaml clone in $dir" >&2
exit 1
fi
cd "$dir"
function failed
{
echo
cat _log
rm _log
echo "$1: $2 failed!"
exit 1
}
function build
{
printf "Building OCaml $1... "
if ! ./configure --prefix "$prefix/ocaml-$1" --enable-warn-error --enable-relative --enable-runtime-search=always > _log 2>&1; then
failed "$1" 'configure'
fi
if ! make -j world.opt > _log 2>&1; then
failed "$1" 'build'
fi
if ! make install > _log 2>&1; then
failed "$1" 'install'
fi
rm -f _log
echo "done"
}
if [[ $# -eq 1 ]]; then
if [[ ! -d "../builds/build-$1" ]]; then
echo "$(realpath ../builds/build-$1) not found?!" >&2
exit 1
fi
cd ../builds/build-$1
build "$1"
exit 0
fi
if [[ -d $prefix ]]; then
echo "$prefix exists - please remove before running" >&2
exit 1
fi
if [[ -n "$(git status --porcelain)" ]]; then
echo 'The working tree is not clean' >&2
exit 1
fi
BACKPORTS=(trunk 5.0 4.14 4.13 4.12 4.11 4.10 4.09 4.08)
problem=0
for v in "${BACKPORTS[@]}"; do
if [[ ! -d ../builds/build-$v ]]; then
git worktree add ../builds/build-$v backport-$v
else
if [[ -n "$(git -C ../builds/build-$v status --porcelain)" ]]; then
echo "Working tree $(realpath ../builds/build-$v) is not clean" >&2
problem=1
else
git -C ../builds/build-$v clean -dfx &> /dev/null
git -C ../builds/build-$v checkout --detach backport-$v &> /dev/null
fi
fi
done
if ((problem)); then
exit 1
fi
printf "%s\n" "${BACKPORTS[@]}" | parallel "$script" {}