#!/bin/bash ref_dir_def=build.saved/xml this_proc=$(basename $0) usage () { echo "Usage : $this_proc [-v] [-d] [-p profile] [ref_profile_dir]" echo "" echo "\tref_profile_dir specified the directory where are stored reference" echo "\tprofiles (D: build.saved/xml)." echo "" echo "\t-d : compare dependency files too" echo "\t-p profile : compare only the specified profile (without .xml)" echo "\t-t : terse output (show only the configuration differences" echo " without context, RPM differences ignored)" echo "\t-v : verbose output (show differences)" echo "" exit } verbose=0 profile='*' check_dep_files=0 terse_output=0 while [ -n "$(echo $1 | grep '^-')" ] do case "$1" in -d|--dep*) check_dep_files=1 ;; -h|--help) usage ;; -v|--ver*) verbose=1 ;; -p|--pro*) shift if [ -z "$1" ] then usage fi profile=$1 ;; -t|--terse) terse_output=1 ;; *) echo "Unsupported option : $1" usage ;; esac shift done if [ -n "$1" ] then ref_dir=$1 else ref_dir=$ref_dir_def fi xml_dir=build/xml if [ $check_dep_files -eq 1 ] then file_pattern="${profile}.xml.dep" echo "Comparing dependency files ($file_pattern)..." files=`find $xml_dir -name "$file_pattern"` for file in $files do filename=$(basename $file) out1="/tmp/${this_proc}.out1" sort $file > $out1 out2="/tmp/${this_proc}.out2" sort $ref_dir/$filename > $out2 xmldiff=`diff $out2 $out1` if [ $? -ne 0 ] then echo Differences found in $file if [ $verbose -gt 0 ] then diff -u $out2 $out1 echo "" fi fi done fi file_pattern="${profile}.xml" echo "" echo "Comparing XML files ($file_pattern)..." files=$(find $xml_dir -name "$file_pattern" -not -name profiles-info.xml) for file in $files do #echo $file xmldiff=`diff $ref_dir $file` if [ $? -ne 0 ] then echo Differences found in $file if [ $verbose -gt 0 ] then diff -u $ref_dir $file echo "" elif [ $terse_output -eq 1 ] then diff -u $ref_dir $file | egrep '^-|\+' | grep -v version | \ egrep -v '^(-|\+)$' | grep -v '^@@.*@@$' echo "" fi fi done