From c54b312043d4bb373d82c45c77e7a7ee48e9b0ac Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Sat, 6 Jan 2018 17:18:11 +0200 Subject: [PATCH] python,python3: honour the SOURCE_DATE_EPOCH for the build-info The Modules/getbuildinfo.c allows the use of DATE and TIME macros to be defined via CFLAGS. These vars, control the build date & time when the interpreter is opened, and can be read via the `platform._sys_version()` function. So, a conversion from SOURCE_DATE_EPOCH to DATE & TIME is required at build-time. This is especially needed for `platform._sys_version()` to work. The installation of pip seems to rely on this. The logic has been adapted from: https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal#Makefile Signed-off-by: Alexandru Ardelean --- lang/python/python/Makefile | 2 +- ...uildinfo-date-time-source-date-epoch.patch | 28 +++++++++++++++++++ lang/python/python3/Makefile | 2 +- ...uildinfo-date-time-source-date-epoch.patch | 28 +++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch create mode 100644 lang/python/python3/patches/013-getbuildinfo-date-time-source-date-epoch.patch diff --git a/lang/python/python/Makefile b/lang/python/python/Makefile index e7500f66d3..8064a6b83c 100644 --- a/lang/python/python/Makefile +++ b/lang/python/python/Makefile @@ -12,7 +12,7 @@ include ./files/python-version.mk PKG_NAME:=python PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO) -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION) diff --git a/lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch b/lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch new file mode 100644 index 0000000000..de7605d1ed --- /dev/null +++ b/lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch @@ -0,0 +1,28 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -625,6 +625,16 @@ regen-all: regen-opcode-targets regen-gr + ############################################################################ + # Special rules for object files + ++DATE_FMT = %b %d %Y ++TIME_FMT = %H:%M:%S ++ifdef SOURCE_DATE_EPOCH ++ BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)") ++ BUILD_TIME ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u "+$(TIME_FMT)") ++else ++ BUILD_DATE ?= $(shell date "+$(DATE_FMT)") ++ BUILD_TIME ?= $(shell date "+$(TIME_FMT)") ++endif ++ + Modules/getbuildinfo.o: $(PARSER_OBJS) \ + $(OBJECT_OBJS) \ + $(PYTHON_OBJS) \ +@@ -633,6 +643,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \ + $(MODOBJS) \ + $(srcdir)/Modules/getbuildinfo.c + $(CC) -c $(PY_CFLAGS) \ ++ -DDATE="\"$(BUILD_DATE)\"" \ ++ -DTIME="\"$(BUILD_TIME)\"" \ + -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \ + -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \ + -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \ diff --git a/lang/python/python3/Makefile b/lang/python/python3/Makefile index 7ab3c51dac..ac1ad01c3b 100644 --- a/lang/python/python3/Makefile +++ b/lang/python/python3/Makefile @@ -14,7 +14,7 @@ PYTHON_VERSION:=$(PYTHON3_VERSION) PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO) PKG_NAME:=python3 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO) PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz diff --git a/lang/python/python3/patches/013-getbuildinfo-date-time-source-date-epoch.patch b/lang/python/python3/patches/013-getbuildinfo-date-time-source-date-epoch.patch new file mode 100644 index 0000000000..340e302d8d --- /dev/null +++ b/lang/python/python3/patches/013-getbuildinfo-date-time-source-date-epoch.patch @@ -0,0 +1,28 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -725,6 +725,16 @@ regen-all: regen-opcode regen-opcode-tar + ############################################################################ + # Special rules for object files + ++DATE_FMT = %b %d %Y ++TIME_FMT = %H:%M:%S ++ifdef SOURCE_DATE_EPOCH ++ BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)") ++ BUILD_TIME ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u "+$(TIME_FMT)") ++else ++ BUILD_DATE ?= $(shell date "+$(DATE_FMT)") ++ BUILD_TIME ?= $(shell date "+$(TIME_FMT)") ++endif ++ + Modules/getbuildinfo.o: $(PARSER_OBJS) \ + $(OBJECT_OBJS) \ + $(PYTHON_OBJS) \ +@@ -732,6 +742,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \ + $(MODOBJS) \ + $(srcdir)/Modules/getbuildinfo.c + $(CC) -c $(PY_CORE_CFLAGS) \ ++ -DDATE="\"$(BUILD_DATE)\"" \ ++ -DTIME="\"$(BUILD_TIME)\"" \ + -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \ + -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \ + -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \ -- 2.30.2