From nobody@FreeBSD.org  Thu Feb 18 22:43:11 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EE84C1065672
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Feb 2010 22:43:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id DDE178FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Feb 2010 22:43:10 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IMhAAf017368
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Feb 2010 22:43:10 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o1IMhA47017367;
	Thu, 18 Feb 2010 22:43:10 GMT
	(envelope-from nobody)
Message-Id: <201002182243.o1IMhA47017367@www.freebsd.org>
Date: Thu, 18 Feb 2010 22:43:10 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Makefile.inc1 ${DESTDIR} make dependency enhancement
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         144079
>Category:       conf
>Synopsis:       Makefile.inc1 ${DESTDIR} make dependency enhancement
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 18 22:50:00 UTC 2010
>Closed-Date:    Sat Oct 16 10:19:40 UTC 2010
>Last-Modified:  Sun Feb 03 22:28:03 UTC 2013
>Originator:     Garrett Cooper
>Release:        RELENG_8
>Organization:
Cisco Systems, Inc
>Environment:
FreeBSD garrcoop-fbsd.cisco.com 8.0-STABLE FreeBSD 8.0-STABLE #2: Wed Feb  3 16:57:07 PST 2010     garrcoop@garrcoop-fbsd.cisco.com:/usr/obj/usr/src/sys/LAPPY_X86  i386
>Description:
A minor annoyance I discovered is that if DESTDIR doesn't exist prior to installworld being called, installworld will error out like so:

--------------------------------------------------------------
>How-To-Repeat:
rm -Rf ${DESTDIR}
make buildworld buildkernel
make installworld DESTDIR=${DESTDIR}
>Fix:
1. mkdir -p ${DESTDIR} before installworld is called.

OR

2. Apply attached patch and invoke with flow shown above.

Patch attached with submission follows:

Index: Makefile.inc1
===================================================================
--- Makefile.inc1	(revision 204027)
+++ Makefile.inc1	(working copy)
@@ -546,6 +546,18 @@
 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
 
 #
+# A real target which corresponds to ${DESTDIR}. This is outside of the
+# distributeworld check below because a) it's a no-op, and b) it could be a
+# make dependency of another target elsewhere.
+#
+# It doesn't matter if it's either undefined here or empty here. The former
+# case is a no-op and the latter case is user error, but gets translated into
+# a no-op via make(1). 
+#
+${DESTDIR}:
+	mkdir -p "${.TARGET}"
+
+#
 # installcheck
 #
 # Checks to be sure system is ready for installworld/installkernel.
@@ -557,7 +569,9 @@
 #
 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
 .if !make(distributeworld)
-installcheck: installcheck_DESTDIR
+# Make sure that the variable isn't empty before marking ${DESTDIR} ok.
+.ORDER: installcheck_DESTDIR ${DESTDIR}
+installcheck: installcheck_DESTDIR ${DESTDIR}
 installcheck_DESTDIR:
 .if !defined(DESTDIR) || empty(DESTDIR)
 	@echo "ERROR: Please set DESTDIR!"; \


>Release-Note:
>Audit-Trail:

