You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

#!/bin/sh
#
# Output the current version number
#
usage() {
echo "Usage: $0 [short|hash]"
echo
echo "Determine the correct version number for the current build"
exit 0
}
# We assume this script is in the TOPDIR/scripts directory and use that
# to find any other files we need
TOPDIR=$(dirname "$0")/..
VER_FILE_SHORT=$(cat "${TOPDIR}/VERSION")
if [ -d "$TOPDIR/.git" ]; then
# If there is a .git directory in our TOPDIR, then this is assumed to be
# real git checkout
Update Openwrt process (#900) * First attempt at a openwrt CI * Fix action - helps if I dont forget the syntax half way through writing it * Try building /this/ branch for the openwrt CI * Try a build with openssl configured * Dont enable the n2n package until we have built the environment - makes errors easier to see and clearly related to n2n * Attempt to speed up the openwrt build * Upload any created ipkg packages * Dont test with openssl for the moment * Attempt to speed up openwrt build using a cache of the build dir * The make defconfig run turns all the built binaries stale, so stop caching them. Also use a real ref for the cache key * Minor text name changes * Address yamllint concerns * Attempt to simplify and document missing parts of the openwrt makefile * Attempt to fix mystery openwrt make error * Rename build job name * Avoid nested checkouts, use two separate dirs for the two checkouts in this build * Move the n2n checkout to earler, allowing us to skip one defconfig run * We are going to need working tags from the n2n repo, so ensure we unbreak the github checkout braindamage * Calculate and save the n2n version string * Prepare the way to pass the correct external vars into the openwrt build * Hook calculated build variables into the openwrt package definition * Update artifacts source to match moved checkout dir * Pass env vars in to the make * Allow version script to be influenced by external vars * It will help if I use the same variable names everywhere * Add more version variable calculation overrides * Configure openwrt to use the external git checkout instead of their create-tar-then-extract dance * Using the correct syntax for ifdef will help significantly * Use as many jobs as we have cpus * As the USE_SOURCE_DIR option allows us to use a full git checkout, we do not need to hack the version.sh to allow overrides * Ensure scripts/version.sh works from anywhere * Remove unneeded variables * Update openwrt build documentation to match the new build process * Catch failure to cd as per shellcheck suggestion * Limit lengthy openwrt builds to manual triggers or on a release * Also run on specially named branches * Break list into separate lines for easier future editing
3 years ago
cd "$TOPDIR" || exit 1
VER_GIT_SHORT=$(git describe --abbrev=0)
if [ "$VER_FILE_SHORT" != "$VER_GIT_SHORT" ]; then
echo "Error: VERSION file does not match tag version ($VER_FILE_SHORT != $VER_GIT_SHORT)"
exit 1
fi
VER_SHORT="$VER_GIT_SHORT"
VER_HASH=$(git rev-parse --short HEAD)
VER=$(git describe --abbrev=7 --dirty)
else
# If there is no .git directory in our TOPDIR, we fall back on relying on
# the VERSION file
VER_SHORT="$VER_FILE_SHORT"
VER_HASH="HEAD"
VER="$VER_FILE_SHORT"
fi
case "$1" in
hash)
echo "$VER_HASH"
;;
short)
echo "$VER_SHORT"
;;
"")
echo "$VER"
;;
*)
usage
;;
esac