ports/12325: Adds refetch functionallity to bsd.port.mk on
checksum mismathes
Mark Linimon
linimon at lonesome.com
Sat Apr 5 10:18:23 PST 2003
OK, I have a patch which **may** be what you want here.
Disclaimer: I've merely done the mechanical work, not any
logical (debugging) work. I simply don't understand the framework
enough to even begin.
FYI the version of bsd.port.mk which the original patch was done
against was probably r1.313. At least that's what I used as a guideline
based on the date.
--- bsd.port.mk.dist Sat Apr 5 11:58:59 2003
+++ bsd.port.mk Sat Apr 5 12:15:00 2003
@@ -553,6 +553,8 @@
# FETCH_AFTER_ARGS -
# Arguments to ${FETCH_CMD} following filename (default: none).
# FETCH_ENV - Environment to pass to ${FETCH_CMD} (default: none).
+# FETCH_REGET - Attempts to reget a file before giving up (default: 1).
+# Set to 0 (null) if you don't want a reget.
#
# For extract:
#
@@ -1443,11 +1445,13 @@
.if ${OSVERSION} < 300000
FETCH_CMD?= /usr/bin/fetch
.else
-FETCH_CMD?= /usr/bin/fetch -A
+FETCH_CMD?= /usr/bin/fetch -AaR
+FETCH_REGET?= 1
.endif
#FETCH_BEFORE_ARGS+= $${CKSIZE:+-S $$CKSIZE}
.else
FETCH_CMD?= /usr/bin/ftp
+FETCH_REGET?= 0
.endif
TOUCH?= /usr/bin/touch
@@ -2505,6 +2509,24 @@
for _file in ${DISTFILES}; do \
file=`echo $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
select=`echo $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \
+ if [ -f $$file -a "${FORCE_FETCH}" = "$$file" ]; then \
+ for site in ${MASTER_SITES}; do \
+ ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
+ DIR=${DIST_SUBDIR}; \
+ CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK}
'{print $$4}'`; \
+ if ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} -r
$${site}$${file} ${FETCH_AFTER_ARGS}; then \
+ if cd ${.CURDIR} && ${MAKE} checksum ; then\
+ exit 0; \
+ else \
+ ${ECHO_MSG} "Refetch didn't help, still checksum mismatch. I'm giving
up."; \
+ exit 1; \
+ fi; \
+ fi \
+ done; \
+ ${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
+ ${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
+ exit 1; \
+ fi ;\
if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
if [ -L $$file -o -L `${BASENAME} $$file` ]; then \
${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
@@ -3393,6 +3415,16 @@
OK="false"; \
fi; \
done; \
+ if [ "$$OK" != "true" ] && [ ${FETCH_REGET} -gt 0 ]; then \
+ ${ECHO_MSG} "===> Refetch $$file"; \
+ if ( cd ${.CURDIR} && \
+ ${MAKE} ${.MAKEFLAGS} FORCE_FETCH="$$file" FETCH_REGET="`expr
${FETCH_REGET} - 1`" fetch); then \
+ ${ECHO_MSG} ">> Successfully refetched $$file"; \
+ OK="true"; \
+ else \
+ exit 1; \
+ fi; \
+ fi ; \
if [ "$$OK" != "true" ]; then \
${ECHO_MSG} "Make sure the Makefile and distinfo file (${MD5_FILE})"; \
${ECHO_MSG} "are up to date. If you are absolutely sure you want to
override this"; \
More information about the freebsd-ports
mailing list