Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 May 2000 12:11:08 +0100
From:      Nik Clayton <nik@freebsd.org>
To:        ports@freebsd.org
Subject:   On generating port size statistics
Message-ID:  <20000519121108.A18067@catkin.nothing-going-on.org>

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

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

-ports,

I recently needed to find out how big a port and it's dependencies are (in
trying to decide whether a particular port is too big to make it a 
reasonable requirement for the doc project).

Not seeing an easy way to do this, I hacked together the attached patch
to bsd.port.mk.  It assumes that files/md5 has an additional SIZE line
for each distfile, which the "makesum" target will now create (based on
code that was already there, I just uncommented it).  "make stats" will
then walk the dependency tree, printing out the size information if it's
present.

It's not particularly elegant, and if there are repetitive dependencies
then they get printed multiple times, with similar problems if a port lists
another port as both a BUILD_DEPEND and a RUN_DEPEND (for example), making 
judicious use of sort(1) and uniq(1) necessary.

For example,

    % cd /usr/ports/graphics/sketch
    % make stats | sort | uniq
    Distutils-0.8.2.tar.gz: 113573
    Imaging-1.0.tar.gz: 313109
    PyXML-0.5.4.tar.gz: 504036
    Wraphelp.c: 
    X336src-1.tgz: 
    X336src-2.tgz: 
    jpegsrc.v6b.tar.gz: 613261
    libtool-1.3.4.tar.gz: 535519
    py152.tgz: 2533053
    sketch-0.6.7.tar.gz: 793745
    tcl8.2.3.tar.gz: 
    tk8.2.3.tar.gz: 

The blank entries are where files/md5 doesn't contain a SIZE line, and I
don't have a distfile handy to generate it.

It could probably be enhanced to flag distfiles that are required, but
not present, or distfiles that are not required because they've already
been installed, to show the total number of bytes that will be downloaded
to satisfy this port's dependencies.

Thoughts?  If there's interest, I'll submit this as a PR for someone to
follow up on.

N
-- 
Internet connection, $19.95 a month.  Computer, $799.95.  Modem, $149.95.
Telephone line, $24.95 a month.  Software, free.  USENET transmission,
hundreds if not thousands of dollars.  Thinking before posting, priceless.
Somethings in life you can't buy.  For everything else, there's MasterCard.
  -- Graham Reed, in the Scary Devil Monastery

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="stats.patch"

--- bsd.port.mk.org	Fri May 19 10:50:14 2000
+++ bsd.port.mk	Fri May 19 12:00:21 2000
@@ -2228,6 +2228,23 @@
 .endif
 .endif
 
+# Statistics -- shows the size of the files required by the port
+
+.if !target(stats)
+stats: 
+	@${MKDIR} ${_DISTDIR}
+	@(cd ${_DISTDIR}; \
+	 for file in ${DISTFILES}; do \
+		DIR=${DIST_SUBDIR}; \
+		CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+		echo "$$file: $$CKSIZE"; \
+	 done)
+	@for i in ${DEPENDS_TMP}; do \
+		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
+		(cd $$dir; ${MAKE} stats) ; \
+	done
+.endif
+
 # Checksumming utilities
 
 .if !target(makesum)
@@ -2238,6 +2255,7 @@
 	@(cd ${DISTDIR}; \
 	 for file in ${_CKSUMFILES}; do \
 		${MD5} $$file >> ${MD5_FILE}; \
+		echo "SIZE ($$file) = "`wc -c < $$file` >> ${MD5_FILE}; \
 	 done)
 	@for file in ${_IGNOREFILES}; do \
 		${ECHO} "MD5 ($$file) = IGNORE" >> ${MD5_FILE}; \
@@ -2351,6 +2369,11 @@
 .if make(run-depends)
 DEPENDS_TMP+=	${RUN_DEPENDS}
 .endif
+
+.if make(stats)
+DEPENDS_TMP+=   ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${RUN_DEPENDS} ${LIB_DEPENDS}
+.endif
+
 
 .if defined(ALWAYS_BUILD_DEPENDS)
 _DEPEND_ALWAYS=	1

--OXfL5xGRrasGEqWY--


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?20000519121108.A18067>