Accepting request 1112494 from Java:packages

reproducible build changes

OBS-URL: https://build.opensuse.org/request/show/1112494
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/antlr3?expand=0&rev=6
This commit is contained in:
Dominique Leuenberger 2023-09-20 11:30:29 +00:00 committed by Git OBS Bridge
commit 56b8ee865f
5 changed files with 547 additions and 359 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,21 @@
-------------------------------------------------------------------
Fri Sep 15 16:02:58 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- Added patches:
* reproducible-order.patch
+ ensure reproducible elements order by sorting
* reproducible-timestamp.patch
+ support SOURCE_DATE_EPOCH for generatedTimestamp
- Modified patch:
* antlr3-generated_sources.patch
+ regenerate in cycle with stringtemplate4 to correspond to
the reproducible build changes
-------------------------------------------------------------------
Fri Sep 15 08:19:19 UTC 2023 - Bernhard Wiedemann <bwiedemann@suse.com>
- Override build date (boo#1047218)"
-------------------------------------------------------------------
Fri Mar 17 06:55:33 UTC 2023 - Fridrich Strba <fstrba@suse.com>

View File

@ -37,6 +37,8 @@ Source0: https://github.com/antlr/antlr3/archive/%{antlr_version}.tar.gz
Patch0: antlr3-java8-fix.patch
# Generate OSGi metadata
Patch1: antlr3-osgi-manifest.patch
Patch2: reproducible-order.patch
Patch3: reproducible-timestamp.patch
Patch100: antlr3-generated_sources.patch
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
@ -128,9 +130,11 @@ BuildArch: noarch
%pom_remove_plugin :antlr3-maven-plugin tool
%endif
sed -i "s,\${buildNumber},`cat %{_sysconfdir}/fedora-release` `date`," tool/src/main/resources/org/antlr/antlr.properties
sed -i "s,\${buildNumber},`date -u -d@${SOURCE_DATE_EPOCH:-$(date +%%s)}`," tool/src/main/resources/org/antlr/antlr.properties
%patch0 -p1
%patch1
%patch2 -p1
%patch3 -p1
# remove pre-built artifacts
find -type f -a -name *.jar -delete
@ -149,7 +153,7 @@ find -type f -a -name *.class -delete
%endif
%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin :maven-javadoc-plugin
%pom_remove_plugin -r :maven-javadoc-plugin
%pom_remove_plugin :maven-enforcer-plugin
# compile for target 1.8
@ -182,6 +186,7 @@ sed -i 's/jsr14/1.8/' antlr3-maven-archetype/src/main/resources/archetype-resour
%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 9}%{!?pkg_vcmp:0}
-Dmaven.compiler.release=8 \
%endif
-Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \
-Dsource=8
%if %{without runtime} && %{without bootstrap}

18
reproducible-order.patch Normal file
View File

@ -0,0 +1,18 @@
--- antlr3-3.5.3/tool/src/main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g 2023-09-15 20:06:39.620275234 +0200
+++ antlr3-3.5.3/tool/src/main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g 2023-09-16 06:38:17.929360459 +0200
@@ -56,6 +56,7 @@
import java.util.HashSet;
import java.util.Set;
import java.util.Collection;
+import java.util.Collections;
import org.antlr.runtime.BitSet;
import org.antlr.runtime.DFA;
import org.stringtemplate.v4.ST;
@@ -284,6 +285,7 @@
}
labels.add( label );
}
+ Collections.sort(labels); // ensure reproducible order
return labels;
}

View File

@ -0,0 +1,12 @@
--- antlr3-3.5.3/tool/src/main/java/org/antlr/Tool.java 2023-09-15 17:54:38.044172037 +0200
+++ antlr3-3.5.3/tool/src/main/java/org/antlr/Tool.java 2023-09-15 17:54:49.090915002 +0200
@@ -1052,6 +1052,9 @@
*/
public static String getCurrentTimeStamp() {
GregorianCalendar calendar = new java.util.GregorianCalendar();
+ if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+ calendar.setTimeInMillis(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
+ }
int y = calendar.get(Calendar.YEAR);
int m = calendar.get(Calendar.MONTH) + 1; // zero-based for months
int d = calendar.get(Calendar.DAY_OF_MONTH);