build-version.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. MY_DIR=$(dirname $0)
  6. MY_DIR=$(readlink -f "${MY_DIR}")
  7. pushd ${MY_DIR} > /dev/null
  8. . functions.sh
  9. version=$1
  10. versionfile="${MY_DIR}/versions/${version}"
  11. [ -r ${versionfile} ] || abort "Failed to find the version '${version}'."
  12. [ -n "${BROKEN}" ] || BROKEN=0
  13. base=`awk 'BEGIN { FS="=" } /^GLUON=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
  14. branch=`awk 'BEGIN { FS="=" } /^BRANCH=([a-z]+)$/ { print $2; }' ${versionfile}`
  15. version=`awk 'BEGIN { FS="=" } /^VERSION=([0-9\.\-+~a-z]+)$/ { print $2; }' ${versionfile}`
  16. site=`awk 'BEGIN { FS="=" } /^SITE=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' ${versionfile} | awk 'BEGIN { FS="#" } { print $1; }'`
  17. targets=`awk 'BEGIN { FS="=" } /^TARGETS=.+$/ { print $2; }' ${versionfile}`
  18. ts=`awk 'BEGIN { FS="=" } /^TS=.+$/ { print $2; }' ${versionfile}`
  19. [ -n "${base}" ] || abort "Failed to parse Gluon base commit-id from version file."
  20. [ -n "${branch}" ] || abort "Failed to parse branch name from version file."
  21. [ -n "${version}" ] || abort "Failed to parse version from version file."
  22. [ -n "${site}" ] || abort "Failed to parse site repo commit-id from version file."
  23. [ -n "${targets}" ] || abort "Failed to parse targets from version file"
  24. [ -n "${ts}" ] || abort "Failed to parse timestamp from version file."
  25. # remove all spaces from git-commit-ids
  26. base="${base// /}"
  27. site="${site// /}"
  28. info "Building ${branch} version '${version}' again ..."
  29. echo " * Gluon base = ${base}"
  30. echo " * Site commit= ${site}"
  31. echo " * Timestamp = ${ts}"
  32. echo " * Targets = ${targets}"
  33. echo
  34. # invoke build script
  35. if [ "${NO_DOCKER}" -eq "1" ]; then
  36. BASE="${base}" BRANCH="${branch}" SITE_ID="${site}" VERSION="${version}" BUILD_TS="${ts}" TARGETS="${targets}" BROKEN="${BROKEN}" ./build.sh
  37. else
  38. BASE="${base}" BRANCH="${branch}" SITE_ID="${site}" VERSION="${version}" BUILD_TS="${ts}" TARGETS="${targets}" BROKEN="${BROKEN}" ./docker-build.sh
  39. fi
  40. popd > /dev/null #${MY_DIR}