diff options
author | xtraeme <xtraeme> | 2005-03-22 22:20:21 +0000 |
---|---|---|
committer | xtraeme <xtraeme> | 2005-03-22 22:20:21 +0000 |
commit | a5c1bfa6ad5b08e996acbfd30c3c73608edf6f26 (patch) | |
tree | 364f7d3d470f6ee0640a1439f50c9769b5541710 /mk/bsd.pkg.mk | |
parent | 77d561783485e6c5d0a6165432fa75da4b694870 (diff) | |
download | pkgsrc-a5c1bfa6ad5b08e996acbfd30c3c73608edf6f26.tar.gz |
Some changes for PKG_RESUME_TRANSFERS:
o If origfile is already downloaded (size ok) and there's
a temp file with incomplete size, don't try to resume the
transfer on the temp file, remove it.
o Clean the code a bit.
Diffstat (limited to 'mk/bsd.pkg.mk')
-rw-r--r-- | mk/bsd.pkg.mk | 108 |
1 files changed, 63 insertions, 45 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk index 40eadfac7c8..e8473edf572 100644 --- a/mk/bsd.pkg.mk +++ b/mk/bsd.pkg.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.mk,v 1.1601 2005/03/20 18:18:09 jmmv Exp $ +# $NetBSD: bsd.pkg.mk,v 1.1602 2005/03/22 22:20:21 xtraeme Exp $ # # This file is in the public domain. # @@ -1223,52 +1223,70 @@ package: ### the original name. ### -_RESUME_TRANSFER= \ +_RESUME_TRANSFER= \ + ofile="${DISTDIR}/${DIST_SUBDIR}/$$bfile"; \ + tfile="${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp"; \ tsize=`${AWK} '/^Size/ && $$2 == '"\"($$file)\""' { print $$4 }' ${DISTINFO_FILE}` || ${TRUE}; \ - if [ ! -f "${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp" ]; then \ - ${CP} ${DISTDIR}/${DIST_SUBDIR}/$$bfile ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp; \ - fi; \ - dsize=`${WC} -c < ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp`; \ - if [ "$$dsize" -eq "$$tsize" -a -f "${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp" ]; then \ - ${MV} ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp ${DISTDIR}/${DIST_SUBDIR}/$$bfile; \ - fi; \ - case "$$tsize" in \ - "") ${ECHO_MSG} "No size in distinfo file (${DISTINFO_FILE})"; \ - break ;; \ - esac; \ - if [ -n "$$ftp_proxy" -o -n "$$http_proxy" ]; then \ + osize=`${WC} -c < $$ofile`; \ + \ + case "$$tsize" in \ + "") ${ECHO_MSG} "No size in distinfo file (${DISTINFO_FILE})"; \ + break;; \ + esac; \ + \ + if [ "$$osize" -eq "$$tsize" ]; then \ + if [ -f "$$tfile" ]; then \ + ${RM} $$tfile; \ + fi; \ + need_fetch=no; \ + break; \ + elif [ "$$osize" -lt "$$tsize" -a ! -f "$$tfile" ]; then \ + ${CP} $$ofile $$tfile; \ + dsize=`${WC} -c < $$tfile`; \ + need_fetch=yes; \ + elif [ -f "$$tfile" -a "$$dsize" -gt "$$ossize" ]; then \ + dsize=`${WC} -c < $$tfile`; \ + need_fetch=yes; \ + else \ + dsize=`${WC} -c < $$tfile`; \ + need_fetch=yes; \ + fi; \ + if [ "$$need_fetch" = "no" ]; then \ + break; \ + elif [ -f "$$tfile" -a "$$dsize" -eq "$$tsize" ]; then \ + ${MV} $$tfile $$ofile; \ + break; \ + elif [ -n "$$ftp_proxy" -o -n "$$http_proxy" ]; then \ ${ECHO_MSG} "===> Resume is not supported by ftp(1) using http/ftp proxies."; \ - break; \ - else \ - if [ "$$dsize" -lt "$$tsize" ]; then \ - if [ "${FETCH_CMD:T}" != "ftp" -a -z "${FETCH_RESUME_ARGS}" ]; then \ - ${ECHO_MSG} "=> Resume transfers are not supported, FETCH_RESUME_ARGS is empty."; \ - break; \ - else \ - for res_site in $$sites; do \ - if [ -z "${FETCH_OUTPUT_ARGS}" ]; then \ - ${ECHO_MSG} "=> FETCH_OUTPUT_ARGS has to be defined."; \ - break; \ - fi; \ - ${ECHO_MSG} "=> $$bfile not completed, resuming:"; \ - ${ECHO_MSG} "=> Downloaded: $$dsize Total: $$tsize."; \ - ${ECHO_MSG}; \ - cd ${_DISTDIR}; \ - ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${FETCH_RESUME_ARGS} \ - ${FETCH_OUTPUT_ARGS} $${bfile}.temp $${res_site}$${bfile}; \ - if [ $$? -eq 0 ]; then \ - ndsize=`${WC} -c < ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp`; \ - if [ "$$tsize" -eq "$$ndsize" ]; then \ - ${MV} ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp ${DISTDIR}/${DIST_SUBDIR}/$$bfile; \ - fi; \ - break; \ - fi; \ - done; \ - fi; \ - elif [ "$$dsize" -gt "$$tsize" ]; then \ - ${ECHO_MSG} "==> Downloaded file larger than the recorded size."; \ - break; \ - fi; \ + break; \ + elif [ "$$need_fetch" = "yes" -a "$$dsize" -lt "$$tsize" ]; then \ + if [ "${FETCH_CMD:T}" != "ftp" -a -z "${FETCH_RESUME_ARGS}" ]; then \ + ${ECHO_MSG} "=> Resume transfers are not supported, FETCH_RESUME_ARGS is empty."; \ + break; \ + else \ + for res_site in $$sites; do \ + if [ -z "${FETCH_OUTPUT_ARGS}" ]; then \ + ${ECHO_MSG} "=> FETCH_OUTPUT_ARGS has to be defined."; \ + break; \ + fi; \ + ${ECHO_MSG} "=> $$bfile not completed, resuming:"; \ + ${ECHO_MSG} "=> Downloaded: $$dsize Total: $$tsize."; \ + ${ECHO_MSG}; \ + cd ${DISTDIR}; \ + ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${FETCH_RESUME_ARGS} \ + ${FETCH_OUTPUT_ARGS} $${bfile}.temp $${res_site}$${bfile}; \ + if [ $$? -eq 0 ]; then \ + ndsize=`${WC} -c < $$tfile`; \ + if [ "$$tsize" -eq "$$ndsize" ]; then \ + ${MV} $$tfile $$ofile; \ + fi; \ + break; \ + fi; \ + done; \ + fi; \ + elif [ "$$dsize" -gt "$$tsize" ]; then \ + ${ECHO_MSG} "==> Downloaded file larger than the recorded size."; \ + break; \ fi # |