Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Aug 2006 21:44:35 +0200
From:      =?ISO-8859-1?Q?G=E1bor_K=F6vesd=E1n?= <gabor@FreeBSD.org>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        babak@farrokhi.net, amdmi3@mail.ru, John E Hein <jhein@timing.com>, freebsd-ports@FreeBSD.org, Erwin Lansing <erwin@FreeBSD.org>
Subject:   Re: DESTDIR implementation [Was:: ATTENTION: is the way DESTDIR was introduced completely wrong?]
Message-ID:  <44ECB023.708@FreeBSD.org>
In-Reply-To: <20060816173628.GA14848@xor.obsecurity.org>
References:  <20060814234414.GA57035@hades.panopticon> <44E194BA.2020507@FreeBSD.org> <17634.5246.887894.836856@gromit.timing.com> <20060816173628.GA14848@xor.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Kris Kennaway wrote:
> On Tue, Aug 15, 2006 at 12:37:50PM -0600, John E Hein wrote:
>
>   
>> The hard part is to get ports writers to think the right way about
>> DESTDIR after ignoring it for so many years.  And once you decide to
>> go about fixing it, there's no way around that problem.
>>     
>
> My preferred solution involves a couple of shell commands, along the
> lines of the following:
>
> 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 installed
> into a jail-ready filesystem hierarchy, while requiring 0 port
> changes.
>
> Kris
>   
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}

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

The new variables I used should be overrideable, if someone would like 
to use some kind of script or so.

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.

-- 
Cheers,

Gabor




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44ECB023.708>