#!/bin/bash dir=`dirname $0` [ -z "$dir" ] && dir=. CLASS_NAME="LMI_YumPackage" declare -A pkg1 pkg2 if [[ "$fedora_release" = 16 ]]; then pkg1=( \ [name]=python-xlib-doc [epoch]=0 \ [ver]=0.15 \ [rel]=0.6.rc1.fc16 \ [arch]=noarch \ [updatable]=0 \ ) pkg2=( \ [name]=ruby-ri \ [epoch]=0 \ [ver]=1.8.7.352 \ [rel]=1.fc16 \ [arch]=x86_64 \ [updatable]=1 \ [up_epoch]=0 \ [up_ver]=1.8.7.358 \ [up_rel]=2.fc16 \ ) elif [[ "$fedora_release" = 17 ]]; then pkg1=( \ [name]=python-xlib-doc [epoch]=0 \ [ver]=0.15 \ [rel]=0.6.rc1.fc17 \ [arch]=noarch \ [updatable]=0 \ ) pkg2=( \ [name]=slv2 \ [epoch]=0 \ [ver]=0.6.6 \ [rel]=8.fc17 \ [arch]=x86_64 \ [updatable]=1 \ [up_epoch]=0 \ [up_ver]=0.6.6 \ [up_rel]=9.fc17 \ ) elif [[ -z "$fedora_release" ]]; then echo "failed to get Fedora release number!" 2>&1 exit 1 else echo "no packages defined for Fedora release $fedora_release" 2>&1 exit 1 fi keys=(name epoch ver rel arch updatable up_epoch up_ver up_rel) make_inst_keys() { # accepts arguments: name, epoch, ver, rel, arch # in this order local path='Name="%s",SoftwareElementID="%s",SoftwareElementState="%s",' path+='TargetOperatingSystem="%s",Version="%s"' printf $path $1 `make_nevra "$@"` 2 36 $3 } test_install() { local name epoch ver rel arch updatable up_epoch up_ver up_rel; read name epoch ver rel arch updatable \ up_epoch up_ver up_rel <<< "$@" echo "********************************************************************" echo " * TEST INSTALL" nevra_arr=($name $epoch $ver $rel $arch) nevra=`make_nevra ${nevra_arr[@]}` echo -n "$nevra is " [ "$updatable" == 0 ] && echo -n "not " echo -n "updatable and " is_installed $name || echo -n "not " echo "installed" if is_installed $name; then echo "removing package \"${nevra}\" with rpm" remove $name fi local keys=`make_inst_keys ${nevra_arr[@]}` local url="$op.${keys}" echo "creating instance of $CLASS_NAME: $url" wbemerr ci "$url" "${keys},Release=\"$rel\"" if is_installed $name; then echo "successful installation" else echo "package not installed" exit 1 fi echo "testing installation of already installed package" wbemcli ci "${url}" "${keys},Release=\"rel\"" |& \ grep -q CIM_ERR_ALREADY_EXISTS && echo "success" || echo "failed" } test_update() { read name epoch ver rel arch updatable \ up_epoch up_ver up_rel <<< "$@" echo "********************************************************************" echo " * TEST UPDATE" if [ "$updatable" == 0 ]; then echo "package not updatable" exit 1 fi nevra_arr=($name $epoch $ver $rel $arch) nevra=`make_nevra ${nevra_arr[@]}` echo -n "$nevra is " [ "$updatable" == 0 ] && echo -n "not " echo -n "updatable and " is_installed $name || echo -n "not " echo "installed" if is_installed $name; then echo "removing package \"${name}\" with rpm" remove $name fi local keys=`make_inst_keys ${nevra_arr[@]}` local url="$op.${keys}" echo "intalling older package with $CLASS_NAME: $url" wbemerr ci "$url" "${keys},Release=\"$rel\"" if is_installed $name; then echo "successful installation" else echo "package not installed" exit 1 fi echo "updating with ${CLASS_NAME}.Update()" wbemerr cm "$url" "Update" | grep -q '\