Accepting request 1113522 from Java:packages

reproducible builds

OBS-URL: https://build.opensuse.org/request/show/1113522
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/jython?expand=0&rev=32
This commit is contained in:
Ana Guerrero 2023-09-26 20:01:41 +00:00 committed by Git OBS Bridge
commit e823ce4b02
5 changed files with 155 additions and 0 deletions

55
jython-java8compat.patch Normal file
View File

@ -0,0 +1,55 @@
diff --git a/build.xml b/build.xml
index 52dfe71..43d7649 100644
--- a/build.xml
+++ b/build.xml
@@ -91,8 +91,8 @@ informix.jar = ../support/jdbc-4.10.12.jar
<property file="${user.home}/ant.properties" />
<property file="${basedir}/ant.properties" />
- <property name="jython.java.version" value="1.8" />
- <property name="jdk.source.version" value="1.8" />
+ <property name="jython.java.version" value="8" />
+ <property name="jdk.source.version" value="8" />
<!-- Designate the official release encoded in parts. In normal times, this is the *next*
official release, e.g. 2.7.2b2 while working towards 2.7.2b2, and sys.version will be
@@ -681,6 +681,7 @@ The text for an official release would continue like ...
destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
+ release="${jdk.target.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
@@ -743,6 +744,7 @@ The text for an official release would continue like ...
<javac destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
+ release="${jdk.target.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
@@ -763,6 +765,7 @@ The text for an official release would continue like ...
destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
+ release="${jdk.target.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
@@ -795,6 +798,7 @@ The text for an official release would continue like ...
destdir="${test.compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
+ release="${jdk.target.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
@@ -1209,6 +1213,7 @@ The text for an official release would continue like ...
destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
+ release="${jdk.target.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"

View File

@ -0,0 +1,43 @@
diff --git a/build.xml b/build.xml
index 52dfe71..0d41bdf 100644
--- a/build.xml
+++ b/build.xml
@@ -721,8 +721,12 @@ The text for an official release would continue like ...
<arg path="${out}"/>
<arg value="-lib"/>
<arg path="${out}"/>
- <arg file="${basedir}/grammar/Python.g"/>
- <arg file="${basedir}/grammar/PythonPartial.g"/>
+ <!-- Reproducible builds
+ Replace 'arg file=...' with 'arg value=...' to prevent using
+ the absolute filename, because these filenames are inserted
+ into the antlr generated getGrammar* methods -->
+ <arg value="grammar/Python.g"/>
+ <arg value="grammar/PythonPartial.g"/>
<classpath refid="main.classpath"/>
</java>
@@ -1151,7 +1155,10 @@ The text for an official release would continue like ...
</target>
<target name="copy-lib" depends="common-dirs, copy-cpythonlib">
- <copy todir="${dist.dir}/Lib">
+ <!-- Reproducible builds
+ Use attribute preservelastmodified="true" because these files'
+ mtime are stored into the generated $py.class files -->
+ <copy todir="${dist.dir}/Lib" preservelastmodified="true">
<fileset dir="${basedir}/Lib">
<exclude name="**/*.class"/>
</fileset>
@@ -1175,7 +1182,10 @@ The text for an official release would continue like ...
<copy file="${basedir}/lib-python/LICENSE.txt"
tofile="${dist.dir}/LICENSE_CPython.txt"
preservelastmodified="true" />
- <copy todir="${dist.dir}/Lib">
+ <!-- Reproducible builds
+ Use attribute preservelastmodified="true" because these files'
+ mtime are stored into the generated $py.class files -->
+ <copy todir="${dist.dir}/Lib" preservelastmodified="true">
<fileset dir="${python.lib}" excludes="**/*.pyc, **/*.pyo" includesfile="${basedir}/CPythonLib.includes">
<!-- The include file gets all of lib-python/2.7's test directory, but we only want the ones from Jython's Lib. -->
<present present="srconly" targetdir="${basedir}/Lib"/>

View File

@ -0,0 +1,40 @@
diff --git a/src/org/python/modules/posix/PosixModule.java b/src/org/python/modules/posix/PosixModule.java
index e3a8dd9..07d4b43 100644
--- a/src/org/python/modules/posix/PosixModule.java
+++ b/src/org/python/modules/posix/PosixModule.java
@@ -1144,7 +1144,7 @@ public class PosixModule implements ClassDictInit {
if (times == Py.None) {
// FIXME dynamically bind to java.time.Instant, available in Java 8,
// to potentially get higher resolution (nanosecond) time
- atime = mtime = FileTime.from(
+ atime = mtime = FileTime.from(System.getenv("SOURCE_DATE_EPOCH") != null ? 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")) :
System.currentTimeMillis(), TimeUnit.MILLISECONDS);
} else if (times instanceof PyTuple && times.__len__() == 2) {
atime = getFileTime(times.__getitem__(0));
diff --git a/src/org/python/modules/random/PyRandom.java b/src/org/python/modules/random/PyRandom.java
index f5ea8d9..0dc4881 100644
--- a/src/org/python/modules/random/PyRandom.java
+++ b/src/org/python/modules/random/PyRandom.java
@@ -45,7 +45,7 @@ public class PyRandom extends PyObject {
final void Random_seed(PyObject seed) {
long n;
if (seed == null) {
- seed = new PyLong(System.currentTimeMillis());
+ seed = new PyLong(System.getenv("SOURCE_DATE_EPOCH") != null ? 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")) : System.currentTimeMillis());
}
if (seed instanceof PyLong) {
PyLong max = new PyLong(Long.MAX_VALUE);
diff --git a/src/org/python/modules/time/Time.java b/src/org/python/modules/time/Time.java
index ebd9871..cf2218d 100644
--- a/src/org/python/modules/time/Time.java
+++ b/src/org/python/modules/time/Time.java
@@ -131,6 +131,9 @@ public class Time implements ClassDictInit
}
public static double time() {
+ if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+ return Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"));
+ }
return System.currentTimeMillis()/1000.0;
}

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Mon Sep 25 16:49:29 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- Added patches:
* jython-java8compat.patch
+ use release=8 on compilers that support it
* jython-reproducible-builds.patch
+ preserve mtimes of files since they get embedded in the
resultiong class files
+ use relative paths of files that get included in antlr
getGrammar* methods
* jython-reproducible-now.patch
+ use SOURCE_DATE_EPOCH for "now" if the variable is set
-------------------------------------------------------------------
Wed Jun 28 10:40:43 UTC 2023 - Pedro Monreal <pmonreal@suse.com>

View File

@ -32,6 +32,9 @@ Patch0: %{name}-build.patch
Patch1: %{name}-dont-validate-pom.patch
Patch2: %{name}-cachedir.patch
Patch3: %{name}-fix-tty-detection.patch
Patch4: %{name}-reproducible-now.patch
Patch5: %{name}-reproducible-builds.patch
Patch6: %{name}-java8compat.patch
BuildRequires: ant
BuildRequires: ant-junit
BuildRequires: antlr3-java