Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Dec 1998 16:07:23 +0100
From:      Martin Cracauer <cracauer@cons.org>
To:        ports@FreeBSD.ORG
Subject:   Proposed implementation of FETCH_SIZE_LIMIT
Message-ID:  <19981208160723.A3372@cons.org>

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

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

Moin,

the bsd.port.mk diff appended implements FETCH_SIZE_LIMIT, see the
diff about semantics.

Please note that I don't have an idea how to implement the temporary
file names correctly, since WRKDIR doesn't exist at fetch time. Any
advice?
TMPFILE?=     /tmp/bsd.port.tmp
FETCH_SIZE_FILE?=     fetchsize

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer
  Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536
  Paper: (private) Waldstrasse 200, 22846 Norderstedt, Germany

--pWyiEgJYm5f9v55/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="port.diff"

*** /usr/src/share/mk/bsd.port.mk	Mon Nov 30 12:07:38 1998
--- bsd.port.mk	Tue Dec  8 16:03:28 1998
***************
*** 1,7 ****
  #-*- mode: Fundamental; tab-width: 4; -*-
  # ex:ts=4
  #
! #	$Id: bsd.port.mk,v 1.299 1998/11/25 00:12:27 asami Exp $
  #	$NetBSD: $
  #
  #	bsd.port.mk - 940820 Jordan K. Hubbard.
--- 1,7 ----
  #-*- mode: Fundamental; tab-width: 4; -*-
  # ex:ts=4
  #
! #	$Id: bsd.port.mk,v 1.1 1998/12/08 14:46:04 cracauer Exp cracauer $
  #	$NetBSD: $
  #
  #	bsd.port.mk - 940820 Jordan K. Hubbard.
***************
*** 302,307 ****
--- 302,316 ----
  #				  Arguments to ${FETCH_CMD} before filename (default: none).
  # FETCH_AFTER_ARGS -
  #				  Arguments to ${FETCH_CMD} following filename (default: none).
+ # FETCH_SIZE_LIMIT -
+ #				  Maxmimum size of distfiles to fetch when building this port.
+ #				  This is the the sum in bytes of the sizes of all DISTFILES
+ #				  and PATCHFILES that currently don't exist on this system.
+ #				  This is on a per-port basis, not the sum of all ports that
+ #				  would be fetch by the command (i.e. as dependencies).
+ # FETCH_SIZE_VERBOSE -
+ #				  If set to "1", the fetch and fetch-size targets will report
+ #				  the size and place of each individual DISTFILE and PATCHFILE.
  #
  # For extract:
  #
***************
*** 721,726 ****
--- 730,738 ----
  .endif
  .endif
  
+ TMPFILE?=	/tmp/bsd.port.tmp
+ FETCH_SIZE_FILE?=	fetchsize
+ 
  AWK?=		/usr/bin/awk
  BASENAME?=	/usr/bin/basename
  CAT?=		/bin/cat
***************
*** 1193,1198 ****
--- 1205,1224 ----
  .if !target(do-fetch)
  do-fetch:
  	@${MKDIR} ${_DISTDIR}
+ .if defined(FETCH_SIZE_LIMIT)
+ .if defined(FETCH_SIZE_VERBOSE) && ${FETCH_SIZE_VERBOSE} == 1
+ 	@${ECHO_MSG} '==> Getting size of distfiles to fetch: '
+ 	@${MAKE} fetch-size
+ .else
+ 	@${ECHO_MSG} -n '==> Getting size of distfiles to fetch: '
+ 	@${ECHO_MSG} `${MAKE} fetch-size`
+ .endif
+ 	@if expr `${CAT} ${FETCH_SIZE_FILE}` \> ${FETCH_SIZE_LIMIT} > /dev/null ; then \
+ 		${ECHO_MSG} -n 'Error: fetch size limit ${FETCH_SIZE_LIMIT} exceeded: '; \
+ 		${ECHO_MSG} `${CAT} ${FETCH_SIZE_FILE}`; \
+ 		exit 1; \
+ 	fi
+ .endif
  	@(cd ${_DISTDIR}; \
  	 for file in ${DISTFILES}; do \
  		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
***************
*** 1697,1702 ****
--- 1723,1787 ----
  		fi \
  	 done)
  .endif
+ .endif
+ 
+ .if !target(fetch-size)
+ fetch-size:
+ 	@${CP} /dev/null ${TMPFILE}
+ 	@${MKDIR} ${_DISTDIR}
+ 	@(cd ${_DISTDIR}; \
+ 	 for file in ${DISTFILES}; do \
+ 		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
+ 			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
+ 				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
+ 				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
+ 				${ECHO_MSG} ">> Please correct this problem and try again."; \
+ 				exit 1; \
+ 			fi ; \
+ 			${ECHO_MSG} ">> $$file doesn't seem to exist on this system." >> ${TMPFILE}; \
+ 			for site in ${MASTER_SITES}; do \
+ 			    ${ECHO_MSG} ">> Ask $${site} for size." >> ${TMPFILE}; \
+ 				DIR=${DIST_SUBDIR}; \
+ 				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ 				if ${FETCH_CMD} -s ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS} >> ${TMPFILE}; then \
+ 					continue 2; \
+ 				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 \
+ 	 done)
+ .if defined(PATCHFILES)
+ 	@(cd ${_DISTDIR}; \
+ 	 for file in ${PATCHFILES}; do \
+ 		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
+ 			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
+ 				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
+ 				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
+ 				${ECHO_MSG} ">> Please correct this problem and try again."; \
+ 				exit 1; \
+ 			fi ; \
+ 			${ECHO_MSG} ">> $$file doesn't seem to exist on this system." >> ${TMPFILE}; \
+ 			for site in ${PATCH_SITES}; do \
+ 			    ${ECHO_MSG} ">> Ask $${site} for size." >> ${TMPFILE}; \
+ 				DIR=${DIST_SUBDIR}; \
+ 				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ 				if ${FETCH_CMD} -s ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS} >> ${TMPFILE}; then \
+ 					continue 2; \
+ 				fi \
+ 			done; \
+ 			${ECHO_MSG} ">> Couldn't get size";\
+ 			exit 1; \
+ 	    fi \
+ 	 done)
+ .endif
+ 	@${AWK} '{size = size +$$1} END {print size}' < ${TMPFILE} > ${FETCH_SIZE_FILE}
+ .if defined(FETCH_SIZE_VERBOSE) && ${FETCH_SIZE_VERBOSE} == 1
+ 	@${CAT} ${TMPFILE}
+ 	@${ECHO} -n 'Total: '
+ .endif
+ 	@${CAT} ${FETCH_SIZE_FILE}
  .endif
  
  # Checksumming utilities

--pWyiEgJYm5f9v55/--

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?19981208160723.A3372>