From 9615d82343148301884bfc79d87e2f408aad64bd Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Wed, 5 Dec 2007 09:50:29 +1000 Subject: Compress hard linked man pages This fixes FS#5392. If hard links are present for a man page, all other hard linked files are removed, the man page is zipped and the hard links are updated to the newly compress man page. Signed-off-by: Allan McRae [Dan: use find -samefile option, don't fail if one of mandirs is nonexistent] Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 953bda2a..0ef0e521 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -722,18 +722,34 @@ tidy_install() { msg2 "$(gettext "Compressing man pages...")" - local manpage ext file link - find {usr{,/local},opt/*}/man -type f 2>/dev/null | while read manpage ; do - ext="${manpage##*.}" - file="${manpage##*/}" - if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then - # update symlinks to this manpage - find {usr{,/local},opt/*}/man -lname "$file" 2>/dev/null | while read link ; do - rm -f "$link" - ln -sf "${file}.gz" "${link}.gz" - done - # compress the original - gzip -9 "$manpage" + local manpage mandirs ext file link hardlinks hl + mandirs="usr/man usr/local/man usr/share/man opt/*/man" + find ${mandirs} -type f 2>/dev/null | while read manpage ; do + # check file still exists (potentially compressed with hard link) + if [ -f ${manpage} ]; then + ext="${manpage##*.}" + file="${manpage##*/}" + if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then + # update symlinks to this manpage + find ${mandirs} -lname "$file" 2>/dev/null | while read link ; do + rm -f "$link" + ln -sf "${file}.gz" "${link}.gz" + done + # find hard links and remove them + # the '|| true' part keeps the script from bailing if find returned an + # error, such as when one of the man directories doesn't exist + hardlinks="$(find ${mandirs} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true + for hl in ${hardlinks}; do + rm -f "${hl}"; + done + # compress the original + gzip -9 "$manpage" + # recreate hard links removed earlier + for hl in ${hardlinks}; do + ln "${manpage}.gz" "${hl}.gz" + chmod 644 ${hl}.gz + done + fi fi done -- cgit v1.2.3-70-g09d2