python311Packages.moto: 4.2.6 -> 4.2.10
[NixPkgs.git] / pkgs / build-support / setup-hooks / compress-man-pages.sh
blob0d8a76558026e965ef796a49cd23b4caf1bdbb43
1 fixupOutputHooks+=('if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi')
3 compressManPages() {
4 local dir="$1"
6 if [ -L "$dir"/share ] || [ -L "$dir"/share/man ] || [ ! -d "$dir/share/man" ]
7 then return
8 fi
9 echo "gzipping man pages under $dir/share/man/"
11 # Compress all uncompressed manpages. Don't follow symlinks, etc.
12 find "$dir"/share/man/ -type f -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 \
13 | while IFS= read -r -d $'\0' f
15 if gzip -c -n "$f" > "$f".gz; then
16 rm "$f"
17 else
18 rm "$f".gz
20 done
22 # Point symlinks to compressed manpages.
23 find "$dir"/share/man/ -type l -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 \
24 | sort -z \
25 | while IFS= read -r -d $'\0' f
27 local target
28 target="$(readlink -f "$f")"
29 if [ -f "$target".gz ]; then
30 ln -sf "$target".gz "$f".gz && rm "$f"
32 done