From 8ca331655e18ee6a3c647ae8bd78661961782a9a Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 9 Aug 2019 15:24:53 +1000 Subject: [PATCH] do_build: tidy up a little and make shellcheck -x clean --- do_build | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/do_build b/do_build index 33c3b14..1355bcb 100755 --- a/do_build +++ b/do_build @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash tree= if [ "$1" ]; then @@ -6,30 +6,44 @@ if [ "$1" ]; then shift fi -tools_dir=$(cd $(dirname "$0"); pwd) -. "$tools_dir/common.sh" +# shellcheck source=common.sh +. "$(dirname "$0")/common.sh" set -e bparent=$(dirname "$build_dir") -line="$(tail -n 1 $SHA1_FILE)" +line=$(tail -n 1 "$SHA1_FILE") # strip everything after the first tab character stree=${line%% *} if [ "$tree" ]; then - [ "$tree" = "$stree" ] || { - echo "That is not the last tree merged ($tree v $stree)" 1>&2 + 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" -[ "$build_host" ] && +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 @@ -49,20 +63,7 @@ $cmd <<-EOF [ -d "$obdir" ] || mkdir -p "$obdir" || exit 1 sanitise_log() { - sed -r ' -/^[[: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/ -' | grep -vxFf $bparent/log-ignore + sed -E -e '$log_regex' | grep -vxFf $bparent/log-ignore } show_log() { -- 2.39.5