diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 4d7508eb1..77f17f7e1 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -1824,7 +1824,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sh macosx/version.sh"; + shellScript = "sh update-version-h.sh"; }; BE75C3510C729EE100DBEFE0 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; diff --git a/macosx/version.sh b/macosx/version.sh deleted file mode 100755 index 1fe43d556..000000000 --- a/macosx/version.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh -# -# $Id$ - -# convention: -TR MAJOR MINOR MAINT STATUS - (each a single char) -# STATUS: "X" for prerelease beta builds, -# "Z" for unsupported trunk builds, -# "0" for stable, supported releases -# these should be the only two lines you need to change -PEERID_PREFIX="-TR172Z-" -USERAGENT_PREFIX="1.72+" - -SVN_REVISION=`find -E ./libtransmission ./macosx \ - -regex ".*\.([chmp]|cpp|po|sh)" \ - -exec grep -oh '\$Id: [^ ]\+ [0-9]\+' {} + \ - | awk '{ if ($3 > max) max = $3} END { print max }'` - -# Generate files to be included: only overwrite them if changed so make -# won't rebuild everything unless necessary -replace_if_differs () -{ - if cmp $1 $2 > /dev/null 2>&1; then - rm -f $1 - else - mv -f $1 $2 - fi -} - -# Generate version.h -cat > libtransmission/version.h.new << EOF -#define PEERID_PREFIX "$PEERID_PREFIX" -#define USERAGENT_PREFIX "$USERAGENT_PREFIX" -#define SVN_REVISION "$SVN_REVISION" -#define SVN_REVISION_NUM $SVN_REVISION -#define SHORT_VERSION_STRING "$USERAGENT_PREFIX" -#define LONG_VERSION_STRING "$USERAGENT_PREFIX ($SVN_REVISION)" - -#define VERSION_STRING_INFOPLIST $USERAGENT_PREFIX -EOF - -# Add a release definition -if [ ${PEERID_PREFIX:6:1} = X ]; then - line='#define TR_BETA_RELEASE "BETA"' -elif [ ${PEERID_PREFIX:6:1} = Z ]; then - line='#define TR_NIGHTLY_RELEASE "NIGHTLY"' -else - line='#define TR_STABLE_RELEASE "STABLE"' -fi -echo $line >> libtransmission/version.h.new - -replace_if_differs libtransmission/version.h.new libtransmission/version.h - -exit 0 diff --git a/update-version-h.sh b/update-version-h.sh index b5d52fdca..ec46358de 100755 --- a/update-version-h.sh +++ b/update-version-h.sh @@ -1,21 +1,46 @@ #!/bin/sh +# Generate files to be included: only overwrite them if changed so make +# won't rebuild everything unless necessary +replace_if_differs () +{ + if cmp $1 $2 > /dev/null 2>&1; then + rm -f $1 + else + mv -f $1 $2 + fi +} + echo "creating libtransmission/version.h" user_agent_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep user_agent_prefix | cut -d , -f 6` peer_id_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep peer_id_prefix | cut -d , -f 6` -if [ -d .svn ]; then - svn_revision=`svnversion -n | cut -d: -f1 | cut -dM -f1 | cut -dS -f1` + +# If this is a svn tree, and svnversion is available in PATH, use it to +# grab the version. +if [ -d ".svn" ] && type svnversion >/dev/null 2>&1; then + svn_revision=`svnversion -n . | cut -d: -f1 | cut -dM -f1 | cut -dS -f1` else - svn_revision=`awk '/\\$Id: /{ if ($4>i) i=$4 } END {print i}' */*.cc */*.[chm]` + # Give up and check the source files + svn_revision=`awk '/\\$Id: /{ if ($4>i) i=$4 } END {print i}' */*.cc */*.[chm] */*.po` fi -cat > libtransmission/version.h << EOF +cat > libtransmission/version.h.new << EOF #define PEERID_PREFIX "${peer_id_prefix}" #define USERAGENT_PREFIX "${user_agent_prefix}" #define SVN_REVISION "${svn_revision}" #define SVN_REVISION_NUM ${svn_revision} #define SHORT_VERSION_STRING "${user_agent_prefix}" #define LONG_VERSION_STRING "${user_agent_prefix} (${svn_revision})" +#define VERSION_STRING_INFOPLIST ${user_agent_prefix} EOF + +# Add a release definition +case "${peer_id_prefix}" in + *X-) echo '#define TR_BETA_RELEASE "BETA"' ;; + *Z-) echo '#define TR_NIGHTLY_RELEASE "NIGHTLY"' ;; + *) echo '#define TR_STABLE_RELEASE "STABLE"' ;; +esac >> "libtransmission/version.h.new" + +replace_if_differs libtransmission/version.h.new libtransmission/version.h