From: Garrett Cooper <yaneurabeya@gmail.com>
To: bug-followup@FreeBSD.org, gcooper@FreeBSD.org
Cc:  
Subject: Re: conf/144079: Makefile.inc1 ${DESTDIR} make dependency enhancement
Date: Thu, 18 Feb 2010 15:23:42 -0800

 --000e0cd138b8f6be63047fe8410f
 Content-Type: text/plain; charset=ISO-8859-1
 
     The patch on the right track, but wasn't complete, so I had to be
 a bit more invasive with where the DESTDIR dependencies went (filled
 in all missing dependencies based on inspection) and where the goal
 itself goes (bsd.own.mk).
     I'm not happy about the placement of the goal, and I'm open to
 move it to another location if one exists, as bsd.own.mk seems to be
 purely variable driven data setting without goals.
 Thanks,
 -Garrett
 
 --000e0cd138b8f6be63047fe8410f
 Content-Type: text/plain; charset=US-ASCII; name="destdir-installcheck.diff.txt"
 Content-Disposition: attachment; filename="destdir-installcheck.diff.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_g5u6gurw1
 
 SW5kZXg6IGV0Yy9NYWtlZmlsZQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBldGMvTWFrZWZpbGUJKHJldmlzaW9u
 IDIwNDAyNykKKysrIGV0Yy9NYWtlZmlsZQkod29ya2luZyBjb3B5KQpAQCAtMTQ4LDcgKzE0OCw3
 IEBACiBQV0RfTUtEQl9FTkRJQU4/PQogLmVuZGlmCiAKLWRpc3RyaWJ1dGlvbjoKK2Rpc3RyaWJ1
 dGlvbjogJHtERVNURElSfQogLmlmICFkZWZpbmVkKERFU1RESVIpCiAJQGVjaG8gInNldCBERVNU
 RElSIGJlZm9yZSBydW5uaW5nIFwibWFrZSAkey5UQVJHRVR9XCIiCiAJQGZhbHNlCkBAIC0yNTIs
 NyArMjUyLDcgQEAKIAkgICAgJHtERVNURElSfS9ib290L2RldmljZS5oaW50cwogLmVuZGlmCiAK
 LWRpc3RyaWItZGlyczoKK2Rpc3RyaWItZGlyczogJHtERVNURElSfQogCW10cmVlIC1lVSAke01U
 UkVFX0ZPTExPV1NfU1lNTElOS1N9IC1mICR7LkNVUkRJUn0vbXRyZWUvQlNELnJvb3QuZGlzdCAt
 cCAke0RFU1RESVJ9LwogCW10cmVlIC1lVSAke01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 --000e0cd138b8f6be63047fe8410f--

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Garrett Cooper <yaneurabeya@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: conf/144079: Makefile.inc1 ${DESTDIR} make dependency
 enhancement
Date: Fri, 19 Feb 2010 15:38:02 +0300

 Garrett,
 
 On Thu, Feb 18, 2010 at 11:30:03PM +0000, Garrett Cooper wrote:
 >      The patch on the right track,
 
 I don't think so.  Our install-related targets never create
 directories themselves; instead, they expect them to be pre-
 created, e.g. by mtree.
 
 >  but wasn't complete, so I had to be
 >  a bit more invasive with where the DESTDIR dependencies went (filled
 >  in all missing dependencies based on inspection) and where the goal
 >  itself goes (bsd.own.mk).
 >      I'm not happy about the placement of the goal, and I'm open to
 >  move it to another location if one exists, as bsd.own.mk seems to be
 >  purely variable driven data setting without goals.
 
 Why all this churn, what are you trying to achieve?  Save
 one mkdir command?  Why the proposed ${DESTDIR} dependency
 only covers etc/, include/, and sys/modules/ makefiles?
 
 
 -- 
 Ruslan Ermilov
 ru@FreeBSD.org
 FreeBSD committer

