Optionally depending on one of two ports (or none of them)

Fabian Keil freebsd-listen at fabiankeil.de
Sun Feb 25 16:17:42 UTC 2007


Gabor Kovesdan <gabor at FreeBSD.org> wrote:

> Fabian Keil schrieb:
> > Gabor Kovesdan <gabor at FreeBSD.org> wrote:
> >   
> >
> >> What about grepping in the output of pkg_info? Or even better just 
> >> grepping in ls ${PKG_DBDIR} to determine which one is installed and 
> >> adding the appropriate dependency.
  
> > Are you aware of ports that already do that?
> >
> > I grepped around a bit but didn't find any,
> > and as my make knowledge is rather limited
> > it sounds like too much work to be worth it.

> No, but I made an example for you, you can use this:
> 
> HAVE_TOR_DEVEL!=        if ls /var/db/pkg | grep tor-devel-\* >/dev/null 
> 2>&1 ; then echo YES; fi;

Thanks a lot.

> Or you can make it better by giving a knob for selecting the default.

I added knobs and used pkg_info as suggested by Matthew
to make sure PKG_DBDIR is honoured:

OPTIONS= 	TOR_DEVEL	"Depend on tor-devel"	On \
		TOR		"Depend on tor"		Off

[...]

#HAVE_TOR_DEVEL!= if ls /var/db/pkg | grep ^tor-devel-[[:digit:]] >/dev/null 2>&1 ; then echo YES; fi
HAVE_TOR_DEVEL!= if pkg_info -I tor-devel\* >/dev/null 2>&1 ; then ${ECHO} YES; fi
.if (${HAVE_TOR_DEVEL} == "YES")
OPTIONS=	TOR_DEVEL	"Depend on tor-devel (already installed)"	On
.else
#HAVE_TOR!= if ls /var/db/pkg | egrep ^tor-[[:digit:]] >/dev/null 2>&1 ; then echo YES; fi
HAVE_TOR_DEVEL!= if pkg_info -I tor-\* >/dev/null 2>&1 ; then ${ECHO} YES; fi
.endif
.if (defined(HAVE_TOR) && ${HAVE_TOR} == "YES")
OPTIONS=	TOR		"Depend on tor (already installed)"	On
.endif

.include <bsd.port.pre.mk>

.if defined(WITH_TOR_DEVEL)
.if defined(WITH_TOR)
IGNORE=	cannot depend on tor and tor-devel at the same time
.endif
RUN_DEPENDS+=	${LOCALBASE}/bin/tor:${PORTSDIR}/security/tor-devel
.elif defined(WITH_TOR)
RUN_DEPENDS+=	${LOCALBASE}/bin/tor:${PORTSDIR}/security/tor
.endif

It happens to work, but causes two new portlint warnings:

fk at TP51 /usr/ports/security/dns-proxy-tor $portlint .
WARN: Makefile: [28]: possible direct use of command "pkg_info" found. use ${PKG_INFO} instead.
WARN: Makefile: [33]: possible direct use of command "pkg_info" found. use ${PKG_INFO} instead.
WARN: Makefile: using hyphen in PORTNAME. consider using PKGNAMEPREFIX and/or PKGNAMESUFFIX.
0 fatal errors and 3 warnings found.

Unfortunately the suggestion is bogus as ${PKG_INFO} isn't set that early.
Can I just ignore the warnings, or is there a way around this?

Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20070225/378bbf58/signature.pgp


More information about the freebsd-ports mailing list