#!/usr/bin/ksh93 FMRI=$1 if [ -z $FMRI ]; then echo "You must provide an FMRI as the first parameter." #FMRI="SUNWckr@0.5.11%2C5.11-0.111%3A20090418T183853Z" fi if [ -z $REPO ]; then REPO=http://pkg.opensolaris.org/dev fi MFST=/tmp/$FMRI if [ ! -e $MFST ]; then wget -O $MFST $REPO/manifest/0/$FMRI fi while read ENTRY; do IFS=" " set -A action ${ENTRY} if [ "${action[0]}" != "file" ]; then continue fi for FIELD in ${action[*]}; do IFS="=" set -A pair ${FIELD} if [ "${pair[0]}" == "path" ]; then FNAME=${pair[1]} break fi done FILE=${action[1]} FP="/var/pkg/download/${FILE:0:2}/${FILE:2:6}" pfexec mkdir -p $FP if [ ! -e $FP/$FILE ]; then echo "Retrieving and caching $FNAME ..." pfexec wget -O $FP/$FILE $REPO/file/0/$FILE fi done < $MFST