diff options
| -rw-r--r-- | scripts/makepkg.sh.in | 40 | 
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  | 
