ports/82661: [patch] Add support to filter MASTER_SITES and PATCH_SITES by protocol in bsd.port.mk

Vasil Dimov vd at datamax.bg
Sun Jun 26 10:00:36 UTC 2005


>Number:         82661
>Category:       ports
>Synopsis:       [patch] Add support to filter MASTER_SITES and PATCH_SITES by protocol in bsd.port.mk
>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:   Sun Jun 26 10:00:35 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Vasil Dimov
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
DataMax
>Environment:

>Description:

Add support to fetch only from sites whose names (inluding the protocol)
start with user-defined string. This can be used to fetch only from http
or ftp sites.

Vaida Bogdan <vaidab at Safe-mail.net> requested this feature in PR/82309
and I think it will be useful.

In the implementation user-variable FETCH_ONLY_SITES is introduced that
contains list of allowed prefixes, for example: FETCH_ONLY_SITES=ftp://
will allow fetching only from ftp sites. By the way the same can be
achieved with FETCH_ONLY_SITES=ftp

I have placed a shell function in a make variable and
define/use it two times (for distfiles and patchfiles)
to avoid the copy-paste technology :-)

>How-To-Repeat:

>Fix:

--- bsd.port.mk_fetch_only_site.diff begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.515
diff -u -r1.515 bsd.port.mk
--- bsd.port.mk	24 Jun 2005 09:18:54 -0000	1.515
+++ bsd.port.mk	26 Jun 2005 09:39:24 -0000
@@ -138,6 +138,10 @@
 # CD_MOUNTPTS	- List of CDROM mountpoints to look for distfiles under.
 #				  This variable supercedes CD_MOUNTPT, which is
 #				  obsolete.
+# FETCH_ONLY_SITES
+#				- List of allowed prefixes for sites from which to try to fetch
+#				distfiles and patchfiles.
+#				Example: FETCH_ONLY_SITES=http fetch only from http sites.
 #
 # Set these if your port should not be built under certain circumstances.
 # These are string variables; you should set them to the reason why
@@ -3109,9 +3113,30 @@
 # Fetch
 
 .if !target(do-fetch)
+
+FUNC_FETCH_FILTER_SITE=\
+fetch_filter_site() { \
+	site=$${1} ; \
+	ret=1 ; \
+	if [ -n "${FETCH_ONLY_SITES}" ] ; then \
+		ret=0 ; \
+		for fetch_only_site in ${FETCH_ONLY_SITES} ; do \
+			if [ "$${site}" != "$${site\#$${fetch_only_site}}" ] ; then \
+				ret=1 ; \
+				break ; \
+			fi ; \
+		done ; \
+	fi ; \
+	if [ $${ret} -eq 0 ] ; then \
+		${ECHO_MSG} "=> Skipping site $${site} due to FETCH_ONLY_SITES filter." ; \
+	fi ; \
+	return $$ret ; \
+}
+
 do-fetch:
 	@${MKDIR} ${_DISTDIR}
-	@(cd ${_DISTDIR}; \
+	@(${FUNC_FETCH_FILTER_SITE} ; \
+	 cd ${_DISTDIR}; \
 	 ${_MASTER_SITES_ENV} ; \
 	 for _file in ${DISTFILES}; do \
 		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
@@ -3160,7 +3185,10 @@
 				SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
 			fi ; \
 			for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
-			    ${ECHO_MSG} "=> Attempting to fetch from $${site}."; \
+				if fetch_filter_site "$${site}" ; then \
+					continue ; \
+				fi ; \
+				${ECHO_MSG} "=> Attempting to fetch from $${site}."; \
 				DIR=${DIST_SUBDIR}; \
 				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
 				case $${file} in \
@@ -3178,7 +3206,8 @@
 	    fi \
 	 done)
 .if defined(PATCHFILES)
-	@(cd ${_DISTDIR}; \
+	@(${FUNC_FETCH_FILTER_SITE} ; \
+	 cd ${_DISTDIR}; \
 	 ${_PATCH_SITES_ENV} ; \
 	 for _file in ${PATCHFILES}; do \
 		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
@@ -3213,6 +3242,9 @@
 				SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
 			fi ; \
 			for site in `eval $$SORTED_PATCH_SITES_CMD_TMP`; do \
+				if fetch_filter_site "$${site}" ; then \
+					continue ; \
+				fi ; \
 			    ${ECHO_MSG} "=> Attempting to fetch from $${site}."; \
 				DIR=${DIST_SUBDIR}; \
 				pattern="$${DIR:+$$DIR/}`${ECHO_CMD} $$file | ${SED} -e 's/\./\\\\./g'`"; \
--- bsd.port.mk_fetch_only_site.diff ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list