]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/schroot/files/setup-all-dchroots
1da5795713e24c0fe9426153018b406b5a0f5b87
[dsa-puppet.git] / modules / schroot / files / setup-all-dchroots
1 #!/bin/bash
2
3 ##
4 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
5 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
6 ##
7
8 # Copyright (c) 2013 Peter Palfrader
9 #
10 # Permission is hereby granted, free of charge, to any person
11 # obtaining a copy of this software and associated documentation
12 # files (the "Software"), to deal in the Software without
13 # restriction, including without limitation the rights to use,
14 # copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following
17 # conditions:
18 #
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
21 #
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
24 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 # OTHER DEALINGS IN THE SOFTWARE.
30
31 DPKGARCH=$(dpkg --print-architecture)
32 UNAMEARCH=$(uname -m)
33
34 if [ "${1:-}" = "buildd" ]; then
35     MODE=buildd
36     if ! [ -d /srv/buildd/ ]; then
37         echo >&2 "Error: /srv/buildd does not exist or is not a directory."
38         exit 1
39     fi
40 else
41     MODE=porterbox
42 fi
43
44 get_suites() {
45     case "$1" in
46       ia64|s390|sparc)
47         echo "wheezy"
48         ;;
49       arm64|ppc64el)
50         echo "sid stretch jessie"
51         ;;
52       amd64|i386)
53         echo "sid stretch jessie wheezy squeeze"
54         ;;
55       kfreebsd-*)
56         echo "sid         jessie wheezy"
57         ;;
58       *)
59         echo "sid stretch jessie wheezy"
60         ;;
61     esac
62 }
63
64 archs="$DPKGARCH"
65 case "$DPKGARCH" in
66     amd64)
67         archs="$archs i386"
68         ;;
69     arm64)
70         archs="$archs armhf armel"
71         ;;
72     armhf)
73         if [ "$(uname -m)" = "aarch64" ] ; then
74             archs="$archs arm64"
75         fi
76         archs="$archs armel"
77         ;;
78     armel)
79         if [ "$(uname -m)" = "armv7l" ] && grep -w vfpv3 -q /proc/cpuinfo ; then
80             archs="$archs armhf"
81         fi
82         ;;
83     s390|s390x)
84         archs="s390 s390x"
85         ;;
86 esac
87
88 err=0
89
90 do_one() {
91     local a="$1"; shift
92     local s="$1"; shift
93
94     case "$MODE" in
95         buildd)
96             mkdir -p /srv/buildd/unpack
97             if ! chronic setup-dchroot -f -a "$a" -D -d '/srv/buildd/unpack' -K "$s"
98             then
99                 return 1
100             fi
101             ;;
102         porterbox)
103             if ! chronic setup-dchroot -f -a "$a" "$s"
104             then
105                 return 1
106             fi
107             ;;
108         *)
109             echo >&2 "Invalid mode $MODE"
110             exit 1
111     esac
112     return 0
113 }
114
115 for a in $archs; do
116     for s in `get_suites "$a"`; do
117         if ! do_one "$a" "$s"; then
118             err=1
119             echo >&2
120             echo >&2 "Error: setting up $s:$a dchroot failed."
121             echo >&2
122             echo >&2
123         fi
124     done
125 done
126
127 exit $err