Date: Mon, 02 Feb 2004 17:19:16 +0100 From: Oliver Eikemeier <eikemeier@fillmore-labs.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/62271: [PATCH] bsd.port.mk: calculate size of needed distribution files Message-ID: <401E7884.9000106@fillmore-labs.com> Resent-Message-ID: <200402021620.i12GKEVk089710@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 62271 >Category: ports >Synopsis: [PATCH] bsd.port.mk: calculate size of needed distribution files >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Feb 02 08:20:13 PST 2004 >Closed-Date: >Last-Modified: >Originator: Oliver Eikemeier >Release: FreeBSD 4.9-STABLE i386 >Organization: Fillmore Labs - http://www.fillmore-labs.com >Environment: System: FreeBSD nuuk.fillmore-labs.com 4.9-STABLE >Description: Just a quick hack to calculate the total size of distribution files a port and its dependencies need to fetch. Improvements welcome: - should it be print-missing-size-recursive? - maybe a shorter summary is appropriate? >How-To-Repeat: # cd /usr/ports/x11/gnome2 ; make print-missing-size To install gnome2-2.4.1 and its dependencies, you have to fetch 4 file(s) with a total size of 10.00 MBytes and 119 file (s) with unknown size. (You mileage may vary, depending on the files you already have in /usr/ports/distfiles) >Fix: --- Mk/bsd.port.mk.orig Sun Jan 25 19:44:54 2004 +++ Mk/bsd.port.mk Mon Feb 2 17:04:53 2004 @@ -4011,6 +4049,56 @@ .if defined(DIST_SUBDIR) @${ECHO_CMD} "${RMDIR} ${_DISTDIR} 2>/dev/null || ${TRUE}" .endif +.endif + +# Prints out the total size of files missing in ${DISTDIR} + +.if !target(print-missing-size) +print-missing-size: + @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \ + (cd $$dir; ${MAKE} print-missing-files); \ + done | ${SORT} -u +1 | ${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="To install ${PKGNAME} and its dependencies, you have to fetch " \ + f " file(s) with a total size of " s; \ + if (u) msg=msg " and " u " file(s) with unknown size."; \ + print msg \ + } \ + ' +.endif + +.if !target(print-missing-files) +print-missing-files: + @if [ -f ${MD5_FILE} ]; then \ + for file in ${_CKSUMFILES}; do \ + if [ -f "${DISTDIR}/$$file" ]; then \ + continue; \ + fi; \ + pattern="`${ECHO_CMD} $$file | ${SED} -e 's/\./\\\\./g'`"; \ + CKSIZE=`${GREP} "^SIZE ($$pattern)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \ + if [ -z "$$CKSIZE" ]; then \ + ${ECHO_CMD} "0 ${DISTDIR}/$$file"; \ + else \ + ${ECHO_CMD} "$$CKSIZE ${DISTDIR}/$$file"; \ + fi; \ + done; \ + for file in ${_IGNOREFILES}; do \ + if [ -f "${DISTDIR}/$$file" ]; then \ + continue; \ + fi; \ + ${ECHO_CMD} "0 ${DISTDIR}/$$file"; \ + done; \ + fi .endif # Prints out a list of files to fetch (useful to do a batch fetch) >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?401E7884.9000106>