common/hooks: add some hooks moved from xbps-src (not yet used).

This commit is contained in:
Juan RP 2014-02-12 12:55:42 +01:00
parent 372ed2763f
commit 907f392e4d
11 changed files with 486 additions and 0 deletions

View file

@ -0,0 +1,31 @@
# This hook compresses manual pages with gzip(1).
hook() {
local fpattern="s|${PKGDESTDIR}||g;s|^\./$||g;/^$/d"
local j f dirat lnkat newlnk
if [ ! -d "${PKGDESTDIR}/usr/share/man" ]; then
return 0
fi
msg_normal "$pkgver: processing manual pages...\n"
find ${PKGDESTDIR}/usr/share/man -type f -follow | while read f
do
j=$(echo "$f"|sed -e "$fpattern")
[ "$j" = "" ] && continue
if $(echo "$j"|grep -q '.*.gz$'); then
continue
fi
if [ -h ${PKGDESTDIR}/"$j" ]; then
dirat=$(dirname "$j")
lnkat=$(readlink ${PKGDESTDIR}/"$j")
newlnk=$(basename "$j")
rm -f ${PKGDESTDIR}/"$j"
cd ${PKGDESTDIR}/"$dirat"
ln -s "${lnkat}".gz "${newlnk}".gz
continue
fi
echo " Compressing manpage: $j..."
gzip -nfq9 ${PKGDESTDIR}/"$j"
done
}