[pca] Total download size

David Stark dave at davidstark.name
Thu Nov 20 18:00:19 CET 2008


Hi all.

Since Sun have decided that rolling enormous patches is absolutely the thing to do, I've had to find a way of figuring out the download size for our patch runs. (Old servers with limited space in /var and /)
I've put together a short script to scrape the SunSolve page for each patch listed in 'pca -l missing', and output the total (in kB, for easy comparison with 'df -kl') to std-out. It's a disgusting, brittle hack, but maybe someone else will find it useful. 

Assumptions:
1) SunSolve's actually working
2) wget has its proxy settings set up ($http_proxy) if required, and is in your $PATH
3) pca is in your $PATH
4) The moon is in the correct phase
5) Sun haven't changed the layout of the patch pages on SunSolve

Anyway, here it is:

-----BEGIN-----
#!/bin/ksh
# Script to calculate total download size (in kB) of a PCA 'missing' run
# (c) David Stark 2008
# This script is terrible. Do what you like with it.


PCA=pca
WGET=wget

rm -f /tmp/pca.patchids /tmp/pca.patchsizes

if ! type $PCA 2>&1 > /dev/null
    then
    echo "Bailing out." 1>&2
    exit 1
fi
if ! type $WGET 2>&1 > /dev/null
    then
    echo "Bailing out." 1>&2
    exit 1
fi

echo "Finding patches..." 1>&2
$PCA -l missing | awk '{print $1 "-" $4}' | grep '^[1-9]' > /tmp/pca.patchids

echo "Scraping patch sizes from SunSolve..." 1>&2
for patch in `cat /tmp/pca.patchids`
do
    $WGET -O - 'http://sunsolve.sun.com/search/document.do?assetkey=1-21-'$patch'-1' 2>/dev/null \
      | grep 'Download Patch' | grep bytes | awk '{print $6}' | sed 's/(//' >> /tmp/pca.patchsizes
done

SUM=0
cat /tmp/pca.patchsizes | while read SIZE
do
    SUM=`expr $SUM + $SIZE`
done
expr $SUM / 1024

rm -f /tmp/pca.patchids /tmp/pca.patchsizes

# There is no more
-----END-----

The scraping phase can take ages, but you can watch the length of /tmp/pca.patchsizes to see if it's doing anything.

Dave



More information about the pca mailing list