1 #!/bin/sh 2 3 # $Id: check_unused.sh 10701 2007-02-28 23:28:48Z laca $ 4 # 5 # Search for files in cvs that are not referenced in spec files. 6 # Depending on command line switch, script searches for: 7 # - patches not referenced in any spec file 8 # - ext-sources not referenced in any spec file 9 # - Linux spec files not mentioned in any Solaris spec file. 10 # 11 12 13 # Display usage if no arguments on command line. 14 if [ $# -eq 0 ] 15 then 16 cat << END_OF_USAGE 17 Usage: `basename $0` [-patches|-ext-sources|-linux-only] 18 19 -patches list patches not referenced in any spec file. 20 -ext-sources list ext-sources files not referenced in any spec file 21 -linux-only list Linux spec files not mentioned in any Solaris spec file. 22 END_OF_USAGE 23 exit 1 24 fi 25 26 27 # Determine the script directory. 28 ScriptDir=`dirname $0` # Get potentially relative script directory. 29 ScriptDir=`( cd $ScriptDir; pwd )` # Get absolute directory. 30 31 # Go to the spec-files directory and ensure other dirs present. 32 cd $ScriptDir/.. 33 if [ ! -d patches -o ! -d base-specs -o ! -d closed -o ! -d ext-sources ] 34 then 35 echo "ERROR: Expected directory structure not present. Contact gnome-re (at] sun.com." 36 exit 1 37 fi 38 39 40 case "$1" in 41 # Search for '^Patch.*' in Solaris, base and closed spec files. 42 -patches|-p*) 43 for d in patches 44 do 45 for f in `cd $d; ls *.diff` 46 do 47 found=`grep "^Patch.*$f" *.spec base-specs/*.spec closed/*.spec` 48 if [ -z "$found" ] 49 then 50 echo $d/$f 51 fi 52 done 53 done ;; 54 55 # Search '^Source' in all spec files, '^SUNW_Copyright' in Solaris spec 56 # files and then '^%.class' (rclass and iclass) in Solaris spec files. 57 -ext-sources|-e*) 58 for f in `cd ext-sources; ls` 59 do 60 if [ -f ext-sources/$f ] 61 then 62 found=`grep "^Source.*$f" *.spec base-specs/*.spec closed/*.spec` 63 if [ -z "$found" ] 64 then 65 found=`grep "^SUNW_Copyright.*$f" *.spec closed/*.spec` 66 if [ -z "$found" ] 67 then 68 found=`grep "^%.class.*$f" *.spec closed/*.spec` 69 if [ -z "$found" ] 70 then 71 echo $f 72 fi 73 fi 74 fi 75 fi 76 done ;; 77 78 # Search for '^%use.*' in Solaris spec files. 79 -linux-only|-l*) 80 for f in *.spec 81 do 82 found=`grep "^%use.*$f" *.spec closed/*.spec` 83 if [ -z "$found" ] 84 then 85 echo $f 86 fi 87 done ;; 88 esac 89 90