pkg-plist and WWWDIR

Scot Hetzel swhetzel at gmail.com
Fri Feb 15 16:14:01 UTC 2008


On Fri, Feb 15, 2008 at 6:52 AM, Gergely CZUCZY <phoemix at harmless.hu> wrote:
> Hello
>
> I've been updating sysutils/nut from 2.2.0 to .1, and I've
> hit some issues there.
>
> First of all, bsd.port.mk sets WWWDIR for the actual port,
> which is very nice of it. OTOH the CGI support is optional
> in nut, which results in a conditional entry in pkg-plist.
> the NUT_CGI plist variable is only set if the CGI support
> is enabled, and WWWDIR is an absolute path. If the CGI
> support is enabled, then NUT_CGI is set to an empty string.
> And WWWDIR is added to the PKG_PLIST variables.
>
> The resulting lines in pkg-plist is the following:
> %%NUT_CGI%%%%WWWDIR%%/file
>
> And when the pkg-plist is processed it preprends /usr/local,
> since that's the PREFIX, so it will end up looking for ${PREFIX}/${WWWDIR},
> which will result in /usr/local/usr/local/www/nut/file .
>
> I've checked other ports, %%WWWDIR%% is used directly at other
> places, so I think when an entry begins with a slash that will
> transform to an absolute path, without prepending the PREFIX.
> As i think the conditional %%NUT_CGI%% messes this auto-logic
> up, and the double-prefix happens.
>
> For now I've fixed this with a workaround, by not setting
> the WWWDIR plist variable to WWWDIR, but to "www/nut".
> I don't consider this a solution, but just a workaround.
>
> My qestions are, how should these situations be handled?
> Shouldn't bsd.port.mk export a version for WWWDIR suitable
> for PLIST variables?
>
This situation is already handled in bsd.ports.mk:

WWWDIR_REL?=	${WWWDIR:S,^${PREFIX}/,,}
ETCDIR_REL?=	${ETCDIR:S,^${PREFIX}/,,}

PLIST_SUB+=	DOCSDIR="${DOCSDIR_REL}" \
		EXAMPLESDIR="${EXAMPLESDIR_REL}" \
		DATADIR="${DATADIR_REL}" \
		WWWDIR="${WWWDIR_REL}" \
		ETCDIR="${ETCDIR_REL}"

WWWDIR_REL strips off the PREFIX from WWWDIR, and then adds it to
PLIST_SUB.  The problem is that sysutils/nut/Makefile has redefined
WWWDIR in PLIST_SUB:

.if !exists(${PREFIX}/www) && exists(${PREFIX}/share/apache)
CGIDIR?=	share/apache/cgi-bin
WWWDIR?=	share/apache/htdocs
.else
CGIDIR?=	www/cgi-bin
WWWDIR?=	www/data
.endif
CONFIGURE_ARGS+=	--with-cgi --with-cgipath=${PREFIX}/${CGIDIR}/nut \
			--with-htmlpath=${PREFIX}/${WWWDIR}/nut \
			--with-gd-includes=-I${PREFIX}/include \
			--with-gd-libs="-L${PREFIX}/lib -lgd"
PLIST_SUB+=	NUT_CGI=""
PLIST_SUB+=	WWWDIR="${WWWDIR}"
PLIST_SUB+=	CGIDIR="${CGIDIR}"
PLIST_SUB+=	CGIETCDIR="etc/nut/"
.else
CONFIGURE_ARGS+=	--without-cgi
PLIST_SUB+=	NUT_CGI="@comment "
.endif

If you do a "make -V PLIST_SUB" you'll see the double entry for
WWWDIR.  My guess is the WWWDIR defined in sysutils/nut/Makefile is
before the WWWDIR defined in bsd.port.mk, and since substitutions
occur in order, %%WWWDIR%% is being replaced with the wrong one.

The port needs to remove PLIST_SUB+= WWWDIR=.... from its Makefile.

Scot


More information about the freebsd-ports mailing list