summaryrefslogtreecommitdiff
path: root/cmake/make_dist.cmake.in
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2014-11-11 10:58:47 +0100
committerTor Didriksen <tor.didriksen@oracle.com>2014-11-11 10:58:47 +0100
commit9bd6e87545dbbba594e8d63c9bfb0c8a744ccbfe (patch)
treec381932bf5e510d69137e77b551d59534967e6f2 /cmake/make_dist.cmake.in
parenta9b61b0029713c3b567ca33be50ad5b2a44045fb (diff)
downloadmariadb-git-9bd6e87545dbbba594e8d63c9bfb0c8a744ccbfe.tar.gz
Bug#19890133 MAKE DIST USING BZR EXPORT EVEN FOR SOURCE DIR NOT A BZR REPO
For 'make dist': only use 'bzr export' if bzr root == ${CMAKE_SOURCE_DIR} Same thing for git.
Diffstat (limited to 'cmake/make_dist.cmake.in')
-rw-r--r--cmake/make_dist.cmake.in76
1 files changed, 61 insertions, 15 deletions
diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in
index ada27c36926..10180aba778 100644
--- a/cmake/make_dist.cmake.in
+++ b/cmake/make_dist.cmake.in
@@ -23,12 +23,12 @@ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "@CPACK_SOURCE_PACKAGE_FILE_NAME@")
SET(CMAKE_CPACK_COMMAND "@CMAKE_CPACK_COMMAND@")
SET(CMAKE_COMMAND "@CMAKE_COMMAND@")
SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
+SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@")
SET(GTAR_EXECUTABLE "@GTAR_EXECUTABLE@")
SET(TAR_EXECUTABLE "@TAR_EXECUTABLE@")
SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@")
SET(CMAKE_MAKE_PROGRAM "@CMAKE_MAKE_PROGRAM@")
SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@")
-SET(PLUGIN_REPOS "@PLUGIN_REPOS@")
SET(VERSION "@VERSION@")
@@ -40,6 +40,23 @@ SET(PACKAGE_DIR ${CMAKE_BINARY_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME})
FILE(REMOVE_RECURSE ${PACKAGE_DIR})
FILE(REMOVE ${PACKAGE_DIR}.tar.gz )
+# Only allow bzr if source dir itself is a bzr repository
+IF(BZR_EXECUTABLE)
+ EXECUTE_PROCESS(
+ COMMAND "${BZR_EXECUTABLE}" root
+ OUTPUT_VARIABLE BZR_ROOT
+ ERROR_VARIABLE BZR_ROOT_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE RESULT
+ )
+
+ IF(NOT RESULT EQUAL 0 OR NOT BZR_ROOT STREQUAL ${CMAKE_SOURCE_DIR})
+ MESSAGE(STATUS "This is not a bzr repository")
+ SET(BZR_EXECUTABLE)
+ ENDIF()
+ENDIF()
+
IF(BZR_EXECUTABLE)
MESSAGE(STATUS "Running bzr export")
EXECUTE_PROCESS(
@@ -50,28 +67,57 @@ IF(BZR_EXECUTABLE)
)
IF(NOT RESULT EQUAL 0)
- SET(BZR_EXECUTABLE)
+ SET(BZR_EXECUTABLE)
ENDIF()
ENDIF()
-IF(BZR_EXECUTABLE)
- FOREACH(REPO ${PLUGIN_REPOS})
- GET_FILENAME_COMPONENT(PLUGIN_NAME ${REPO} NAME)
- SET(DEST ${PACKAGE_DIR}/plugin/${PLUGIN_NAME})
- MESSAGE(STATUS "Running bzr export for plugin/${PLUGIN_NAME}")
+IF(GIT_EXECUTABLE AND NOT BZR_EXECUTABLE)
+ EXECUTE_PROCESS(
+ COMMAND "${GIT_EXECUTABLE}" rev-parse --show-toplevel
+ OUTPUT_VARIABLE GIT_ROOT
+ ERROR_VARIABLE GIT_ROOT_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE RESULT
+ )
+
+ IF(NOT RESULT EQUAL 0 OR NOT GIT_ROOT STREQUAL ${CMAKE_SOURCE_DIR})
+ MESSAGE(STATUS "This is not a git repository")
+ SET(GIT_EXECUTABLE)
+ ENDIF()
+ENDIF()
+
+IF(GIT_EXECUTABLE AND NOT BZR_EXECUTABLE)
+ MESSAGE(STATUS "Running git archive -o ${PACKAGE_DIR}.tar")
+ EXECUTE_PROCESS(
+ COMMAND "${GIT_EXECUTABLE}" archive --format=tar
+ --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ -o ${PACKAGE_DIR}.tar HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE RESULT
+ )
+ IF(NOT RESULT EQUAL 0)
+ SET(GIT_EXECUTABLE)
+ ELSE()
+ # Unpack tarball
EXECUTE_PROCESS(
- COMMAND "${BZR_EXECUTABLE}" export ${DEST}
- WORKING_DIRECTORY ${REPO}
- RESULT_VARIABLE RESULT
+ COMMAND ${CMAKE_COMMAND} -E tar xf ${PACKAGE_DIR}.tar
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ RESULT_VARIABLE TAR_RESULT
)
- IF(NOT RESULT EQUAL 0)
- MESSAGE(STATUS "bzr export failed")
+ IF(NOT TAR_RESULT EQUAL 0)
+ SET(GIT_EXECUTABLE)
+ ELSE()
+ # Remove tarball after unpacking
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_COMMAND} -E remove ${PACKAGE_DIR}.tar
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
ENDIF()
- ENDFOREACH()
+ ENDIF()
ENDIF()
-IF(NOT BZR_EXECUTABLE)
- MESSAGE(STATUS "bzr not found or source dir is not a repo, use CPack")
+IF(NOT BZR_EXECUTABLE AND NOT GIT_EXECUTABLE)
+ MESSAGE(STATUS "bzr/git not found or source dir is not a repo, use CPack")
IF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
# In-source build is the worst option, we have to cleanup source tree.