[yquake2] 11/11: Rewrite __DATE__ patch to use SOURCE_DATE_EPOCH directly

Simon McVittie smcv at debian.org
Thu Jun 30 09:23:57 UTC 2016


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

smcv pushed a commit to branch master
in repository yquake2.

commit 5d21324b572d2f9328917c704b356d1221477b40
Author: Simon McVittie <smcv at debian.org>
Date:   Thu Jun 30 10:05:47 2016 +0100

    Rewrite __DATE__ patch to use SOURCE_DATE_EPOCH directly
---
 debian/changelog                                   |  1 +
 debian/clean                                       |  1 -
 ...TE-macro-which-overrides-__DATE__-for-rep.patch | 60 --------------
 ...de-__DATE__-from-SOURCE_DATE_EPOCH-if-set.patch | 95 ++++++++++++++++++++++
 debian/patches/series                              |  2 +-
 debian/rules                                       |  7 +-
 6 files changed, 98 insertions(+), 68 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 39b8c7c..21587ce 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ yquake2 (5.34~dfsg1-1) UNRELEASED; urgency=medium
     - refresh patches
     - install new README.md instead of old README
   * Enable full compiler hardening
+  * Rewrite __DATE__ patch to use SOURCE_DATE_EPOCH directly
 
  -- Simon McVittie <smcv at debian.org>  Fri, 22 Jan 2016 11:11:19 +0000
 
