[blfs-dev] Package stats

Bruce Dubbs bruce.dubbs at gmail.com
Thu Mar 6 08:36:37 PST 2014


There is a question in the tickets about statistics.  This is how I do 
it.  I have a script for each package that measures time and size.

I build packages in /tmp, but really could be anywhere.

First measure the free disk space:

before=`df -k /tmp | grep / | sed -e "s/ \{2,\}/ /g" | cut -d' ' -f3`

Run the build:

TIMEFMT='%1R Elapsed Time - '

{ time \
   {
     echo Making $TITLE
     date
     # Instructions go here


   }
} 2>&1 | tee -a $LOG

Get the statistics:

stats $LOG $DIR/$PROGRAM.tar.?z* $before

Where stats does:

function stats()
{
   log=$1
   tarball=$2
   b4=$3

   #  This changes slightly for a base LFS build
   base_sbu=118

   free_now=`df -k /tmp | grep / | sed -e "s/ \{2,\}/ /g" |
     cut -d" " -f3`

   buildtime=`tail -n1 $log|cut -f1 -d" "`
   sbu=`echo "scale=3; $buildtime / $base_sbu" | bc`

   psizeK=`du -k $tarball | cut -f1`
   psizeM=`echo "scale=3; $psizeK / 1024"   | bc`

   bsizeK=`echo "$free_now - $b4"           | bc`
   bsizeM=`echo "scale=3; $bsizeK / 1024"   | bc`

   echo "SBU=$sbu"                                  | tee -a $log
   echo "$psizeK $tarball size ($psizeM MB)"        | tee -a $log
   echo "$bsizeK kilobytes build size ($bsizeM MB)" | tee -a $log
   (echo -n "md5sum : "; md5sum $tarball)           | tee -a $log
   (echo -n "sha1sum: "; sha1sum $tarball)          | tee -a $log

   echo "`date` $tarball" >> /usr/src/packages-$(lsb_release -r|
     cut -f2).log
}

   So build size is measured as df_after - df_before.  The issue to note 
is that there is activity during the build that adds or deletes space on 
/tmp, the size will be off.  I have /tmp on its own partition.

   -- Bruce



More information about the blfs-dev mailing list