summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan McRae <mcrae_allan@hotmail.com>2007-12-05 09:50:29 +1000
committerDan McGee <dan@archlinux.org>2007-12-04 18:55:44 -0600
commit9615d82343148301884bfc79d87e2f408aad64bd (patch)
tree6e963a5bd6b9e1f974f0856874ef8674ec172cf1
parent87d95f14f70cc133642db3041a2b3e78b5a74516 (diff)
downloadpacman-9615d82343148301884bfc79d87e2f408aad64bd.tar.xz
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 <mcrae_allan@hotmail.com> [Dan: use find -samefile option, don't fail if one of mandirs is nonexistent] Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--scripts/makepkg.sh.in40
1 files 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