setup-all-dchroots: wheezy is gone, jessie is limited to LTS architectures
[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 if [ -t 0 ] ; then
45     SILENT=""
46 else
47     SILENT="chronic"
48 fi
49
50 get_suites() {
51     case "$1" in
52       amd64|i386|armel|armhf)
53         echo "sid buster stretch jessie"
54         ;;
55       powerpc)
56         echo "sid"
57         ;;
58       *)
59         echo "sid buster stretch"
60         ;;
61     esac
62 }
63
64 extra=""
65
66 archs="$DPKGARCH"
67 case "$DPKGARCH" in
68     amd64)
69         archs="$archs i386"
70         ;;
71     arm64)
72         archs="$archs armhf armel"
73         ;;
74     armhf)
75         if [ "$(uname -m)" = "aarch64" ] ; then
76             archs="$archs arm64"
77         fi
78         archs="$archs armel"
79         ;;
80     armel)
81         if [ "$(uname -m)" = "armv7l" ] && grep -w vfpv3 -q /proc/cpuinfo ; then
82             archs="$archs armhf"
83         fi
84         ;;
85     mips64el)
86         archs="$archs mipsel"
87         ;;
88     mipsel)
89         archs="$archs mips64el"
90         ;;
91 esac
92
93 err=0
94
95 do_one() {
96     local a="$1"; shift
97     local s="$1"; shift
98
99     case "$MODE" in
100         buildd)
101             mkdir -p /srv/buildd/unpack
102             if ! $SILENT setup-dchroot -f -a "$a" $extra -D -d '/srv/buildd/unpack' -K "$s"
103             then
104                 return 1
105             fi
106             ;;
107         porterbox)
108             if ! $SILENT setup-dchroot -f -a "$a" $extra "$s"
109             then
110                 return 1
111             fi
112             ;;
113         *)
114             echo >&2 "Invalid mode $MODE"
115             exit 1
116     esac
117     return 0
118 }
119
120 for a in $archs; do
121     for s in `get_suites "$a"`; do
122         if ! do_one "$a" "$s"; then
123             err=1
124             echo >&2
125             echo >&2 "Error: setting up $s:$a dchroot failed."
126             echo >&2
127             echo >&2
128         fi
129     done
130 done
131
132 exit $err