summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks/compress-man-pages.sh
blob: 74c565ebffc599689458af0da32f825198ee1a8c (plain) (blame)
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
addHook fixupOutput 'if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi'

compressManPages() {
    local dir="$1"

    echo "gzipping man pages in $dir"

    GLOBIGNORE=.:..:*.gz:*.bz2

    for f in "$dir"/share/man/*/* "$dir"/share/man/*/*/*; do
        if [ -f "$f" -a ! -L "$f" ]; then
            if gzip -c -n "$f" > "$f".gz; then
                rm "$f"
            else
                rm "$f".gz
            fi
        fi
    done

    for f in "$dir"/share/man/*/* "$dir"/share/man/*/*/*; do
        if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then
            ln -sf `readlink "$f"`.gz "$f".gz && rm "$f"
        fi
    done

    unset GLOBIGNORE
}