]> git.bitcoin.ninja Git - ldk-java/commitdiff
Add a utility script to make release jars deterministic
authorMatt Corallo <git@bluematt.me>
Thu, 24 Jun 2021 22:52:18 +0000 (22:52 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 24 Jun 2021 22:55:03 +0000 (22:55 +0000)
build-release-jar.sh [new file with mode: 0755]

diff --git a/build-release-jar.sh b/build-release-jar.sh
new file mode 100755 (executable)
index 0000000..61d6fbc
--- /dev/null
@@ -0,0 +1,36 @@
+#/bin/sh
+set -e
+set -x
+
+# zips are not generally deterministic without some tweaking, which we do here.
+
+echo "Checking that required release native libraries are present..."
+ls src/main/resources/liblightningjni_Linux-amd64.nativelib
+ls src/main/resources/liblightningjni_MacOSX-x86_64.nativelib
+ls src/main/resources/liblightningjni_MacOSX-aarch64.nativelib
+
+export LANG=C
+
+mvn clean
+faketime 2021-01-01 mvn -DskipTests=true package
+
+mkdir ziptmp
+cd ziptmp
+unzip ../target/ldk-java-1.0-SNAPSHOT-sources.jar | grep inflating | awk '{ print $2 }' | sort > ../sources-zip-files.txt
+sed -i 's/#Fri Jan 01 00:.* UTC 2021/#Fri Jan 01 00:00:00 UTC 2021/' META-INF/maven/org.ldk/ldk-java/pom.properties
+touch -d "2021-01-01 00:00 UTC" $(cat ../sources-zip-files.txt)
+cat ../sources-zip-files.txt | zip -X@ ../ldk-java-1.0-SNAPSHOT-sources-deterministic.jar
+cd ..
+rm -r ziptmp
+mv ldk-java-1.0-SNAPSHOT-sources-deterministic.jar target/ldk-java-1.0-SNAPSHOT-sources.jar
+
+mkdir ziptmp
+cd ziptmp
+unzip ../target/ldk-java-1.0-SNAPSHOT.jar | grep inflating | awk '{ print $2 }' | sort > ../classes-zip-files.txt
+sed -i 's/#Fri Jan 01 00:.* UTC 2021/#Fri Jan 01 00:00:00 UTC 2021/' META-INF/maven/org.ldk/ldk-java/pom.properties
+sed -i 's/Built-By: .*/Built-By: ldk-deterministic-builds/' META-INF/MANIFEST.MF
+touch -d "2021-01-01 00:00 UTC" $(cat ../classes-zip-files.txt)
+cat ../classes-zip-files.txt | zip -X@ ../ldk-java-1.0-SNAPSHOT-deterministic.jar
+cd ..
+rm -r ziptmp
+mv ldk-java-1.0-SNAPSHOT-deterministic.jar target/ldk-java-1.0-SNAPSHOT.jar