pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Perplexed about LOCALBASE vs. SU_CMD



LOCALBASE must be set at the time of the .if statement (it's like a
CPP conditional, and is evaluated immediately), and at the top of my
etc/mk.conf, I have

LOCALBASE?=     /usr/pkg

before anything else - which is why it works for me.

Regards,
Alistair

On 28 September 2017 at 16:37, John D. Baker <jdbaker%mylinuxisp.com@localhost> wrote:
> For years (soon to be decades) I've always read that using 'sudo' as
> one's SU_CMD could be accomplished by adding:
>
> .if exists(${LOCALBASE}/bin/sudo)
> SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
> .endif
>
> to one's "/etc/mk.conf".
>
> I have never had this work.  If I use the above snippet, I end up with
> the default:
>
>   /usr/bin/su - root -c
>
> Running 'make show-var VARNAME=LOCALBASE' reports the correct
> value:
>
>   /usr/pkg
>
>   $ which sudo
>   /usr/pkg/bin/sudo
>
> yet the existence test for "${LOCALBASE}/bin/sudo" fails while an
> explicit test for "/usr/pkg/bin/sudo" succeeds.  Thus, I've always
> had to keep "/usr/pkg/bin/sudo" hard-coded in this construct.
>
> I tried something like:
>
>   TESTLOCALBASE=${LOCALBASE}
>
> ahead of the test to see if there was something about lazy evaluation
> of variables, but my "TESTLOCALBASE" showed the correct value as well.
> Likewise:
>
>   TESTLOCALBASE=${LOCALBASE}
>   .if exists(${TESTLOCALBASE}/bin/sudo)
>     SU_CMD=     sudo ${SH} -c
>   .endif
>
> fails in the same way.  If I explicitly set:
>
>   TESTLOCALBASE=/usr/pkg
>
> the test succeeds.  In case it matters, I keep pkgsrc-related stuff
> inside of a big:
>
>   .ifdef BSD_PKG_MK
>   [...]
>   .endif
>
> construct in my "/etc/mk.conf" file.  I tried putting the test outside
> it (before the block), but it made no difference.
>
> What's going on and why does it appear to work for everyone else, but
> not me?
>
> --
> |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
> |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
> | X  No HTML/proprietary data in email.   BSD just sits there and works!
> |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645
>


Home | Main Index | Thread Index | Old Index