Module Name:    src
Committed By:   apb
Date:           Thu Apr 23 09:37:03 UTC 2009

Modified Files:
        src/distrib/sets: Makefile

Log Message:
Clean up the handling of METALOG.sanitised:

* Don't change METALOG in place while creating METALOG.sanitised in the
  sanitise_METALOG target.  This makes it easier to manually inspect
  METALOG to find the order in which lines were added during a build.

* Add a clean_METALOG target, to be invoked from src/Makefile early in
  the build, to prevent unbounded growth of METALOG during multiple
  MKUPDATE builds.

* Remove the old hack of incorporating etc/mtree/NetBSD.dist into
  METALOG.sanitised.  It was needed only during a short transition
  period when people might have done MKUPDATE builds starting from
  existing DESTDIR and OBJDIR trees that had been created before
  revision 1.317 of src/etc/Makefile.

* Since etc/mtree/NetBSD.dist is no longer added, there's will not
  be any "optional" lines, so there's no need to filter them from
  METALOG.sanitised.

* There's no need for two different METALOG.unpriv and
  METALOG.sanitised.unpriv variables; combine them into a single
  METALOG.unpriv variable whose value is "-M ${METALOG}.sanitised".

* Reorder some lines in the Makefile, to bring related targets,
  variables and comments together.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/distrib/sets/Makefile

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

Modified files:

Index: src/distrib/sets/Makefile
diff -u src/distrib/sets/Makefile:1.66 src/distrib/sets/Makefile:1.67
--- src/distrib/sets/Makefile:1.66	Sat Apr 11 15:09:32 2009
+++ src/distrib/sets/Makefile	Thu Apr 23 09:37:03 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.66 2009/04/11 15:09:32 apb Exp $
+#	$NetBSD: Makefile,v 1.67 2009/04/23 09:37:03 apb Exp $
 
 # The `all' target must appear before bsd.own.mk is pulled in.
 all:
@@ -60,54 +60,80 @@
 print_toolchain_missing: .PHONY
 	@echo "${TOOLCHAIN_MISSING}"
 
