misc/129639: mergemaster does not use the right mk files

Sam Leffler sam at FreeBSD.org
Sun Dec 14 12:20:12 PST 2008


>Number:         129639
>Category:       misc
>Synopsis:       mergemaster does not use the right mk files
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 14 20:20:11 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Sam Leffler
>Release:        HEAD
>Organization:
>Environment:
>Description:
mergemaster (implicitly) uses /usr/share/mk for all make operations.  This fails when the source tree adds MK_* knobs not present on the host.  The problem is make is invoked without a -m option to specify the location of .mk files.

Note the only way to deal with this is to pollute the host build environment by doing something like

cp $SRC/share/mk/bsd.own.mk /usr/share/mk

which is unacceptable.

>How-To-Repeat:
Use a 7.0-RELEASE system to cross-build for a different architecture; e.g. setup an NFS root for arm:

make TARGET_ARCH=arm TARGET_CPUTYPE=xscale TARGET_BIG_ENDIAN=true buildworld
ROOT=/data/freebsd/roots/gateworks
make TARGET_ARCH=arm TARGET_CPUTYPE=xscale TARGET_BIG_ENDIAN=true \
       DESTDIR=$ROOT installworld
mergemaster -m $SRC/etc -D $ROOT -i -A arm

Note the make distrib-dirs done by mergemaster fails because MK_* knobs are undefined:

*** Creating and populating directory structure in /var/tmp/temproot

"Makefile", line 34: Malformed conditional (${MK_AMD} != "no")
"Makefile", line 36: if-less endif
"Makefile", line 38: Malformed conditional (${MK_APM} != "no")
"Makefile", line 40: if-less endif
  ...

>Fix:
See attached patch for a proof of concept change.  It changes the meaning of the -m option to the path to the top of the source tree (not include /etc) and then passes an explicit -m option to make for all work.  This is unlikely to be acceptable as people use mergemaster for directories/paths other than "/usr/src".  I suggest adding a different option with these semantics; e.g. -M.


Patch attached with submission follows:

Index: mergemaster.sh
===================================================================
--- mergemaster.sh	(revision 186013)
+++ mergemaster.sh	(working copy)
@@ -412,8 +412,12 @@
 
 # Assign the source directory
 #
-SOURCEDIR=${SOURCEDIR:-/usr/src/etc}
+SOURCEDIR=${SOURCEDIR:-/usr/src}
 
+#
+# Setup make to use system files from SOURCEDIR
+MAKE="make -m ${SOURCEDIR}/share/mk"
+
 # Check DESTDIR against the mergemaster mtree database to see what
 # files the user changed from the reference files.
 #
@@ -548,20 +552,20 @@
 
   case "${PRE_WORLD}" in
   '')
-    { cd ${SOURCEDIR} &&
+    { cd ${SOURCEDIR}/etc &&
       case "${DESTDIR}" in
       '') ;;
       *)
-      make DESTDIR=${DESTDIR} ${ARCHSTRING} distrib-dirs
+      ${MAKE} DESTDIR=${DESTDIR} ${ARCHSTRING} distrib-dirs
         ;;
       esac
-      make DESTDIR=${TEMPROOT} ${ARCHSTRING} distrib-dirs &&
-      MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} obj &&
-      MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} all &&
-      MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} \
+      ${MAKE} DESTDIR=${TEMPROOT} ${ARCHSTRING} distrib-dirs &&
+      MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj ${MAKE} ${ARCHSTRING} obj &&
+      MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj ${MAKE} ${ARCHSTRING} all &&
+      MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj ${MAKE} ${ARCHSTRING} \
 	  DESTDIR=${TEMPROOT} distribution;} ||
     { echo '';
-     echo "  *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to";
+     echo "  *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR}/etc and install files to";
       echo "      the temproot environment";
       echo '';
       exit 1;}
@@ -569,8 +573,8 @@
   *)
     # Only set up files that are crucial to {build|install}world
     { mkdir -p ${TEMPROOT}/etc &&
-      cp -p ${SOURCEDIR}/master.passwd ${TEMPROOT}/etc &&
-      cp -p ${SOURCEDIR}/group ${TEMPROOT}/etc;} ||
+      cp -p ${SOURCEDIR}/etc/master.passwd ${TEMPROOT}/etc &&
+      cp -p ${SOURCEDIR}/etc/group ${TEMPROOT}/etc;} ||
     { echo '';
       echo '  *** FATAL ERROR: Cannot copy files to the temproot environment';
       echo '';
@@ -647,7 +651,7 @@
     echo ''
     echo " *** Your umask is currently set to ${USER_UMASK}.  By default, this script"
     echo "     installs all files with the same user, group and modes that"
-    echo "     they are created with by ${SOURCEDIR}/Makefile, compared to"
+    echo "     they are created with by ${SOURCEDIR}/etc/Makefile, compared to"
     echo "     a umask of 022.  This umask allows world read permission when"
     echo "     the file's default permissions have it."
     echo ''
@@ -904,7 +908,7 @@
 fi
 
 # Using -size +0 avoids uselessly checking the empty log files created
-# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does
+# by ${SOURCEDIR}/etc/Makefile and the device entries in ./dev, but does
 # check the scripts in ./dev, as we'd like (assuming no devfs of course).
 #
 for COMPFILE in `find . -type f -size +0`; do
@@ -1206,7 +1210,7 @@
 case "${PRE_WORLD}" in
 '') ;;
 *)
-  MAKE_CONF="${SOURCEDIR%etc}share/examples/etc/make.conf"
+  MAKE_CONF="${SOURCEDIR}/share/examples/etc/make.conf"
 
   (echo ''
   echo '*** Comparing make variables'


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list