Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Apr 2001 00:46:54 +0200
From:      Anton Berezin <tobez@tobez.org>
To:        ports@freebsd.org
Cc:        Mark Murray <mark@grondar.za>, Josef Karthauser <joe@tao.org.uk>
Subject:   Request for review: new *_DEPENDS thingy: PERLPM_DEPENDS
Message-ID:  <20010416004654.A13090@heechee.tobez.org>

next in thread | raw e-mail | index | archive | help
Hi,

Quite a number of p5 (and other) ports, which depend upon some perl
modules, would benefit from a mechanism that allows to specify such
module dependencies, not unlike the existing LIB_DEPENDS, which only
works for shared libraries.

Currently such dependencies are usually solved by a kludge like this:

BUILD_DEPENDS=	${LOCALBASE}/lib/perl5/site_perl/${PERL_VER}/NetAddr/IP.pm:${PORTSDIR}/net/p5-NetAddr-IP
RUN_DEPENDS=	${BUILD_DEPENDS}

This has two problems:  first, it is often (though admittedly not
always) necessary to specify both BUILD_DEPENDS and RUN_DEPENDS.  This
is nasty, redundant, and confuses portlint.

Second, using a direct filepath can lead to problems, when a dependency
module is already present as a part of the system Perl distribution.  As
an example, look at the devel/p5-File-Temp port.  At least on -current,
there is perfectly legitimate File::Spec, yet this port insists on
installing devel/p5-File-Spec.

I suggest to add another way to specify Perl module dependencies.  Then,
the example above will look like this:

PERLPM_DEPENDS=	NetAddr/IP:${PORTSDIR}/net/p5-NetAddr-IP

I use `/' here instead of more canonical (for Perl) `::' for obvious
reasons.

I will be happy to submit the diffs for the existing ports, if
PERLPM_DEPENDS idea is accepted (and committed).

Here's the patch against fresh bsd.port.mk:


--- Mk/bsd.port.mk	Wed Apr  4 01:08:12 2001
+++ Mk/bsd.port.mk	Mon Apr 16 00:30:51 2001
@@ -202,6 +202,12 @@
 #				  package depends on.  "lib" is the name of a shared library.
 #				  make will use "ldconfig -r" to search for the
 #				  library.  Note that lib can not contain regular expressions.
+# PERLPM_DEPENDS - A list of "module:dir[:target]" tuples of other ports this
+#				  package depends on.  "module" is the name of a perl module,
+#				  where `::' are replaced with `/'.
+#				  make will search perl's @INC for a file named "module" or
+#				  "module.pm'.  Note that "module" can not contain regular
+#				  expressions.
 # DEPENDS		- A list of "dir[:target]" tuples of other ports this
 #				  package depends on being made first.  Use this only for
 #				  things that don't fall into the above four categories.
@@ -1937,7 +1943,7 @@
 .endif
 .if make(real-extract)
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} checksum REAL_EXTRACT=yes
-	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} build-depends lib-depends misc-depends
+	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} build-depends lib-depends perlpm-depends misc-depends
 .endif
 .if make(real-install)
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} check-categories
@@ -1957,7 +1963,7 @@
 		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
 		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
 	fi
-	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} run-depends lib-depends
+	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} run-depends lib-depends perlpm-depends
 .endif
 .if make(real-install)
 	@${MKDIR} ${PREFIX}
@@ -2444,7 +2450,7 @@
 ################################################################
 
 .if !target(depends)
-depends: lib-depends misc-depends
+depends: lib-depends perlpm-depends misc-depends
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} fetch-depends
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} build-depends
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} run-depends
@@ -2572,6 +2578,56 @@
 	@${DO_NADA}
 .endif
 
