Browse Source

build-version.sh: rework

We are now able to include the verion file instead of parsing it via awk
Karsten Böddeker 6 years ago
parent
commit
a0984eb69c
1 changed files with 15 additions and 28 deletions
  1. 15 28
      build-version.sh

+ 15 - 28
build-version.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 # (c) 2014-2018 Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 #
-# calls build.sh with information found in given version
+# calls build.sh with information found in given versionfile
 
 ### includes
 . functions.sh
@@ -10,39 +10,26 @@
 MY_DIR=$(dirname $0)
 MY_DIR=$(readlink -f "${MY_DIR}")
 
-pushd ${MY_DIR} > /dev/null
-
 ### set reasonable defaults for unset environment variables
 versionfile=$1
 [ -r ${versionfile} ] || abort "Failed to find versionfile: '${versionfile}'."
-
+. ${versionfile}
 [ -n "${BROKEN}" ] || BROKEN=0
-base=`awk 'BEGIN { FS="=" } /^GLUON=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
-branch=`awk 'BEGIN { FS="=" } /^BRANCH=([a-z]+)$/ { print $2; }' ${versionfile}`
-version=`awk 'BEGIN { FS="=" } /^VERSION=([0-9\.\-+~a-z]+)$/ { print $2; }' ${versionfile}`
-site=`awk 'BEGIN { FS="=" } /^SITE=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
-targets=`awk 'BEGIN { FS="=" } /^TARGETS=.+$/ { print $2; }' ${versionfile}`
-ts=`awk 'BEGIN { FS="=" } /^TS=.+$/ { print $2; }' ${versionfile}`
 
-[ -n "${base}" ] || abort "Failed to parse Gluon base commit-id from version file."
-[ -n "${branch}" ] || abort "Failed to parse branch name from version file."
-[ -n "${version}" ] || abort "Failed to parse version from version file."
-[ -n "${site}" ] || abort "Failed to parse site repo commit-id from version file."
-[ -n "${targets}" ] || abort "Failed to parse targets from version file"
-[ -n "${ts}" ] || abort "Failed to parse timestamp from version file."
+[ -n "${BRANCH}" ] || abort "Failed to parse branch name from version file."
+[ -n "${GLUON}" ] || abort "Failed to parse Gluon base commit-id from version file."
+[ -n "${SITE}" ] || abort "Failed to parse site repo commit-id from version file."
+[ -n "${TARGETS}" ] || abort "Failed to parse targets from version file"
+[ -n "${TS}" ] || abort "Failed to parse timestamp from version file."
+[ -n "${VERSION}" ] || abort "Failed to parse version from version file."
 
-# remove all spaces from git-commit-ids
-base="${base// /}"
-site="${site// /}"
-
-info "Building ${branch} version '${version}' again ..."
-echo " * Gluon base = ${base}"
-echo " * Site commit= ${site}"
-echo " * Timestamp  = ${ts}"
-echo " * Targets    = ${targets}"
-echo
+info "Building ${BRANCH} version '${VERSION}' again ..."
+echo " * Gluon base:  ${GLUON}"
+echo " * Site commit: ${SITE}"
+echo " * Targets:     ${TARGETS}"
+echo " * Timestamp:   ${TS}"
 
 # invoke build script
-BASE="${base}" BRANCH="${branch}" SITE="${site}" VERSION="${version}" BUILD_TS="${ts}" TARGETS="${targets}" BROKEN="${BROKEN}" ./build.sh
-
+pushd ${MY_DIR} > /dev/null
+BASE="${GLUON}" BRANCH="${BRANCH}" SITE="${SITE}" VERSION="${VERSION}" BUILD_TS="${TS}" TARGETS="${TARGETS}" BROKEN="${BROKEN}" ./build.sh
 popd > /dev/null #${MY_DIR}