--- pkg-size Wed Apr 10 22:27:29 2002 +++ pkg-size.new Sat May 25 14:44:38 2002 @@ -40,7 +40,32 @@ pkgname=`echo $file | sed -e "s:\/var\/db\/pkg\/::" -e "s:\/CONTENTS::"` files=`cat $file|grep "obj"|awk '{ print $2 }'` -size=`(du -scb $files | tail -n 1 | awk '{ print $1 }') 2> /dev/null` + +# begin changes - danarmak +# get temp filename since split can only split into files. get it in current dir. +temp=`tempfile -d .` +# split with whole lines and a 64k limit, with a filename prefix of $temp. i.e. if +# tempfile returned "foo", temp will write fooaa, fooab, fooac... this is pretty good +# temp filename security, but not perfect. ideas? +echo $files | split -C 64k - $temp + +declare -i size +size=0 +# split outputs files into *aa, *ab, *ac... i can't remember how to cycle through the letters +# of the alphabet in bash. also i don't suppose there'll ever be more than 23*64k entries +# per package, so i haven't added support for *aa, ..., *az, *ba, *bb..., *zz. +for x in a b c d e f g h i j k l m n o p q r s t u v w x y z; do + + if [ -f "${temp}a${x}" ]; then + # the same code, only use expr to add the result to $size. + files=`cat ${temp}a${x}` + size=`expr $size + \`(du -scb $files | tail -n 1 | awk '{ print $1 }') 2> /dev/null\`` + fi + +done + +# remove temp files we created. +rm -rf ${temp}* echo "$pkgname $size ($[size/1024]KB)"