Currently, the libraries a port depends on can only be specified exactly with or without the version number, even though, quite often an exact version number is not important, as long as it is above certain value. In some other occasions, certain flavor of a library would satisfy a port too, but the flavor is named differently. Allowing ports to use regular expression to specify the dependencies in general, and LIB_DEPENDS in particular can be a useful feature of the ports. Fix: This patch seems sufficient to me:
State Changed From-To: open->feedback The patch is insufficient because of the following: 1. Documentation wasn't updated to reflect the change of semantics. 2. Because of dot's special RE meaning the patch could lead to a wrong matches, following is a short example: $ echo qt23.1234 | grep -qwE qt.3 && echo 'Bzzt, Wrong!!!' Bzzt, Wrong!!!
Responsible Changed From-To: freebsd-ports->portmgr portmgr material.
Ok, how about the following patch. It only deals with the bsd.port.mk. If aproved, I'll do a patch for the porter's guide. The issues -- allow specifying regular expressions in the library names and versions of the LIB_DEPENDS items. If there is more than one or none ``.'' for some reason, the whole "library" is taken as a template. If there is just one dot, as in lib.V, the template passed to egrep will be lib\.V. [The patch also replaces a bunch of sed(1) invocations with the sh(1)'s expressions. No need to spawn off an external process for something, shell can do itself. A LOT more of such fixes should be applied elsewhere in this and other makefile :-\] =================================================================== RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v retrieving revision 1.397 diff -U2 -r1.397 bsd.port.mk --- bsd.port.mk 24 Jan 2002 01:15:03 -0000 1.397 +++ bsd.port.mk 8 Feb 2002 07:11:11 -0000 @@ -2964,18 +2964,23 @@ lib-depends: -.if defined(LIB_DEPENDS) -.if !defined(NO_DEPENDS) - @for i in ${LIB_DEPENDS}; do \ - lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \ - dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \ - if ${EXPR} "$$dir" : '.*:' > /dev/null; then \ - target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \ - dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \ - else \ +.if defined(LIB_DEPENDS) && !defined(NO_DEPENDS) + @for i in ${LIB_DEPENDS}; do \ + lib=$${i%%:*}; \ + case $$lib in \ + *.*.*) pattern=$$lib ;;\ + *.*) pattern="$${lib%%.*}\.$${lib#*.}" ;;\ + *) pattern=$$lib ;;\ + esac; \ + dir=$${i#*:}; \ + target=$${i##*:}; \ + if ${TEST} $$dir = $$target; then \ target="${DEPENDS_TARGET}"; \ depends_args="${DEPENDS_ARGS}"; \ + else \ + dir=$${dir%%:*}; \ fi; \ - if ${LDCONFIG} -r | ${GREP} -qwF -e "-l$$lib"; then \ - ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib - found"; \ + ${ECHO_MSG} -n "===> ${PKGNAME} depends on shared library: $$lib"; \ + if ${LDCONFIG} -r | ${GREP} -qwE -e "-l$$pattern"; then \ + ${ECHO_MSG} " - found"; \ if [ ${_DEPEND_ALWAYS} = 1 ]; then \ ${ECHO_MSG} " (but building it anyway)"; \ @@ -2985,5 +2990,5 @@ fi; \ else \ - ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib - not found"; \ + ${ECHO_MSG} " - not found"; \ notfound=1; \ fi; \ @@ -2995,7 +3000,5 @@ (cd $$dir; ${MAKE} $$target $$depends_args) ; \ ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ - if ${LDCONFIG} -r | ${GREP} -qwF -e "-l$$lib"; then \ - ${TRUE}; \ - else \ + if ! ${LDCONFIG} -r | ${GREP} -qwE -e "-l$$pattern"; then \ ${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \ ${FALSE}; \ @@ -3004,7 +3007,4 @@ fi; \ done -.endif -.else - @${DO_NADA} .endif
I'm still not convinced that `put regexs everywhere' is the right attitude. For something as simple as library version numbers simple ranges should be sufficient, i.e.: LIB_DEPENDS= foo.[10-15] bsd.port.mk is already overloaded, so that we shouldn't obfuscate it further with practically useless features. Of course I'm speaking for myself only. Other portmgr@ people could have different views. -Maxim Mikhail Teterin wrote: > > The following reply was made to PR ports/34126; it has been noted by GNATS. > > From: Mikhail Teterin <mi@aldan.algebra.com> > To: freebsd-gnats-submit@FreeBSD.org > Cc: > Subject: Re: ports/34126: regexps in the LIB_DEPENDS > Date: Fri, 08 Feb 2002 03:33:37 -0500 > > Heck, the ``set -x; '' in the previous patch is the debugging remnant. > Should be changed to ``@'', of course. >
On 8 Feb, Maxim Sobolev wrote: > I'm still not convinced that `put regexs everywhere' is the right > attitude. For something as simple as library version numbers simple > ranges should be sufficient, i.e.: > > LIB_DEPENDS= foo.[10-15] What about tcl83.so vs. tcl84.so? A lot of ports don't care, which tcl it is, for example... Implementing such range processing is actually harder, I think. The regexps are given to us by grep -- for free. > bsd.port.mk is already overloaded, so that we shouldn't obfuscate it > further with practically useless features. Ok, if this passes, I'll de-obfuscate it a bit by replacing some more of those sed/tr/awk invocations by the shell expressions :-) . Deal? -mi
State Changed From-To: feedback->open The requested feedback was provided with the new version of the patch.
State Changed From-To: open->analyzed I will test this PR in the next build run.
State Changed From-To: analyzed->closed Patch committed, thanks!