From f6163ef34662c316ad35fccf6d3af2c7d317fe8f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 3 Dec 2011 10:20:52 +0100 Subject: [PATCH] Handle man pages with hardlinks. --- scripts/compress-man-pages | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/compress-man-pages b/scripts/compress-man-pages index e546f4b29..cc96b33a6 100755 --- a/scripts/compress-man-pages +++ b/scripts/compress-man-pages @@ -8,7 +8,11 @@ echo "Compressing man pages..." BUILDROOT=${1} shift -for file in $(find ${BUILDROOT}/usr/share/man -type f); do +dir="${BUILDROOT}/usr/share/man" + +for file in $(find ${dir} -type f 2>/dev/null); do + [ -f "${file}" ] || continue + case "${file}" in *.gz) gzip -d ${file} @@ -21,10 +25,24 @@ for file in $(find ${BUILDROOT}/usr/share/man -type f); do esac echo " Compressing man page ${file//${BUILDROOT}/}..." - ${COMPRESSOR} ${file} + ${COMPRESSOR} ${file} /dev/null || { + # Handle files with hardlinks. + others=$(find ${dir} -type f -samefile ${file}) + if [ -n "${others}" ]; then + for afile in ${others}; do + [ "${afile}" != "${file}" ] && rm -f ${afile} + done + ${COMPRESSOR} -f ${file} + for afile in ${others}; do + [ "${afile}" != "${file}" ] && ln ${file}${COMPRESS_EXT} ${afile}${COMPRESS_EXT} + done + else + ${COMPRESSOR} -f ${file} + fi + } done -for file in $(find ${BUILDROOT}/usr/share/man -type l); do +for file in $(find ${dir} -type l); do link=$(ls -l ${file} | sed -e 's/.* -> //' -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\)$//') rm -f ${file} b=$(echo ${file} | sed -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\)$//') -- 2.39.5