2014-11-05 17:21:44 +00:00
|
|
|
findTarball() {
|
2014-11-05 17:06:14 +00:00
|
|
|
local suffix i
|
2014-11-05 17:21:44 +00:00
|
|
|
if [ -d "$1/tarballs/" ]; then
|
2012-07-13 18:58:39 +00:00
|
|
|
for suffix in tar.gz tgz tar.bz2 tbz2 tar.xz tar.lzma; do
|
2014-11-20 12:19:36 +00:00
|
|
|
for i in $1/tarballs/*.$suffix; do echo $i; break; done
|
2014-11-05 17:21:44 +00:00
|
|
|
done | sort | head -1
|
|
|
|
return
|
2014-11-10 19:06:14 +00:00
|
|
|
else
|
|
|
|
echo "$1"
|
|
|
|
return
|
2014-11-05 17:21:44 +00:00
|
|
|
fi
|
2012-07-13 18:58:39 +00:00
|
|
|
}
|
|
|
|
|
2014-08-14 05:20:44 +00:00
|
|
|
canonicalizeJarManifest() {
|
2014-11-05 17:07:25 +00:00
|
|
|
local input=$1
|
|
|
|
# http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#Notes_on_Manifest_and_Signature_Files
|
|
|
|
(head -n 1 $input && tail -n +2 $input | sort | grep -v '^\s*$') > $input-tmp
|
|
|
|
mv $input-tmp $input
|
2014-08-14 05:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Post-process a jar file to contain canonical timestamps and metadata ordering
|
|
|
|
canonicalizeJar() {
|
2014-11-05 17:07:25 +00:00
|
|
|
local input=$1
|
|
|
|
local outer=$(pwd)
|
|
|
|
unzip -qq $input -d $input-tmp
|
|
|
|
canonicalizeJarManifest $input-tmp/META-INF/MANIFEST.MF
|
|
|
|
# Set all timestamps to Jan 1 1980, which is the earliest date the zip format supports...
|
|
|
|
find $input-tmp -exec touch -t 198001010000.00 {} +
|
|
|
|
rm $input
|
|
|
|
pushd $input-tmp
|
|
|
|
zip -q -r -o -X $outer/tmp-out.jar . 2> /dev/null
|
|
|
|
popd
|
|
|
|
rm -rf $input-tmp
|
|
|
|
mv $outer/tmp-out.jar $input
|
2014-08-14 05:20:44 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 18:58:39 +00:00
|
|
|
propagateImageName() {
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p $out/nix-support
|
2012-07-13 18:58:39 +00:00
|
|
|
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
|
|
|
|
}
|