pkgbase uses DISTDIR in Makefile.inc1 as an optional environment variable. This conflicts with the global ports environment variable; if someone has DISTDIR set in her environment make packages fails in funny ways. An initial attempt to fix parts of this problem was done in https://svnweb.freebsd.org/base?view=revision&revision=337991 . This change was (a) not enough to fix the entire problem (b) does not fix the underlying problem of the conflict It would be advisable to rename the variable in Makefile.inc1 and also fix the "packages" target to work if a DISTDIR (replacement) variable is set.
A commit references this bug: Author: tcberner Date: Sat Oct 20 16:19:12 UTC 2018 New revision: 482589 URL: https://svnweb.freebsd.org/changeset/ports/482589 Log: databases/kdb: fix build with GCC-based architectures PR: 232293 Submitted by: Piotr Kubaj <pkubaj@anongoth.pl> Changes: head/databases/kdb/Makefile
Also `DISTDIR` is not set when running plain `make packages`. Log shows paths like /usr/obj/tmp/cirrus-ci-build/amd64.amd64/worldstage//METALOG (.../${DISTDIR}/METALOG)
is this still a valid issue ?
(In reply to Baptiste Daroussin from comment #3) Honestly, I cannot say but it's easy to test; set DISTDIR to /home/bapt/distfiles1234 and see if the build works. I have since worked around with a symlink in /usr/ports/distfiles to point elsewhere or use a nullfs mount so I don't have to set DISTDIR anymore in the environment. It's not nice as DISTDIR really was for that in the ports tree and is documented as such in ports(7). Looking at Makefile.inc1 I do see a lot of DISTDIR still but I cannot say if it used consistently these days so that you at least get any (working) result.