Helge Jung 9 лет назад
Родитель
Сommit
2946b4b641
2 измененных файлов с 60 добавлено и 5 удалено
  1. 29 0
      build-version.sh
  2. 31 5
      build.sh

+ 29 - 0
build-version.sh

@@ -0,0 +1,29 @@
+#!/bin/bash
+# calls build.sh with information found in given version
+
+MY_DIR=$(dirname $0)
+MY_DIR=$(readlink -f "$MY_DIR")
+pushd $MY_DIR > /dev/null
+
+. functions.sh
+
+version=$1
+versionfile="${MY_DIR}/versions/${version}"
+[ -r $versionfile ] || abort "Failed to find the version '$version'."
+
+base=`awk 'BEGIN { FS="=" } /^gluon=([a-f0-9]+)$/ { print $2; }' $versionfile`
+branch=`awk 'BEGIN { FS="=" } /^branch=([a-z]+)$/ { print $2; }' $versionfile`
+site=`awk 'BEGIN { FS="=" } /^site=([a-f0-9]+)$/ { print $2; }' $versionfile`
+
+[ -z "$base" ] && abort "Failed to parse Gluon base commit-id from version file."
+[ -z "$branch" ] && abort "Failed to parse branch name from version file."
+[ -z "$site" ] && abort "Failed to parse site repo commit-id from version file."
+
+info Building $branch version '$version' again ...
+echo " * Gluon base = $base"
+echo " * Site repo  = $site"
+echo
+
+# invoke build script
+BASE=$base BRANCH=$branch SITE=$site VERSION=$version ./build.sh
+

+ 31 - 5
build.sh

@@ -1,4 +1,14 @@
 #!/bin/bash
+# (c) 2014-2015 Helge Jung <hej@c3pb.de>
+#
+# This script is controlled by environment variables, the
+# first two being mandatory:
+#
+# BASE      = Gluon Version (tag or commit, i.e. v2014.4)
+# BRANCH    = Firmware Branch (stable/testing/experimental)
+# SITE      = specific site repository commit-id (leave blank to use HEAD)
+# VERSION   = the version tag (can only be empty if BRANCH=experimental)
+#
 
 if [ "_$BRANCH" == "_" ]; then
 	echo "Please specify BRANCH environment variable." >&2
@@ -22,11 +32,16 @@ pushd $MY_DIR > /dev/null
 
 . functions.sh
 
+### CHECK THAT VERSION DOES NOT YET EXISTS
+[ -x "versions/${VERSION}" ] && abort "There exists a version file for '$VERSION' ... you are trying to do something really stupid, aren't you?"
+
+### INIT /src IF NECESSARY
 if [ ! -d "$CODE_DIR" ]; then
 	info "Code directory does not exist yet - fetching Gluon ..."
 	git clone https://github.com/freifunk-gluon/gluon.git "$CODE_DIR"
 fi
 
+### INIT /src/site IF NECESSARY
 if [ ! -d "$CODE_DIR/site" ]; then
         info "Site repository does not exist, fetching it ..."
 	git clone https://git.c3pb.de/freifunk-pb/site-ffpb.git "$CODE_DIR/site"
@@ -41,11 +56,17 @@ git fetch ; git checkout -q $BASE
 GLUON_COMMIT=$(git rev-list --max-count=1 HEAD)
 
 ### CHECKOUT SITE REPO
-progress "Pulling SITE REPO for '$BRANCH' ..."
+progress "Checking out SITE REPO ..."
 cd site
 # TODO: check if site got modified locally and bail out if necessary
-git checkout -q $BRANCH ; git pull
-[ "$?" -eq "0" ] || abort "Failed to checkout '$BRANCH' branch in site repository, mimimi."
+if [ "_$SITE" == "_" ]; then
+	# no specific site given - get the most current one
+	git checkout -q $BRANCH ; git pull
+	[ "$?" -eq "0" ] || abort "Failed to get newest '$BRANCH' in site repository, mimimi."
+else
+	# commit given - use this one
+	git checkout -q $SITE || abort "Failed to checkout requested site commit, mimimi."
+fi
 SITE_COMMIT=$(git rev-list --max-count=1 HEAD)
 
 cd ..
@@ -68,7 +89,7 @@ make toolchain -j 1
 ### BUILD FIRMWARE
 progress "Building the firmware - please stand by!"
 if [ "$BRANCH" != "experimental" ]; then
-	GLUON_BRANCH=$BRANCH GLUON_RELEASE=$VERSION make
+	GLUON_BRANCH=$BRANCH GLUON_RELEASE=$VERSION make -j 4
 else
 	GLUON_BRANCH=experimental make -j 4
 fi
@@ -83,6 +104,7 @@ mkdir -p "output/${BRANCH}"
 echo -en "" > "output/${BRANCH}/build_info.txt"
 echo "VERSION=${VERSION}" >> "output/${BRANCH}/build_info.txt"
 echo "GLUON=${GLUON_COMMIT} # ${BASE}" >> "output/${BRANCH}/build_info.txt"
+echo "BRANCH=${BRANCH}" >> "output/${BRANCH}/build_info.txt"
 echo "SITE=${SITE_COMMIT} # ${VERSION}" >> "output/${BRANCH}/build_info.txt"
 
 # compress all binaries into 7z archive
@@ -95,6 +117,10 @@ progress "Generating and copying manifest ..."
 make manifest || abort "Failed to generate the manifest, try running 'make manifest' in '$CODE_DIR' directory manually."
 cp "${CODE_DIR}/images/sysupgrade/${BRANCH}.manifest" "output/${BRANCH}/"
 
-success "We're done, go and checkout your new firmware in output/${BRANCH}!"
+# write (copy) version file
+cp "output/${BRANCH}/build_info.txt" "versions/${VERSION}"
 
+# The end. Finally.
+success "We're done, go and checkout your new firmware in output/${BRANCH}!"
 popd > /dev/null
+