build-version.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # (c) 2014-2016 Freifunk Hochstift <kontakt@hochstift.freifunk.net>
  3. #
  4. # calls build.sh with information found in given version
  5. ### includes
  6. . functions.sh
  7. ### static variables
  8. MY_DIR=$(dirname $0)
  9. MY_DIR=$(readlink -f "${MY_DIR}")
  10. pushd ${MY_DIR} > /dev/null
  11. ### set reasonable defaults for unset environment variables
  12. versionfile=$1
  13. [ -r ${versionfile} ] || abort "Failed to find versionfile: '${versionfile}'."
  14. [ -n "${BROKEN}" ] || BROKEN=0
  15. base=`awk 'BEGIN { FS="=" } /^GLUON=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
  16. branch=`awk 'BEGIN { FS="=" } /^BRANCH=([a-z]+)$/ { print $2; }' ${versionfile}`
  17. version=`awk 'BEGIN { FS="=" } /^VERSION=([0-9\.\-+~a-z]+)$/ { print $2; }' ${versionfile}`
  18. site=`awk 'BEGIN { FS="=" } /^SITE=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
  19. targets=`awk 'BEGIN { FS="=" } /^TARGETS=.+$/ { print $2; }' ${versionfile}`
  20. ts=`awk 'BEGIN { FS="=" } /^TS=.+$/ { print $2; }' ${versionfile}`
  21. [ -n "${base}" ] || abort "Failed to parse Gluon base commit-id from version file."
  22. [ -n "${branch}" ] || abort "Failed to parse branch name from version file."
  23. [ -n "${version}" ] || abort "Failed to parse version from version file."
  24. [ -n "${site}" ] || abort "Failed to parse site repo commit-id from version file."
  25. [ -n "${targets}" ] || abort "Failed to parse targets from version file"
  26. [ -n "${ts}" ] || abort "Failed to parse timestamp from version file."
  27. # remove all spaces from git-commit-ids
  28. base="${base// /}"
  29. site="${site// /}"
  30. info "Building ${branch} version '${version}' again ..."
  31. echo " * Gluon base = ${base}"
  32. echo " * Site commit= ${site}"
  33. echo " * Timestamp = ${ts}"
  34. echo " * Targets = ${targets}"
  35. echo
  36. # invoke build script
  37. BASE="${base}" BRANCH="${branch}" SITE_ID="${site}" VERSION="${version}" BUILD_TS="${ts}" TARGETS="${targets}" BROKEN="${BROKEN}" ./build.sh
  38. popd > /dev/null #${MY_DIR}