Selaa lähdekoodia

Makes build.sh write build-info.txt before compiling the images.

As build-info.txt contains all necessary information to produce clones
of the images that get build in a particular run, obtaining this file at
an earlier stage of the build process avoids that others will have to
wait for the result of the build process to generate, for instance, a
verification build on a different machine.

As it was before, the file gets written to "./output/${BRANCH}/", but
still only is saved in "./versions/" with its version-name if the build
process finishes successfully.

This closes issue #21.

Signed-off-by: Stefan Laudemann <thisco@webcake.de>
Stefan Laudemann 9 vuotta sitten
vanhempi
commit
637c2cfd5b
1 muutettua tiedostoa jossa 21 lisäystä ja 13 poistoa
  1. 21 13
      build.sh

+ 21 - 13
build.sh

@@ -43,6 +43,10 @@ fi
 MY_DIR=$(dirname $0)
 MY_DIR=$(readlink -f "$MY_DIR")
 CODE_DIR="src"
+OUTPUT_DIR="${MY_DIR}/output"
+BUILD_INFO_FILENAME="build-info.txt"
+VERSIONS_INFO_DIR="versions"
+
 pushd $MY_DIR > /dev/null
 [ "_$BUILD_TS" == "_" ] && export BUILD_TS=$(date +"%Y-%m-%d %H:%M:%S")
 
@@ -98,6 +102,19 @@ progress "Preparing the build environment (make update) ..."
 make update
 [ "$?" -eq "0" ] || abort "Failed to update the build environment, mimimi."
 
+# we are now ready to produke the firmware images, so let's "save" our state
+build_info_path="${OUTPUT_DIR}/${BRANCH}/${BUILD_INFO_FILENAME}"
+progress "Saving build information to: ${build_info_path}"
+mkdir -p $(dirname ${build_info_path})
+[ "$?" -eq "0" ] || abort "Unable to create output directory: $(dirname ${build_info_path})"
+touch $(dirname ${build_info_path})
+[ "$?" -eq "0" ] || abort "Cannot create build information file: ${build_info_path}"
+echo "VERSION=${VERSION}" >> ${build_info_path}
+echo "GLUON=${GLUON_COMMIT} # ${BASE}" >> ${build_info_path}
+echo "BRANCH=${BRANCH}" >> ${build_info_path}
+echo "SITE=${SITE_COMMIT} # ${VERSION}" >> ${build_info_path}
+echo "TS=${BUILD_TS}" >> ${build_info_path}
+
 ### BUILD FIRMWARE
 progress "Building the firmware - please stand by!"
 [ -n "${BROKEN}" ] || BROKEN=0
@@ -138,16 +155,6 @@ done
 
 cd ..
 
-# write build info
-progress "Writing build info ..."
-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"
-echo "TS=${BUILD_TS}" >> "output/${BRANCH}/build_info.txt"
-
 # compress all binaries into 7z archive
 progress "Assembling images.7z ..."
 [ -e "output/${BRANCH}/images.7z" ] && rm "output/${BRANCH}/images.7z"
@@ -169,10 +176,11 @@ grep -hE "*.bin$" ./images/sysupgrade/*.${BRANCH}.manifest | sort >> ${frankenme
 popd
 cp "${CODE_DIR}/images/sysupgrade/${BRANCH}.manifest" "output/${BRANCH}/"
 
-# write (copy) version file
-cp "output/${BRANCH}/build_info.txt" "versions/${VERSION}"
+# Saving a copy of the build info file as reference
+progress "Building a greater and brighter firmware finished successfully. Saving build information at: ${VERSIONS_INFO_DIR}/${VERSION}"
+cp -p "${build_info_path}" "${VERSIONS_INFO_DIR}/${VERSION}"
 
 # The end. Finally.
-success "We're done, go and checkout your new firmware in output/${BRANCH}!"
+success "We're done, go and enjoy your new firmware in ${OUTPUT_DIR}/${BRANCH}!"
 popd > /dev/null