build-version.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # (c) 2014-2015 Freifunk Paderborn <maschinenraum@paderborn.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_repo=`awk 'BEGIN { FS="=" } /^SITE_REPO=([a-z]+)$/ { print $2; }' $versionfile`
  17. site=`awk 'BEGIN { FS="=" } /^SITE=([a-f0-9]+)(\s*#.+)?$/ { print $2; }' $versionfile | awk 'BEGIN { FS="#" } { print $1; }'`
  18. targets=`awk 'BEGIN { FS="=" } /^TARGETS=.+$/ { print $2; }' $versionfile`
  19. ts=`awk 'BEGIN { FS="=" } /^TS=.+$/ { print $2; }' $versionfile`
  20. [ -z "$base" ] && abort "Failed to parse Gluon base commit-id from version file."
  21. [ -z "$branch" ] && abort "Failed to parse branch name from version file."
  22. [ -z "$version" ] && abort "Failed to parse version from version file."
  23. [ -z "$site_repo" ] && site_repo="ffpb"
  24. [ -z "$site" ] && abort "Failed to parse site repo commit-id from version file."
  25. [ -z "$ts" ] && abort "Failed to parse timestamp from version file."
  26. # remove all spaces from git-commit-ids
  27. base="${base// /}"
  28. site="${site// /}"
  29. info "Building $branch version '$version' again ..."
  30. echo " * Gluon base = $base"
  31. echo " * Site repo = $site_repo"
  32. echo " * Site commit= $site"
  33. echo " * Timestamp = $ts"
  34. echo " * Targets = $targets"
  35. echo
  36. # invoke build script
  37. if [ "$NO_DOCKER" == "1" ]; then
  38. BASE="$base" BRANCH="$branch" SITE="$site_repo" SITE_ID="$site" VERSION="$version" BUILD_TS="$ts" TARGETS="$targets" BROKEN="$BROKEN" ./build.sh
  39. else
  40. BASE="$base" BRANCH="$branch" SITE="$site_repo" SITE_ID="$site" VERSION="$version" BUILD_TS="$ts" TARGETS="$targets" BROKEN="$BROKEN" ./docker-build.sh
  41. fi