File reproducible.patch of Package eccodes
Author: Alastair McKinstry <mckinstry@debian.org>
Description: Make builds bit-reproducible
Last-Updated: 2016-10-27
Forwarded: https://software.ecmwf.int/issues/browse/SUP-1590
Index: eccodes-2.4.1/CMakeLists.txt
===================================================================
--- eccodes-2.4.1.orig/CMakeLists.txt
+++ eccodes-2.4.1/CMakeLists.txt
@@ -137,6 +137,12 @@ ecbuild_add_option( FEATURE FORTRAN
DESCRIPTION "Build the ecCodes Fortran interface"
DEFAULT ON )
+ecbuild_add_option( FEATURE BIT_REPRODUCIBLE
+ DESCRIPTION "build bit-reproducible package"
+ DEFAULT ON
+ # Required for Debian, soon the world ...
+)
+
# TODO Remove this after REQUIRED_LANGUAGES
if( ENABLE_FORTRAN )
# will set EC_HAVE_FORTRAN with the result
Index: eccodes-2.4.1/cmake/ecbuild_config.h.in
===================================================================
--- eccodes-2.4.1.orig/cmake/ecbuild_config.h.in
+++ eccodes-2.4.1/cmake/ecbuild_config.h.in
@@ -25,14 +25,18 @@
/* config info */
-#define @PNAME@_OS_NAME "@CMAKE_SYSTEM@"
+#define @PNAME@_OS_NAME "linux"
#define @PNAME@_OS_BITS @EC_OS_BITS@
#define @PNAME@_OS_BITS_STR "@EC_OS_BITS@"
#define @PNAME@_OS_STR "@EC_OS_NAME@.@EC_OS_BITS@"
-#define @PNAME@_OS_VERSION "@CMAKE_SYSTEM_VERSION@"
+#define @PNAME@_OS_VERSION "OBS"
#define @PNAME@_SYS_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@"
-#define @PNAME@_BUILD_TIMESTAMP "@EC_BUILD_TIMESTAMP@"
+#ifndef HAVE_BIT_REPRODUCIBLE
+ #define @PNAME@_BUILD_TIMESTAMP "@EC_BUILD_TIMESTAMP@"
+#else
+ #define @PNAME@_BUILD_TIMESTAMP "NO-TIMESTAMP-FOR-BIT_REPRODUCIBLE-BUILD"
+#endif
#define @PNAME@_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#define @PNAME@_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@"
@@ -54,9 +58,6 @@
#define @PNAME@_INSTALL_LIB_DIR "@CMAKE_INSTALL_PREFIX@/@INSTALL_LIB_DIR@"
#define @PNAME@_INSTALL_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@INSTALL_DATA_DIR@"
-#define @PNAME@_DEVELOPER_SRC_DIR "@CMAKE_SOURCE_DIR@"
-#define @PNAME@_DEVELOPER_BIN_DIR "@CMAKE_BINARY_DIR@"
-
/* Fortran support */
#if @EC_HAVE_FORTRAN@
Index: eccodes-2.4.1/cmake/ecbuild_print_summary.cmake
===================================================================
--- eccodes-2.4.1.orig/cmake/ecbuild_print_summary.cmake
+++ eccodes-2.4.1/cmake/ecbuild_print_summary.cmake
@@ -61,7 +61,9 @@ macro( ecbuild_print_summary )
ecbuild_info( "endiness : Little Endian -- IEEE [${IEEE_LE}]" )
endif()
ecbuild_info( "build type : [${CMAKE_BUILD_TYPE}]" )
- ecbuild_info( "timestamp : [${EC_BUILD_TIMESTAMP}]" )
+ if ( NOT HAVE_BIT_REPRODUCIBLE )
+ ecbuild_info( "timestamp : [${EC_BUILD_TIMESTAMP}]" )
+ endif()
ecbuild_info( "install prefix : [${CMAKE_INSTALL_PREFIX}]" )
ecbuild_info( " bin dir : [${${PROJECT_NAME}_FULL_INSTALL_BIN_DIR}]" )
ecbuild_info( " lib dir : [${${PROJECT_NAME}_FULL_INSTALL_LIB_DIR}]" )
Index: eccodes-2.4.1/cmake/ecbuild_get_date.cmake
===================================================================
--- eccodes-2.4.1.orig/cmake/ecbuild_get_date.cmake
+++ eccodes-2.4.1/cmake/ecbuild_get_date.cmake
@@ -20,12 +20,16 @@
##############################################################################
macro(ecbuild_get_date RESULT)
+ if (HAVE_BIT_REPRODUCIBLE)
+ ecbuild_info("date not included in bit-reproducible builds")
+ else()
if(UNIX)
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3.\\2.\\1" ${RESULT} ${${RESULT}})
else()
ecbuild_error("date not implemented")
endif()
+ endif()
endmacro(ecbuild_get_date)
##############################################################################
@@ -42,11 +46,15 @@ endmacro(ecbuild_get_date)
##############################################################################
macro(ecbuild_get_timestamp RESULT)
+ if (HAVE_BIT_REPRODUCIBLE)
+ ecbuild_info("timestamp not included in bit-reproducible builds")
+ else()
if(UNIX)
execute_process(COMMAND "date" "+%Y/%m/%d/%H/%M/%S" OUTPUT_VARIABLE _timestamp)
string(REGEX REPLACE "(....)/(..)/(..)/(..)/(..)/(..).*" "\\1\\2\\3\\4\\5\\6" ${RESULT} ${_timestamp})
else()
ecbuild_warn("This is NOT UNIX - timestamp not implemented")
endif()
+ endif()
endmacro(ecbuild_get_timestamp)