Bug 268299 - PORTSDIR variable not being read from /etc/make.conf when building kernel.
Summary: PORTSDIR variable not being read from /etc/make.conf when building kernel.
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Pankov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-10 14:07 UTC by Jonathan Vasquez
Modified: 2024-11-25 05:19 UTC (History)
2 users (show)

See Also:
linimon: mfc-stable14?
linimon: mfc-stable13?


Attachments
kern.post.mk change to properly expand PORTSDIR (893 bytes, patch)
2022-12-10 16:17 UTC, Yuri
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Vasquez 2022-12-10 14:07:41 UTC
This is a copy/paste of the message I sent to the stable mailing list. I wasn't able to get an official confirmation of behavior, so I'm asking here:

TLDR: So ultimately the question is, is it intended behavior for PORTSDIR to be ignored by the make for buildkernel when it's defined in /etc/make.conf? From what man ports says, /etc/make.conf is suppose to be used for all aspects of building doc, src, and ports.. or is this a bug?

If it helps, I'm running on stable/13-n253245-209ebfa26ec4/GENERIC amd64)

For now, I'm going with a suggested workaround of making a symlink from /usr/ports to /usr/local/poudriere/ports/default.


Hey all,

I'm currently trying to centralize my poudriere ports directory and my normal /usr/ports dir so that I can reduce the load on the central freebsd servers, and also to clean it up on my end.

Since I have PORTS_MODULES defined in my /etc/make.conf, building my kernel will properly automatically rebuild the modules listed properly. This requires your ports directory to exist and working (obviously). Since my ports dir was in the default location: /usr/ports, it was working properly. At the moment I have my poudriere ports directory and distfiles defined at:

/usr/local/poudriere/ports/default (The standard path for poudriere).
/usr/local/poudriere/distfiles

I went ahead and added the following to /etc/make.conf:

PORTSDIR=/usr/local/poudriere/ports/default
DISTDIR=/usr/local/poudriere/distfiles

However, when running a "make -j32 buildkernel", the PORTSDIR variable doesn't get read in properly and will default to /usr/ports. I tried placing in another variable (that I saw in the module rebuilding phase of buildkernel) in /etc/make.conf to see if that was working properly, I picked SRC_BASE as an example (I also wanted to test if variable substitution was working properly as well):

/etc/make.conf:

_TEST="/omega"
SRC_BASE="${_TEST}/lol"

Running make -j32 buildkernel again properly displayed the "/omega/lol" path for SRC_BASE, but the PORTSDIR still was ignored. I then tried inlining the variable to see if that worked:

make -j32 buildkernel PORTSDIR="/some/path"

and that worked. There was one or two times that I was able to non-deterministically get the PORTSDIR to be read in from /etc/make.conf, but for the most part, it was ignored 99% of the time. Running "make buildkernel" without any parallelization didn't help either.


Thank you,
Comment 1 Yuri 2022-12-10 16:17:27 UTC
Created attachment 238693 [details]
kern.post.mk change to properly expand PORTSDIR

There was similar discussion on current@ recently with a suggestion of putting PORTSDIR to /etc/src{,-env}.conf which did not work for me.

Looks like the expansion does not happen properly (for me, at least) in kern.post.mk and the attached patch (note, it's against main) seems to help with PORTSDIR specified in one of /etc/{make,src,src-env}.conf files or in environment.
Comment 2 Yuri 2022-12-24 12:07:37 UTC
Created review D37868.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-03-27 12:00:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=12496806098d9d9915817edcd0df17cdd27f60c8

commit 12496806098d9d9915817edcd0df17cdd27f60c8
Author:     Yuri Pankov <yuripv@FreeBSD.org>
AuthorDate: 2023-03-27 11:42:31 +0000
Commit:     Yuri Pankov <yuripv@FreeBSD.org>
CommitDate: 2023-03-27 11:57:57 +0000

    kern.post.mk: fix PORTSDIR handling

    Using subshell's PORTSDIR variable (via $${PORTSDIR}}) seems to be
    only working if PORTSDIR is specified directly on the make command
    line.

    Use ${PORTDIR} here instead so that setting the variable in
    /etc/{make,src,src-env}.conf would work (also works for variable
    being set on command line or in the environment).

    PR:             268299
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D37868

 sys/conf/kern.post.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)