ports/87318: [patch] bsd.port.mk - add support for PERL_RUN_DEPENDS and PERL_BUILD_DEPENDS
Edwin Groothuis
edwin at mavetju.org
Wed Oct 12 11:40:19 UTC 2005
>Number: 87318
>Category: ports
>Synopsis: [patch] bsd.port.mk - add support for PERL_RUN_DEPENDS and PERL_BUILD_DEPENDS
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Oct 12 11:40:16 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Edwin Groothuis
>Release: FreeBSD 5.2.1-RELEASE i386
>Organization:
-
>Environment:
System: FreeBSD k7.mavetju 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #8: Wed Dec 15 16:58:01 EST 2004 edwin at k7.mavetju:/usr/src-5.2.1/sys/i386/compile/k7 i386
>Description:
Perl modules produce horrible RUN_DEPENDS and BUILD_DEPENDS:
BUILD_DEPENDS= \
${SITE_PERL}/${PERL_ARCH}/Digest/MD5.pm:${PORTSDIR}/security/p5-Digest-MD5 \
${SITE_PERL}/MIME/Tools.pm:${PORTSDIR}/mail/p5-MIME-Tools \
${SITE_PERL}/Time/Timezone.pm:${PORTSDIR}/devel/p5-Time-modules \
${SITE_PERL}/${PERL_ARCH}/DBD/SQLite2.pm:${PORTSDIR}/databases/p5-DBD-SQLite2 \
${SITE_PERL}/${PERL_ARCH}/XML/Parser.pm:${PORTSDIR}/textproc/p5-XML-Parser \
${SITE_PERL}/${PERL_ARCH}/Curses.pm:${PORTSDIR}/devel/p5-Curses \
${SITE_PERL}/Curses/UI.pm:${PORTSDIR}/devel/p5-Curses-UI \
${SITE_PERL}/Locale/TextDomain.pm:${PORTSDIR}/devel/p5-Locale-libintl
It would be much nicer if you could define it easier:
PERL_BUILD_DEPENDS= \
Digest::MD5:${PORTSDIR}/security/p5-Digest-MD5 \
MIME::Tools:${PORTSDIR}/mail/p5-MIME-Tools \
Time::Timezone:${PORTSDIR}/devel/p5-Time-modules \
DBD::SQLite2:${PORTSDIR}/databases/p5-DBD-SQLite2 \
XML::Parser:${PORTSDIR}/textproc/p5-XML-Parser \
Curses:${PORTSDIR}/devel/p5-Curses \
Curses::UI:${PORTSDIR}/devel/p5-Curses-UI \
Locale::TextDomain:${PORTSDIR}/devel/p5-Locale-libintl
Unfortunately, this introduced too much double code to handle the
::'s. But this layout didn't:
PERL_BUILD_DEPENDS= \
Digest-MD5:${PORTSDIR}/security/p5-Digest-MD5 \
MIME-Tools:${PORTSDIR}/mail/p5-MIME-Tools \
Time-Timezone:${PORTSDIR}/devel/p5-Time-modules \
DBD-SQLite2:${PORTSDIR}/databases/p5-DBD-SQLite2 \
XML-Parser:${PORTSDIR}/textproc/p5-XML-Parser \
Curses:${PORTSDIR}/devel/p5-Curses \
Curses-UI:${PORTSDIR}/devel/p5-Curses-UI \
Locale-TextDomain:${PORTSDIR}/devel/p5-Locale-libintl
>How-To-Repeat:
>Fix:
This patch adds support for PERL_RUN_DEPENDS and PERL_BUILD_DEPENDS
by checking the existance of the Perl modules with the "perl -e
'use module;'" command. It completes all the possible -fetch, -list
and pretty-print targets.
If this patch gets commited, I volunteer for updating the Porters
Manual and, if given a carte blanch, a single sweep to convert all
the ports.
--- bsd.port.mk.orig Wed Oct 12 17:45:38 2005
+++ bsd.port.mk Wed Oct 12 21:32:51 2005
@@ -480,6 +480,18 @@
# package depends on. "lib" is the name of a shared library.
# make will use "ldconfig -r" to search for the library.
# lib can contain extended regular expressions.
+# PERL_BUILD_DEPENDS
+# - A list of "module:dir" tuples of Perl modules this
+# package depends to build. "module" is the name of the Perl
+# module which should be "use"d. make will use
+# "perl -e 'use module'" to check if the module is
+# available.
+# PERL_RUN_DEPENDS
+# - A list of "module:dir" tuples of Perl modules this
+# package depends to run. "module" is the name of the Perl
+# module which should be "use"d. make will use
+# "perl -e 'use module'" to check if the module is
+# available.
# 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.
@@ -1724,6 +1736,10 @@
USE_REINPLACE=yes
.endif
+.if defined(PERL_RUN_DEPENDS) || defined(PERL_BUILD_DEPENDS)
+USE_PERL5_BUILD= yes
+.endif
+
.if ${PERL_LEVEL} >= 500600
.if defined(USE_PERL5) || defined(USE_PERL5_BUILD)
EXTRACT_DEPENDS+=${PERL5}:${PORTSDIR}/lang/${PERL_PORT}
@@ -3800,16 +3816,18 @@
_PATCH_SEQ= patch-message patch-depends patch-dos2unix pre-patch \
pre-patch-script do-patch post-patch post-patch-script
_CONFIGURE_DEP= patch
-_CONFIGURE_SEQ= build-depends lib-depends misc-depends configure-message \
- pre-configure pre-configure-script patch-autotools \
- run-autotools do-configure post-configure post-configure-script
+_CONFIGURE_SEQ= build-depends lib-depends perl-build-depends misc-depends \
+ configure-message pre-configure pre-configure-script \
+ patch-autotools run-autotools do-configure post-configure \
+ post-configure-script
_BUILD_DEP= configure
_BUILD_SEQ= build-message pre-build pre-build-script do-build \
post-build post-build-script
_INSTALL_DEP= build
_INSTALL_SEQ= install-message check-conflicts \
- run-depends lib-depends apply-slist pre-install \
- pre-install-script generate-plist check-already-installed
+ run-depends lib-depends perl-run-depends apply-slist \
+ pre-install pre-install-script generate-plist \
+ check-already-installed
_INSTALL_SUSEQ= check-umask install-mtree pre-su-install \
pre-su-install-script do-install post-install \
post-install-script add-plist-info add-plist-docs \
@@ -4307,7 +4325,7 @@
################################################################
.if !target(depends)
-depends: extract-depends patch-depends lib-depends misc-depends fetch-depends build-depends run-depends
+depends: extract-depends patch-depends lib-depends perl-build-depends perl-run-depends misc-depends fetch-depends build-depends run-depends
.if defined(ALWAYS_BUILD_DEPENDS)
_DEPEND_ALWAYS= 1
@@ -4460,6 +4478,46 @@
done
.endif
+.for deptype in BUILD RUN
+perl-${deptype:L}-depends:
+.if defined(PERL_${deptype}_DEPENDS)
+ @for tupple in ${PERL_${deptype}_DEPENDS}; do \
+ mod=$${tupple%:*}; \
+ mod=`${ECHO_CMD} $${mod} | sed -e 's/\-/::/g'`; \
+ dir=$${tupple##*:}; \
+ ${ECHO_MSG} -n "===> ${PKGNAME} depends on Perl module: $$mod"; \
+ if ${PERL} -e "use $${mod};" 2>/dev/null; then \
+ ${ECHO_MSG} " - found"; \
+ else \
+ ${ECHO_MSG} " - not found"; \
+ ${ECHO_MSG} "===> Verifying install for $$mod in $$dir"; \
+ if [ ! -d "$$dir" ]; then \
+ ${ECHO_MSG} " => No directory for $$mod. Skipping.."; \
+ else \
+ if [ X${USE_PACKAGE_DEPENDS} != "X" ]; then \
+ subpkgfile=`(cd $$dir; ${MAKE} $$depends_args -V PKGFILE)`; \
+ if [ -r "$${subpkgfile}" -a "$$target" = "${DEPENDS_TARGET}" ]; then \
+ ${ECHO_MSG} "===> Installing existing package $${subpkgfile}"; \
+ ${PKG_ADD} $${subpkgfile}; \
+ else \
+ (cd $$dir; ${MAKE} -DINSTALLS_DEPENDS install ) ; \
+ fi; \
+ else \
+ (cd $$dir; ${MAKE} -DINSTALLS_DEPENDS install) ; \
+ fi ; \
+ ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \
+ if ! ${PERL} -e "use $${mod};" 2>/dev/null; then \
+ ${ECHO_MSG} "Error: Perl module \"$${mod}\" does not exist"; \
+ ${FALSE}; \
+ fi; \
+ fi; \
+ fi; \
+ done
+.else
+ @${DO_NADA}
+.endif
+.endfor
+
misc-depends:
.if defined(DEPENDS)
.if !defined(NO_DEPENDS)
@@ -4490,13 +4548,13 @@
# Dependency lists: both build and runtime, recursive. Print out directory names.
all-depends-list:
-.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS)
+.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS) || defined(PERL_BUILD_DEPENDS) || defined(PERL_RUN_DEPENDS)
@${ALL-DEPENDS-LIST}
.endif
ALL-DEPENDS-LIST= \
checked="${PARENT_CHECKED}"; \
- for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
+ for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS} ${PERL_RUN_DEPENDS} ${PERL_BUILD_DEPENDS} " | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
if [ -d $$dir ]; then \
if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \
@@ -4541,7 +4599,7 @@
.if !target(fetch-required)
fetch-required: fetch
@${ECHO_MSG} "===> Fetching all required distfiles for ${PKGNAME} and dependencies"
-.for deptype in EXTRACT PATCH FETCH BUILD RUN
+.for deptype in EXTRACT PATCH FETCH BUILD RUN PERL_BUILD PERL_RUN
.if defined(${deptype}_DEPENDS)
.if !defined(NO_DEPENDS)
@for i in ${${deptype}_DEPENDS}; do \
@@ -4569,7 +4627,7 @@
.if !target(fetch-required-list)
fetch-required-list: fetch-list
-.for deptype in EXTRACT PATCH FETCH BUILD RUN
+.for deptype in EXTRACT PATCH FETCH BUILD RUN PERL_BUILD PERL_RUN
.if defined(${deptype}_DEPENDS)
.if !defined(NO_DEPENDS)
@for i in ${${deptype}_DEPENDS}; do \
@@ -4611,12 +4669,12 @@
# Dependency lists: build and runtime. Print out directory names.
build-depends-list:
-.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
+.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS) || defined(PERL_BUILD_DEPENDS)
@${BUILD-DEPENDS-LIST}
.endif
BUILD-DEPENDS-LIST= \
- for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | ${SORT} -u) $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | ${SORT} -u); do \
+ for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${PERL_BUILD_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | ${SORT} -u) $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | ${SORT} -u); do \
if [ -d $$dir ]; then \
${ECHO_CMD} $$dir; \
else \
@@ -4625,12 +4683,12 @@
done | ${SORT} -u
run-depends-list:
-.if defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS)
+.if defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS) || defined(PERL_RUN_DEPENDS)
@${RUN-DEPENDS-LIST}
.endif
RUN-DEPENDS-LIST= \
- for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':' | ${SORT} -u) $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':' | ${SORT} -u); do \
+ for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS} ${PERL_RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':' | ${SORT} -u) $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':' | ${SORT} -u); do \
if [ -d $$dir ]; then \
${ECHO_CMD} $$dir; \
else \
@@ -4642,7 +4700,7 @@
# and package names.
package-depends-list:
-.if defined(CHILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS)
+.if defined(CHILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS) || defined(PERL_RUN_DEPENDS)
@${PACKAGE-DEPENDS-LIST}
.endif
@@ -4661,7 +4719,7 @@
done; \
fi; \
checked="${PARENT_CHECKED}"; \
- for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
+ for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS} ${PERL_RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
dir=$$(${REALPATH} $$dir); \
if [ -d $$dir ]; then \
if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
@@ -4730,7 +4788,9 @@
@rdirs = map((split /:/)[1], split(q{ }, q{${RUN_DEPENDS}})); \
@ddirs = map((split /:/)[0], split(q{ }, q{${DEPENDS}})); \
@ldirs = map((split /:/)[1], split(q{ }, q{${LIB_DEPENDS}})); \
- for my $$i (\@edirs, \@pdirs, \@fdirs, \@bdirs, \@rdirs, \@ddirs, \@ldirs) { \
+ @prdirs = map((split /:/)[1], split(q{ }, q{${PERL_RUN_DEPENDS}})); \
+ @pbdirs = map((split /:/)[1], split(q{ }, q{${PERL_BUILD_DEPENDS}})); \
+ for my $$i (\@edirs, \@pdirs, \@fdirs, \@bdirs, \@rdirs, \@ddirs, \@ldirs, \@prdirs, \@pbdirs) { \
my @dirs = @$$i; \
@$$i = (); \
for (@dirs) { \
@@ -4754,11 +4814,11 @@
$$xf{$$_} = 1; \
} \
print join(q{ }, sort keys %xf), q{|}; \
- for (@bdirs, @ddirs, @ldirs) { \
+ for (@bdirs, @ddirs, @ldirs, @pbdirs) { \
$$xb{$$_} = 1; \
} \
print join(q{ }, sort keys %xb), q{|}; \
- for (@rdirs, @ddirs, @ldirs) { \
+ for (@rdirs, @ddirs, @ldirs, @prdirs) { \
$$xr{$$_} = 1; \
} \
print join(q{ }, sort keys %xr), q{|}; \
@@ -4819,7 +4879,8 @@
pretty-print-build-depends-list:
.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || \
defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
- defined(LIB_DEPENDS) || defined(DEPENDS)
+ defined(LIB_DEPENDS) || defined(DEPENDS) || \
+ defined(PERL_BUILD_DEPENDS)
@${ECHO_CMD} -n 'This port requires package(s) "'
@${ECHO_CMD} -n `${GREP} '^${PKGNAME}|' ${PORTSDIR}/${INDEXFILE} | ${AWK} -F\| '{print $$8;}'`
@${ECHO_CMD} '" to build.'
@@ -4828,7 +4889,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(DEPENDS) || defined(PERL_RUN_DEPENDS)
@${ECHO_CMD} -n 'This port requires package(s) "'
@${ECHO_CMD} -n `${GREP} '^${PKGNAME}|' ${PORTSDIR}/${INDEXFILE} | ${AWK} -F\| '{print $$9;}'`
@${ECHO_CMD} '" to run.'
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list