From owner-freebsd-ports@FreeBSD.ORG Wed Aug 23 21:16:38 2006 Return-Path: X-Original-To: freebsd-ports@FreeBSD.org Delivered-To: freebsd-ports@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 09BCE16A4DE; Wed, 23 Aug 2006 21:16:38 +0000 (UTC) (envelope-from jhein@timing.com) Received: from Daffy.timing.com (w.timing.com [206.168.13.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E47243D46; Wed, 23 Aug 2006 21:16:37 +0000 (GMT) (envelope-from jhein@timing.com) Received: from gromit.timing.com (gromit.timing.com [206.168.13.209]) by Daffy.timing.com (8.13.1/8.13.1) with ESMTP id k7NLGYiS073910; Wed, 23 Aug 2006 15:16:34 -0600 (MDT) (envelope-from jhein@timing.com) Received: from gromit.timing.com (localhost [127.0.0.1]) by gromit.timing.com (8.13.6/8.13.6) with ESMTP id k7NLGYtu098945; Wed, 23 Aug 2006 15:16:34 -0600 (MDT) (envelope-from jhein@gromit.timing.com) Received: (from jhein@localhost) by gromit.timing.com (8.13.6/8.13.6/Submit) id k7NLGXEW098938; Wed, 23 Aug 2006 15:16:33 -0600 (MDT) (envelope-from jhein) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: <17644.50609.673610.67525@gromit.timing.com> Date: Wed, 23 Aug 2006 15:16:33 -0600 From: John E Hein To: =?ISO-8859-1?Q?G=E1bor_K=F6vesd=E1n?= In-Reply-To: <44ECB023.708@FreeBSD.org> References: <20060814234414.GA57035@hades.panopticon> <44E194BA.2020507@FreeBSD.org> <17634.5246.887894.836856@gromit.timing.com> <20060816173628.GA14848@xor.obsecurity.org> <44ECB023.708@FreeBSD.org> X-Mailer: VM 7.19 under Emacs 21.3.1 X-Virus-Scanned: ClamAV version 0.87.1, clamav-milter version 0.87 on Daffy.timing.com X-Virus-Status: Clean Cc: babak@farrokhi.net, amdmi3@mail.ru, Erwin Lansing , freebsd-ports@FreeBSD.org, Kris Kennaway Subject: Re: DESTDIR implementation [Was:: ATTENTION: is the way DESTDIR was introduced completely wrong?] X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2006 21:16:38 -0000 G=E1bor K=F6vesd=E1n wrote at 21:44 +0200 on Aug 23, 2006: > Kris Kennaway wrote: > > mount_nullfs ${PORTSDIR} ${DESTDIR}${PORTSDIR} > > mount_nullfs ${WRKDIR} ${DESTDIR}${WRKDIR} > > mount_devfs foo ${DESTDIR}/dev > > chroot ${DESTDIR} cd ${.CURDIR} && make install > > > > A suitable version of the above should allow all ports to be install= ed > > into a jail-ready filesystem hierarchy, while requiring 0 port > > changes. > > Ok, I think it's time to follow this way, but have to make some parts = > clearer. For your last line, it should be > = > chroot ${DESTDIR} cd ${.CURDIR} && make ${.TARGETDIR} I assume you mean .TARGET > since we want to run all targets chrooted. We could put this part into= = > an .if defined(DESTDIR) block before the targets, but I don't know how= = > to prevent running the further code, since we don't want to reach = > do-install in the host environment, but only in the chroot. I think of= = > exit 0, if that's correct, or what else is better. > So, what I mean: > = > .if defined(DESTDIR) > .BEGIN # We need this if not in a target > ${MOUNT_NULLFS} ${PORTSDIR} ${DESTDIR}${PORTSDIR} > ${MOUNT_NULLFS} ${WRKDIR} ${DESTDIR}${WRKDIR} > ${MOUNT_DEVFS} foo ${DESTDIR}/dev > ${CHROOT} ${DESTDIR} cd ${.CURDIR} && ${MAKE} ${.TARGETDIR} > exit 0 > .endif Each line with a command in a makefile is it's own shell. So 'exit 0' will start a shell and exit that shell. It will not prevent make from continuing. 'exit 1' (or anything that returns a non-zero code, like false) will stop make (unless -k or -i or similar is specified), but that's not what you want. make(1) is not a very good tool for this kind of thing (a script would probably be better), but here is one way to do this kind of two stage make (untested, but illustrates the point): bsd.port.mk would have something like this: STAGE?=3D 1 =2Eif ${STAGE} =3D=3D 1 && defined(DESTDIR) && !empty(DESTDIR) =2EMAKEFLAGS: STAGE=3D2 =2EBEGIN: ${MOUNT_NULLFS} ${PORTSDIR} ${DESTDIR}${PORTSDIR} ${MOUNT_NULLFS} ${WRKDIR} ${DESTDIR}${WRKDIR} ${MOUNT_DEVFS} foo ${DESTDIR}/dev ${CHROOT} ${DESTDIR} cd ${.CURDIR} && ${MAKE} ${.TARGET} =2Eelse . . rest of bsd.port.mk . . =2Eendif You could put the first part into a bsd.destdir.mk and .include it to make it look cleaner. Note there are other complications like unmounting the nullfs and devfs. > The another issue I find is how we can pass variables to the chrooted = > make. E.g. if we want to set WITH_FOO in command line or in make.conf.= = > And note, that we can't just pass everything, since DESTDIR should be = > unset in the chroot, otherwise we would run into infinite loop and it = > would fail due to the non-existent directories. Really, for these and other reasons, a script would be better. It could be done with make(1) and bsd.port.mk, but it's probably not worth it. Again, if we do decide to go this route, we should remove all mention of DESTDIR from Mk/*.mk (rather than pretend to support it, but incorrectly). Others have mentioned cross building. Neither proper DESTDIR support in bsd.port.mk nor a scripted mount_nullfs & a chroot is going to be the one thing to solve that problem. Some ports will build okay if you give them access to cross tools (like ppc-gcc) and tell them what target architecture to produce. Other ports will need to be taught. Some ports might need to run intermediate native architecture tools produced at build time in order to produce the final cross arch product. It's not as simple as just being able to install to an alternate location. And I don't think it matters much how ports/Mk handles DESTDIR. There are bigger issues.