Bug 34126 - regexps in the LIB_DEPENDS
Summary: regexps in the LIB_DEPENDS
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-21 19:40 UTC by Mikhail T.
Modified: 2003-02-10 09:15 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (581 bytes, patch)
2002-01-21 19:40 UTC, Mikhail T.
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail T. 2002-01-21 19:40:00 UTC
	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:
Comment 1 Maxim Sobolev freebsd_committer freebsd_triage 2002-01-22 08:03:16 UTC
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!!! 


Comment 2 Maxim Sobolev freebsd_committer freebsd_triage 2002-01-22 08:03:16 UTC
Responsible Changed
From-To: freebsd-ports->portmgr

portmgr material.
Comment 3 Mikhail T. 2002-02-08 07:17:36 UTC
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
Comment 4 Maxim Sobolev freebsd_committer freebsd_triage 2002-02-08 15:59:41 UTC
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.
>
Comment 5 Mikhail T. 2002-02-08 17:26:18 UTC
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
Comment 6 Mikhail Teterin freebsd_committer freebsd_triage 2002-03-12 19:38:14 UTC
State Changed
From-To: feedback->open

The requested feedback was provided with the new version of the patch.
Comment 7 Kris Kennaway freebsd_committer freebsd_triage 2003-02-01 22:55:03 UTC
State Changed
From-To: open->analyzed

I will test this PR in the next build run.
Comment 8 Kris Kennaway freebsd_committer freebsd_triage 2003-02-10 09:14:48 UTC
State Changed
From-To: analyzed->closed

Patch committed, thanks!