Jörn Clausen <joe...@googlemail.com> writes: >> If the pkg_chk "binary" compiled in /vol/pkg/20190803 looks in /usr/pkg >> at all, I'd say that's a bug, and patch welcome. > > As I said, I am bad at guessing, so what's the correct approach here: > > The problem is, that pkg_chk tries to determine PKGSRCDIR and > LOCALBASE and gets both wrong. The code in extract_mk_var() seems not > to be working as intended. LOCALBASE is set correctly later, because > it is defined in mk.conf generated by bootstrap, but PKGSRCDIR is > empty and thus assumed to be /usr/pkgsrc.
That's the bug. The right thing, IMHO of course, absent run-time switches, is to have had these variables determined at build time and substituted in. See pkgtools/pkg_rolling-replace for an example that substitutes PREFIX and the location of mk.conf. (Not that this is special; that's just what I knew how to find fast.) > So I added PKGSRCDIR to mk.conf, and pkg_chk behaved as intended, i.e. > neither pkgchk.conf nor binary packages were assumed to be under > /usr/pkgsrc. You have found a good workaround. > So the easy fix would be to have bootstrap also generate a definition > for PKGSRCDIR in the initial mk.conf. I'd call that a workoarond not a fix. > The hard(er) fix would be to > help pkg_chk in guessing the correct values if they are not explicitly > defined. Opinions? No guessing is needed; this is known when pkg_chk is built.