Index: Mk/bsd.port.mk =================================================================== RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v retrieving revision 1.490 diff -u -r1.490 bsd.port.mk --- Mk/bsd.port.mk 31 May 2004 18:07:57 -0000 1.490 +++ Mk/bsd.port.mk 1 Jun 2004 19:33:37 -0000 @@ -1627,6 +1627,8 @@ PTHREAD_LIBS?= -lpthread .endif +.if defined(OLD_DISTFILES_HANDLING) + .if exists(/usr/bin/fetch) # avoid -A for 2.2 -- it's not ported to that branch .if ${OSVERSION} < 300000 @@ -1656,6 +1658,18 @@ .endif .endif +.else ## OLD_DISTFILES_HANDLING ## + +.if defined(FETCH_USE_CURL) && exists(${LOCALBASE}/bin/curl) +FETCH_CMD?= ${LOCALBASE}/bin/curl --create-dirs -L --max-redirs 1 -C - +.elif defined(FETCH_USE_WGET) && exists(${LOCALBASE}/bin/wget) +FETCH_CMD?= ${LOCALBASE}/bin/wget -c +.else +FETCH_CMD?= /usr/bin/fetch -ARr +.endif + +.endif ## OLD_DISTFILES_HANDLING ## + TOUCH?= /usr/bin/touch TOUCH_FLAGS?= -f @@ -1866,6 +1880,8 @@ # Popular master sites .include "bsd.sites.mk" +.if defined(OLD_DISTFILES_HANDLING) + # Empty declaration to avoid "variable MASTER_SITES recursive" error MASTER_SITES?= PATCH_SITES?= @@ -2061,6 +2077,8 @@ _PATCH_SITES_DEFAULT:= ${PATCH_SITES_TMP} PATCH_SITES_TMP= +.endif ## OLD_DISTFILES_HANDLING ## + # The primary backup site. MASTER_SITE_BACKUP?= \ ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/ @@ -2076,6 +2094,8 @@ _MASTER_SITE_BACKUP= ${MASTER_SITE_BACKUP} .endif +.if defined(OLD_DISTFILES_HANDLING) + # Search CDROM first if mounted, symlink instead of copy if # FETCH_SYMLINK_DISTFILES is set .for MOUNTPT in ${CD_MOUNTPTS} @@ -2258,6 +2278,35 @@ _IGNOREFILES?= ${IGNOREFILES} .endif +.else ## OLD_DISTFILES_HANDLING ## + +# Search CDROM first if mounted +.for MOUNTPT in ${CD_MOUNTPTS} +.if exists(${MOUNTPT}/ports/distfiles) +_MASTER_SITE_OVERRIDE:= file:${MOUNTPT}/ports/distfiles/${DIST_SUBDIR}/ ${_MASTER_SITE_OVERRIDE} +.endif +.endfor + +DISTFILES?= ${DISTNAME}${EXTRACT_SUFX} + +_DISTFILES= ${DISTFILES:C/:[^:]+$//} +_PATCHFILES= ${PATCHFILES:C/:[^:]+$//} + +# +# Sort the master site list according to the patterns in MASTER_SORT +# +MASTER_SORT?= +MASTER_SORT_REGEX?= +MASTER_SORT_REGEX+= ${MASTER_SORT:S|.|\\.|g:S|^|://[^/]*|:S|$|/|} + +MASTER_SORT_AWK= BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX:S|\\|\\\\|g}"; } +.for srt in ${MASTER_SORT_REGEX} +MASTER_SORT_AWK+= /${srt:S|/|\\/|g}/ { good["${srt:S|\\|\\\\|g}"] = good["${srt:S|\\|\\\\|g}"] " " $$0 ; next; } +.endfor +MASTER_SORT_AWK+= { rest = rest " " $$0; } END { n=split(gl, gla); for(i=1;i<=n;i++) { print good[gla[i]]; } print rest; } + +.endif ## OLD_DISTFILES_HANDLING ## + # This is what is actually going to be extracted, and is overridable # by user. EXTRACT_ONLY?= ${_DISTFILES} @@ -2810,6 +2859,164 @@ @${ECHO_MSG} "===> Vulnerability check disabled" .endif +# New style distfile handling + +.if !defined(OLD_DISTFILES_HANDLING) + +DISTFILES_SH?= ${PORTSDIR}/Tools/scripts/distfiles.sh + +DISTINFO_ALGORITHMS?= MD5 +VALID_ALGORITHMS= MD5 SHA1 RMD160 + +MK_FILE?= ${MASTERDIR}/Makefile +RANK_FILE?= /var/db/distrank/ranks +RANK_FUZZ?= 5 +RANK_HIGH?= 9999 +.if !defined(OPENSSL) +.if exists(/usr/bin/openssl) +OPENSSL= /usr/bin/openssl +.elif exists(${LOCALBASE}/bin/openssl) +OPENSSL= ${LOCALBASE}/bin/openssl +.endif +.endif + +# remove extra quoting +#_FETCHDISTFILES_ENV= \ +# DISTFILES='${DISTFILES:C/\\\\(.)/\1/g}'; \ +# PATCHFILES='${PATCHFILES:C/\\\\(.)/\1/g}' +_FETCHDISTFILES_ENV= \ + DISTFILES='${DISTFILES}'; \ + PATCHFILES='${PATCHFILES}' +.for env in \ + MASTER_SITES MASTER_SITE_SUBDIR PATCH_SITES PATCH_SITE_SUBDIR \ + DISABLE_SIZE DISTDIR DISTINFO_ALGORITHMS DISTINFO_LABEL \ + DIST_SUBDIR ECHO_MSG FETCH_AFTER_ARGS FETCH_BEFORE_ARGS \ + FETCH_CMD FETCH_SYMLINK_DISTFILES IGNOREFILES MASTER_SORT_AWK \ + MD5_FILE MK_FILE NO_CHECKSUM NO_SIZE OPENSSL OSVERSION \ + PERL5 RANK_FILE RANK_FUZZ RANK_HIGH VALID_ALGORITHMS \ + _MASTER_SITE_BACKUP _MASTER_SITE_OVERRIDE +_FETCHDISTFILES_ENV+= ; ${env}='${${env}}' +.endfor +.for env in ${VALID_ALGORITHMS} SIZE +_FETCHDISTFILES_ENV+= ; DISTINFO_${env}='${DISTINFO${DISTINFO_LABEL:C/^./_&/}_${env}}' +.endfor + +.if !target(do-fetch) +.PHONY: do-fetch +do-fetch: + @${_FETCHDISTFILES_ENV}; \ + set -- -f; \ + . '${DISTFILES_SH}' +.endif + +.if !target(checksum) +.PHONY: checksum +checksum: fetch + @${DO_NADA} +.endif + +.if !target(makesum) +.PHONY: makesum +makesum: +.if !defined(FETCH_ALL) + @cd ${.CURDIR} && ${MAKE} FETCH_ALL=yes ${__softMAKEFLAGS} ${.TARGET} +.else + @${_FETCHDISTFILES_ENV}; \ + set -- -m; \ + . '${DISTFILES_SH}' +.endif +.endif + +.if !target(migratesum) +.PHONY: migratesum +migratesum: + @${_FETCHDISTFILES_ENV}; \ + set -- -M; \ + . '${DISTFILES_SH}' +.endif + +.if !target(migratesum2) +.PHONY: migratesum2 +migratesum2: + @${_FETCHDISTFILES_ENV}; \ + set -- -N; \ + . '${DISTFILES_SH}' +.endif + +.if !target(checkdistfiles) +.PHONY: checkdistfiles +checkdistfiles: +.if !defined(FETCH_ALL) + @cd ${.CURDIR} && ${MAKE} FETCH_ALL=yes ${__softMAKEFLAGS} ${.TARGET} +.else + @${_FETCHDISTFILES_ENV}; \ + set -- -F; \ + . '${DISTFILES_SH}' +.endif +.endif + +# Prints out the total size of files missing in ${DISTDIR} + +_MISSING_SIZE_SUMMARY= \ + ${AWK} ' \ + BEGIN {t=0; f=0; u=0} \ + {if ($$1 > 0) {t+=$$1; f+=1} else {u+=1}} \ + END { \ + if (t >= 10^9) \ + s=sprintf("%.2f GBytes", t/10^9); \ + else if (t >= 10^6) \ + s=sprintf("%.2f MBytes", t/10^6); \ + else if (t >= 10^3) \ + s=sprintf("%.2f KBytes", t/10^3); \ + else \ + s=t " Bytes"; \ + msg=ENVIRON["MISSING_MSG"] \ + f " file(s) with a total size of " s; \ + if (u) msg=msg " and " u " file(s) with unknown size."; \ + print msg \ + } \ + ' + +.if !target(missing-size) +.PHONY: missing-size +missing-size: + @cd ${.CURDIR} && ${MAKE} print-missing-files \ + | ${SETENV} MISSING_MSG="To install ${PKGNAME}, you have to fetch " ${_MISSING_SIZE_SUMMARY} +.endif + +.if !target(missing-size-recursive) +.PHONY: missing-size-recursive +missing-size-recursive: + @cd ${.CURDIR} && ${MAKE} print-missing-files-recursive \ + | ${SETENV} MISSING_MSG="To install ${PKGNAME} and its dependencies, you have to fetch " ${_MISSING_SIZE_SUMMARY} +.endif + +.if !target(print-missing-files-recursive) +.PHONY: print-missing-files-recursive +print-missing-files-recursive: + @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \ + (cd $$dir; ${MAKE} print-missing-files); \ + done | ${SORT} -u +1; +.endif + +.if !target(print-missing-files) +.PHONY: print-missing-files +print-missing-files: + @${_FETCHDISTFILES_ENV}; \ + set -- -S; \ + . '${DISTFILES_SH}' +.endif + +.if !target(fetch-list) +.PHONY: fetch-list +fetch-list: + @${_FETCHDISTFILES_ENV}; \ + set -- -L; \ + . '${DISTFILES_SH}' +.endif + +.endif ## !OLD_DISTFILES_HANDLING ## + # Fetch .if !target(do-fetch) @@ -2944,12 +3151,9 @@ do-extract: @${RM} -rf ${WRKDIR} @${MKDIR} ${WRKDIR} - @for file in ${EXTRACT_ONLY}; do \ - if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ - then \ - exit 1; \ - fi \ - done +.for file in ${EXTRACT_ONLY} + @cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "${_DISTDIR}/${file}" ${EXTRACT_AFTER_ARGS} +.endfor .if !defined(EXTRACT_PRESERVE_OWNERSHIP) @if [ `${ID} -u` = 0 ]; then \ ${CHMOD} -R ug-s ${WRKDIR}; \ @@ -2971,13 +3175,13 @@ fi; \ case $$i in \ *.Z|*.gz) \ - ${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ + ${GZCAT} "$$i" | ${PATCH} ${PATCH_DIST_ARGS}; \ ;; \ *.bz2) \ - ${BZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ + ${BZCAT} "$$i" | ${PATCH} ${PATCH_DIST_ARGS}; \ ;; \ *) \ - ${PATCH} ${PATCH_DIST_ARGS} < $$i; \ + ${PATCH} ${PATCH_DIST_ARGS} < "$$i"; \ ;; \ esac; \ done) @@ -2985,7 +3189,7 @@ .if defined(EXTRA_PATCHES) @for i in ${EXTRA_PATCHES}; do \ ${ECHO_MSG} "===> Applying extra patch $$i"; \ - ${PATCH} ${PATCH_ARGS} < $$i; \ + ${PATCH} ${PATCH_ARGS} < "$$i"; \ done .endif @if [ -d ${PATCHDIR} ]; then \ @@ -3001,7 +3205,7 @@ if [ ${PATCH_DEBUG_TMP} = yes ]; then \ ${ECHO_MSG} "===> Applying ${OPSYS} patch $$i" ; \ fi; \ - if ${PATCH} ${PATCH_ARGS} < $$i ; then \ + if ${PATCH} ${PATCH_ARGS} < "$$i" ; then \ PATCHES_APPLIED="$$PATCHES_APPLIED $$i" ; \ else \ ${ECHO_MSG} `${ECHO_CMD} ">> Patch $$i failed to apply cleanly." | ${SED} "s|${PATCHDIR}/||"` ; \ @@ -3480,9 +3684,15 @@ _FETCH_SEQ= fetch-depends pre-fetch pre-fetch-script \ do-fetch post-fetch post-fetch-script _EXTRACT_DEP= fetch +.if defined(OLD_DISTFILES_HANDLING) _EXTRACT_SEQ= extract-message checksum extract-depends pre-extract \ pre-extract-script do-extract \ post-extract post-extract-script +.else ## OLD_DISTFILES_HANDLING ## +_EXTRACT_SEQ= extract-message extract-depends pre-extract \ + pre-extract-script do-extract \ + post-extract post-extract-script +.endif ## OLD_DISTFILES_HANDLING ## _PATCH_DEP= extract _PATCH_SEQ= patch-message patch-depends pre-patch pre-patch-script \ do-patch post-patch post-patch-script @@ -3752,18 +3962,21 @@ .if !target(delete-distfiles) delete-distfiles: @${ECHO_MSG} "===> Deleting distfiles for ${PKGNAME}" - @(if [ "X${RESTRICTED_FILES}" != "X" -a -d ${_DISTDIR} ]; then \ - cd ${_DISTDIR}; \ - for file in ${RESTRICTED_FILES}; do \ - ${RM} -f $${file}; \ - dir=$${file%/*}; \ +.if defined(RESTRICTED_FILES) + @if [ -d "${_DISTDIR}" ]; then ( \ + cd "${_DISTDIR}"; \ + RESTRICTED_FILES="${RESTRICTED_FILES}"; \ + for file in $${RESTRICTED_FILES}; do \ + ${RM} -f "$${file}"; \ + dir="$${file%/*}"; \ if [ "$${dir}" != "$${file}" ]; then \ - ${RMDIR} -p $${dir} >/dev/null 2>&1 || :; \ + ${RMDIR} -p "$${dir}" >/dev/null 2>&1 || ${TRUE}; \ fi; \ - done; \ - fi) + done \ + ); fi +.endif .if defined(DIST_SUBDIR) - -@${RMDIR} ${_DISTDIR} >/dev/null 2>&1 || ${TRUE} + @${RMDIR} "${_DISTDIR}" >/dev/null 2>&1 || ${TRUE} .endif .endif @@ -4170,7 +4383,7 @@ for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \ if [ -d $$dir ]; then \ if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \ - child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" run-depends-list); \ + child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \ for d in $$child; do ${ECHO_CMD} $$d; done; \ ${ECHO_CMD} $$dir; \ checked="$$dir $$child $$checked"; \