Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Dec 1997 07:16:44 -0700 (MST)
From:      bgingery@gtcs.com
To:        asami@cs.berkeley.edu
Cc:        freebsd-ports@FreeBSD.ORG
Subject:   Re: Recommended added target for bsd.port.mk
Message-ID:  <199712171416.HAA15618@home.gtcs.com>
In-Reply-To: <199712171149.DAA16651@silvia.HIP.Berkeley.EDU>

next in thread | previous in thread | raw e-mail | index | archive | help
On 17 Dec, Satoshi Asami wrote:

-} "size" is fine, can someone send me a patch?  As for the others, I
-} don't think we should start adding things that can be done by simple
-} aliases.  bsd.port.mk is long and complicated enough as it is.

   Okay, it's not QUITE a patch (and evidently I don't have the most
   current bsd.port.mk which you'd want a patch against, anyways).


DESCRIPTION
===========

   Here's the idea.  In FILESDIR, we add a file called "sizes"
   makesizes is the logical equivalent to makesum.  It creates that
   file from scratch.  The biggest difference is that "make makesizes"
   depends on "make package" .. which depends on "make install" ....

   The only thing I've NOT taken into account is the package registry
   database, which will vary according to subsequent depends, anyways.
   I don't allow for those, but I'd think that they'd rarely make
   a k difference.

   Makesizes target creates line entries for each "stage" of the sizing.
   Just for the consistency, each line has THREE entries, an ident, the
   size in k, and the file or directory to which it applies.  Although
   the ident is followed by a colon, that's for raw readability.  
   The fields are whitespace delimited.

          package: <size in k of package tarball> <package tarball name>
          dist:  <size in k of distfile> <distfile name>
             ... dist may reoccur depending on number of distfiles for
                  port.
          make:  <size in k of a completed make, INCLUDING lowest level
                  port dir>  <a dot for CURDIR>
          work:  <size in k of completed make, work and below> work/
          installed: <size in k of contents of package> <packagename>
          port:  <approx size in k of port itself>  <dot for CURDIR>

   other size targets merely extract that info.  In order to get "size",
   we need "make" and "installed", anyways.  The others are just gravy,
   because they'd certainly be useful, either to users or CD builders.

   E.g. someone with a slow link, building from the net, might want to
   "make fetch-list sizedist" to get an idea of the time it's apt to
   take on that connection - BEFORE attempting a make fetch.

   Someone building a ports-and-distfiles CD might do JUST sizedist and
   sizeport, while if packages also were being put on that same CD, a
   sizecd gives the total size for it all.
   
   Someone with "close space" on their filesystem would do a "make size"
   to find out if they have enough workspace to build it, or "make
   sizepkg installed" to see if they even have room to install the
   binaries.

SYNOPSIS
========

   Size target below (gather information)
       makesizes:  Creates ${FILESDIR}/sizes by analyzing fully created
                   and present port.  Could replace "make package" as
                   a "standard target" for ppl used to just using that
                   target to "do it all".

   Size targets below (informational)

       size:       Normal user's size to install
       sizemax:    Size with EVERYTHING made and installed and not
                   cleaned - including package.  This is the "port
                   tester's required size".
       sizepkg:    Size of binary dist package
       sizeport:   Size of just the port (within a few bytes) in k
       sizedist:   Size of the "fetch files"
       sizemake:   Size to make but not install - e.g. just test it.
       sizeinst:   Size installed, distclean (not counting port dir).
       sizecd:     Size of port plus size of package plus size of
                   distfiles
       
    and I left off the other total, size-of-work with port built,
    which is really just for makesizes use, but COULD also be included.
    I had each size target return JUST the size-in-k, figuring that if
    the full record was wanted, 'grep' would easily handle it in an
    alias.

Approximate code, off the top of my (tired) head.  Its been a few weeks
since I did anything in awk, and a year or two since I did anything
serious in awk/gawk....  Feel free to improve!  Excuse the sometimes
weirdly line wrapped.

CODE
=====

for bsd.port.mk ...

     SIZES=${FILESDIR}/sizes

     makesizes:  ${WRKDIR}/.package-done
            @echo -n "package: " > ${SIZES}
            @ls -ks ${PKGNAME}.tar.gz >> ${SIZES}
            @foreach $f in ${DISTFILES}; do \
                echo -n "dist: " >> ${SIZES}; \
                ls -ks ${DISTDIR}/$f >> ${SIZES}; \
             done
            @echo -n "make: "`du -s .` >> ${SIZES}
            @echo -n "work: "`du -s work/` >> ${SIZES}
            @tar -tvzf ${PKGNAME}.tar.gz | awk -v n=0 '{n += $$2}; \
                END {printf "installed: %d ",n;}' >>${SIZES}           
            @echo ${PKGNAME}.tar.gz >> ${SIZES}
            @awk <${SIZES}'/^make/ {n += $$2};/^work/ {n -= $$2}; \
               /^package/ {n -= $$2}; END {print "port:",n," ."};' \
               >> ${SIZES}

    ${SIZES}: makesizes

     #  size of actual portdir in k (within a few bytes).
     sizeport:  ${SIZES}
             awk < $> '/^port/ {print $$2;}'

     #  size of binary "package" in k
     sizepkg:   ${SIZES}
             awk < $> '/^package/ {print $$2;}'

     #  size for make [build] in k
     sizemake:  ${SIZES}
             awk < $> '/^make/ {print $$2;}'

     #  fetch size in k
     sizedist:  ${SIZES}
             awk < $> '/^dist/ {n += $$2}; END {print n;}'

     # size for make package in k - larger than make install
     sizemax:  ${SIZES}
             awk < $> '/^dist/ {n += $$2}; /^make/ {n += $$2};  \
                 /^package/ {n += $$2}; END {print n;}'

     # size installed, not including port, package, dist, in k
     sizeinst: ${SIZES}
             awk < $> '/^installed/ {print $$2;}'

     # size to make install in k
     size:     ${SIZES}
             awk < $> '/^dist/ {n += $$2}; /^make/ {n += $$2}; \
                /^installed/ {n += $$2}; END {print n;}

      # size of package PLUS size of port+distfiles, e.g. for CD-ROM
      sizecd:  ${SIZES}
              awk < $> '/^dist/ {n += $$2}; /^package/ {n += $$2};\
                 /^port/ {n += $$2}; END {print n;}'

  Presumes that "make package" puts package in ${CURDIR}, not in ../pkg/
  or other site tree.


for bsd.port.subdir.mk 

  I'll leave that as an exercise for someone fresher.  Same targets
  could easily accumulate from each subdir.

	Bruce Gingery	<bgingery@gtcs.com>
	Advanced Integrators, LC






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712171416.HAA15618>