2000-01-08 01:32:27 +08:00
|
|
|
#!/bin/sh
|
2000-05-23 01:33:32 +08:00
|
|
|
|
2000-01-08 01:32:27 +08:00
|
|
|
# If using normal root, avoid changing anything.
|
2019-08-09 22:30:43 +08:00
|
|
|
if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then
|
2000-01-08 01:32:27 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-10-01 20:37:48 +08:00
|
|
|
PREFIX=${1:-/usr}
|
|
|
|
|
2011-09-06 14:52:19 +08:00
|
|
|
cd "$RPM_BUILD_ROOT"
|
2000-01-08 01:32:27 +08:00
|
|
|
|
|
|
|
# Compress man pages
|
2015-08-12 07:27:52 +08:00
|
|
|
COMPRESS=${COMPRESS:-gzip -9 -n}
|
|
|
|
COMPRESS_EXT=${COMPRESS_EXT:-.gz}
|
2000-01-08 01:32:27 +08:00
|
|
|
|
2018-10-01 20:37:48 +08:00
|
|
|
for d in .${PREFIX}/man/man* .${PREFIX}/man/*/man* .${PREFIX}/info \
|
2021-09-14 00:39:54 +08:00
|
|
|
.${PREFIX}/share/man/man* .${PREFIX}/share/man/*/man* \
|
|
|
|
.${PREFIX}/share/info .${PREFIX}/kerberos/man \
|
|
|
|
.${PREFIX}/X11R6/man/man* .${PREFIX}/lib/perl5/man/man* \
|
|
|
|
.${PREFIX}/share/doc/*/man/man* .${PREFIX}/lib/*/man/man* \
|
|
|
|
.${PREFIX}/share/fish/man/man*
|
2000-01-08 01:32:27 +08:00
|
|
|
do
|
|
|
|
[ -d $d ] || continue
|
2021-09-14 00:39:54 +08:00
|
|
|
find $d -type f ! -name dir -print0 |
|
2021-09-14 00:15:06 +08:00
|
|
|
while IFS= read -r -d '' f; do
|
2021-09-14 00:39:54 +08:00
|
|
|
[ -f "$f" ] || continue
|
|
|
|
|
|
|
|
case "$f" in
|
|
|
|
*.gz|*.Z) gunzip -f "$f"; b=`echo "$f" | sed -e 's/\.\(gz\|Z\)$//'`;;
|
|
|
|
*.bz2) bunzip2 -f "$f"; b=`echo "$f" | sed -e 's/\.bz2$//'`;;
|
|
|
|
*.xz|*.lzma) unxz -f "$f"; b=`echo "$f" | sed -e 's/\.\(xz\|lzma\)$//'`;;
|
|
|
|
*.zst|*.zstd) unzstd -f --rm $f; b=`echo "$f" | sed -e 's/\.\(zst\|zstd\)$//'`;;
|
|
|
|
*) b="$f";;
|
|
|
|
esac
|
|
|
|
|
|
|
|
$COMPRESS "$b" </dev/null 2>/dev/null || {
|
|
|
|
inode=`ls -i "$b" | awk '{ print $1 }'`
|
|
|
|
others="`find $d -type f -inum $inode`"
|
|
|
|
if [ -n "$others" ]; then
|
2000-06-21 05:45:50 +08:00
|
|
|
for afile in $others ; do
|
|
|
|
[ "$afile" != "$b" ] && rm -f $afile
|
|
|
|
done
|
2021-09-14 00:15:06 +08:00
|
|
|
$COMPRESS -f "$b"
|
2000-06-21 05:45:50 +08:00
|
|
|
for afile in $others ; do
|
2021-09-14 00:15:06 +08:00
|
|
|
[ "$afile" != "$b" ] && ln "$b$COMPRESS_EXT" "$afile$COMPRESS_EXT"
|
2000-06-21 05:45:50 +08:00
|
|
|
done
|
2021-09-14 00:39:54 +08:00
|
|
|
else
|
2021-09-14 00:15:06 +08:00
|
|
|
$COMPRESS -f "$b"
|
2021-09-14 00:39:54 +08:00
|
|
|
fi
|
|
|
|
}
|
2000-02-07 02:07:12 +08:00
|
|
|
done
|
2000-06-21 05:45:50 +08:00
|
|
|
|
2022-03-03 19:51:32 +08:00
|
|
|
find $d -type l -print0 |
|
2022-01-14 20:50:37 +08:00
|
|
|
while IFS= read -r -d '' f; do
|
2021-09-14 00:39:54 +08:00
|
|
|
l=`ls -l $f | sed -e 's/.* -> //' -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\|zst\|zstd\)$//'`
|
|
|
|
rm -f $f
|
|
|
|
b=`echo $f | sed -e 's/\.\(gz\|Z\|bz2\|xz\|lzma\|zst\|zstd\)$//'`
|
|
|
|
ln -sf "$l$COMPRESS_EXT" "$b$COMPRESS_EXT"
|
2000-01-08 01:32:27 +08:00
|
|
|
done
|
|
|
|
done
|