]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/dist-s390x-linux-netbsd/build-netbsd-toolchain.sh
include compiler hash in wrapper scripts
[rust.git] / src / ci / docker / dist-s390x-linux-netbsd / build-netbsd-toolchain.sh
1 #!/bin/bash
2 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
5 #
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
11
12 # ignore-tidy-linelength
13
14 set -ex
15
16 hide_output() {
17   set +x
18   on_err="
19 echo ERROR: An error was encountered with the build.
20 cat /tmp/build.log
21 exit 1
22 "
23   trap "$on_err" ERR
24   bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
25   PING_LOOP_PID=$!
26   $@ &> /tmp/build.log
27   rm /tmp/build.log
28   trap - ERR
29   kill $PING_LOOP_PID
30   set -x
31 }
32
33 mkdir netbsd
34 cd netbsd
35
36 mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot
37
38 URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
39
40 # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz
41 curl $URL/2017-03-17-netbsd-src.tgz | tar xzf -
42 curl $URL/2017-03-17-netbsd-gnusrc.tgz | tar xzf -
43 curl $URL/2017-03-17-netbsd-sharesrc.tgz | tar xzf -
44 curl $URL/2017-03-17-netbsd-syssrc.tgz | tar xzf -
45
46 # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/amd64/binary/sets/*.tgz
47 curl $URL/2017-03-17-netbsd-base.tgz | \
48   tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
49 curl $URL/2017-03-17-netbsd-comp.tgz | \
50   tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib
51
52 cd usr/src
53
54 # The options, in order, do the following
55 # * this is an unpriviledged build
56 # * output to a predictable location
57 # * disable various uneeded stuff
58 MKUNPRIVED=yes TOOLDIR=/x-tools/x86_64-unknown-netbsd \
59 MKSHARE=no MKDOC=no MKHTML=no MKINFO=no MKKMOD=no MKLINT=no MKMAN=no MKNLS=no MKPROFILE=no \
60 hide_output ./build.sh -j10 -m amd64 tools
61
62 cd ../..
63
64 rm -rf usr
65
66 cat > /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc-sysroot <<'EOF'
67 #!/bin/bash
68 exec /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc --sysroot=/x-tools/x86_64-unknown-netbsd/sysroot "$@"
69 EOF
70
71 cat > /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++-sysroot <<'EOF'
72 #!/bin/bash
73 exec /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++ --sysroot=/x-tools/x86_64-unknown-netbsd/sysroot "$@"
74 EOF
75
76 GCC_SHA1=`sha1sum -b /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc | cut -d' ' -f1`
77 GPP_SHA1=`sha1sum -b /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++ | cut -d' ' -f1`
78
79 echo "# $GCC_SHA1" >> /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc-sysroot
80 echo "# $GPP_SHA1" >> /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++-sysroot
81
82 chmod +x /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc-sysroot
83 chmod +x /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++-sysroot