From 515204913c9168e8db77c96fdd7c29feba5bb6f4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 30 Sep 2014 15:32:08 +0200 Subject: Embed changelog entry date and time instead of build date and time This makes reproducible builds possible. For non-package builds, simply use the start of the Unix time. Also make sure that all time values are in the UTC timezone. Closes: #762674 --- debian/rules | 8 +++++++- python/apt_pkgmodule.cc | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/debian/rules b/debian/rules index 3ceeb205..20a3fa25 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,13 @@ #!/usr/bin/make -f # Should be include-links, but that somehow fails. export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') -export DEB_CFLAGS_MAINT_APPEND=-Wno-write-strings +export DATETIME:=$(shell dpkg-parsechangelog | sed -n -e 's/^Date: //p') +export DATE_CMD:=env TZ=UTC LC_ALL=C.UTF-8 date +export DATE:=$(shell $(DATE_CMD) --date="$(DATETIME)" "+%b %_d %Y") +export TIME:=$(shell $(DATE_CMD) --date="$(DATETIME)" "+%H:%M:%S") +export DEB_CFLAGS_MAINT_APPEND=-Wno-write-strings \ + -DDATE=\""$(DATE)"\" \ + -DTIME=\""$(TIME)"\" export PATH := $(CURDIR)/utils:$(PATH) export pyversions := $(CURDIR)/utils/pyversions diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 5f211b3e..ca20ef18 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -880,8 +880,13 @@ extern "C" void initapt_pkg() // Version.. PyModule_AddStringConstant(Module,"VERSION",(char *)pkgVersion); PyModule_AddStringConstant(Module,"LIB_VERSION",(char *)pkgLibVersion); - PyModule_AddStringConstant(Module,"DATE",__DATE__); - PyModule_AddStringConstant(Module,"TIME",__TIME__); +#ifdef DATE + PyModule_AddStringConstant(Module,"DATE",DATE); + PyModule_AddStringConstant(Module,"TIME",TIME); +#else + PyModule_AddStringConstant(Module,"DATE", "Jan 1 1970"); + PyModule_AddStringConstant(Module,"TIME", "00:00:00"); +#endif // My constants PyModule_AddIntConstant(Module,"PRI_IMPORTANT",pkgCache::State::Important); -- cgit v1.2.3