-#!/bin/sh
+#!/bin/bash
-. "$(dirname $0)/common.sh"
+tree=
+if [ "$1" ]; then
+ tree=$1
+ shift
+fi
+
+# shellcheck source=common.sh
+. "$(dirname "$0")/common.sh"
set -e
-###ssh "$build_host" /bin/sh -e <<-EOF
-ssh root@"$build_host" unshare -n su $(id -u -n) <<-EOF
- set -e
+bparent=$(dirname "$build_dir")
+
+line=$(tail -n 1 "$SHA1_FILE")
+
+# strip everything after the first tab character
+stree=${line%% *}
+if [ "$tree" ]; then
+ if [ "$tree" != "$stree" ]; then
+ printf 'That is not the last tree merged (%s v %s)\n' "$tree" "$stree" 1>&2
+ exit 1
+ fi
+else
+ tree="$stree"
+fi
+obdir="$bparent/old/$tree"
+
+cmd="/bin/sh"
+if [ "$build_host" ]; then
+ cmd="ssh root@$build_host unshare -n su $(id -u -n)"
+fi
+
+log_regex='/^[[:space:]]+$/d
+/^[.[:digit:]]+user [.[:digit:]]+system [:.[:digit:]]+elapsed [[:digit:]]+%CPU \([[:digit:]]+avgtext\+[[:digit:]]+avgdata [[:digit:]]+maxresident\)k$/d
+/^[[:digit:]]+inputs\+[[:digit:]]+outputs \([[:digit:]]+major\+[[:digit:]]+minor\)pagefaults [[:digit:]]+swaps$/d
+/^Setup is [[:digit:]]+ bytes \(padded to [[:digit:]]+ bytes\)\.$/d
+/^System is [[:digit:]]+ kB$/d
+/^CRC [[:xdigit:]]+$/d
+/^Kernel: arch\/x86\/boot\/bzImage is ready \(#[[:digit:]]+\)$/d
+/^WARNING: vmlinux\.o\(\.text\+0x[[:xdigit:]]+\): Section mismatch in reference from /d
+/^WARNING: drivers\/built-in\.o\(\.text\+0x[[:xdigit:]]+\): Section mismatch in reference from /d
+/^Warning: Kernel ABI header at /d
+/^[[:space:]]+PERF_VERSION = /d
+s/^([[:xdigit:]]+)([[:space:]]+R_PPC64_REL32[[:space:]].*)$/XXX\2/'
+
+$cmd <<-EOF
echo Building on \$(hostname)
echo \$PATH | grep -q "\$HOME/bin" || export PATH="\$HOME/bin:\$PATH"
export LANG=C
- cd "$build_dir"
-
- export CCACHE_DIR="${build_dir%/*}/.ccache"
- export TMPDIR="${build_dir%/*}/tmp"
-
- git reset --hard next
- touch .scmversion
+ cd "$build_dir" || exit 1
+
+ export CCACHE_DIR="$bparent/.ccache"
+ export TMPDIR="$bparent/tmp"
+
+ git reset --hard next || exit 1
+ touch .scmversion || exit 1
+
+ [ -d "$obdir" ] || mkdir -p "$obdir" || exit 1
+
+ sanitise_log() {
+ sed -E -e '$log_regex' | grep -vxFf $bparent/log-ignore
+ }
+
+ show_log() {
+ arch=\$1
+ conf=\$2
+ log=\$3
+
+ sep='======================================================================'
+
+ echo "\$sep"
+ echo " \$arch \$conf build OK - log follows"
+ echo "\$sep"
+ cat \$log
+ b=\$(basename \$log)
+ olen=0
+ if [ -f $obdir/\$b ]; then
+ olen=\$(sanitise_log <$obdir/\$b | wc -l)
+ fi
+ len=\$(sanitise_log <\$log | wc -l)
+ if [ \$len -gt \$olen ]; then
+ echo "\$sep"
+ echo " log \$b increased number of lines"
+ echo "\$sep"
+ linux-next-notify "\$arch \$conf log got bigger"
+ if [ -f $obdir/\$b ]; then
+ diff -u $obdir/\$b \$log 2>&1 | less
+ else
+ diff -u /dev/null \$log 2>&1 | less
+ fi
+ fi
+ if [ \$len -gt 0 ]; then
+ (sanitise_log <\$log; cat $bparent/log-ignore ) |
+ sort -u >$bparent/log-ignore.tmp
+ mv $bparent/log-ignore.tmp $bparent/log-ignore
+ fi
+ mv \$log $obdir/\$b
+ }
echo Building: x86_64 allmodconfig
- d=../x86_64_allmodconfig
- [ -d \$d ] || mkdir \$d
+ d="$bparent/x86_64_allmodconfig"
+ [ -d \$d ] || mkdir \$d || exit 1
log_x86=\$d.log
- e=\$d.except
- echo CONFIG_BUILD_DOCSRC=n >\$e
- {
- KCONFIG_ALLCONFIG=\$e cross -n -N -a x86_64 -c $gcc_version O=\$d allyesconfig
- /usr/bin/time cross -n -N -a x86_64 -c $gcc_version O=\$d -j$j_factor -s
- } > \$log_x86 2>&1 &
+ make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- O=\$d -s allmodconfig || exit 1
+ echo "Forking x86 build ..."
+ /usr/bin/time make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- O=\$d -j"$j_factor" -O -s > \$log_x86 2>&1 &
+ x86_64_pid=\$!
echo Building: powerpc ppc64_defconfig
- d=../powerpc_ppc64_defconfig
- [ -d \$d ] || mkdir \$d
+ d="$bparent/powerpc_ppc64_defconfig"
+ [ -d \$d ] || mkdir \$d || exit 1
log_ppc=\$d.log
- {
- cross -n -N -a powerpc64 -k powerpc -c $gcc_version O=\$d ppc64_defconfig
- /usr/bin/time cross -n -N -a powerpc64 -k powerpc -c $gcc_version O=\$d -j$j_factor -s
- } > \$log_ppc 2>&1 &
+ make ARCH=powerpc O=\$d -s ppc64_defconfig || exit 1
+ echo "Forking powerpc build ..."
+ /usr/bin/time make ARCH=powerpc O=\$d -j"$j_factor" -O -s > \$log_ppc 2>&1 &
+ ppc64_pid=\$!
echo Building: arm multi_v7_defconfig
- d=../arm_multi_v7_defconfig
- [ -d \$d ] || mkdir \$d
+ d="$bparent/arm_multi_v7_defconfig"
+ [ -d \$d ] || mkdir \$d || exit 1
log_arm=\$d.log
- {
- cross -n -N -a arm -c $gcc_version O=\$d multi_v7_defconfig
- /usr/bin/time cross -n -N -a arm -c $gcc_version O=\$d -j$j_factor -s
- } > \$log_arm 2>&1 &
+ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- O=\$d -s multi_v7_defconfig || exit 1
+ echo "Forking arm build ..."
+ /usr/bin/time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- O=\$d -j"$j_factor" -O -s > \$log_arm 2>&1 &
+ arm_pid=\$!
+
+ echo Building: perf
+ d="$bparent/perf"
+ [ -d \$d ] || mkdir \$d || exit 1
+ log_perf=\$d.log
+ echo "Forking perf build ..."
+ /usr/bin/time make -C tools/perf -f Makefile.perf -s -O -j"$j_factor" O=\$d > \$log_perf 2>&1 &
+ perf_pid=\$!
+
+ wait \$perf_pid
+ rc=\$?
+
+ if [ \$rc -ne 0 ]; then
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ echo "ERROR: perf build failed - log follows"
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ cat \$log_perf
+ kill \$x86_64_pid || true
+ kill \$ppc64_pid || true
+ kill \$arm_pid || true
+ killall make
+ rm .scmversion
+ exit 1
+ else
+ show_log native perf \$log_perf
+ fi
- wait %3
+ wait \$arm_pid
rc=\$?
- cat \$log_arm
if [ \$rc -ne 0 ]; then
- echo "ERROR: ARM build failed"
- kill %1
- kill %2
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ echo "ERROR: arm multi_v7_defconfig build failed - log follows"
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ cat \$log_arm
+ kill \$x86_64_pid || true
+ kill \$ppc64_pid || true
+ killall make
rm .scmversion
exit 1
else
- echo "ARM build OK"
+ show_log arm multi_v7_defconfig \$log_arm
fi
- wait %2
+ wait \$ppc64_pid
rc=\$?
- cat \$log_ppc
if [ \$rc -ne 0 ]; then
- echo "ERROR: powerpc build failed"
- kill %1
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ echo "ERROR: powerpc ppc64_defconfig build failed - log follows"
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ cat \$log_ppc
+ kill \$x86_64_pid || true
+ killall make
rm .scmversion
exit 1
else
- echo "powerpc build OK"
+ show_log powerpc ppc64_defconfig \$log_ppc
fi
- wait %1
+ wait \$x86_64_pid
rc=\$?
- cat \$log_x86
if [ \$rc -ne 0 ]; then
- echo "ERROR: x86 build failed"
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ echo "ERROR: x86_64 allmodconfig build failed - log follows"
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ cat \$log_x86
rm .scmversion
exit 1
else
- echo "x86 build OK"
+ show_log x86_64 allmodconfig \$log_x86
fi
rm .scmversion