List:Commits« Previous MessageNext Message »
From:Joerg Bruehe Date:January 21 2011 8:40pm
Subject:bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969
View as plain text  
#At file:///MySQL/REPO/V55/bug42969-5.5/ based on revid:jorgen.loland@stripped

 3209 Joerg Bruehe	2011-01-21
      Fix bug#42969    Please add a MANIFEST to each build
      
      With this change, there will be new files "VERSION_src"
      and "VERSION_bin", which describe the source and the
      binaries.
      They will be contained in all packages.
      
      "VERSION_src" is also part of a source tarball.
      It gives the version as exact as possible, preferably
      by calling "bzr versioninfo" on the source tree.
      If that is not possible, it just contains the three
      level version number.
      
      "VERSION_bin" contains some info when and where the
      binaries were built, the options given to the compiler,
      and the flags controlling the included features.
     @ CMakeLists.txt
        For the new files describing the source and the build
        ("VERSION_src" and "VERSION_bin"), we need a new file
        "cmake/version_files.cmake.in" with the build rules.
        
        1) This file must be configured with the current variables.
        
        2) "VERSION_src" can be created during the cmake phase.
        
        3) "VERSION_bin" must be created during the make phase
           only, because it contains information from files
        which will be written at the end of the cmake phase only.
        Therefore, it must be a custom target which is included
        in all "make" targets.
        
        4) The resulting version files must be included in packages.
     @ cmake/make_dist.cmake.in
        Create a "VERSION_src" file during "make dist".
        
        In case it already exists from a preceding "cmake" run
        (which is quite likely), a new "make dist" must not modify it.
     @ cmake/version_files.cmake.in
        New file.
        
        It will contain macros to create the "VERSION_*" files
        during various steps of the build,
        the calls will be at other places.
        
        1) For source: If running from a BZR tree, always create
           (update) "VERSION_src" by running "bzr version-info".
           Outside a BZR tree, create it only if missing, and
           put the three level version number into it.
        
        2) "VERSION_bin" contains
           - date/time and host name of the build host,
           - information about the platform, if cmake
             provides it
             (2.6.0 does not, the manual is wrong),
           - information about the C and CXX compiler
             and the options given to them
             (these may vary by directory, take those of
             the "sql/" subdirectory),
           - the "WITH*" options (ON or OFF) from
             "CMakeCache.txt"
             (taking them from there rather than using
             "CONFIGURE_FILE()" avoids maintenance when
             features get added or removed).
        
        Several actions are more complicated than is nice,
        this was needed to make it work using cmake 2.6.0.
        When all builds move to newer versions, there will
        hopefully be room for improvement.
     @ support-files/mysql.spec.sh
        Add "VERSION_src" and "VERSION_bin" to the RPM contents.

    added:
      cmake/version_files.cmake.in
    modified:
      CMakeLists.txt
      cmake/make_dist.cmake.in
      support-files/mysql.spec.sh
=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	2010-12-15 10:30:09 +0000
+++ b/CMakeLists.txt	2011-01-21 20:40:21 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -317,6 +317,19 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/inclu
                ${CMAKE_BINARY_DIR}/include/mysql_version.h )
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
     ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
+CONFIGURE_FILE(
+    ${CMAKE_SOURCE_DIR}/cmake/version_files.cmake.in ${CMAKE_BINARY_DIR}/version_files.cmake @ONLY)
+
+# Handle the "VERSION_*" files.
+INCLUDE(${CMAKE_BINARY_DIR}/version_files.cmake)
+# Source: This can be done during the cmake phase, all information is
+# available.
+CREATE_VERSION_SRC(${CMAKE_BINARY_DIR})
+# Build flags: This must be postponed to the make phase.
+ADD_CUSTOM_TARGET(VERSION_BIN ALL
+  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/version_files.cmake
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)
 
 # Packaging
 IF(WIN32)
@@ -331,6 +344,7 @@ ADD_SUBDIRECTORY(packaging/WiX)
 SET(CPACK_MONOLITHIC_INSTALL 1 CACHE INTERNAL "")
 
 INCLUDE(CPack)
+INSTALL(FILES VERSION_src VERSION_bin DESTINATION . )
 IF(UNIX)
   INSTALL(FILES Docs/mysql.info DESTINATION ${INSTALL_INFODIR} OPTIONAL COMPONENT Info)
 ENDIF()

