/usr/bin/rezip is in hxtools 20170430-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/bin/bash
#
# rezip - optimize a ZIP archive and its members for size
# written by Jan Engelhardt, 2011
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the WTF Public License version 2 or
# (at your option) any later version.
self=$(readlink -f "$0");
if [[ -z "$rezip_level" ]]; then
rezip_level=0;
fi;
export rezip_level;
rezip_level=$(($rezip_level+1));
do_dir()
{
#
# optipng would abort the whole batch if just one odd PNG
# is in it, so call with -n1.
#
echo " [$rezip_level] optipng";
find "$1" -iname "*.png" -print0 | xargs -0rn1 optipng;
find "$1" "(" -iname "*.jpg" -o -iname "*.jpeg" ")" -print0 | \
xargs -0rn1 -I% jpegtran -optimize -progressive -copy none \
-outfile % %
find "$1" "(" -iname "*.zip" -o -iname "*.jar" -o -iname "*.odt" -o \
-iname "*.ods" -o -iname "*.odp" ")" -print0 | \
xargs -0r "$self";
}
do_zip()
{
mkdir "tmp.$$";
pushd "tmp.$$";
echo " [$rezip_level] Unzip $1";
unzip -q "../$1";
r="$?";
if [[ "$r" -ne 0 ]]; then
continue;
fi;
do_dir .;
rm -f "../$1";
echo " [$rezip_level] Rezip $1";
zip -9qr "../$1" *;
popd;
rm -Rf "tmp.$$";
}
for i in "$@"; do
if [[ -d "$i" ]]; then
do_dir "$i";
else
do_zip "$i";
fi;
done;
|