[openjk] 01/32: Pick up date from SOURCE_DATE_EPOCH, for reproducible builds

Simon McVittie smcv at debian.org
Sun Mar 12 18:03:01 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit 829b049780e745c6400e3f4f7baed8a5823f1651
Author: Simon McVittie <smcv at debian.org>
Date:   Fri Oct 28 11:09:16 2016 +0100

    Pick up date from SOURCE_DATE_EPOCH, for reproducible builds
    
    The goal of reproducible builds is that a rebuild of the same source
    code with the same compiler, libraries, etc. should result in the same
    binaries. SOURCE_DATE_EPOCH provides a standard way for build systems
    to fill in the date of the latest source change, typically from a git
    commit or from metadata like the debian/changelog in Debian packages.
    
    This does not change anything if SOURCE_DATE_EPOCH is not defined;
    the intention is that a larger build system like a Debian package
    will define it.
    
    Please see https://reproducible-builds.org/ for more information about
    reproducible builds.
    
    Similar to <https://github.com/ioquake/ioq3/pull/225>.
---
 CMakeLists.txt              | 9 +++++++++
 code/game/g_main.cpp        | 4 ++--
 code/qcommon/common.cpp     | 4 ++--
 codeJK2/game/g_main.cpp     | 4 ++--
 codemp/game/g_main.c        | 2 +-
 codemp/game/g_xcvar.h       | 2 +-
 codemp/qcommon/common.cpp   | 4 ++--
 shared/qcommon/q_platform.h | 5 +++++
 8 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a17d4d..e393e4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -302,6 +302,15 @@ if(BuildPortableVersion)
 	set(SharedDefines ${SharedDefines} "_PORTABLE_VERSION")
 endif()
 
+# https://reproducible-builds.org/specs/source-date-epoch/
+if (NOT ("$ENV{SOURCE_DATE_EPOCH}" STREQUAL ""))
+	execute_process(COMMAND "date"
+		"--date=@$ENV{SOURCE_DATE_EPOCH}" "+%b %_d %Y"
+		OUTPUT_VARIABLE source_date
+		ERROR_QUIET
+		OUTPUT_STRIP_TRAILING_WHITESPACE)
+	set(SharedDefines ${SharedDefines} "SOURCE_DATE=\"${source_date}\"")
+endif()
 
 
 
