[Bug 270706] Mk/Uses/nodejs.mk: fix '.if empty()' usage

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 08 Apr 2023 15:56:47 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270706

            Bug ID: 270706
           Summary: Mk/Uses/nodejs.mk: fix '.if empty()' usage
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: pizzamig@freebsd.org
          Reporter: jcfyecrayz@liamekaens.com
          Assignee: pizzamig@freebsd.org
             Flags: maintainer-feedback?(pizzamig@freebsd.org)

Mk/Uses/nodejs.mk currently has the following:

.  if !empty(${nodejs_ARGS:Nbuild:Nrun:Nlts:Ncurrent:N14:N16:N18:N19})
IGNORE=     USES=nodejs has invalid arguments ${nodejs_ARGS}.
.  endif


'empty' should take an expression that is a variable or variable with modifiers
- such as empty(FOO) or empty(FOO:Nsomething).  It should not normally take the
expansion of the expression - such as empty(${FOO}) or empty(${FOO:Nsomething})
- unless the expansion is a desired variable expression to be tested for
emptiness itself.

For nodejs.mk it wants to check if the nodejs_ARGS variable (with modifiers) is
empty, so it should be:

.  if !empty(nodejs_ARGS:Nbuild:Nrun:Nlts:Ncurrent:N14:N16:N18:N19)
IGNORE=     USES=nodejs has invalid arguments ${nodejs_ARGS}.
.  endif


But there's another error, namely the :N modifiers should include a test for
'env'.  It appears omission of that was just an oversight.  So:

.  if !empty(nodejs_ARGS:Nbuild:Nenv:Nrun:Nlts:Ncurrent:N14:N16:N18:N19)
IGNORE=     USES=nodejs has invalid arguments ${nodejs_ARGS}.
.  endif


Locally this mistake was noticed after www/yarn added USES=nodejs:env, and it
just so happened that the environment had 'env' defined in the environment.  So
that triggered the following incorrect error:

% env env=x make -C www/yarn extract
===>  yarn-1.22.18_1 USES=nodejs has invalid arguments env..
*** Error code 1


After fixing the 'empty()' expression as described above, that same command
does not failure.

If you only fix the missing :Nenv without removing the incorrect expansion of
nodejs_ARGS and modifiers, then the invalid arguments test does not catch the
invalid argument as it should:

% make -C www/yarn extract USES=metaport\ nodejs:inval
===> Fetching all distfiles required by yarn-1.22.18_1 for building
===>  Extracting for yarn-1.22.18_1

-- 
You are receiving this mail because:
You are the assignee for the bug.