NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/49238: postinstall mtree check is broken

>Number:         49238
>Category:       bin
>Synopsis:       postinstall mtree check is broken
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 26 16:15:00 +0000 2014
>Originator:     J. Lewis Muir
>Release:        6.1_STABLE (Sept. 23, 2014)
$ uname -a
NetBSD 6.1_STABLE NetBSD 6.1_STABLE (GENERIC) #0: Tue Sep 23 17:30:30 CDT 2014 amd64
When a source tree is available, let's say at /usr/src, postinstall, for the mtree item check, will attempt to generate the expected NetBSD.dist by invoking the emit_dist_file target of /usr/src/etc/mtree/Makefile and redirect the standard output to a file named NetBSD.dist.  Unfortunately, the standard output will contain the echoed command make ran to execute the target, thus corrupting the generated expected NetBSD.dist which is then compared for the check with the actual NetBSD.dist and found to be different, hence the check fails.
In the postinstall mtree invocation, we replace "check" with "diff -u" so we can see what is different and causing the check to fail.

Invoke postinstall on a machine with a full source tree at /usr/src:

# postinstall diff -u mtree
Source directory: /usr/src
Target directory: /
mtree check:
        /tmp/_postinstall.851.0/NetBSD.dist != /etc/mtree/NetBSD.dist
--- /etc/mtree/NetBSD.dist      2014-09-23 16:01:14.000000000 -0500
+++ /tmp/_postinstall.851.0/NetBSD.dist 2014-09-26 10:48:36.000000000 -0500
@@ -1,3 +1,4 @@
+cat /usr/src/etc/mtree/NetBSD.dist.base /usr/src/etc/mtree/NetBSD.dist.x86_64 /usr/src/etc/mtree/NetBSD.dist.tests
 #      $NetBSD: NetBSD.dist.base,v 2012/11/18 22:38:37 riz Exp $
 #      @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
postinstall checks passed:
postinstall checks failed: mtree
To fix, run:
    sh /usr/sbin/postinstall -s '/usr/src' -d / fix mtree
Note that this may overwrite local changes.

In the above output, the mtree check failed because the expected NetBSD.dist erroneously contains the line "cat /usr/src/etc/mtree/NetBSD.dist.base /usr/src/etc/mtree/NetBSD.dist.x86_64 /usr/src/etc/mtree/NetBSD.dist.tests" at the top.  This line is the command make echoed to standard output.
Apply this patch which adds the '-s' option to the make invocation to turn off echoing commands as they are executed:

Index: usr.sbin/postinstall/postinstall
RCS file: /cvsroot/src/usr.sbin/postinstall/postinstall,v
retrieving revision
diff -u -r1.129.2.11 postinstall
--- usr.sbin/postinstall/postinstall	21 May 2014 20:29:02 -0000
+++ usr.sbin/postinstall/postinstall	24 Sep 2014 20:57:20 -0000
@@ -998,7 +998,7 @@
 	if ! $SOURCEMODE; then
-		${MAKE} -C ${SRC_DIR}/etc/mtree emit_dist_file > \
+		${MAKE} -s -C ${SRC_DIR}/etc/mtree emit_dist_file > \

Now, we run postinstall again and the mtree check passes:

# postinstall diff -u mtree 
Source directory: /usr/src
Target directory: /
mtree check:
postinstall checks passed: mtree
postinstall checks failed:

An alternative fix would be to modify the Makefile (or Makefiles?) to ensure that commands are not echoed for the emit_dist_file target.

Home | Main Index | Thread Index | Old Index