setup-all-dchroots: stop creating s390 chroots on s390x
[mirror/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       amd64|i386|armel|armhf)
47         echo "sid stretch jessie wheezy"
48         ;;
49       kfreebsd-*)
50         echo "sid         jessie"
51         ;;
52       mips64el)
53         echo "sid"
54         ;;
55       ppc64)
56         echo "sid"
57         ;;
58       *)
59         echo "sid stretch jessie"
60         ;;
61     esac
62 }
63
64 extra=""
65
66 case `hostname` in
67     pizzetti)
68         archs="ppc64"
69         extra="$extra -m http://ftp.de.debian.org/debian-ports"
70         extra="$extra -k /root/debian-ports-archive-2016.gpg"
71         extra="$extra -I debian-ports-archive-keyring"
72         ;;
73     *)
74         archs="$DPKGARCH"
75         case "$DPKGARCH" in
76             amd64)
77                 archs="$archs i386"
78                 ;;
79             arm64)
80                 archs="$archs armhf armel"
81                 ;;
82             armhf)
83                 if [ "$(uname -m)" = "aarch64" ] ; then
84                     archs="$archs arm64"
85                 fi
86                 archs="$archs armel"
87                 ;;
88             armel)
89                 if [ "$(uname -m)" = "armv7l" ] && grep -w vfpv3 -q /proc/cpuinfo ; then
90                     archs="$archs armhf"
91                 fi
92                 ;;
93             mips64el)
94                 archs="$archs mipsel"
95                 ;;
96             mipsel)
97                 archs="$archs mips64el"
98                 ;;
99         esac
100     ;;
101 esac
102
103 err=0
104
105 do_one() {
106     local a="$1"; shift
107     local s="$1"; shift
108
109     case "$MODE" in
110         buildd)
111             mkdir -p /srv/buildd/unpack
112             if ! chronic setup-dchroot -f -a "$a" $extra -D -d '/srv/buildd/unpack' -K "$s"
113             then
114                 return 1
115             fi
116             ;;
117         porterbox)
118             if ! chronic setup-dchroot -f -a "$a" $extra "$s"
119             then
120                 return 1
121             fi
122             ;;
123         *)
124             echo >&2 "Invalid mode $MODE"
125             exit 1
126     esac
127     return 0
128 }
129
130 for a in $archs; do
131     for s in `get_suites "$a"`; do
132         if ! do_one "$a" "$s"; then
133             err=1
134             echo >&2
135             echo >&2 "Error: setting up $s:$a dchroot failed."
136             echo >&2
137             echo >&2
138         fi
139     done
140 done
141
142 exit $err