#!/bin/sh # Generate updated software list # BSD License. Copyright (C) by Rashid N. "CityCat" Achilov # $Id: genupdlist,v 1.1.1.1 2008/01/20 21:10:58 shelton Exp $ # Output file name outfile="/tmp/portlist" # Test output file on existance and ability to write if [ -e $outfile ]; then if [ ! -O $outfile ]; then echo "Output file exist and owned by another user" exit else rm -f $outfile fi fi # Print header (hostname and date) echo "Obsoleted packages on `hostname` at `date`" echo "----------------------------------------------------------------------" echo "" # Take updating caididates list file=`pkg_version -v | grep updating` saveifs=$IFS newline=" " IFS=$newline for one in $file do # $1 is old package name and version, $7 is new package version IFS=$saveifs set $one # Strip out package name oldverx=${1##*-} # Strip out '_' in version, if any oldverz=${oldverx%%_*} # Strip out '.' in version, if any. Result: version 1.22.33_4,5 strips to 1.22.33 oldvery=${oldverz%%,*} # Strip out ')' in version newverx=${7%%)} # Similar old version, strip out '_' and ',' in version, if any newverz=${newverx%%_*} newvery=${newverz%%,*} # Compare versions if [ ! $oldvery = $newvery ]; then # Calculate package name string length and output it xx=${1%-*} len=${#xx} echo -n $xx echo $xx >> $outfile # Output package old version with appropriate quantity of separators if [ $len -lt 8 ]; then printf "\t\t\t\t%s" $oldvery elif [ $len -ge 8 ] && [ $len -lt 16 ]; then printf "\t\t\t%s" $oldvery elif [ $len -ge 16 ] && [ $len -lt 24 ]; then printf "\t\t%s" $oldvery else printf "\t%s" $oldvery fi # Calculate old version string length len=${#oldvery} # Output old version string with appropriate quantity of separators if [ $len -le 7 ]; then printf "\t\t%s\n" $newvery else printf "\t%s\n" $newvery fi fi IFS=$newline done