From 61378e1a055733cfef273abf609df7517eb2fbf7 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 24 Jun 2021 22:52:18 +0000 Subject: [PATCH] Add a utility script to make release jars deterministic --- build-release-jar.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 build-release-jar.sh diff --git a/build-release-jar.sh b/build-release-jar.sh new file mode 100755 index 00000000..61d6fbcc --- /dev/null +++ b/build-release-jar.sh @@ -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 -- 2.39.5