+perlpm-depends:
+.if defined(PERLPM_DEPENDS)
+.if !defined(NO_DEPENDS)
+	@for i in ${PERLPM_DEPENDS}; do \
+		perlpm=`${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 \
+			target="${DEPENDS_TARGET}"; \
+			depends_args="${DEPENDS_ARGS}"; \
+		fi; \
+		if ${PERL} -e "delete @ENV{qw(PERL5LIB PERLLIB)}; \
+				for (@INC) { -f qq(\$$_/$${perlpm}) || -f qq(\$$_/$${perlpm}.pm) \
+					and exit(0) } exit 1"; then \
+			${ECHO_MSG} "===>   ${PKGNAME} depends on perl module: $$perlpm - found"; \
+			if [ ${_DEPEND_ALWAYS} = 1 ]; then \
+				${ECHO_MSG} "       (but building it anyway)"; \
+				notfound=1; \
+			else \
+				notfound=0; \
+			fi; \
+		else \
+			${ECHO_MSG} "===>   ${PKGNAME} depends on perl module: $$perlpm - not found"; \
+			notfound=1; \
+		fi; \
+		if [ $$notfound != 0 ]; then \
+			${ECHO_MSG} "===>    Verifying $$target for $$perlpm in $$dir"; \
+			if [ ! -d "$$dir" ]; then \
+				${ECHO_MSG} "     >> No directory for $$perlpm.  Skipping.."; \
+			else \
+				(cd $$dir; ${MAKE} $$target $$depends_args) ; \
+				${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
+				if ${PERL} -e "delete @ENV{qw(PERL5LIB PERLLIB)}; \
+						for (@INC) { -f qq(\$$_/$${perlpm}) || -f qq(\$$_/$${perlpm}.pm) \
+							and exit(0) } exit 1"; then \
+					${TRUE}; \
+				else \
+					${ECHO_MSG} "Error: perl module \"$$perlpm\" does not exist"; \
+					${FALSE}; \
+				fi; \
+			fi; \
+		fi; \
+	done
+.endif
+.else
+	@${DO_NADA}
+.endif
+
 misc-depends:
 .if defined(DEPENDS)
 .if !defined(NO_DEPENDS)
@@ -2606,7 +2662,7 @@
 
 ALL-DEPENDS-LIST= \
 	checked="${PARENT_CHECKED}"; \
-	for dir in $$(${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//') $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'); do \
+	for dir in $$(${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${PERLPM_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//') $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'); do \
 		if [ -d $$dir ]; then \
 			if (${ECHO} $$checked | ${GREP} -qwv "$$dir"); then \
 				child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \
@@ -2662,7 +2718,7 @@
 	@${BUILD-DEPENDS-LIST}
 
 BUILD-DEPENDS-LIST= \
-	for dir in $$(${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u) $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u); do \
+	for dir in $$(${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${PERLPM_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u) $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u); do \
 		if [ -d $$dir ]; then \
 			${ECHO} $$dir; \
 		else \
@@ -2674,7 +2730,7 @@
 	@${RUN-DEPENDS-LIST}
 
 RUN-DEPENDS-LIST= \
-	for dir in $$(${ECHO} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u) $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u); do \
+	for dir in $$(${ECHO} "${LIB_DEPENDS} ${PERLPM_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u) $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u); do \
 		if [ -d $$dir ]; then \
 			${ECHO} $$dir; \
 		else \
@@ -2689,7 +2745,7 @@
 
 PACKAGE-DEPENDS-LIST= \
 	checked="${PARENT_CHECKED}"; \
-	for dir in $$(${ECHO} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//') $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'); do \
+	for dir in $$(${ECHO} "${LIB_DEPENDS} ${PERLPM_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//') $$(${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'); do \
 		if [ -d $$dir ]; then \
 			if (${ECHO} $$checked | ${GREP} -qwv "$$dir"); then \
 				child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" package-depends-list); \
@@ -2737,7 +2793,7 @@
 			print "|/dev/null"; \
 		} \
 		print q#|${MAINTAINER}|${CATEGORIES}|#; \
-		for (split /\s+/, "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}") { \
+		for (split /\s+/, "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${PERLPM_DEPENDS}") { \
 			next if /^$$/; \
 			s/^[^:]*\://; \
 			s/\:.*//; \
@@ -2747,7 +2803,7 @@
 				push @bdirs, $$_; \
 			} \
 		} \
-		for (split /\s+/, "${LIB_DEPENDS} ${RUN_DEPENDS}") { \
+		for (split /\s+/, "${LIB_DEPENDS} ${PERLPM_DEPENDS} ${RUN_DEPENDS}") { \
 			next if /^$$/; \
 			s/^[^:]*\://; \
 			s/\:.*//; \
@@ -2830,7 +2886,7 @@
 .if !target(pretty-print-build-depends-list)
 pretty-print-build-depends-list:
 .if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
-	defined(LIB_DEPENDS) || defined(DEPENDS)
+	defined(LIB_DEPENDS) || defined(PERLPM_DEPENDS) || defined(DEPENDS)
 	@${ECHO} -n 'This port requires package(s) "'
 	@${ECHO} -n `${GREP} '^${PKGNAME}|' ${PORTSDIR}/INDEX | awk -F\| '{print $$8;}'`
 	@${ECHO} '" to build.'
@@ -2839,7 +2895,8 @@
 
 .if !target(pretty-print-run-depends-list)
 pretty-print-run-depends-list:
-.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
+.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || \
+	defined(PERLPM_DEPENDS) || defined(DEPENDS)
 	@${ECHO} -n 'This port requires package(s) "'
 	@${ECHO} -n `${GREP} '^${PKGNAME}|' ${PORTSDIR}/INDEX | awk -F\| '{print $$9;}'`
 	@${ECHO} '" to run.'


What do you think?

Cheers,
%Anton.
-- 
May the tuna salad be with you.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010416004654.A13090>