Bug#1050944: jtreg6: please make the build reproducible

Chris Lamb lamby at debian.org
Thu Aug 31 18:12:50 BST 2023


Source: jtreg6
Version: 6.2+1-1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed that
jtreg6 could not be built reproducibly.

This was caused by two issues:

1. Due to the moving from Ant's build.xml to the Makefile-based build,
the build date embedded into the MANIFEST.MF file was being generated
from the system/build time. This requires a patch to the build system
to use SOURCE_DATE_EPOCH if available. (This hunk can go upstream.)

2. The jtreg.jar file was being generated with 444 (read-only)
permissions. This meant that strip-determinism could not fixup the
file modification times of the files within that archive. It was
actually printing: "dh_strip_nondeterminism: warning: Ignoring unwritable
file: jtreg.jar".

A patch for both issues is attached.

 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
--- a/debian/patches/reproducible-build.patch	1969-12-31 16:00:00.000000000 -0800
--- b/debian/patches/reproducible-build.patch	2023-08-31 10:04:38.116032765 -0700
@@ -0,0 +1,29 @@
+Description: Make the build reproducible
+Author: Chris Lamb <lamby at debian.org>
+Last-Update: 2023-08-31
+
+--- jtreg6-6.2+1.orig/make/Rules.gmk
++++ jtreg6-6.2+1/make/Rules.gmk
+@@ -55,6 +55,13 @@ $(CLASSDIR) $(BUILDDIR) $(BUILDDIR)/test
+ # default copyright; override as necessary
+ JAR_COPYRIGHT = -C $(TOPDIR) COPYRIGHT
+ 
++DATE_FMT = %B %d, %Y
++ifdef SOURCE_DATE_EPOCH
++    BUILD_DATE ?= $(shell LC_ALL=C date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || LC_ALL=C date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || LC_ALL=C date -u "$(DATE_FMT)")
++else
++    BUILD_DATE ?= $(shell date "$(DATE_FMT)")
++endif
++
+ $(IMAGES_DIR)/%.jar: pkgsToFiles.sh
+ 	$(RM) $@ $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%) 
+ 	$(MKDIR) -p $(@D)
+@@ -68,7 +75,7 @@ $(IMAGES_DIR)/%.jar: pkgsToFiles.sh
+ 	  echo "$(@F:%.jar=%)-Build: $(BUILD_NUMBER)" ; \
+ 	  echo "$(@F:%.jar=%)-BuildJavaVersion: `$(JDKJAVA) -fullversion 2>&1 | awk '{print $$NF}'  | \
+ 		sed -e 's|^"\(.*\)"$$|Java(TM) 2 SDK, Version \1|'`" ; \
+-	  echo "$(@F:%.jar=%)-BuildDate: `/bin/date +'%B %d, %Y'`" ; \
++	  echo "$(@F:%.jar=%)-BuildDate: $(BUILD_DATE)" ; \
+ 	) \
+ 		> $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/manifest.txt)
+ 	sh pkgsToFiles.sh $(CLASSDIR) $($(@F:%.jar=PKGS.JAR.%)) > $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/includes.txt)
--- a/debian/patches/series	2023-08-31 09:50:06.571624952 -0700
--- b/debian/patches/series	2023-08-31 10:04:37.028021356 -0700
@@ -2,3 +2,4 @@
 launchers.patch
 add-jcommander-to-classpath.patch
 add-logger-to-classpath.patch
+reproducible-build.patch
--- a/debian/rules	2023-08-31 09:50:06.571624952 -0700
--- b/debian/rules	2023-08-31 10:08:31.850276393 -0700
@@ -33,3 +33,6 @@
 	# Generate the manpages
 	JT_HOME=./dist/jtreg/lib/ help2man --name="Regression Test Harness" --help-option="-help all" dist/jtreg/bin/jtdiff > jtdiff.1
 	JT_HOME=./dist/jtreg/lib/ help2man --name="Regression Test Harness" --help-option="-help all" dist/jtreg/bin/jtreg > jtreg.1
+
+execute_before_dh_strip_nondeterminism:
+	find  debian/ -type f -name jtreg.jar -print0 | xargs -0tr chmod +w


More information about the pkg-java-maintainers mailing list