I have run into a strange problem with git and zip files. My build script takes a bunch of documentation html pages and zips them into a docs.zip I then check this file into
Use below script to create deterministic zip or jar files
#!/bin/bash
usage() {
echo "Usage : ./createDeterministicArtifact.sh "
exit 1
}
info() {
echo "$1"
}
strip_artifact() {
if [ -z ${file} ]; then
usage
fi
if [ -f ${file} -a -s ${file} ]; then
mkdir -p ${file}.tmp
unzip -oq -d ${file}.tmp ${file}
find ${file}.tmp -follow -exec touch -a -m -t 201912010000.00 {} \+
if [ "$UNAME" == "Linux" ] ; then
find ${file}.tmp -follow -exec chattr -a {} \+
elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* ]] ; then
find ${file}.tmp -follow -exec attrib -A {} \+
fi
cd ${file}.tmp
zip -rq -D -X -9 -A --compression-method deflate ../${file}.new .
cd -
rm -rf ${file}.tmp
info "Recreated deterministic artifact: ${file}.new"
else
info "Input file is empty. Please validate the file and try again"
fi
}
file=$1
strip_artifact