#! /bin/bash # @(#) import.sh 1.02 10/17/2000 A. Schwarz; #----------------------------------------------------------------------------- # # Purpose: Produce listings of all Rational views required to build each # of the input Ada main programs # # Usage: ksh import.sh main.lst [] # # Arguments # main.lst full path name to all main programs to be tar'd # directory directory to place output files # # return # 0 succeed # 1 fail # # Description # # For each main program, the Rational imports are used to determine # the list of all views required to build the given main (using the # 'import.sh' script). # # # # FILES: # Output #
.imp listing of all imports required to build # the main program. # # Variables and Constants: # none # # Assumptions: # # # Notes: # # Version History: # Date name Description # 2000/10/17 AIS support paths to views and to main programs. keep .Rational # 1999/09/12 AIS allow Rational directories but remove .Rational # 1999/08/17 AIS Original issue #----------------------------------------------------------------------------- tmp=/tmp/$$.import checkFile=${tmp}/check.txt tmpFile=${tmp}/tmp.txt outDir=`pwd` retval=0 function getImports { echo ' ' $1 importName=$1/Imports touch ${2} if [ -d ${importName} ] ; then cat ${importName}/*.cfg | egrep -iv '^( | )*#|<|>' | tr -s '' '\012' | sort >> ${2} fi return; } if [ $# -lt 1 ] then retval=1 echo ' ' echo "Missing Input Arguments" echo "import.sh main.lst []" elif [ ! -e $1 ] then retval=1 echo ' ' echo "Main List File does not exist: " \'$1\' elif [ $# -gt 1 ] then if [ ! -d $2 ] then retval=1 echo ' ' echo "Output directory not a directory or does not exist: $2" else outDir=$2 fi fi if [ ${retval} == 0 ] then mkdir -p ${tmp} for main in `cat $1` do outName=`basename ${main}` outName=${outName%\.*} if [ -e ${main} ] then echo ' ' if [ -d ${main} ] ; then view=${main} echo ' View : ' ${view} else view=`dirname ${main}` echo ' Main file: ' ${outName} fi uniq=${tmp}/uniq.txt outFile=${outDir}/${outName}.imp rm -f ${outFile} rm -f ${tmpFile} getImports ${view} ${outFile} echo ${view} >> ${outFile} sort -u ${outFile} > ${tmpFile} mv ${tmpFile} ${outFile} grep -iv rational ${outFile} > ${checkFile} until [ ! -s ${checkFile} ] do for imports in `cat ${checkFile}` do getImports ${imports} ${tmpFile} done sort -u ${tmpFile} > ${uniq} diff ${outFile} ${uniq} | grep '>' |\ sed 's/> //' | grep -iv rational > ${checkFile} sort -m -u ${outFile} ${uniq} > ${tmpFile} mv ${tmpFile} ${outFile} done else echo "Main file does not exist: " ${main} fi done fi rm -rf ${tmp} exit ${retval}