diff --git a/code/game/g_main.cpp b/code/game/g_main.cpp
index 8ae2c6d..6b385af 100644
--- a/code/game/g_main.cpp
+++ b/code/game/g_main.cpp
@@ -617,7 +617,7 @@ void G_InitCvars( void ) {
 
 	// noset vars
 	gi.cvar( "gamename", GAMEVERSION , CVAR_SERVERINFO | CVAR_ROM );
-	gi.cvar( "gamedate", __DATE__ , CVAR_ROM );
+	gi.cvar( "gamedate", SOURCE_DATE , CVAR_ROM );
 	g_skippingcin = gi.cvar ("skippingCinematic", "0", CVAR_ROM);
 
 	// latched vars
@@ -734,7 +734,7 @@ void InitGame(  const char *mapname, const char *spawntarget, int checkSum, cons
 
 	gi.Printf ("------- Game Initialization -------\n");
 	gi.Printf ("gamename: %s\n", GAMEVERSION);
-	gi.Printf ("gamedate: %s\n", __DATE__);
+	gi.Printf ("gamedate: %s\n", SOURCE_DATE);
 
 	srand( randomSeed );
 
diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp
index a1e73e4..031e2b3 100644
--- a/code/qcommon/common.cpp
+++ b/code/qcommon/common.cpp
@@ -1050,7 +1050,7 @@ Com_Init
 void Com_Init( char *commandLine ) {
 	char	*s;
 
-	Com_Printf( "%s %s %s\n", Q3_VERSION, PLATFORM_STRING, __DATE__ );
+	Com_Printf( "%s %s %s\n", Q3_VERSION, PLATFORM_STRING, SOURCE_DATE );
 
 	try {
 		Com_InitZoneMemory();
@@ -1126,7 +1126,7 @@ void Com_Init( char *commandLine ) {
 			Cmd_AddCommand ("freeze", Com_Freeze_f);
 		}
 
-		s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ );
+		s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, SOURCE_DATE );
 		com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
 
 #ifdef JK2_MODE
diff --git a/codeJK2/game/g_main.cpp b/codeJK2/game/g_main.cpp
index ef78173..3dba32d 100644
--- a/codeJK2/game/g_main.cpp
+++ b/codeJK2/game/g_main.cpp
@@ -558,7 +558,7 @@ void G_InitCvars( void ) {
 
 	// noset vars
 	gi.cvar( "gamename", GAMEVERSION , CVAR_SERVERINFO | CVAR_ROM );
-	gi.cvar( "gamedate", __DATE__ , CVAR_ROM );
+	gi.cvar( "gamedate", SOURCE_DATE , CVAR_ROM );
 	g_skippingcin = gi.cvar ("skippingCinematic", "0", CVAR_ROM);
 
 	// latched vars
@@ -620,7 +620,7 @@ void InitGame(  const char *mapname, const char *spawntarget, int checkSum, cons
 
 	gi.Printf ("------- Game Initialization -------\n");
 	gi.Printf ("gamename: %s\n", GAMEVERSION);
-	gi.Printf ("gamedate: %s\n", __DATE__);
+	gi.Printf ("gamedate: %s\n", SOURCE_DATE);
 
 	srand( randomSeed );
 
diff --git a/codemp/game/g_main.c b/codemp/game/g_main.c
index e2a3e6b..f70f6e1 100644
--- a/codemp/game/g_main.c
+++ b/codemp/game/g_main.c
@@ -193,7 +193,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
 
 	trap->Print ("------- Game Initialization -------\n");
 	trap->Print ("gamename: %s\n", GAMEVERSION);
-	trap->Print ("gamedate: %s\n", __DATE__);
+	trap->Print ("gamedate: %s\n", SOURCE_DATE);
 
 	srand( randomSeed );
 
diff --git a/codemp/game/g_xcvar.h b/codemp/game/g_xcvar.h
index ea1761c..ff0588b 100644
--- a/codemp/game/g_xcvar.h
+++ b/codemp/game/g_xcvar.h
@@ -165,7 +165,7 @@ XCVAR_DEF( g_voteDelay,					"3000",			NULL,				CVAR_NONE,										qfalse )
 XCVAR_DEF( g_warmup,					"20",			NULL,				CVAR_ARCHIVE,									qtrue )
 XCVAR_DEF( g_weaponDisable,				"0",			NULL,				CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH,		qtrue )
 XCVAR_DEF( g_weaponRespawn,				"5",			NULL,				CVAR_NONE,										qtrue )
-XCVAR_DEF( gamedate,					__DATE__,		NULL,				CVAR_ROM,										qfalse )
+XCVAR_DEF( gamedate,					SOURCE_DATE,		NULL,				CVAR_ROM,										qfalse )
 XCVAR_DEF( gamename,					GAMEVERSION,	NULL,				CVAR_SERVERINFO|CVAR_ROM,						qfalse )
 XCVAR_DEF( pmove_fixed,					"0",			NULL,				CVAR_SYSTEMINFO|CVAR_ARCHIVE,					qtrue )
 XCVAR_DEF( pmove_float,					"0",			NULL,				CVAR_SYSTEMINFO|CVAR_ARCHIVE,					qtrue )
diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp
index 525e3d4..3011c8d 100644
--- a/codemp/qcommon/common.cpp
+++ b/codemp/qcommon/common.cpp
@@ -1126,7 +1126,7 @@ void Com_Init( char *commandLine ) {
 	char	*s;
 	int		qport;
 
-	Com_Printf( "%s %s %s\n", JK_VERSION, PLATFORM_STRING, __DATE__ );
+	Com_Printf( "%s %s %s\n", JK_VERSION, PLATFORM_STRING, SOURCE_DATE );
 
 	try
 	{
@@ -1241,7 +1241,7 @@ void Com_Init( char *commandLine ) {
 
 		com_bootlogo = Cvar_Get( "com_bootlogo", "1", CVAR_ARCHIVE, "Show intro movies" );
 
-		s = va("%s %s %s", JK_VERSION_OLD, PLATFORM_STRING, __DATE__ );
+		s = va("%s %s %s", JK_VERSION_OLD, PLATFORM_STRING, SOURCE_DATE );
 		com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
 
 		SE_Init();
diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h
index 0d60290..9e1067a 100644
--- a/shared/qcommon/q_platform.h
+++ b/shared/qcommon/q_platform.h
@@ -362,3 +362,8 @@ typedef union byteAlias_u {
 #else
 	#define PLATFORM_STRING OS_STRING "-" ARCH_STRING "-debug"
 #endif
+
+// to support https://reproducible-builds.org/specs/source-date-epoch/
+#ifndef SOURCE_DATE
+#define SOURCE_DATE __DATE__
+#endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list