=== modified file 'cmake/make_dist.cmake.in'
--- a/cmake/make_dist.cmake.in	2010-11-20 14:47:50 +0000
+++ b/cmake/make_dist.cmake.in	2011-01-21 20:40:21 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -106,6 +106,12 @@ IF(MYSQL_DOCS_LOCATION)
   EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_directory "${MYSQL_DOCS_LOCATION}" "${PACKAGE_DIR}")
 ENDIF()
 
+# Ensure there is a "VERSION_src" file.
+INCLUDE(${CMAKE_BINARY_DIR}/version_files.cmake)
+IF(NOT EXISTS ${PACKAGE_DIR}/VERSION_src)
+  CREATE_VERSION_SRC(${PACKAGE_DIR})
+ENDIF()
+
 # In case we used CPack, it could have copied some
 # extra files that are not usable on different machines.
 FILE(REMOVE ${PACKAGE_DIR}/CMakeCache.txt)

=== added file 'cmake/version_files.cmake.in'
--- a/cmake/version_files.cmake.in	1970-01-01 00:00:00 +0000
+++ b/cmake/version_files.cmake.in	2011-01-21 20:40:21 +0000
@@ -0,0 +1,111 @@
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
+
+
+# Handle/create the "VERSION_*" files describing a MySQL (server) binary.
+# This is part of the fix for bug#42969.
+
+SET(VERSION "@VERSION@")
+SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
+SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME "@CPACK_SOURCE_PACKAGE_FILE_NAME@")
+SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
+SET(PACKAGE_DIR  ${CMAKE_BINARY_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME})
+ 
+ 
+# This may be used during "make dist".
+# So this is the moment to start a "VERSION_src" file with information about the source (only).
+# We use the "VERSION" contents and try to add "bzr version-info".
+#
+# It will also be used during build, if that is done without a preceding "make dist"
+# (typically, by developers directly in their tree).
+  
+MACRO(CREATE_VERSION_SRC target_dir)
+  IF(EXISTS ${CMAKE_SOURCE_DIR}/.bzr)
+    # We have a working "bzr" and sources are in a BZR repository: Always update.
+    EXECUTE_PROCESS(
+      COMMAND ${BZR_EXECUTABLE} version-info ${CMAKE_SOURCE_DIR}
+      WORKING_DIRECTORY ${target_dir}
+      OUTPUT_FILE "VERSION_src"
+      RESULT_VARIABLE RESULT
+    )
+    # For better readability ...
+    FILE(APPEND "${target_dir}/VERSION_src" "\nMySQL source ${VERSION}\n")
+  ELSEIF(NOT EXISTS ${target_dir}/VERSION_src)
+    # The following is a fall-back if there should be no BZR available.
+    FILE(WRITE "${target_dir}/VERSION_src" "\nMySQL source ${VERSION}\n")
+  ENDIF()
+ENDMACRO(CREATE_VERSION_SRC)
+
+
+# This is for the "real" build, must be run again with each cmake run
+# to make sure we report the current flags (not those of some previous run).
+
+MACRO(CREATE_VERSION_BIN)
+  SET(VERSION_BIN "VERSION_bin")
+
+  FILE(WRITE ${VERSION_BIN} "===== Information about the build process: =====\n")
+  IF (WIN32)
+    EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE)
+  ELSEIF(UNIX)
+    EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE TMP_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
+  ELSE()
+    SET(TMP_DATE "No date command known")
+  ENDIF()
+  SITE_NAME(HOSTNAME)
+  FILE(APPEND ${VERSION_BIN} "Build was run at: ${TMP_DATE} on host '${HOSTNAME}'\n\n")
+
+  # According to the cmake docs, this variable should always be set.
+  # However, it is empty in my local tests, cmake 2.6.0 on Linux (Debian stable, Jan 2011).
+  # Include this code, so we will profit if a build environment does provide that info.
+  IF(${CMAKE_HOST_SYSTEM})
+    IF(${CMAKE_CROSSCOMPILING})
+      FILE(APPEND ${VERSION_BIN} "Build was done for ${CMAKE_SYSTEM} using ${CMAKE_SYSTEM_PROCESSOR}\n")
+    ENDIF()
+    FILE(APPEND ${VERSION_BIN} "Build was done on  ${CMAKE_HOST_SYSTEM} using ${CMAKE_HOST_SYSTEM_PROCESSOR}\n\n")
+  ENDIF()
+
+  FILE(APPEND ${VERSION_BIN} "===== Compiler flags used (from the 'sql/' subdirectory): =====\n")
+  IF(EXISTS sql/CMakeFiles/sql.dir/flags.make)
+    # current dir == ${CMAKE_BINARY_DIR}, see the call in top "CMakeLists.txt"
+    FILE(STRINGS sql/CMakeFiles/sql.dir/flags.make COMPILE_FLAGS REGEX "^# compile|^C_|^CXX_")
+    STRING(REPLACE "# compile" "\n# compile" COMPILE_FLAGS_1 ${COMPILE_FLAGS})
+    STRING(REPLACE "C_"        "\nC_"        COMPILE_FLAGS_2 ${COMPILE_FLAGS_1})
+    STRING(REPLACE "CXX_"      "\nCXX_"      COMPILE_FLAGS_LINES ${COMPILE_FLAGS_2})
+    # The below line did not work in tests using cmake 2.6.0, the matter should be checked again with newer versions.
+    # STRING(REGEX REPLACE "(^# compile|^C_|^CXX_)" "\n\\1" COMPILE_FLAGS_LINES ${COMPILE_FLAGS})
+    FILE(APPEND ${VERSION_BIN} ${COMPILE_FLAGS_LINES} "\n\n")
+  ELSE()
+    FILE(APPEND ${VERSION_BIN} "File 'sql/CMakeFiles/sql.dir/flags.make' is not yet found.\n\n")
+  ENDIF()
+
+  FILE(APPEND ${VERSION_BIN} "===== Feature flags used: =====\n")
+  IF(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+    # The intention is to do the equivalent of "grep '^WITH' CMakeCache.txt".
+    # Note that "FILE(STRINGS ...)" will simply ignore carriage return (CR) characters,
+    # so the variable will have all those lines joined to one.
+    # To get readable output, "STRING(REPLACE ...)" is used, making it multi-line again.
+    FILE(STRINGS ${CMAKE_BINARY_DIR}/CMakeCache.txt FEATURE_FLAGS REGEX "^WITH")
+    STRING(REPLACE "WITH" "\nWITH" FEATURE_FLAGS_LINES ${FEATURE_FLAGS})
+    FILE(APPEND ${VERSION_BIN} ${FEATURE_FLAGS_LINES} "\n\n")
+  ELSE()
+    FILE(APPEND ${VERSION_BIN} "File 'CMakeCache.txt' is not yet found.\n\n")
+  ENDIF()
+
+  FILE(APPEND ${VERSION_BIN} "===== EOF =====\n")
+
+ENDMACRO(CREATE_VERSION_BIN)
+
+CREATE_VERSION_BIN()

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2010-11-24 15:55:23 +0000
+++ b/support-files/mysql.spec.sh	2011-01-21 20:40:21 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -907,6 +907,8 @@ echo "====="                            
 %if %{defined license_files_server}
 %doc %{license_files_server}
 %endif
+%doc %{src_dir}/VERSION_src
+%doc release/VERSION_bin
 %doc %{src_dir}/Docs/ChangeLog
 %doc release/support-files/my-*.cnf
 
@@ -1085,6 +1087,10 @@ echo "====="                            
 # merging BK trees)
 ##############################################################################
 %changelog
+* Fri Jan 21 2011 Joerg Bruehe <joerg.bruehe@stripped>
+
+- Add the new "manifest" files: "VERSION_src" and "VERSION_bin".
+
 * Tue Nov 23 2010 Jonathan Perkin <jonathan.perkin@stripped>
 
 - EXCEPTIONS-CLIENT has been deleted, remove it from here too


Attachment: [text/bzr-bundle] bzr/joerg@mysql.com-20110121204021-w3wvzv884snvbk2o.bundle
Thread
bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Joerg Bruehe21 Jan
  • RE: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Vladislav Vaintroub21 Jan
    • Re: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Joerg Bruehe22 Jan
      • RE: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Vladislav Vaintroub22 Jan
        • RE: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Vladislav Vaintroub22 Jan
          • Re: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Joerg Bruehe31 Jan
            • RE: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Vladislav Vaintroub31 Jan
              • Re: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Joerg Bruehe31 Jan
        • Re: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Joerg Bruehe25 Jan
          • Re: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Joerg Bruehe26 Jan
          • RE: bzr commit into mysql-5.5-bugteam branch (joerg:3209) Bug#42969Vladislav Vaintroub26 Jan