compress-man-pages: skip compressed manpages

Because of bash 4.4 the semantics GLOBIGNORE changed.
This resulted in already compressed manpages to be compressed twice.
Also be careful about symlinks to fix #21777, e.g. the ledger example.
This commit is contained in:
Vladimír Čunát 2017-02-27 20:03:45 +01:00
parent 079353e208
commit 20ffc3cd73
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA

View File

@ -3,26 +3,30 @@ fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; f
compressManPages() { compressManPages() {
local dir="$1" local dir="$1"
if [ ! -d "$dir/share/man" ]; then return; fi if [ -L "$dir"/share ] || [ -L "$dir"/share/man ] || [ ! -d "$dir/share/man" ]
echo "gzipping man pages in $dir" then return
fi
echo "gzipping man pages under $dir/share/man/"
GLOBIGNORE=.:..:*.gz:*.bz2 # Compress all uncompressed manpages. Don't follow symlinks, etc.
find "$dir"/share/man/ -type f -a '!' -regex '.*\.\(bz2\|gz\)$' -print0 \
for f in "$dir"/share/man/*/* "$dir"/share/man/*/*/*; do | while IFS= read -r -d $'\0' f
if [ -f "$f" -a ! -L "$f" ]; then do
if gzip -c -n "$f" > "$f".gz; then if gzip -c -n "$f" > "$f".gz; then
rm "$f" rm "$f"
else else
rm "$f".gz rm "$f".gz
fi
fi fi
done done
for f in "$dir"/share/man/*/* "$dir"/share/man/*/*/*; do # Point symlinks to compressed manpages.
if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then find "$dir"/share/man/ -type l -a '!' -regex '.*\.\(bz2\|gz\)$' -print0 \
ln -sf `readlink "$f"`.gz "$f".gz && rm "$f" | while IFS= read -r -d $'\0' f
do
local target
target="$(readlink -f "$f")"
if [ -f "$target".gz ]; then
ln -sf "$target".gz "$f".gz && rm "$f"
fi fi
done done
unset GLOBIGNORE
} }