Browse Source

Merge pull request #5360 from commodo/python_reproducible

python,python3: honour the SOURCE_DATE_EPOCH for the build-info
lilik-openwrt-22.03
Hannu Nyman 7 years ago
committed by GitHub
parent
commit
f460719bf4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 2 deletions
  1. +1
    -1
      lang/python/python/Makefile
  2. +28
    -0
      lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch
  3. +1
    -1
      lang/python/python3/Makefile
  4. +28
    -0
      lang/python/python3/patches/013-getbuildinfo-date-time-source-date-epoch.patch

+ 1
- 1
lang/python/python/Makefile View File

@ -12,7 +12,7 @@ include ../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)


+ 28
- 0
lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch View File

@ -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)`\"" \

+ 1
- 1
lang/python/python3/Makefile View File

@ -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


+ 28
- 0
lang/python/python3/patches/013-getbuildinfo-date-time-source-date-epoch.patch View File

@ -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)`\"" \

Loading…
Cancel
Save