diff options
author | xtraeme <xtraeme> | 2004-10-26 21:14:59 +0000 |
---|---|---|
committer | xtraeme <xtraeme> | 2004-10-26 21:14:59 +0000 |
commit | 326adc30e5abe78e4bbf5e9e864760e30c5875e9 (patch) | |
tree | 4e3539641ba56f3d115b750c1f265c7c2582ed5c /mk | |
parent | 5488d3b0cfecab361324d80ad46ec94a5d9296b6 (diff) | |
download | pkgsrc-326adc30e5abe78e4bbf5e9e864760e30c5875e9.tar.gz |
2nd round for PKG_RESUME_TRANSFERS:
* Add FETCH_OUTPUT_ARGS (new option, defaults to "-o" with NetBSD's ftp(1))
* Use FETCH_OUTPUT_ARGS to move the file transfer to a temporary name
on ${DISTDIR}/${DIST_SUBDIR} with extension ".temp"
* If temporary file matches the checksum recorded in distinfo, move it
to the original name (removing temp file)
For example, if you want to use PKG_RESUME_TRANSFERS with wget
(pkgsrc/net/wget), the following vars should be defined in mk.conf:
FETCH_CMD=wget
FETCH_RESUME_ARGS=-c
FETCH_OUTPUT_ARGS=-O
No need to set these vars when using defaults (NetBSD's ftp(1))
Diffstat (limited to 'mk')
-rw-r--r-- | mk/bsd.pkg.mk | 64 | ||||
-rw-r--r-- | mk/defaults/mk.conf | 12 |
2 files changed, 62 insertions, 14 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk index e7db8ca146d..d32a16b4e7f 100644 --- a/mk/bsd.pkg.mk +++ b/mk/bsd.pkg.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.mk,v 1.1524 2004/10/26 02:23:37 lukem Exp $ +# $NetBSD: bsd.pkg.mk,v 1.1525 2004/10/26 21:14:59 xtraeme Exp $ # # This file is in the public domain. # @@ -1462,37 +1462,75 @@ package: # adding pre-* or post-* targets/scripts, override these. ################################################################ -# Resume a previous transfer not finished totally. +### +### _RESUME_TRANSFER: +### +### Macro to resume a previous transfer, needs to have defined +### the following options in mk.conf: +### +### PKG_RESUME_TRANSFERS +### FETCH_RESUME_ARGS (if FETCH_CMD != default) +### FETCH_OUTPUT_ARGS (if FETCH_CMD != default) +### +### For example if you want to use wget (pkgsrc/net/wget): +### +### FETCH_CMD=wget +### FETCH_RESUME_ARGS=-c +### FETCH_OUTPUT_ARGS=-O +### +### How does it work? +### +### FETCH_CMD downloads the file and saves it temporally into $$bfile.temp +### if the checksum match the correct one, $$bfile.temp is renamed to +### the original name. +### + _RESUME_TRANSFER= \ - dsize=`${WC} -c < ${DISTDIR}/${DIST_SUBDIR}/$$bfile`; \ 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 ${TEST} -n "$$ftp_proxy" -o -n "$$http_proxy"; then \ + if [ -n "$$ftp_proxy" -o -n "$$http_proxy" ]; then \ ${ECHO_MSG} "===> Resume is not supported by ftp(1) using http/ftp proxies."; \ break; \ else \ - if ${TEST} "$$dsize" -lt "$$tsize"; then \ - if ${TEST} "${FETCH_CMD:T}" != "ftp" -a \ - -z "${FETCH_RESUME_ARGS}"; then \ + 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 \ - ${ECHO_MSG} "===> $$bfile not completed, resuming..."; \ - cd ${_DISTDIR}; \ - ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${FETCH_RESUME_ARGS} $${res_site}$${bfile}; \ - if ${TEST} $$? -eq 0; then \ + 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 ${TEST} "$$dsize" -gt "$$tsize"; then \ + elif [ "$$dsize" -gt "$$tsize" ]; then \ ${ECHO_MSG} "==> Downloaded file larger than the recorded size."; \ break; \ - fi; \ + fi; \ fi # diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf index eb7d99de954..c4854dc5c74 100644 --- a/mk/defaults/mk.conf +++ b/mk/defaults/mk.conf @@ -1,4 +1,4 @@ -# $NetBSD: mk.conf,v 1.9 2004/10/21 17:00:10 tv Exp $ +# $NetBSD: mk.conf,v 1.10 2004/10/26 21:14:59 xtraeme Exp $ # # A file providing defaults for pkgsrc and the packages collection. @@ -257,6 +257,16 @@ FETCH_RESUME_ARGS?= # empty # Default: -R # Possible: depends on your FETCH_CMD value. +.if ${FETCH_CMD:T} == "ftp" +FETCH_OUTPUT_ARGS?= -o +.else +FETCH_OUTPUT_ARGS?= # empty +.endif +# Used when PKG_RESUME_TRANSFERS is enabled, to specify default argument +# in FETCH_CMD to fetch the file to a temporary name. +# Default: -o +# Possible: depends on your FETCH_CMD value. + LIBTOOLIZE_PLIST?= yes # This determines whether to expand libtool archives in PLISTs into the # represented library names. |