Browse Source

build.sh: small rework

Karsten Böddeker 6 years ago
parent
commit
781da32633
1 changed files with 9 additions and 15 deletions
  1. 9 15
      build.sh

+ 9 - 15
build.sh

@@ -4,7 +4,7 @@
 # This script builds the firmware by the environment variables given, the
 # first two being mandatory:
 #
-# BASE        = Gluon Version (tag or commit, i.e. v2014.4)
+# BASE        = Gluon Version (branch, tag or commit, i.e. v2014.4)
 # BRANCH      = Firmware Branch (stable/testing/experimental)
 # VERSION     = the version tag (can only be empty if BRANCH=experimental)
 #
@@ -55,13 +55,7 @@ pushd ${MY_DIR} > /dev/null
 
 ### set reasonable defaults for unset environment variables
 [ -n "${AUTOUPDATER}" ] || AUTOUPDATER=${BRANCH}
-if [ -n "${BROKEN}" ]; then
-	if [ "${BROKEN}" -eq "1" ]; then
-		export BROKEN
-	else
-		unset BROKEN
-	fi
-fi
+[ "${BROKEN}" -eq "1" ] && export BROKEN || unset BROKEN
 [ -n "${BUILD_TS}" ] || BUILD_TS=$(date +"%Y-%m-%d %H:%M:%S")
 [ -n "${CLEAN}" ] || CLEAN="none"
 
@@ -89,8 +83,8 @@ MAKE_PARAM=""
 
 ### ERROR handling
 [ -n "${BASE}" ] || abort "Please specify BASE environment variable (Gluon, i.e. 'v2014.3' or commit-id)."
+[ "${BASE}" == "HEAD" ] && abort "HEAD is not an allowed BASE-identifier. Either use a branch, a tagged commit or the commit-SHA itself."
 [ -n "${BRANCH}" ] || abort "Please specify BRANCH environment variable."
-[ "${BRANCH}" == "experimental" -o "${BASE}" != "HEAD" ] || abort "HEAD is not an allowed BASE-identifier for non-experimental builds. Either use a tagged commit or the commit-SHA itself."
 [ -n "${VERSION}" -o "${BRANCH}" == "experimental" ] || abort "Please specify VERSION environment variable (not necessary for experimental branch)."
 [ "${BRANCH}" == "experimental" -o ! -r "${VERSIONS_DIR}/${VERSION}" ] || abort "There exists a version file for '${VERSION}' ... you are trying to do something really stupid, aren't you?"
 
@@ -120,15 +114,15 @@ fi
 progress "Checking out GLUON '${BASE}' ..."
 pushd ${CODE_DIR} > /dev/null
 # check if gluon got modified and bail out if necessary
-[ "$(git status --porcelain)" ] && abort "Local changes to peers directory. Cowardly refusing to update gluon repository." >&2
+[ "$(git status --porcelain)" ] && abort "Local changes to gluon directory. Cowardly refusing to update repository." >&2
 git fetch
 git show-ref --verify --quiet refs/remotes/origin/${BASE}
 if [ "$?" -eq "0" ]; then
 	git checkout -B build origin/${BASE}
-	[ "$?" -eq "0" ] || abort "Failed to get newest '${BASE}' in gluon repository, mimimi."
+	[ "$?" -eq "0" ] || abort "Failed to checkout gluon origin/${BASE}."
 else
 	git checkout -q ${BASE}
-	[ "$?" -eq "0" ] || abort "Failed to checkout '${BASE}' gluon base version, mimimi." >&2
+	[ "$?" -eq "0" ] || abort "Failed to checkout gluon ${BASE}." >&2
 fi
 GLUON_COMMIT=$(git rev-list --max-count=1 HEAD)
 popd > /dev/null #${CODE_DIR}
@@ -171,14 +165,14 @@ progress "Preparing the build environment (make update) ..."
 make update
 [ "$?" -eq "0" ] || abort "Failed to update the build environment, mimimi."
 
-### set reasonable defaults for ${TARGETS} and ${BRANCH} if unset
+### set reasonable defaults for TARGETS and VERSION if unset
 if [ -z "${TARGETS}" ]; then
 	TARGETS=$(make list-targets | sed ':a;N;$!ba;s/\n/ /g')
 	info "building all targets: '${TARGETS}'"
 fi
-if [ "${BRANCH}" == "experimental" -a -z "${VERSION}" ] ; then
+if [ -z "${VERSION}" ] ; then
 	VERSION=$(make show-release)
-	info "EXPERIMENTAL FIRMWARE: using version tag '${VERSION}'"
+	info "${BRANCH} firmware: using version tag '${VERSION}'"
 fi
 popd > /dev/null #${CODE_DIR}