Bug #74556 make dist using bzr export even for source dir not a bzr repo
Submitted: 24 Oct 2014 21:29 Modified: 12 Nov 2014 16:11
Reporter: Mauritz Sundell Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[24 Oct 2014 21:29] Mauritz Sundell
Description:
If one unpack a MySQL source code archive to a directory where one of the enclosing directories is a bazaar repository branch, make dist will use bzr export to copy out mysql source code committed to that bazaar repository, most likely none, and the resulting tar file will only contain a number of hand picked files.

How to repeat:
cd /path/to/repo/mysql-trunk
bzr init /path/to/dir
bzr export /path/to/dir/mysql-export
cd /path/to/dir/mysql-export
cmake .
make dist
tar tzf mysql-5.7.6-m16.tar.gz

gives only a few files:
mysql-5.7.6-m16/
mysql-5.7.6-m16/sql/
mysql-5.7.6-m16/sql/sql_yacc.h
mysql-5.7.6-m16/sql/sql_yacc.cc
mysql-5.7.6-m16/Docs/
mysql-5.7.6-m16/Docs/INFO_SRC
mysql-5.7.6-m16/support-files/
mysql-5.7.6-m16/support-files/mysql.5.7.6-m16.spec

Suggested fix:
Check that CMAKE_SOURCE_DIR is the bazaar repository branch, else disable bzr export.

=== modified file 'cmake/make_dist.cmake.in'
--- cmake/make_dist.cmake.in
+++ cmake/make_dist.cmake.in
@@ -40,6 +40,21 @@ SET(PACKAGE_DIR  ${CMAKE_BINARY_DIR}/${C
 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
+    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})
+    SET(BZR_EXECUTABLE)
+  ENDIF()
+ENDIF()
+
 IF(BZR_EXECUTABLE)
   MESSAGE(STATUS "Running bzr export")
   EXECUTE_PROCESS(
[12 Nov 2014 16:11] Paul DuBois
Fixed in 5.5.42, 5.6.23, 5.7.6. Affects no released versions. No changelog entry needed.