Subject: postinstall fix makedev gets wrong file
To: None <current-users@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: current-users
Date: 02/02/2003 11:11:24
I've managed to get postinstall to install the i386 MAKEDEV
into my sparc filesystem.

I'd done a build.sh -m sparc ... install and the postinstall check
reported a load of errors (not surprising since the target filesystem
was empty when I started).  Anyway at the end it outputs:

To fix, run:
    /bsd/src/etc/postinstall -s /bsd/src -d /sparc_root ...

So I duly cut and paste the command to execute it.

Unfortunately postinstall relies on MACHINE being set in the environment.
So it pulled in the i386 MAKEDEV.

The following patch adds a '-m machine' option to postinstall.

	David

Index: postinstall
===================================================================
RCS file: /cvsroot/src/etc/postinstall,v
retrieving revision 1.49
diff -u -r1.49 postinstall
--- postinstall	2003/01/21 14:28:55	1.49
+++ postinstall	2003/02/02 10:49:33
@@ -665,14 +665,15 @@
 usage()
 {
 	cat 1>&2 << _USAGE_
-Usage: ${PROGNAME} [-s srcdir] [-d destdir] operation [item [...]]
+Usage: ${PROGNAME} [-s srcdir] [-d destdir] [-m machine] operation [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.
+	configuration files.
+	If no items are provided, all checks or fixes are applied.
 
 	Options:
 	-s srcdir	Source directory to compare from.  [${SRC_DIR:-/}]
 	-d destdir	Destination directory to check.    [${DEST_DIR:-/}]
+	-m machine	Machine architecture.              [${MACHINE:-$(uname -m)}]
 
 	Operation may be one of:
 		help	display this help
@@ -705,6 +706,8 @@
 		SRC_DIR=${OPTARG} ;;
 	d)
 		DEST_DIR=${OPTARG} ;;
+	m)
+		MACHINE=${OPTARG} ;;
 	*)
 		usage ;;
 	esac
@@ -773,9 +776,10 @@
 		echo "${PROGNAME} ${plural} passed:${items_passed}"
 		echo "${PROGNAME} ${plural} failed:${items_failed}"
 		if [ -n "${items_failed}" -a "${op}" = "check" ]; then
+			[ "$MACHINE" = "$(uname -m)" ] && m= || m=" -m $MACHINE"
 			cat <<_Fix_me_
 To fix, run:
-    ${0} -s ${SRC_DIR} -d ${DEST_DIR:-/} fix${items_failed}
+    ${0} -s ${SRC_DIR} -d ${DEST_DIR:-/}$m fix${items_failed}
 _Fix_me_
 		fi
 

-- 
David Laight: david@l8s.co.uk