1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-02-28 09:21:53 -05:00

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>
This commit is contained in:
Allan McRae 2007-12-05 09:50:29 +10:00 committed by Dan McGee
parent 87d95f14f7
commit 9615d82343

View File

@ -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