Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Sep 1999 10:53:08 +0200
From:      Alexander Langer <alex@cichlids.com>
To:        ports@freebsd.org
Subject:   Refetch for bsd.port.mk on checksum errors
Message-ID:  <19990910105308.A1631@cichlids.cichlids.com>

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

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii

Hello!

Please take a look at the included patch. It works well for me.
It refetches the distfiles on md5 checksum errors.
(for example in port audio/dagrab the 0.3.0 version had a file
freebsd-patches.tar.gz and the 0.3.1 version had a new one, but the
same filename. Of course the checksum was wrong. This bsd.port.mk
would have fetched a new one)
Additionally it continues interrupted transfers.

log:
root:/usr/ports/Mk> patch <~alex/bsd.port.mk.diff 
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- bsd.port.mk.old    Mon Jun 21 13:18:36 1999
|+++ bsd.port.mk        Mon Jun 21 13:19:45 1999
--------------------------
Patching file bsd.port.mk using Plan A...
Hunk #1 succeeded at 322 (offset 3 lines).
Hunk #2 succeeded at 706 (offset 16 lines).
Hunk #3 succeeded at 1449 (offset 25 lines).
Hunk #4 succeeded at 2081 (offset 24 lines).
done
root:/usr/ports/Mk> 

root:/usr/ports/math/sc> make
>> sc-6.21.tar.Z doesn't seem to exist on this system.
>> Attempting to fetch from ftp://gatekeeper.dec.com/pub/misc/.
Receiving sc-6.21.tar.Z (180360 bytes): 18%^C
root:/usr/ports/math/sc> 
fetch: retrieving file from FTP server: interrupted by signal: int

ok, I Ctrl-C'd the fetch, so I interrupted it. The distfile-part is
still here.

root:/usr/ports/math/sc> make
===>  Extracting for sc-6.21
>> Checksum mismatch for sc-6.21.tar.Z.
===>  Refetch sc-6.21.tar.Z
>> Attempting to fetch from ftp://gatekeeper.dec.com/pub/misc/.
Receiving sc-6.21.tar.Z (180360 bytes): 100%
139400 bytes transferred in 19.7 seconds  (6.90 Kbytes/s)
>> Checksum OK for sc-6.21.tar.Z.
>> Successfully refetched sc-6.21.tar.Z
===>  Patching for sc-6.21
===>  Applying FreeBSD patches for sc-6.21
===>  Configuring for sc-6.21
===>  Building for sc-6.21
^C
root:/usr/ports/math/sc> 

Alex
-- 
************** I doubt, therefore I might be. **************
*** Send email to <pgp-keys@cichlids.com> to get PGP-Key ***

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename="bsd.port.mk.diff"
Content-Transfer-Encoding: 8bit

--- bsd.port.mk.old	Mon Jun 21 13:18:36 1999
+++ bsd.port.mk	Mon Jun 21 13:19:45 1999
@@ -319,6 +319,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:
 #
@@ -688,11 +690,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
@@ -1420,6 +1424,24 @@
 	@${MKDIR} ${_DISTDIR}
 	@(cd ${_DISTDIR}; \
 	 for file in ${DISTFILES}; do \
+		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 [ -h $$file -o -h `${BASENAME} $$file` ]; then \
 				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
@@ -2035,6 +2057,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 md5 file (${MD5_FILE})"; \
 			${ECHO_MSG} "are up to date.  If you want to override this check, type"; \

--PNTmBPCT7hxwcZjr--


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?19990910105308.A1631>