diff options
Diffstat (limited to 'abuild.in')
-rw-r--r-- | abuild.in | 40 |
1 files changed, 22 insertions, 18 deletions
@@ -1407,29 +1407,33 @@ default_doc() { done # compress man pages - local previnode= prevname= mandir="$subpkgdir"/usr/share/man - [ -d "$mandir" ] && find "$subpkgdir"/usr/share/man \ - -type f \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \ - -exec stat -c "%i %n" {} \; | sort -n \ - | while read inode name; do - - if [ "$inode" = "$previnode" ]; then - # update hard link - rm "$name" - ln "$prevname".gz "$name".gz - else - gzip -9 "$name" - fi + local mandir="$subpkgdir"/usr/share/man + [ -d "$mandir" ] && find "$mandir" -type f \ + -a \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \ + -exec stat -c "%i %n" \{\} \; | while read inode name; do + + # Skip hardlinks removed in last iteration. + [ -f "$name" ] || continue + + local islink=0 + find "$mandir" -type f -links +1 \ + -a \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \ + -exec stat -c "%i %n" \{\} \; | while read linode lname; do + if [ "$linode" = "$inode" -a "$lname" != "$name" ]; then + islink=1 + rm -f "$lname" + ln -s "${name##*/}".gz "$lname".gz + fi + done - previnode="$inode" - prevname="$name" + [ $islink -eq 0 ] && gzip -9 "$name" done - [ -d "$mandir" ] && find "$subpkgdir"/usr/share/man \ - -type l \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \ + [ -d "$mandir" ] && find "$mandir" -type l \ + -a \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \ | while read symlink; do ln -s $(readlink $symlink).gz "$symlink".gz - rm "$symlink" + rm -f "$symlink" done rm -f "$subpkgdir/usr/share/info/dir" |