Module Name:    src
Committed By:   joerg
Date:           Wed Feb 15 13:01:00 UTC 2012

Modified Files:
        src/usr.sbin/postinstall: postinstall

Log Message:
Clean up cat pages that are older than the corresponding man pages.
Remove cat page directories that are empty.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/usr.sbin/postinstall/postinstall

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.128 src/usr.sbin/postinstall/postinstall:1.129
--- src/usr.sbin/postinstall/postinstall:1.128	Sat Dec 17 13:37:49 2011
+++ src/usr.sbin/postinstall/postinstall	Wed Feb 15 13:01:00 2012
@@ -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

Reply via email to