5 export MSYS_NO_PATHCONV=1
7 script=`cd $(dirname $0) && pwd`/`basename $0`
10 docker_dir="`dirname $script`"
11 ci_dir="`dirname $docker_dir`"
12 src_dir="`dirname $ci_dir`"
13 root_dir="`dirname $src_dir`"
16 dist=$objdir/build/dist
18 source "$ci_dir/shared.sh"
20 travis_fold start build_docker
23 if [ -f "$docker_dir/$image/Dockerfile" ]; then
24 if [ "$CI" != "" ]; then
25 hash_key=/tmp/.docker-hash-key.txt
27 echo $image >> $hash_key
29 cat "$docker_dir/$image/Dockerfile" >> $hash_key
30 # Look for all source files involves in the COPY command
31 copied_files=/tmp/.docker-copied-files.txt
33 for i in $(sed -n -e 's/^COPY \(.*\) .*$/\1/p' "$docker_dir/$image/Dockerfile"); do
35 find "$docker_dir/$i" -type f >> $copied_files
37 # Sort the file names and cat the content into the hash key
38 sort $copied_files | xargs cat >> $hash_key
40 docker --version >> $hash_key
41 cksum=$(sha512sum $hash_key | \
44 s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
45 url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum"
46 upload="aws s3 cp - $s3url"
48 echo "Attempting to download $url"
49 rm -f /tmp/rustci_docker_cache
51 retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o /tmp/rustci_docker_cache "$url"
52 loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/')
54 echo "Downloaded containers:\n$loaded_images"
57 dockerfile="$docker_dir/$image/Dockerfile"
58 if [ -x /usr/bin/cygpath ]; then
59 context="`cygpath -w $docker_dir`"
60 dockerfile="`cygpath -w $dockerfile`"
71 if [ "$upload" != "" ]; then
72 digest=$(docker inspect rust-ci --format '{{.Id}}')
73 echo "Built container $digest"
74 if ! grep -q "$digest" <(echo "$loaded_images"); then
75 echo "Uploading finished image to $url"
77 docker history -q rust-ci | \
84 echo "Looks like docker image is the same as before, not uploading"
86 # Record the container image for reuse, e.g. by rustup.rs builds
87 info="$dist/image-$image.txt"
90 echo "$digest" >>"$info"
92 elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
94 echo Cannot run disabled images on CI!
97 # retry messes with the pipe from tar to docker. Not needed on non-travis
98 # Transform changes the context of disabled Dockerfiles to match the enabled ones
99 tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \
103 -f "$image/Dockerfile" \
106 echo Invalid image: $image
110 travis_fold end build_docker
113 mkdir -p $HOME/.cargo
115 mkdir -p $objdir/cores
118 if [ "$SCCACHE_BUCKET" != "" ]; then
119 args="$args --env SCCACHE_BUCKET"
120 args="$args --env SCCACHE_REGION"
121 args="$args --env AWS_ACCESS_KEY_ID"
122 args="$args --env AWS_SECRET_ACCESS_KEY"
124 mkdir -p $HOME/.cache/sccache
125 args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
128 # Run containers as privileged as it should give them access to some more
129 # syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
130 # discovered that the leak sanitizer apparently needs these syscalls nowadays so
131 # we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
132 # goes ahead and sets it for all builders.
133 args="$args --privileged"
137 --volume "$root_dir:/checkout:ro" \
138 --volume "$objdir:/checkout/obj" \
139 --workdir /checkout/obj \
140 --env SRC=/checkout \
142 --env CARGO_HOME=/cargo \
145 --env LOCAL_USER_ID=`id -u` \
148 --env TRAVIS_BRANCH \
150 --env BUILD_SOURCEBRANCHNAME \
151 --env TOOLSTATE_REPO_ACCESS_TOKEN \
152 --env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
153 --volume "$HOME/.cargo:/cargo" \
154 --volume "$HOME/rustsrc:$HOME/rustsrc" \
158 /checkout/src/ci/run.sh