#! /bin/sh -p # # depend # # Shell script to find other packages that depend (via includes) on the # specified package. # # The user can then call lnkpkg to create links to the $BFDIST/packages # area for each of the listed packages. # # Or can do this at the file level using the -f option, listing all # packages and files that depend on the specified package and file. # # Glenn Cooper Jan 1997 # Glenn Cooper, Feb 19, 1997: add -f option # Glenn Cooper, Feb 21, 1997: several speedups in searching # A.M.Jonckheere, May 1, 1998: # 1) the test for "depend " was always true, so it merely # returned a list of all packages. # 2) the same test above didn't discriminate between packages # that begin with the same string as another: ie) depend abc # would return packages that depended on abc, abcd, abcde etc # 3) In .d files created by KCC, the source file field sometimes # is just the file name and sometimes the full path to the file. # Added a filter on the $srcfile output: `basename $srcfile`. # This takes care of both cases. # # Function: # # Search the .d files in # $BFDIST/releases//tmp// # for mention of the specified package [and file]. # # # Options: # -f List dependencies at the file level # -q Quiet mode: suppress notices, only print list of packages or files # # Arguments: # Package [and file] name # Optional: if present, check this release for dependencies # if not present, use release listed in .current # # Examples: # depend geom [current] # depend -f geom/CdfGeometry.hh # ########################################################################## USAGE="Usage: $0 [-fq] package[/file] [release]" # process options ckfiles=0 quiet=0 #set -v #set -x #amj:FNAL: getopts has replaced getopt as recommended usage on SGI and # DECUnix. Only getopts exists in the cygnus NT system. while getopts fq c do case $c in f) ckfiles=1;; q) quiet=1;; esac done shift `expr $OPTIND - 1` # check for correct number of arguments if [ "$#" -gt 2 -o "$#" -lt 1 ]; then echo "Error: $0 requires one or two arguments:" echo $USAGE exit 2 fi # if first argument looks like xxx/yyy, check for -f flag if [ `echo $1 | awk -F/ '{print NF}'` -gt 1 ]; then if [ $ckfiles = 0 ]; then echo "Please specify the -f option if you want to list\c" echo " file-level dependencies." echo $USAGE exit 2 fi fi # if release wasn't specified, tell user we're using one from .current if [ "$#" -eq 2 ]; then release=$2 else if [ -r ./.current ]; then release=`cat ./.current` if [ $quiet = 0 ]; then echo "No release specified; will check release $release." fi else echo "No release specified, and can't find .current in directory" echo " $PWD." echo "Please specify a release, or issue the $0 command from " echo "the directory you created with newrel." exit 2 fi fi # make sure the release we're checking exists, then go there if [ -r $BFDIST/releases/$release/tmp/$BFARCH ]; then cd $BFDIST/releases/$release/tmp/$BFARCH else if [ -d $BFDIST/releases/$release ]; then echo Error: tmp/$BFARCH area for release $release not found. else echo Error: release $release does not exist. Available releases are: ls $BFDIST/releases fi exit 2 fi # now search for dependencies, and print them if [ $ckfiles = 0 ]; then # list package dependencies if [ $quiet = 0 ]; then echo "These packages in release $release use include files from package $1:" fi for pkg in * do if [ "`grep -l /include/$1/ $pkg/* 2>/dev/null`" ]; then echo "$pkg \c" fi done echo " " else # list file dependencies if [ $quiet = 0 ]; then echo "These files in release $release include file $1:" fi depfiles=`find . -type f -name "*.d" -print | xargs grep -l /$1` for file in $depfiles do pkg=`echo $file | awk -F/ '{print $(NF-1)}'` srcfile=`head -1 $file | awk -F: '{print $2}'` echo $pkg/`basename $srcfile` done fi exit 0