]> git.ozlabs.org Git - next-scripts/commitdiff
do_build: tidy up a little and make shellcheck -x clean
authorStephen Rothwell <sfr@canb.auug.org.au>
Fri, 9 Aug 2019 05:24:53 +0000 (15:24 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 9 Aug 2019 06:38:52 +0000 (16:38 +1000)
do_build

index 33c3b14e402f07beb31a0f9e80d69b533bf74766..1355bcbbf65a3fb3a616bb431dd90cb570b276ec 100755 (executable)
--- 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() {