normalizeZip now uses specified timestamp, since git will not propagate VERSION file timestamp during git clone

pull/35/head
knaccc 5 years ago
parent 421590dee6
commit ac054f8d51

@ -7,7 +7,6 @@ else
fi
source "$basedir/bin/java-config.sh"
source "$basedir/bin/util.sh"
echo "*** Compiling CLI"
"$JAVA_HOME"/bin/javac --module-path target/modules/combined.jar -d target/classes/org.getmonero.i2p.zero $(find org.getmonero.i2p.zero/src -name '*.java')

@ -7,7 +7,6 @@ else
fi
source "$basedir/bin/java-config.sh"
source "$basedir/bin/util.sh"
echo "*** Compiling Zip normalizer utility"
"$JAVA_HOME"/bin/javac --module-path import/commons-compress-1.18/commons-compress-1.18.jar -d target/classes/org.getmonero.util.normalizeZip $(find org.getmonero.util.normalizeZip/src -name '*.java')

@ -7,7 +7,6 @@ else
fi
source "$basedir/bin/java-config.sh"
source "$basedir/bin/util.sh"
cp "$basedir"/import/jetty-lib/*.jar "$basedir/import/lib/"

@ -46,3 +46,19 @@ if [ $OS = "Darwin" ]; then
else
export JAVA_HOME=$JAVA_HOME_LINUX
fi
# get the SHA-256 hash of the specified file
getHash () {
if [ $(uname -s) = Darwin ]; then
h=`shasum -a 256 $1 | awk '{print $1}'`
else
h=`sha256sum $1 | awk '{print $1}'`
fi
echo $h
}
# normalizes the specified jar or zip for reproducible build. Enforces consistent zip file order and sets all timestamps to midnight on Jan 1 2019
normalizeZip () {
$JAVA_HOME/bin/java --module-path "$basedir/import/commons-compress-1.18/commons-compress-1.18.jar":"$basedir/target/org.getmonero.util.normalizeZip.jar" \
-m org.getmonero.util.normalizeZip 1546300800000 "$1"
}

@ -1,17 +0,0 @@
#!/bin/bash
# get the SHA-256 hash of the specified file
getHash () {
if [ $(uname -s) = Darwin ]; then
h=`shasum -a 256 $1 | awk '{print $1}'`
else
h=`sha256sum $1 | awk '{print $1}'`
fi
echo $h
}
# normalizes the specified jar or zip for reproducible build. Enforces consistent zip file order and sets all timestamps to the last modified date of the VERSION file
normalizeZip () {
$JAVA_HOME/bin/java --module-path "$basedir/import/commons-compress-1.18/commons-compress-1.18.jar":"$basedir/target/org.getmonero.util.normalizeZip.jar" \
-m org.getmonero.util.normalizeZip "$basedir/org.getmonero.i2p.zero/src/org/getmonero/i2p/zero/VERSION" "$1"
}

@ -6,7 +6,7 @@ else
basedir=$(dirname $(dirname $(readlink -fm $0)))
fi
source "$basedir/bin/util.sh"
source "$basedir/bin/java-config.sh"
VERSION=$(head -n 1 "$basedir/org.getmonero.i2p.zero/src/org/getmonero/i2p/zero/VERSION")

@ -36,30 +36,26 @@ public final class NormalizeZip {
public static void main(String[] args) throws Exception {
if(args.length!=2) {
System.out.println("Arguments: timestampSource zip");
System.out.println("Arguments: timestamp zip");
System.exit(1);
}
File timestampSourceFile = Path.of(args[0]).toFile();
long timestamp = Long.parseLong(args[0]);
File sourceZipFile = Path.of(args[1]).toFile();
File destZipFile = Path.of(args[1]+".tmp").toFile();
if(!timestampSourceFile.exists()) {
System.out.println("Timestamp source file does not exist");
System.exit(1);
}
if(!sourceZipFile.exists()) {
System.out.println("Source zip file does not exist");
System.exit(1);
}
System.out.println("Normalizing zip " + sourceZipFile.getCanonicalPath() + " to timestamp: " + new Date(timestampSourceFile.lastModified()));
System.out.println("Normalizing zip " + sourceZipFile.getCanonicalPath() + " to timestamp: " + new Date(timestamp));
NormalizeZip nz = new NormalizeZip(timestampSourceFile.lastModified(), true).addFileStripper("META-INF/MANIFEST.MF", new ManifestStripper());
NormalizeZip nz = new NormalizeZip(timestamp, true).addFileStripper("META-INF/MANIFEST.MF", new ManifestStripper());
nz.strip(sourceZipFile, destZipFile);
if(!sourceZipFile.delete()) System.out.println("Cannot delete source file");
if(!destZipFile.renameTo(sourceZipFile)) System.out.println("Cannot rename temporary zip file");
destZipFile = sourceZipFile;
if(!destZipFile.setLastModified(timestampSourceFile.lastModified())) System.out.println("Cannot update zip last modified date");
if(!destZipFile.setLastModified(timestamp)) System.out.println("Cannot update zip last modified date");
}
/**

Loading…
Cancel
Save