tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make fetch-list suport for DIST_PATH



I noticed that "make fetch-list | sh" does not behave the same as
"make fetch" with respect to the DIST_PATH variable as documented in
pkgsrc/mk/defaults/mk.conf and pkgsrc/mk/fetch/bsd.fetch-vars.mk.
The attached patch fixes this and I'd like to commit it.  It cribs
the DIST_PATH support from pkgsrc/mk/fetch/fetch.mk

However, there are some nits that I noticed while developing it that
I wanted to get feedback on.

1. It verbosely echos when it takes action, although the curl download
only echos on failure.  Does this matter?

2. It assumes ${_DISTDIR} is an absolute path as it cd's to it twice
in a row.  I could fix this but didn't investigate.

3. I wasn't able to test the support for DYNAMIC_SITES_SCRIPT.  The only
package that uses this appears to be pkgsrc/graphics/ns-cult3d and
the script that it tries to download is no longer available.

4. In the case of DYNAMIC_SITES_SCRIPT, it downloads the dynamic script
even if it found a local copy of the distfile and symlinked it.  Given
the existing brokenness, I didn't bother to optimize this.

Thanks,

Darrin

diff --git a/mk/fetch/fetch-list.mk b/mk/fetch/fetch-list.mk
index 9cddf8f06faf..82e857fee10d 100644
--- a/mk/fetch/fetch-list.mk
+++ b/mk/fetch/fetch-list.mk
@@ -73,13 +73,26 @@ fetch-list-one-pkg:
 			' ${DISTINFO_FILE}` || true;			\
 		${ECHO} '# Fetch ${fetchfile} ('$${filesize-???}' bytes):'; \
 		${ECHO} '#';						\
+		${ECHO} "${MKDIR} ${_DISTDIR}";				\
+		${ECHO}	paths='"'${DIST_PATH:S/:/ /g}'"';		\
+		${ECHO} 'cd ${_DISTDIR} && { [ -f ${fetchfile} -o -f ${fetchfile:T} ] ||'; \
+		${ECHO}	'for path in "" $$paths; do';			\
+		${ECHO}	'	case "$${path}" in';			\
+		${ECHO}	'	""|${DISTDIR})	continue ;;';		\
+		${ECHO}	'	esac;';					\
+		${ECHO} '	file="$${path}/${DIST_SUBDIR:D${DIST_SUBDIR}/}${fetchfile:T}"'; \
+		${ECHO} '	if ${TEST} -f $$file; then';		\
+		${ECHO} '		${ECHO} "Using $$file";';	\
+		${ECHO} '		${RM} -f ${fetchfile:T};';	\
+		${ECHO} '		${LN} -s $$file ${fetchfile:T};'; \
+		${ECHO} '	fi;';					\
+		${ECHO}	'done; }';					\
 		${ECHO} '${SH} -s ${fetchfile:T} <<"EOF" |(';		\
 		${CAT} ${DYNAMIC_SITES_SCRIPT};				\
 		${ECHO} EOF;						\
 		${ECHO} read unsorted_sites;				\
 		${ECHO} 'unsorted_sites="$${unsorted_sites} ${_MASTER_SITE_BACKUP}"'; \
 		${ECHO} sites='"'${_ORDERED_SITES:Q}'"';		\
-		${ECHO} "${MKDIR} ${_DISTDIR}";				\
 		${ECHO} 'cd ${_DISTDIR} && { [ -f ${fetchfile} -o -f ${fetchfile:T} ] ||'; \
 		${ECHO}	'for site in $$sites; do';			\
 		${ECHO}	'	case "$${site}" in';			\
@@ -103,9 +116,22 @@ fetch-list-one-pkg:
 			' ${DISTINFO_FILE}` || true;			\
 		${ECHO} '# Fetch ${fetchfile} ('$${filesize-???}' bytes):'; \
 		${ECHO} '#';						\
+		${ECHO} "${MKDIR} ${_DISTDIR}";				\
+		${ECHO}	paths='"'${DIST_PATH:S/:/ /g}'"';		\
+		${ECHO} 'cd ${_DISTDIR} && { [ -f ${fetchfile} -o -f ${fetchfile:T} ] ||'; \
+		${ECHO}	'for path in "" $$paths; do';			\
+		${ECHO}	'	case "$${path}" in';			\
+		${ECHO}	'	""|${DISTDIR})	continue ;;';		\
+		${ECHO}	'	esac;';					\
+		${ECHO} '	file="$${path}/${DIST_SUBDIR:D${DIST_SUBDIR}/}${fetchfile:T}"'; \
+		${ECHO} '	if ${TEST} -f $$file; then';		\
+		${ECHO} '		${ECHO} "Using $$file";';	\
+		${ECHO} '		${RM} -f ${fetchfile:T};';	\
+		${ECHO} '		${LN} -s $$file ${fetchfile:T};'; \
+		${ECHO} '	fi;';					\
+		${ECHO}	'done; }';					\
 		${ECHO} 'unsorted_sites="${SITES.${fetchfile:T:S/=/--/}} ${_MASTER_SITE_BACKUP}"'; \
 		${ECHO} sites='"'${_ORDERED_SITES:Q}'"';		\
-		${ECHO} "${MKDIR} ${_DISTDIR}";				\
 		${ECHO} 'cd ${_DISTDIR} && { [ -f ${fetchfile} -o -f ${fetchfile:T} ] ||'; \
 		${ECHO}	'for site in $$sites; do';			\
 		${ECHO}	'	case "$${site}" in';			\


Home | Main Index | Thread Index | Old Index