#!/bin/ksh93 SDIR=$( cd ${ dirname $0; }; printf "$PWD" ) typeset -r FPROG=${.sh.file} typeset -r PROG=${FPROG##*/} IGROUPS=' solaris-minimal-server solaris-small-server solaris-large-server solaris-desktop ' FEATURES=' group/feature/amp group/feature/developer-gnu group/feature/multi-user-desktop group/feature/storage-avs group/feature/storage-nas group/feature/storage-server group/feature/trusted-desktop ' init() { for H in log.kshlib man.kshlib ; do HELPER=$SDIR/$H if [[ -r $HELPER ]]; then . $HELPER else HELPER=${ whence $H; } if [[ -n $HELPER ]]; then . $HELPER else print "$H not found - exiting." exit fi fi done unset HELPER Man.addFunc showUsage '' '[+NAME?showUsage - show usagae info.] [+DESCRIPTION?If \aarg2\a == \bMAIN\b show usage info for this script, oterwise show usage info for the given function if available. \aarg1\a is the name shown in the Synopsis section.] \n\nprogname fname ' X='[+NAME?'"$PROG"' - Update diff files for two different versions.] [+DESCRIPTION?Update the diff files for two different Solaris versions. If related \blist-\b\aVERSION\a\b.txt\b files are available, they will be used, otherwise re-created to speed up diffing.] [h:help?Print this help and exit.] [a:all?Get the list of all possible entire versions and do an update for each consecutive pair and finally exit. NOTE: Remove solaris/**/* to force an update of those files as well (otherwise missing files will be built, only). If you wanna re-create the cached package list info used as source for the diffs, you need to remove the corresponding \b{{solaris*,everything}}/list-\b\aVERSION\a\b.txt\b files as well!] [l:list?List all available entire versions and exit.] [F:functions?Print out a list of all defined functions. Just invokes the \btypeset +f\b builtin.] [H:usage]:[function?Show the usage information for the given function if available and exit. See also option \b-F\b.] [T:trace]:[fname_list?A comma or whitspace separated list of function names, which should be traced during execution.] [+EXAMPLES?]{ [+?'"$PROG"' 0.5.11-0.175.0.4.0.5.0 0.5.11-0.175.0.4.0.6.0] } \n\n \aoldVersion\a \anewVersion\a ' Man.addFunc MAIN '' "$X" } init function showUsage { typeset WHAT="$2" if [[ $WHAT != MAIN ]]; then typeset X="${Man.FUNC[$WHAT]}" X+="[+ENVIRONMENT VARIABLES]{ ${Man.VAR[*]}\n}" getopts -a "$1" "${ print ${X}; }" OPT --man else typeset X="${Man.FUNC[$WHAT]}" getopts -a $1 "${ print ${X}; }" OPT --man fi } function doAll { typeset -a ALL=( ${ ipsCompare.sh -l; } ) integer OLD=1 NEW=0 for (( ; OLD < ${#ALL[@]}; OLD++, NEW++ )) ; do typeset OV=${ALL[$OLD]} NV=${ALL[$NEW]} Log.info "$PROG $OV $NV ..." $FPROG $OV $NV [[ "$OV" == '0.5.11-0.175.0.4.0.5.0' ]] && break # olders are unreliable done } function doGroups { for WHAT in $IGROUPS ; do if [[ ! -d $WHAT ]]; then mkdir $WHAT || exit 1 fi PARAMS="" if [[ -r $WHAT/list-${OR}.txt ]]; then PARAMS+="-O $WHAT/list-${OR}.txt " else PARAMS+="-o $OLD " fi if [[ -r $WHAT/list-${NR}.txt ]]; then PARAMS+="-N $WHAT/list-${NR}.txt " else PARAMS+="-n $NEW " fi Log.info "Doing $WHAT/${OR}-${NR}-diff.txt ..." ipsCompare.sh ${PARAMS} -S /tmp/ips $WHAT \ >"$WHAT/${OR}-${NR}-diff.txt" [[ ! -r "$WHAT/list-${OR}.txt" ]] && cp /tmp/ips.old "$WHAT/list-${OR}.txt" [[ ! -r "$WHAT/list-${NR}.txt" ]] && cp /tmp/ips.new "$WHAT/list-${NR}.txt" Log.info "Doing $WHAT/${OR}-${NR}-full-diff.txt ..." ipsCompare.sh -O /tmp/ips.old -N /tmp/ips.new -a $WHAT \ >"$WHAT/${OR}-${NR}-full-diff.txt" Log.info "Doing $WHAT/${OR}-${NR}-all.txt ..." ipsCompare.sh -O /tmp/ips.old -N /tmp/ips.new -A $WHAT \ >"$WHAT/${OR}-${NR}-all.txt" for FEATURE in $FEATURES ; do DIR=$WHAT/${FEATURE//\//_} [[ ! -d $DIR ]] && mkdir $DIR Log.info "Doing $DIR/${OR}-diff.txt ..." [[ ! -r "$DIR/${OR}-diff.txt" ]] && \ ipsCompare.sh -O /tmp/ips.old -n $OLD $WHAT $FEATURE \ >"$DIR/${OR}-diff.txt" Log.info "Doing $DIR/${NR}-diff.txt ..." [[ ! -r "$DIR/${NR}-diff.txt" ]] && \ ipsCompare.sh -O /tmp/ips.new -n $NEW $WHAT $FEATURE \ >"$DIR/${NR}-diff.txt" done done } function doAllPkgs { # handled like an IGROUP but done here, since it takes a while -> should be # done last DIR='everything' PARAMS="" if [[ -r "$DIR/list-${OR}.txt" ]]; then PARAMS+="-O $DIR/list-${OR}.txt " else PARAMS+="-o $OLD " fi if [[ -r "$DIR/list-${NR}.txt" ]]; then PARAMS+="-N $DIR/list-${NR}.txt " else PARAMS+="-n $NEW " fi Log.info "Doing $DIR/${OR}-${NR}-diff.txt ..." ipsCompare.sh ${PARAMS} -f -S /tmp/ips >"$DIR/${OR}-${NR}-diff.txt" \ || exit 1 [[ ! -r "$DIR/list-${OR}.txt" ]] && cp /tmp/ips.old "$DIR/list-${OR}.txt" [[ ! -r "$DIR/list-${NR}.txt" ]] && cp /tmp/ips.new "$DIR/list-${NR}.txt" Log.info "Doing $DIR/${OR}-${NR}-full-diff.txt ..." ipsCompare.sh -O /tmp/ips.old -N /tmp/ips.new -a >"$DIR/${OR}-${NR}-full-diff.txt" Log.info "Doing $DIR/${OR}-${NR}-all.txt ..." ipsCompare.sh -O /tmp/ips.old -N /tmp/ips.new -A >"$DIR/${OR}-${NR}-all.txt" # handled like a FEATURE group for WHAT in $IGROUPS ; do SDIR="$WHAT/$DIR" if [[ ! -d "$SDIR" ]]; then mkdir "$SDIR" || exit 1 fi Log.info "Doing $SDIR/${OR}-diff.txt ..." [[ ! -r "$SDIR/${OR}-diff.txt" ]] && \ ipsCompare.sh -O "$WHAT/list-${OR}.txt" -N "$DIR/list-${OR}.txt" \ >"$SDIR/${OR}-diff.txt" Log.info "Doing $SDIR/${NR}-diff.txt ..." [[ ! -r "$SDIR/${NR}-diff.txt" ]] && \ ipsCompare.sh -O "$WHAT/list-${NR}.txt" -N "$DIR/list-${NR}.txt" \ >"$SDIR/${NR}-diff.txt" done Log.info "Done." } while getopts "${ print ${Man.FUNC[MAIN]}; }" option ; do case "$option" in h) showUsage $PROG MAIN ; exit 0 ;; a) doAll ; exit 0 ;; l) print -u2 "Versions available:\n" ipsCompare.sh -l >&2 exit 0 ;; F) typeset +f ; exit 0 ;; H) if [[ ${OPTARG%_t} != $OPTARG ]]; then $OPTARG --man # self-defined types else showUsage "$OPTARG" "$OPTARG" # function fi exit 0 ;; T) typeset -ft ${OPTARG//,/ } ;; esac done X=$((OPTIND-1)) shift $X OLD="$1" NEW="$2" if [[ -z $OLD || -z $NEW ]]; then showUsage $PROG MAIN exit 1 fi OLDIFS="$IFS" IFS='.' typeset -ia ANV=( ${NEW#*-} ) typeset -ia AOV=( ${OLD#*-} ) IFS="$OLDIFS" NR=${NEW%-*} OR=${OLD%-*} NR=${NR##*.} OR=${OR##*.} NR+=".${ANV[2]}.${ANV[3]}.${ANV[5]}" OR+=".${AOV[2]}.${AOV[3]}.${AOV[5]}" doGroups doAllPkgs