mirror of
https://github.com/transmission/transmission
synced 2025-01-03 05:25:52 +00:00
#5934: Generate REVISION file and use it in case of missing reliable source
This commit is contained in:
parent
b5eee9b0fc
commit
a1393e7b35
5 changed files with 48 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
/.depend
|
/.depend
|
||||||
|
/REVISION
|
||||||
Transmission.xcodeproj/*.mode*
|
Transmission.xcodeproj/*.mode*
|
||||||
Transmission.xcodeproj/*.pbxuser
|
Transmission.xcodeproj/*.pbxuser
|
||||||
Transmission.xcodeproj/*.xcworkspace
|
Transmission.xcodeproj/*.xcworkspace
|
||||||
|
|
|
@ -56,23 +56,15 @@ else()
|
||||||
set(TR_STABLE_RELEASE 1)
|
set(TR_STABLE_RELEASE 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(TR_SCM_REVISION_FILE "${CMAKE_SOURCE_DIR}/REVISION")
|
||||||
|
set(TR_SCM_REVISION_RELIABLE ON)
|
||||||
|
|
||||||
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.svn)
|
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.svn)
|
||||||
find_package(Subversion)
|
find_package(Subversion)
|
||||||
if(Subversion_FOUND)
|
if(Subversion_FOUND)
|
||||||
Subversion_WC_INFO(${CMAKE_SOURCE_DIR} TR_SVN)
|
Subversion_WC_INFO(${CMAKE_SOURCE_DIR} TR_SVN)
|
||||||
set(TR_SCM_REVISION "${TR_SVN_WC_REVISION}")
|
set(TR_SCM_REVISION "${TR_SVN_WC_REVISION}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("${TR_SCM_REVISION}" STREQUAL "")
|
|
||||||
file(GLOB_RECURSE TR_ALL_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} *.cc *.[chm] *.po)
|
|
||||||
set(TR_SCM_REVISION 0)
|
|
||||||
foreach(F ${TR_ALL_SOURCES})
|
|
||||||
file(STRINGS ${F} F_ID REGEX "\\$Id:")
|
|
||||||
if(F_ID MATCHES "\\$Id: [^ ]+ ([0-9]+) " AND CMAKE_MATCH_1 GREATER TR_SCM_REVISION)
|
|
||||||
set(TR_SCM_REVISION ${CMAKE_MATCH_1})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
elseif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
elseif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
if(GIT_FOUND)
|
if(GIT_FOUND)
|
||||||
|
@ -88,8 +80,32 @@ elseif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if("${TR_SCM_REVISION}" STREQUAL "" AND EXISTS "${TR_SCM_REVISION_FILE}")
|
||||||
|
file(READ "${TR_SCM_REVISION_FILE}" TR_SCM_REVISION)
|
||||||
|
string(STRIP "${TR_SCM_REVISION}" TR_SCM_REVISION)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${TR_SCM_REVISION}" STREQUAL "")
|
||||||
|
# Give up and check the source files
|
||||||
|
set(TR_SCM_REVISION 0)
|
||||||
|
set(TR_SCM_REVISION_RELIABLE OFF)
|
||||||
|
file(GLOB_RECURSE TR_ALL_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} *.cc *.[chm] *.po)
|
||||||
|
foreach(F ${TR_ALL_SOURCES})
|
||||||
|
file(STRINGS ${F} F_ID REGEX "\\$Id:")
|
||||||
|
if(F_ID MATCHES "\\$Id: [^ ]+ ([0-9]+) " AND CMAKE_MATCH_1 GREATER TR_SCM_REVISION)
|
||||||
|
set(TR_SCM_REVISION ${CMAKE_MATCH_1})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
if("${TR_SCM_REVISION}" STREQUAL "")
|
if("${TR_SCM_REVISION}" STREQUAL "")
|
||||||
set(TR_SCM_REVISION 0)
|
set(TR_SCM_REVISION 0)
|
||||||
|
else()
|
||||||
|
if(TR_SCM_REVISION_RELIABLE)
|
||||||
|
file(WRITE "${TR_SCM_REVISION_FILE}" "${TR_SCM_REVISION}")
|
||||||
|
else()
|
||||||
|
file(REMOVE "${TR_SCM_REVISION_FILE}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
|
@ -47,17 +47,22 @@ EXTRA_DIST += \
|
||||||
po/CMakeLists.txt \
|
po/CMakeLists.txt \
|
||||||
qt/CMakeLists.txt \
|
qt/CMakeLists.txt \
|
||||||
third-party/b64-01-newline.patch \
|
third-party/b64-01-newline.patch \
|
||||||
|
third-party/b64-02-unsigned-char.patch \
|
||||||
third-party/b64.cmake \
|
third-party/b64.cmake \
|
||||||
third-party/dht.cmake \
|
third-party/dht.cmake \
|
||||||
third-party/event2.cmake \
|
third-party/event2.cmake \
|
||||||
third-party/natpmp.cmake \
|
third-party/natpmp.cmake \
|
||||||
|
third-party/utp-01-ticket-5002.patch \
|
||||||
third-party/utp.cmake \
|
third-party/utp.cmake \
|
||||||
third-party/utp_config.h \
|
third-party/utp_config.h \
|
||||||
utils/CMakeLists.txt
|
utils/CMakeLists.txt
|
||||||
|
|
||||||
dist-hook:
|
if HAVE_REVISION_FILE
|
||||||
rm -rf `find $(distdir)/qt -name .svn`
|
EXTRA_DIST += REVISION
|
||||||
|
endif
|
||||||
|
|
||||||
|
dist-hook:
|
||||||
|
find "$(distdir)/qt" "$(distdir)/cmake" -name .svn -exec rm -rf '{}' '+' -prune
|
||||||
|
|
||||||
DISTCLEANFILES = \
|
DISTCLEANFILES = \
|
||||||
intltool-extract \
|
intltool-extract \
|
||||||
|
|
|
@ -31,6 +31,7 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
|
AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
|
||||||
|
AM_CONDITIONAL(HAVE_REVISION_FILE, test -f REVISION)
|
||||||
|
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
|
|
|
@ -20,6 +20,9 @@ peer_id_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep peer_id_
|
||||||
major_version=`echo ${user_agent_prefix} | awk -F . '{print $1}'`
|
major_version=`echo ${user_agent_prefix} | awk -F . '{print $1}'`
|
||||||
minor_version=`echo ${user_agent_prefix} | awk -F . '{print $2 + 0}'`
|
minor_version=`echo ${user_agent_prefix} | awk -F . '{print $2 + 0}'`
|
||||||
|
|
||||||
|
svn_revision_file=REVISION
|
||||||
|
svn_revision_reliable=true
|
||||||
|
|
||||||
if [ -n "$JENKINS_URL" -a -n "$SVN_REVISION" ]; then
|
if [ -n "$JENKINS_URL" -a -n "$SVN_REVISION" ]; then
|
||||||
# Jenkins automated build, use the set environment variables to avoid
|
# Jenkins automated build, use the set environment variables to avoid
|
||||||
# version mismatches between java's svn and command line's svn
|
# version mismatches between java's svn and command line's svn
|
||||||
|
@ -28,9 +31,18 @@ elif [ -d ".svn" ] && type svnversion >/dev/null 2>&1; then
|
||||||
# If this is a svn tree, and svnversion is available in PATH, use it to
|
# If this is a svn tree, and svnversion is available in PATH, use it to
|
||||||
# grab the version.
|
# grab the version.
|
||||||
svn_revision=`svnversion -n . | cut -d: -f1 | cut -dM -f1 | cut -dS -f1`
|
svn_revision=`svnversion -n . | cut -d: -f1 | cut -dM -f1 | cut -dS -f1`
|
||||||
|
elif [ -f "$svn_revision_file" ]; then
|
||||||
|
svn_revision=`cat "$svn_revision_file"`
|
||||||
else
|
else
|
||||||
# Give up and check the source files
|
# Give up and check the source files
|
||||||
svn_revision=`awk '/\\$Id: /{ if ($4>i) i=$4 } END {print i}' */*.cc */*.[chm] */*.po`
|
svn_revision=`awk '/\\$Id: /{ if ($4>i) i=$4 } END {print i}' */*.cc */*.[chm] */*.po`
|
||||||
|
svn_revision_reliable=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $svn_revision_reliable; then
|
||||||
|
[ -f "$svn_revision_file" ] && [ "`cat "$svn_revision_file"`" -eq "$svn_revision" ] || echo "$svn_revision" > "$svn_revision_file"
|
||||||
|
else
|
||||||
|
rm -f "$svn_revision_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > libtransmission/version.h.new << EOF
|
cat > libtransmission/version.h.new << EOF
|
||||||
|
|
Loading…
Reference in a new issue