X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fiw.git;a=blobdiff_plain;f=version.sh;h=9ef607d79cf34cebbd11111afa91a2a28de74b4d;hp=773486faacebaa63d2f980be67cde9ec00dd7de1;hb=feea0ff28c8ca01d832b8dd36af2d196fbfee772;hpb=4601f55c714e77e040d9bbfdca4f518e0a23732e diff --git a/version.sh b/version.sh index 773486f..9ef607d 100755 --- a/version.sh +++ b/version.sh @@ -1,23 +1,41 @@ #!/bin/sh -VERSION="0.9.5" +VERSION="4.7" +OUT="$1" -( -if head=`git rev-parse --verify HEAD 2>/dev/null`; then - git update-index --refresh --unmerged > /dev/null - descr=$(git describe) +# get the absolute path for the OUT file +OUT_NAME=$(basename ${OUT}) +OUT_DIR=$(cd $(dirname ${OUT}); pwd) +OUT="${OUT_DIR}/${OUT_NAME}" - # on git builds check that the version number above - # is correct... - [ "${descr%%-*}" = "v$VERSION" ] || exit 2 - - echo -n '#define IW_VERSION "' - echo -n "${descr#v}" - if git diff-index --name-only HEAD | read dummy ; then - echo -n "-dirty" - fi - echo '"' -else -echo "#define IW_VERSION \"$VERSION-nogit\"" +# the version check should be under the source directory +# where this script is located, instead of the currect directory +# where this script is excuted. +SRC_DIR=$(dirname $0) +SRC_DIR=$(cd ${SRC_DIR}; pwd) +cd "${SRC_DIR}" + +v="" +if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then + git update-index --refresh --unmerged > /dev/null + descr=$(git describe --match=v* 2>/dev/null) + if [ $? -eq 0 ]; then + # on git builds check that the version number above + # is correct... + if [ "${descr%%-*}" = "v$VERSION" ]; then + v="${descr#v}" + if git diff-index --name-only HEAD | read dummy ; then + v="$v"-dirty + fi + fi + fi +fi + +# set to the default version when failed to get the version +# information with git +if [ -z "${v}" ]; then + v="$VERSION" fi -) > version.h + +echo '#include "iw.h"' > "$OUT" +echo "const char iw_version[] = \"$v\";" >> "$OUT"