diff options
Diffstat (limited to 'scripts/combinejars')
-rwxr-xr-x | scripts/combinejars | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/combinejars b/scripts/combinejars new file mode 100755 index 0000000..338bd6d --- /dev/null +++ b/scripts/combinejars @@ -0,0 +1,26 @@ +#!/bin/bash +# Usage: combinejars <destination> <jars...> +# +# Combines contents of jars into a single destination jar. The +# destination jar will have all it entries dates set to the unix +# epoch, hence making it reproducible for the same input. +# +# Contents at same paths are overwritten, the latter overwriting the earlier. + +destination="$(realpath "$1")" +shift +sources=("$@") + +workdir="$(mktemp -d)" + +cleanup() { + rm -rf "$workdir" +} +trap cleanup EXIT + +for s in "${sources[@]}"; do + absolute=$(realpath "$s") + (cd "$workdir" || exit 1; unzip -uo "$absolute" > /dev/null) +done +find "$workdir" -exec touch -t 197001010000 {} \; +jar -cMf "$destination" -C "$workdir" . |