-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinstall
executable file
·72 lines (66 loc) · 2.2 KB
/
install
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
#!/bin/sh
# Copyright dunnhumby Germany GmbH 2017.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Build a docker image for D projects
set -eu
beaver=$(dirname $0)/../beaver
# Package name deduced based on supplied DMD version
case "$DMD" in
dmd* ) PKG= ;;
1.* ) PKG="dmd1=$DMD-$DIST" ;;
2.*.s* ) PKG="dmd-transitional=$DMD-$DIST" ;;
2.* ) if [ $(echo $DMD | cut -d. -f2) -ge 077 ]; then
PKG="dmd-compiler=$DMD dmd-tools=$DMD libphobos2-dev=$DMD"
else
PKG="dmd-bin=$DMD libphobos2-dev=$DMD"
fi ;;
* ) echo "Unknown \$DMD ($DMD)" >&2; exit 1 ;;
esac
# FIXME: Use beaver install for this for consistency and DRY
# Copy a file only if it exist
maybe_cp()
{
if test "$(readlink -m "$1")" != "$(readlink -m "$2")" -a -f "$1"
then
cp -v "$1" "$2"
fi
}
# Store if a .dockerignore existed already
dockerignore=false
if test -f ".dockerignore"
then
dockerignore=true
fi
# Look if a particular context was given and copy the .dockerfile from it
if test -n "${BEAVER_DOCKER_CONTEXT:-}"
then
# Only remove .dockerignore if none existed
if ! $dockerignore
then
trap 'r=$?; if test $r -eq 0 -a "${BEAVER_DEBUG:-0}" -ne 1; \
then rm -f .dockerignore; fi; exit $r' EXIT
fi
maybe_cp "$BEAVER_DOCKER_CONTEXT/.dockerignore" .dockerignore
maybe_cp "$BEAVER_DOCKER_CONTEXT/dockerignore" .dockerignore
docker_dir="-d $BEAVER_DOCKER_CONTEXT"
else
BEAVER_DOCKER_CONTEXT=.
docker_dir=
fi
# Generate the Dockerfile including the DMD_PKG argument and install the
# relevant DMD
"$beaver" docker gen-dockerfile $docker_dir \
-i "$BEAVER_DOCKER_CONTEXT/beaver.Dockerfile" \
-I 'ARG DMD_PKG' -I 'ENV DMD_PKG=$DMD_PKG' \
-I 'RUN apt update && apt -y install --allow-downgrades $DMD_PKG' \
-o beaver.Dockerfile.generated
# Build the docker image from the generated Dockerfile passing DMD_PKG
"$beaver" docker build --build-arg "DMD_PKG=$PKG" \
-f beaver.Dockerfile.generated "$@" .
if test "${BEAVER_DEBUG:-0}" -ne 1
then
rm -f beaver.Dockerfile.generated
fi