]> git.ozlabs.org Git - next-scripts/blob - do_build
do_build: factor out showing the successful logs
[next-scripts] / do_build
1 #!/bin/sh
2
3 tree=
4 if [ "$1" ]; then
5         tree=$1
6         shift
7 fi
8
9 tools_dir=$(dirname "$0")
10 . "$tools_dir/common.sh"
11
12 set -e
13
14 bparent=$(dirname "$build_dir")
15
16 line="$(tail -n 1 $SHA1_FILE)"
17
18 # strip everything after the first tab character
19 stree=${line%%  *}
20 if [ "$tree" ]; then
21         [ "$tree" = "$stree" ] || {
22                 echo "That is not the last tree merged ($tree v $stree)" 1>&2
23                 exit 1
24         }
25 else
26         tree="$stree"
27 fi
28 obdir="$bparent/old/$tree"
29
30 cmd="/bin/sh"
31 [ "$build_host" ] &&
32         cmd="ssh root@$build_host unshare -n su $(id -u -n)"
33
34 $cmd <<-EOF
35
36         echo Building on \$(hostname)
37
38         echo \$PATH | grep -q "\$HOME/bin" || export PATH="\$HOME/bin:\$PATH"
39         export LANG=C
40
41         cd "$build_dir" || exit 1
42
43         export CCACHE_DIR="$bparent/.ccache"
44         export TMPDIR="$bparent/tmp"
45
46         git reset --hard next || exit 1
47         touch .scmversion || exit 1
48
49         [ -d "$obdir" ] || mkdir -p "$obdir" || exit 1
50
51         show_log() {
52                 arch=\$1
53                 conf=\$2
54                 log=\$3
55
56                 sep='======================================================================'
57
58                 echo "\$sep"
59                 echo " \$arch \$conf build OK - log follows"
60                 echo "\$sep"
61                 cat \$log
62                 b=\$(basename \$log)
63                 if [ -f $obdir/\$b ]; then
64                         if [ \$(wc -l <$obdir/\$b) -lt \$(wc -l <\$log) ]; then
65                                 echo "\$sep"
66                                 echo " log \$b increased number of lines"
67                                 echo "\$sep"
68                                 diff -u $obdir/\$b \$log 2>&1 | less
69                         fi
70                 fi
71                 mv \$log $obdir/\$b
72         }
73
74         echo Building: x86_64 allmodconfig
75         d="$bparent/x86_64_allmodconfig"
76         [ -d \$d ] || mkdir \$d || exit 1
77         log_x86=\$d.log
78         e=\$d.except
79         echo CONFIG_BUILD_DOCSRC=n >\$e || exit 1
80         echo CONFIG_MODULES=y >>\$e || exit 1
81         KCONFIG_ALLCONFIG=\$e cross -n -N -a x86_64 -c "$gcc_version" O=\$d allmodconfig || exit 1
82         echo "Forking x86 build ..."
83         /usr/bin/time cross -n -N -a x86_64 -c "$gcc_version" O=\$d -j"$j_factor" -s > \$log_x86 2>&1 &
84         x86_64_pid=\$!
85
86         echo Building: powerpc ppc64_defconfig
87         d="$bparent/powerpc_ppc64_defconfig"
88         [ -d \$d ] || mkdir \$d || exit 1
89         log_ppc=\$d.log
90         cross -n -N -a powerpc64 -k powerpc -c "$gcc_ppc_version" O=\$d ppc64_defconfig || exit 1
91         echo "Forking powerpc build ..."
92         /usr/bin/time cross -n -N -a powerpc64 -k powerpc -c "$gcc_ppc_version" O=\$d -j"$j_factor" -s > \$log_ppc 2>&1 &
93         ppc64_pid=\$!
94
95         echo Building: arm multi_v7_defconfig
96         d="$bparent/arm_multi_v7_defconfig"
97         [ -d \$d ] || mkdir \$d || exit 1
98         log_arm=\$d.log
99         cross -n -N -a arm -c "$gcc_version" O=\$d multi_v7_defconfig || exit 1
100         echo "Forking arm build ..."
101         /usr/bin/time cross -n -N -a arm -c "$gcc_version" O=\$d -j"$j_factor" -s > \$log_arm 2>&1 &
102         arm_pid=\$!
103
104         echo Building: perf
105         d="$bparent/perf"
106         [ -d \$d ] || mkdir \$d || exit 1
107         log_perf=\$d.log
108         echo "Forking perf build ..."
109         /usr/bin/time make -s -C tools/perf JOBS="$j_factor" O=\$d > \$log_perf 2>&1 &
110         perf_pid=\$!
111
112         wait \$perf_pid
113         rc=\$?
114
115         if [ \$rc -ne 0 ]; then
116                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
117                 echo "ERROR: perf build failed - log follows"
118                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
119                 cat \$log_perf
120                 kill \$x86_64_pid
121                 kill \$ppc64_pid
122                 kill \$arm_pid
123                 killall make
124                 rm .scmversion
125                 exit 1
126         else
127                 show_log native perf \$log_perf
128         fi
129
130         wait \$arm_pid
131         rc=\$?
132
133         if [ \$rc -ne 0 ]; then
134                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
135                 echo "ERROR: arm multi_v7_defconfig build failed - log follows"
136                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
137                 cat \$log_arm
138                 kill \$x86_64_pid
139                 kill \$ppd64_pid
140                 killall make
141                 rm .scmversion
142                 exit 1
143         else
144                 show_log arm multi_v7_defconfig \$log_arm
145         fi
146
147         wait \$ppc64_pid
148         rc=\$?
149
150         if [ \$rc -ne 0 ]; then
151                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
152                 echo "ERROR: powerpc ppc64_defconfig build failed - log follows"
153                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
154                 cat \$log_ppc
155                 kill \$x86_64_pid
156                 killall make
157                 rm .scmversion
158                 exit 1
159         else
160                 show_log powerpc ppc64_defconfig \$log_ppc
161         fi
162
163         wait \$x86_64_pid
164         rc=\$?
165
166         if [ \$rc -ne 0 ]; then
167                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
168                 echo "ERROR: x86_64 allmodconfig build failed - log follows"
169                 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
170                 cat \$log_x86
171                 rm .scmversion
172                 exit 1
173         else
174                 show_log x86_64 allmodconfig \$log_x86
175         fi
176
177         rm .scmversion
178 EOF