From: Garrett Cooper <yaneurabeya@gmail.com>
To: Ruslan Ermilov <ru@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: conf/144079: Makefile.inc1 ${DESTDIR} make dependency enhancement
Date: Fri, 19 Feb 2010 12:47:08 -0800

 Hi Ruslan!
 
 On Fri, Feb 19, 2010 at 4:38 AM, Ruslan Ermilov <ru@freebsd.org> wrote:
 > Garrett,
 >
 > On Thu, Feb 18, 2010 at 11:30:03PM +0000, Garrett Cooper wrote:
 >> =A0 =A0 =A0The patch on the right track,
 >
 > I don't think so. =A0Our install-related targets never create
 > directories themselves; instead, they expect them to be pre-
 > created, e.g. by mtree.
 
 Yes, but mtree doesn't handle creating DESTDIR beforehand AFAIK on
 RELENG_8, which is where I was getting shot at... I did some more
 hunting and after figuring out the proper terminology for the method,
 it turns out that the overall `build process' is discussed under
 http://www.freebsd.org/doc/handbook/jails-build.html -- which is a bit
 different from what I expected because the general topic applies to
 installing out-of-build tree, in general, which is paramount for
 releases and building for embedded devices, etc.
 
 >> =A0but wasn't complete, so I had to be
 >> =A0a bit more invasive with where the DESTDIR dependencies went (filled
 >> =A0in all missing dependencies based on inspection) and where the goal
 >> =A0itself goes (bsd.own.mk).
 >> =A0 =A0 =A0I'm not happy about the placement of the goal, and I'm open t=
 o
 >> =A0move it to another location if one exists, as bsd.own.mk seems to be
 >> =A0purely variable driven data setting without goals.
 >
 > Why all this churn, what are you trying to achieve? =A0Save
 > one mkdir command? =A0Why the proposed ${DESTDIR} dependency
 > only covers etc/, include/, and sys/modules/ makefiles?
 
 The intent was to cover the implied ${DESTDIR} dependency for the sake
 of completeness, because determining that an issue is present (and
 recovering automatically if possible) via make is much quicker than
 discovering after an install command failed that you have an issue
 with your environment setup because some assumptions that are made
 about it haven't been fulfilled (in this case ${DESTDIR} doesn't
 exist).
 
 There are a few niceties thrown about the tree, and if you execute a
 set of goals in any particular order, depending on what -j you specify
 you'll run into non-deterministic cases because base directories (in
 some targets) are being created via mkdir -p, whilst others aren't
 (build32 and an etc distribute-dirs is an excellent example of what
 I'm trying to illustrate, if it executes the latter step before the
 former one and gets to the install before mkdir -p is executed).
 
 Thanks!
 -Garrett

From: Garrett Cooper <yaneurabeya@gmail.com>
To: bug-followup@FreeBSD.org, gcooper@FreeBSD.org
Cc:  
Subject: Re: conf/144079: Makefile.inc1 ${DESTDIR} make dependency enhancement
Date: Fri, 15 Oct 2010 23:57:50 -0700

     Please close this bug.
 Thanks,
 -Garrett
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Oct 16 10:19:19 UTC 2010 
State-Changed-Why:  
Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144079 
>Unformatted:
 >>> Making hierarchy
 --------------------------------------------------------------
 cd /usr/home/garrcoop/ipcvs/freebsd/src; /usr/bin/make -f Makefile.inc1 hierarchy
 cd /usr/home/garrcoop/ipcvs/freebsd/src/etc;            /usr/bin/make distrib-dirs
 mtree -eU  -f /usr/home/garrcoop/ipcvs/freebsd/src/etc/mtree/BSD.root.dist -p /usr/home/garrcoop/rootfs/
 mtree: /usr/home/garrcoop/rootfs/: No such file or directory
 *** Error code 1
 
 Stop in /usr/home/garrcoop/ipcvs/freebsd/src/etc.
 *** Error code 1
 
 Stop in /usr/home/garrcoop/ipcvs/freebsd/src.
 *** Error code 1
 
 Stop in /usr/home/garrcoop/ipcvs/freebsd/src.
 *** Error code 1
 
 Stop in /usr/home/garrcoop/ipcvs/freebsd/src.
 *** Error code 1
 
 Stop in /usr/home/garrcoop/ipcvs/freebsd/src.
 
 This can be properly worked out by adding a ${DESTDIR} dependency goal, and (at bare minimum) add a dependency goal after installcheck_DESTDIR in installcheck to properly fulfill the minimum requirement such that I don't have to maintain a hacky build sc ript in order to get this to work.
 
 I implemented the bare minimum set of logic to address the issue with as little churn as possible.
