Clean up cat pages that are older than the corresponding man pages.

Remove cat page directories that are empty.
This commit is contained in:
joerg 2012-02-15 13:01:00 +00:00
parent c15df986d8
commit d99b3bd499

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: postinstall,v 1.128 2011/12/17 13:37:49 tsutsui Exp $
# $NetBSD: postinstall,v 1.129 2012/02/15 13:01:00 joerg Exp $
#
# Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
# All rights reserved.
@ -1143,7 +1143,7 @@ do_rc()
irdaattach iscsi_target isdnd isibootd \
kdc \
ldconfig local lpd lvm\
mdnsd mixerctl mopd motd mountall mountcritlocal \
makemandb mdnsd mixerctl mopd motd mountall mountcritlocal \
mountcritremote mountd moused mrouted \
named ndbootd network newsyslog nfsd nfslocking npf \
ntpd ntpdate \
@ -1583,6 +1583,62 @@ do_atf()
return ${failed}
}
#
# catpages
#
obsolete_catpages()
{
basedir="$2"
section="$3"
mandir="${basedir}/man${section}"
catdir="${basedir}/cat${section}"
test -d "$mandir" || return 0
test -d "$catdir" || return 0
(cd "$mandir" && find . -type f) | {
failed=0
while read manpage; do
manpage="${manpage#./}"
case "$manpage" in
*.Z)
catname="$catdir/${manpage%.*.Z}.0"
;;
*.gz)
catname="$catdir/${manpage%.*.gz}.0"
;;
*)
catname="$catdir/${manpage%.*}.0"
;;
esac
test -e "$catname" -a "$catname" -ot "$mandir/$manpage" || continue
if [ "$1" = "fix" ]; then
rm "$catname"
failed=$(( ${failed} + $? ))
echo "Removed obsolete cat page $catname"
else
echo "Obsolete cat page $catname"
failed=1
fi
done
exit $failed
}
}
additem catpages "remove outdated cat pages"
do_catpages()
{
failed=0
for manbase in /usr/share/man /usr/X11R6/man /usr/X11R7/man; do
for sec in 1 2 3 4 5 6 7 8 9; do
obsolete_catpages $1 ${DEST_DIR}${manbase} ${sec}
failed=$(( ${failed} + $? ))
if [ "$1" = "fix" ]; then
rmdir ${DEST_DIR}${manbase}/cat${sec}/* 2>/dev/null
rmdir ${DEST_DIR}${manbase}/cat${sec} 2>/dev/null
fi
done
done
return $failed
}
#
# obsolete