ci: Rework SDK build steps

Significantly rework how we're doing the SDK step for our CI scripts:

 * Reduce the number of packages to speed up SDK build step. The only
   reusable piece of an SDK is the toolchain and it's own dependent
   pieces (i.e., sysroot dir), so don't waste time by building packages
   that will be rebuilt when the SDK is used.

 * Instead of always building the SDK based on witherspoon_defconfig,
   take into account the platform for which the SDK is being built for,
   but try to canonize it and consider it's primary characteristics to
   make it unique, such as buildroot version, architecture, OS, Kernel
   Headers and GCC version used.
   Without this, at the time of this commit, the complete zz_defconfig
   build is using GCC 7.4.0, the sdk build is using GCC 6.5.0 from
   witherspoon_defconfig - an inconsistency in the result from a
   complete versus an sdk-based build.

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
diff --git a/ci/build.sh b/ci/build.sh
index a0430df..e0acc1a 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -7,7 +7,7 @@
 SDK_ONLY=0
 
 opt=$(getopt -o 's:Sab:p:c:hr' -- "$@")
-if [ $? != 0 ] ; then
+if [ $? -ne 0 ] ; then
 	echo "Invalid arguments"
 	exit 1
 fi
@@ -96,10 +96,6 @@
          -t $1 $2
 }
 
-function toolchain_hash
-{
-    echo -n 'toolchain-'$((git submodule ; cd openpower/configs/; cat `ls -1 |grep '_defconfig$'|sort`)|sha1sum |sed -e 's/ .*//')
-}
 
 env
 
@@ -144,15 +140,6 @@
 EOF
 		  )
 	$DOCKER_PREFIX docker build --network=host -t openpower/op-build-$distro - <<< "${Dockerfile}"
-	SDK_DIR=$SDK_CACHE/$(toolchain_hash)-$distro
-	if [ ! -d "$SDK_DIR" ]; then
-	    chmod +x ci/build-sdk.sh
-	    run_docker openpower/op-build-$distro "./ci/build-sdk.sh $distro witherspoon_defconfig"
-	    mv output-$distro-witherspoon_defconfig $SDK_DIR
-	    $SDK_DIR/host/relocate-sdk.sh
-	fi
-
-	sdk_args="-s $SDK_DIR/host"
 
 	if [ -n "$PLATFORMS" ]; then
 	    platform_args="-p $PLATFORMS"
@@ -160,11 +147,15 @@
 	    platform_args=""
 	fi
 
-	if [ $SDK_ONLY == 0 ]; then
-	    run_docker openpower/op-build-$distro "./ci/build-all-defconfigs.sh -o `pwd`/output-$distro ${platform_args} ${release_args} ${sdk_args}"
+	if [ $SDK_ONLY -ne 0 ]; then
+	    sdk_args="-S"
+	else
+	    sdk_args=""
 	fi
 
-	if [ $? != 0 ]; then
+	run_docker openpower/op-build-$distro "./ci/build-all-defconfigs.sh -o `pwd`/output-$distro ${platform_args} ${release_args} ${sdk_args} -s $SDK_CACHE"
+
+	if [ $? -ne 0 ]; then
 		exit $?;
 	fi
 done;