Merge pull request #2431 from shenki/ci-script-fixes

Ci script fixes
diff --git a/ci/build-all-defconfigs.sh b/ci/build-all-defconfigs.sh
index 0ab53bf..e1455b2 100755
--- a/ci/build-all-defconfigs.sh
+++ b/ci/build-all-defconfigs.sh
@@ -39,6 +39,12 @@
   esac
 done
 
+function get_kernel_release
+{
+	IFS=. read major minor macro <<<"$1"
+	echo -n "${major}_${minor}"
+}
+
 if [ -z "${PLATFORM_LIST}" ]; then
         echo "Using all the defconfigs for all the platforms"
         DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)`
@@ -84,7 +90,11 @@
 	    ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CXX y
 	    # FIXME: How do we work this out programatically?
 	    ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_GCC_6 y
-	    ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_18 y
+
+	    KERNEL_VER=$(./buildroot/utils/config --file $O/.config --state BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE)
+	    echo "KERNEL_VER " $KERNEL_VER
+	    HEADERS=BR2_TOOLCHAIN_EXTERNAL_HEADERS_$(get_kernel_release $KERNEL_VER)
+	    ./buildroot/utils/config --file $O/.config --set-val $HEADERS y
 	fi
         op-build O=$O olddefconfig
         op-build O=$O
diff --git a/ci/build.sh b/ci/build.sh
index f663ef4..9359ca6 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -37,9 +37,12 @@
       echo "-a          Build firmware images for all the platform defconfig's."
       echo "-b DIR      Bind DIR to container."
       echo "-p          List of comma separated platform names to build images for particular platforms."
-      echo "-s DIR      SDK cache dir."
+      echo "-s DIR      SDK cache dir (must exist)."
       echo "-S          Build SDK only"
       echo "-c          Container to run in"
+      echo ""
+      echo "Note: set environment variables HTTP_PROXY and HTTPS_PROXY if a proxy is required."
+      echo ""
       echo "Example:DOCKER_PREFIX=sudo ./ci/build.sh -a"
       echo -e "\tDOCKER_PREFIX=sudo ./ci/build.sh -p firestone"
       echo -e "\tDOCKER_PREFIX=sudo ./ci/build.sh -p garrison,palmetto,openpower_p9_mambo"
@@ -105,10 +108,10 @@
 	    PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
 	  fi
         fi
-	if [[ -n "DL_DIR" ]]; then
+	if [ ! -z ${DL_DIR+x} ]; then
 	  DL_DIR_ENV="ENV DL_DIR $DL_DIR"
 	fi
-	if [[ -n "CCACHE_DIR" ]]; then
+	if [ ! -z ${CCACHE_DIR+x} ]; then
 	  CCACHE_DIR_ENV="ENV CCACHE_DIR $CCACHE_DIR"
 	fi