Subject: disabling some postinstall fixes
To: None <tech-userlevel@netbsd.org>
From: Pavel Cahyna <pavel@netbsd.org>
List: tech-userlevel
Date: 05/25/2007 11:19:07
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

hello,

I have filed PR install/36180
(http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=36180)
about postinstall removing sendmail configuration. I believe that this
should not happen by default during upgrades, because users who want to
continue using sendmail would lose their configuration files.

To prevent it, I want to separate the postinstall checks in two groups:
enabled and disabled by default. The latter would not be executed if no
items are given on the command line; to execute them one would have to ask
for them explicitely.

(In the future, one might use this to add an item to remove obsolete shared
libraries which different major number, which we currently keep for
compatibility reasons. Those who don't run old binaries might appreciate
an automated way to ged rid of them.)

Here is the diff, I would really like to have it in the 4.0 release.

Pavel

--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="postinstall.diff"

? postinstall.diff
Index: postinstall
===================================================================
RCS file: /cvsroot/src/usr.sbin/postinstall/postinstall,v
retrieving revision 1.40
diff -u -p -r1.40 postinstall
--- postinstall	11 Apr 2007 07:16:28 -0000	1.40
+++ postinstall	25 May 2007 09:05:12 -0000
@@ -93,12 +93,24 @@ mkdtemp()
 }
 
 # additem item description
-#	Add item to list of supported items to check/fix.
+#	Add item to list of supported items to check/fix,
+#	which are checked/fixed by default if no item is requsted by user.
 #
 additem()
 {
 	[ $# -eq 2 ] || err 2 "USAGE: additem item description"
-	items="${items}${items:+ }$1"
+	defaultitems="${defaultitems}${defaultitems:+ }$1"
+	eval desc_$1=\"$2\"
+}
+
+# adddisableditem item description
+#	Add item to list of supported items to check/fix,
+#	but execute the item only if the user asks for it explicitely.
+#
+adddisableditem()
+{
+	[ $# -eq 2 ] || err 2 "USAGE: adddisableditem item description"
+	otheritems="${otheritems}${otheritems:+ }$1"
 	eval desc_$1=\"$2\"
 }
 
@@ -889,7 +901,7 @@ do_rc()
 #
 #	sendmail
 #
-additem sendmail "remove obsolete sendmail configuration files and scripts"
+adddisableditem sendmail "remove obsolete sendmail configuration files and scripts"
 do_sendmail()
 {
 	[ -n "$1" ] || err 2 "USAGE: do_sendmail  fix|check"
@@ -1148,7 +1160,7 @@ usage()
 Usage: ${PROGNAME} [-s srcdir] [-d destdir] [-m mach] [-a arch] op [item [...]]
 	Perform post-installation checks and/or fixes on a system's
 	configuration files.
-	If no items are provided, all checks or fixes are applied.
+	If no items are provided, a default set of checks or fixes is applied.
 
 	Options:
 	-s {srcdir|tgzfile|tempdir}
@@ -1180,13 +1192,21 @@ _USAGE_
 
 list()
 {
-	echo "Supported items:"
+	echo "Default set of items (to apply if no items are provided by user):"
 	echo "  Item          Description"
 	echo "  ----          -----------"
-	for i in ${items}; do
+	for i in ${defaultitems}; do
 		eval desc="\${desc_${i}}"
 		printf "  %-12s  %s\n" "${i}" "${desc}"
 	done
+	echo "Items disabled by default (must be requested explicitely):"
+	echo "  Item          Description"
+	echo "  ----          -----------"
+	for i in ${otheritems}; do
+		eval desc="\${desc_${i}}"
+		printf "  %-12s  %s\n" "${i}" "${desc}"
+	done
+
 }
 
 
@@ -1309,7 +1329,7 @@ main()
 
 	check|fix)
 		todo="$@"
-		: ${todo:=${items}}
+		: ${todo:=${defaultitems}}
 
 		# ensure that all supplied items are valid
 		#
Index: postinstall.8
===================================================================
RCS file: /cvsroot/src/usr.sbin/postinstall/postinstall.8,v
retrieving revision 1.6
diff -u -p -r1.6 postinstall.8
--- postinstall.8	26 Mar 2007 18:09:42 -0000	1.6
+++ postinstall.8	25 May 2007 09:05:12 -0000
@@ -58,9 +58,14 @@ from
 .Nx 1.6.2
 to
 .Nx 2.0 .
+The items to check or fix are divided in two groups: enabled by
+default and disabled by default.
+The latter are items that are dangerous for some reason, for example
+because they remove files which may be still in use. 
 If no
 .Ar items
-are provided, all checks or fixes are applied.
+are provided, the default checks or fixes are applied.
+Those which are disabled by default must be provided explicitely.
 .Pp
 Supported options:
 .Bl -tag -width XsXsrcdirXXX -offset indent
@@ -142,7 +147,8 @@ may help, and in some cases manual inter
 Display a short help.
 .It Cm list
 List available
-.Ar items .
+.Ar items ,
+showing if they are enabled or disabled by default.
 .It Cm usage
 Same as
 .Cm help .

--jRHKVT23PllUwdXP--