diff --git a/debian/clean b/debian/clean
deleted file mode 100644
index 5c6f8f7..0000000
--- a/debian/clean
+++ /dev/null
@@ -1 +0,0 @@
-debian/yquake2.h
diff --git a/debian/patches/Add-BUILDDATE-macro-which-overrides-__DATE__-for-rep.patch b/debian/patches/Add-BUILDDATE-macro-which-overrides-__DATE__-for-rep.patch
deleted file mode 100644
index b485439..0000000
--- a/debian/patches/Add-BUILDDATE-macro-which-overrides-__DATE__-for-rep.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From: Simon McVittie <smcv at debian.org>
-Date: Tue, 5 May 2015 10:44:00 +0100
-Subject: Add BUILDDATE macro which overrides __DATE__, for reproducible builds
-
----
- src/common/header/common.h   | 4 ++++
- src/common/misc.c            | 2 +-
- src/game/savegame/savegame.c | 4 ++--
- 3 files changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/src/common/header/common.h b/src/common/header/common.h
-index 9199fe0..39a66e8 100644
---- a/src/common/header/common.h
-+++ b/src/common/header/common.h
-@@ -44,6 +44,10 @@
- #error ARCH should be defined by the build system
- #endif
- 
-+#ifndef BUILDDATE
-+#define BUILDDATE __DATE__
-+#endif
-+
- #ifdef _WIN32
-  #define CFGDIR "YamagiQ2"
- #else
-diff --git a/src/common/misc.c b/src/common/misc.c
-index 98a90e5..c9088ca 100644
---- a/src/common/misc.c
-+++ b/src/common/misc.c
-@@ -241,7 +241,7 @@ Qcommon_Init(int argc, char **argv)
- 	dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET);
- #endif
- 
--	s = va("%s %s %s %s", YQ2VERSION, ARCH, __DATE__, OSTYPE);
-+	s = va("%s %s %s %s", YQ2VERSION, ARCH, BUILDDATE, OSTYPE);
- 	Cvar_Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
- 
- 	if (dedicated->value)
-diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c
-index 1d1e133..188bc05 100644
---- a/src/game/savegame/savegame.c
-+++ b/src/game/savegame/savegame.c
-@@ -207,7 +207,7 @@ void
- InitGame(void)
- {
- 	gi.dprintf("Game is starting up.\n");
--	gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, __DATE__);
-+	gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, BUILDDATE);
- 
- 	gun_x = gi.cvar("gun_x", "0", 0);
- 	gun_y = gi.cvar("gun_y", "0", 0);
-@@ -223,7 +223,7 @@ InitGame(void)
- 	/* latched vars */
- 	sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
- 	gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH);
--	gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH);
-+	gi.cvar("gamedate", BUILDDATE, CVAR_SERVERINFO | CVAR_LATCH);
- 	maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
- 	maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO);
- 	deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH);
diff --git a/debian/patches/Override-__DATE__-from-SOURCE_DATE_EPOCH-if-set.patch b/debian/patches/Override-__DATE__-from-SOURCE_DATE_EPOCH-if-set.patch
new file mode 100644
index 0000000..fe91ad9
--- /dev/null
+++ b/debian/patches/Override-__DATE__-from-SOURCE_DATE_EPOCH-if-set.patch
@@ -0,0 +1,95 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Thu, 30 Jun 2016 10:05:40 +0100
+Subject: Override __DATE__ from SOURCE_DATE_EPOCH if set
+
+For deterministic/reproducible builds (where the same source and
+toolchain can be verified to produce the same binary, allowing
+maliciously substituted binaries to be detected) it is desirable to
+take the software's idea of the build date from the build system;
+otherwise, the real-time clock at the time of building affects the
+result, making it non-reproducible.
+
+SOURCE_DATE_EPOCH is a distribution-neutral specification for how
+to do that. It is meant to be set by meta-build systems such as
+dpkg or RPM, using a date/time that is already part of the source code,
+for example the date of the latest git commit, the date in
+the package's debian/changelog, or the date in the RPM spec file.
+
+See https://reproducible-builds.org/specs/source-date-epoch/ for the
+specification of SOURCE_DATE_EPOCH, or https://reproducible-builds.org/
+for more information on reproducible builds in general.
+---
+ Makefile                     | 7 +++++++
+ src/common/header/common.h   | 4 ++++
+ src/common/misc.c            | 2 +-
+ src/game/savegame/savegame.c | 4 ++--
+ 4 files changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 01405dc..bd264dd 100755
+--- a/Makefile
++++ b/Makefile
+@@ -172,6 +172,13 @@ CFLAGS += -DOSTYPE=\"$(OSTYPE)\" -DARCH=\"$(ARCH)\"
+ 
+ # ----------
+ 
++# https://reproducible-builds.org/specs/source-date-epoch/
++ifdef SOURCE_DATE_EPOCH
++CFLAGS += -DBUILD_DATE=\"$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +"%b %_d %Y" | sed -e 's/ /\\ /g')\"
++endif
++
++# ----------
++
+ # Systemwide installation
+ ifeq ($(WITH_SYSTEMWIDE),yes)
+ CFLAGS += -DSYSTEMWIDE
+diff --git a/src/common/header/common.h b/src/common/header/common.h
+index 9199fe0..9ae5fb3 100644
+--- a/src/common/header/common.h
++++ b/src/common/header/common.h
+@@ -44,6 +44,10 @@
+ #error ARCH should be defined by the build system
+ #endif
+ 
++#ifndef BUILD_DATE
++#define BUILD_DATE __DATE__
++#endif
++
+ #ifdef _WIN32
+  #define CFGDIR "YamagiQ2"
+ #else
+diff --git a/src/common/misc.c b/src/common/misc.c
+index 98a90e5..7589b15 100644
+--- a/src/common/misc.c
++++ b/src/common/misc.c
+@@ -241,7 +241,7 @@ Qcommon_Init(int argc, char **argv)
+ 	dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET);
+ #endif
+ 
+-	s = va("%s %s %s %s", YQ2VERSION, ARCH, __DATE__, OSTYPE);
++	s = va("%s %s %s %s", YQ2VERSION, ARCH, BUILD_DATE, OSTYPE);
+ 	Cvar_Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
+ 
+ 	if (dedicated->value)
+diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c
+index 1d1e133..6e011a4 100644
+--- a/src/game/savegame/savegame.c
++++ b/src/game/savegame/savegame.c
+@@ -207,7 +207,7 @@ void
+ InitGame(void)
+ {
+ 	gi.dprintf("Game is starting up.\n");
+-	gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, __DATE__);
++	gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, BUILD_DATE);
+ 
+ 	gun_x = gi.cvar("gun_x", "0", 0);
+ 	gun_y = gi.cvar("gun_y", "0", 0);
+@@ -223,7 +223,7 @@ InitGame(void)
+ 	/* latched vars */
+ 	sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
+ 	gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH);
+-	gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH);
++	gi.cvar("gamedate", BUILD_DATE, CVAR_SERVERINFO | CVAR_LATCH);
+ 	maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
+ 	maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO);
+ 	deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH);
diff --git a/debian/patches/series b/debian/patches/series
index 77479c4..3d8f560 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,4 +2,4 @@ Append-to-C-LD-FLAGS-instead-of-overriding-them-to-o.patch
 Remove-unwanted-rpaths-from-LDFLAGS.patch
 Fix-spelling-errors-detected-by-lintian.patch
 Optionally-link-libopenal-at-compile-time.patch
-Add-BUILDDATE-macro-which-overrides-__DATE__-for-rep.patch
+Override-__DATE__-from-SOURCE_DATE_EPOCH-if-set.patch
diff --git a/debian/rules b/debian/rules
index 03cb110..eb8920e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,21 +4,16 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+all
 export LC_ALL=C.UTF-8
 export TZ=UTC
 
-DEB_CPPFLAGS_MAINT_APPEND += -I$(CURDIR) -include debian/yquake2.h
 DEB_LDFLAGS_MAINT_APPEND  += -Wl,--as-needed -Wl,-z,defs
 export DEB_CPPFLAGS_MAINT_APPEND DEB_LDFLAGS_MAINT_APPEND
 
 %:
 	dh $@
 
-debian/yquake2.h:
-	date --utc --date="`dpkg-parsechangelog -SDate`" \
-		"+#define BUILDDATE \"%b %_d %Y\"" > $@
-
 export LC_ALL=C.UTF-8
 export TZ=UTC
 
-override_dh_auto_build: debian/yquake2.h
+override_dh_auto_build:
 	dh_auto_build -- \
 		DLOPEN_LIBGL=no \
 		DLOPEN_OPENAL=no \

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



More information about the Pkg-games-commits mailing list