-# This target has debugging value only, really.
-makeflist: .PHONY .PRECIOUS check_DESTDIR
-	${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
-
 #
-# SET BUILDING TARGETS
+# METALOG MANIPULATION TARGETS
+#
+# METALOG is the name of a metadata log file, and is set in <bsd.own.mk>
+# if MKUNPRIVED is not "no".
+#
+# METALOG.unpriv is a command line option passed to various scripts;
+# it is either blank or "-M ${METALOG}.sanitised", depending on the
+# MKUNPRIVED flag.
+#
+# The sanitise_METALOG target creates METALOG.sanitised from METALOG,
+# without modifying METALOG itself.  METALOG.sanitised is sorted, and
+# has duplicates merged.  This is used near the end of a build, after
+# build products have been installed in DESTDIR and corresponding lines
+# have been added to METALOG, but before METALOG.sanitised is used in
+# the creation of sets in RELEASEDIR.
+#
+# The clean_METALOG either deletes METALOG or replaces METALOG with
+# a sanitised version of itself, depending on the MKUPDATE flag, and
+# deletes old METALOG.* files.  This is intended to be used at the start
+# of a build, to ensure that repeated MKUPDATE builds do not cause
+# unbounded growth of METALOG.
 #
-
-TARDIR=		${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
-SOURCETARDIR=	${RELEASEDIR}/source/sets
 
 .if ${MKUNPRIVED} == "no"
 METALOG.unpriv=
-METALOG.sanitised.unpriv=
-.else
-METALOG.unpriv=	-M ${METALOG}
-METALOG.sanitised= ${METALOG}.sanitised
-METALOG.sanitised.unpriv= -M ${METALOG.sanitised}
-.endif
-
-.if ${MKUNPRIVED} == "no"
 sanitise_METALOG: .PHONY
 	@true
-.else
-sanitise_METALOG: .PHONY ${METALOG.sanitised}
-${METALOG.sanitised}: ${METALOG}
-	( cat ${NETBSDSRCDIR}/etc/mtree/NetBSD.dist ; \
-		echo '/unset all' ; \
-		cat ${METALOG} ) \
-	| ${TOOL_MTREE} -CS -k all -N ${NETBSDSRCDIR}/etc > ${METALOG}.new && \
-		( rm -f ${METALOG} ; \
-		mv ${METALOG}.new ${METALOG} )
-	cat ${METALOG} | ${GREP} -v " optional" > ${.TARGET}
-.endif
+clean_METALOG: .PHONY
+	@true
+.else	# MKUNPRIVED
+METALOG.unpriv= -M ${METALOG}.sanitised
+sanitise_METALOG: .PHONY ${METALOG}.sanitised
+${METALOG}.sanitised: ${METALOG}
+	${TOOL_MTREE} -CS -k all -N ${NETBSDSRCDIR}/etc <${METALOG} \
+	    >${METALOG}.new
+	mv ${METALOG}.new ${METALOG}.sanitised
+.if ${MKUPDATE} == "no" || !exists(${METALOG})
+clean_METALOG: .PHONY
+	rm -f ${METALOG} ${METALOG}.*
+.else	# MKUPDATE
+clean_METALOG: .PHONY ${METALOG}.sanitised
+	mv ${METALOG}.sanitised ${METALOG}
+	rm -f ${METALOG}.*
+.endif	# MKUPDATE
+.endif	# MKUNPRIVED
 
-.if defined(DESTDIR) && ${DESTDIR} != ""
-checkflist_if_DESTDIR: checkflist
-.else
-checkflist_if_DESTDIR:
-.endif
+#
+# FILE LIST TARGETS
+#
+
+# This target has debugging value only, really.
+makeflist: .PHONY .PRECIOUS check_DESTDIR
+	${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
 
 checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
 	${SETSCMD} ${.CURDIR}/checkflist \
-	    ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.sanitised.unpriv}
+	    ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv}
 
 checkflist-x11: .PHONY check_DESTDIR
 	${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS}
 
+.if defined(DESTDIR) && ${DESTDIR} != ""
+checkflist_if_DESTDIR: checkflist
+.else
+checkflist_if_DESTDIR:
+.endif
+
+#
+# SET BUILDING TARGETS
+#
+
+TARDIR=		${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
+SOURCETARDIR=	${RELEASEDIR}/source/sets
 
 # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be
 # made in series, even if make's "-j" flag requests multiple parallel
@@ -139,17 +165,17 @@
 		rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \
 	done
 
-makesetfiles: .PHONY
+makesetfiles: .PHONY sanitise_METALOG
 	${_MKMSG_CREATE} "set lists"
-	${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \
-	    ${MAKETARS_FLAGS} \
+	${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
+	    ${METALOG.unpriv} \
 	    -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR}
 
 .for tar in ${MAKETARSETS}
 do-${tar}: .PHONY sanitise_METALOG
 	${_MKMSG_CREATE} "${tar}.tgz"
 	${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
-	    ${METALOG.sanitised.unpriv} \
+	    ${METALOG.unpriv} \
 	    -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \
 	|| rm -f ${TARDIR}/${tar}.tgz
 .endfor
@@ -185,7 +211,7 @@
 	@false
 .endif
 	${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
-	    ${METALOG.sanitised.unpriv} -N ${NETBSDSRCDIR}/etc \
+	    ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \
 	    ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS}
 
 # Should we ignore errors like extra or missing files in the flists?
@@ -212,7 +238,7 @@
 	${SETSCMD} ${.CURDIR}/regpkgset \
 	    ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \
 	    ${REGPKG.cache} ${REGPKG.update} \
-	    -d ${DESTDIR:S,^$,/,} ${METALOG.sanitised.unpriv} \
+	    -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \
 	    -N ${NETBSDSRCDIR}/etc \
 	    -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS}
 

Reply via email to