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 | \
43 s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
44 url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum"
45 echo "Attempting to download $s3url"
46 rm -f /tmp/rustci_docker_cache
48 retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o /tmp/rustci_docker_cache "$url"
49 loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/')
51 echo "Downloaded containers:\n$loaded_images"
54 dockerfile="$docker_dir/$image/Dockerfile"
55 if [ -x /usr/bin/cygpath ]; then
56 context="`cygpath -w $docker_dir`"
57 dockerfile="`cygpath -w $dockerfile`"
68 if [ "$s3url" != "" ]; then
69 digest=$(docker inspect rust-ci --format '{{.Id}}')
70 echo "Built container $digest"
71 if ! grep -q "$digest" <(echo "$loaded_images"); then
72 echo "Uploading finished image to $s3url"
74 docker history -q rust-ci | \
81 echo "Looks like docker image is the same as before, not uploading"
83 # Record the container image for reuse, e.g. by rustup.rs builds
84 info="$dist/image-$image.txt"
87 echo "$digest" >>"$info"
89 elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
90 if [ -n "$TRAVIS_OS_NAME" ]; then
91 echo Cannot run disabled images on travis!
94 # retry messes with the pipe from tar to docker. Not needed on non-travis
95 # Transform changes the context of disabled Dockerfiles to match the enabled ones
96 tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \
100 -f "$image/Dockerfile" \
103 echo Invalid image: $image
107 travis_fold end build_docker
110 mkdir -p $HOME/.cargo
112 mkdir -p $objdir/cores
115 if [ "$SCCACHE_BUCKET" != "" ]; then
116 args="$args --env SCCACHE_BUCKET"
117 args="$args --env SCCACHE_REGION"
118 args="$args --env AWS_ACCESS_KEY_ID"
119 args="$args --env AWS_SECRET_ACCESS_KEY"
121 mkdir -p $HOME/.cache/sccache
122 args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
125 # Run containers as privileged as it should give them access to some more
126 # syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
127 # discovered that the leak sanitizer apparently needs these syscalls nowadays so
128 # we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
129 # goes ahead and sets it for all builders.
130 args="$args --privileged"
134 --volume "$root_dir:/checkout:ro" \
135 --volume "$objdir:/checkout/obj" \
136 --workdir /checkout/obj \
137 --env SRC=/checkout \
139 --env CARGO_HOME=/cargo \
142 --env LOCAL_USER_ID=`id -u` \
144 --env TRAVIS_BRANCH \
145 --env TOOLSTATE_REPO_ACCESS_TOKEN \
146 --env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
147 --volume "$HOME/.cargo:/cargo" \
148 --volume "$HOME/rustsrc:$HOME/rustsrc" \
152 /checkout/src/ci/run.sh