Source: jtreg7
Version: 7.2+1-3
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

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

This is because jtreg.jar file:

a) Includes a BuildDate field in the manifest file (which is later
parsed by the 'About' dialog) that is based on the current build date
instead of SOURCE_DATE_EPOCH.

b) The build system creates a .jar file that is not writable
(ie. -r--r--r---) so that it is ignored by strip-nondeterminism and
thus the timestamps are not normalised.

A patch is attached that addresses both issues.

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


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/reproducible-build.patch   1970-01-01 01:00:00.000000000 
+0100
--- b/debian/patches/reproducible-build.patch   2023-06-22 19:43:10.340572525 
+0100
@@ -0,0 +1,29 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2023-06-22
+
+--- jtreg7-7.2+1.orig/make/Rules.gmk
++++ jtreg7-7.2+1/make/Rules.gmk
+@@ -60,6 +60,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 || 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)
+@@ -73,7 +80,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-06-22 16:26:43.865668373 +0100
--- b/debian/patches/series     2023-06-22 19:43:09.036561740 +0100
@@ -1,3 +1,4 @@
 launchers.patch
 add-jcommander-to-classpath.patch
 do-not-export-headless-display.patch
+reproducible-build.patch
--- a/debian/rules      2023-06-22 16:26:43.865668373 +0100
--- b/debian/rules      2023-06-22 17:52:43.345400601 +0100
@@ -40,3 +40,6 @@
        # Generate the manpages
        JT_HOME=./build/images/jtreg/lib/ help2man --no-discard-stderr 
--name="Regression Test Harness" --help-option="-help all" 
./build/images/jtreg/bin/jtdiff > jtdiff.1
        JT_HOME=./build/images/jtreg/lib/ help2man --no-discard-stderr 
--name="Regression Test Harness" --help-option="-help all" 
./build/images/jtreg/bin/jtreg > jtreg.1
+
+       # Make jtreg.jar writable so it is not ignored by strip-nondeterminism
+       chmod +w build/images/jtreg/lib/jtreg.jar

Reply via email to