mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
renamed bin/foamCheckSourceDeps -> bin/rmdepold and cleaned up
This commit is contained in:
@ -24,32 +24,33 @@
|
|||||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#
|
#
|
||||||
# Script
|
# Script
|
||||||
# foamCheckSourceDeps
|
# rmdepold
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# Usage: foamCheckSourceDeps [dir1 .. dirN]
|
# Usage: rmdepold [dir1 .. dirN]
|
||||||
#
|
#
|
||||||
# Search for *.dep files that are without a corresponding .C or .L file.
|
# Remove *.dep files that are without a corresponding .C or .L file.
|
||||||
# These could indicate a directory that has been moved.
|
# This often occurs when a directory has been moved.
|
||||||
# - print questionable directory and the *.dep file
|
# - print questionable directory and the *.dep file
|
||||||
|
# - optionally remove empty directories
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
cat<<USAGE 1>&2
|
cat<<USAGE 1>&2
|
||||||
Usage: ${0##*/} [OPTION] [dir1 .. dirN]
|
Usage: ${0##*/} [OPTION] [dir1 .. dirN]
|
||||||
options:
|
options:
|
||||||
-rm | -remove remove the offending .dep file
|
|
||||||
-rmdir find and remove empty directories (recursively)
|
-rmdir find and remove empty directories (recursively)
|
||||||
|
|
||||||
* Search for .dep files that are without a corresponding .C or .L file.
|
Remove *.dep files that are without a corresponding .C or .L file.
|
||||||
This could indicate a directory that has been moved.
|
This often occurs when a directory has been moved.
|
||||||
- print questionable directory and file
|
- print questionable directory and file
|
||||||
|
- optionally remove empty directories
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
unset optRemove optrmDir
|
unset optRmdir
|
||||||
|
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
@ -58,12 +59,8 @@ do
|
|||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
-rm | -remove)
|
|
||||||
optRemove=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-rmdir)
|
-rmdir)
|
||||||
optrmDir=true
|
optRmdir=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
@ -75,36 +72,38 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]
|
# default is the current directory
|
||||||
then
|
[ "$#" -gt 0 ] || set -- .
|
||||||
set -- .
|
|
||||||
fi
|
|
||||||
|
|
||||||
for checkDir
|
for checkDir
|
||||||
do
|
do
|
||||||
if [ -d $checkDir ]
|
if [ -d $checkDir ]
|
||||||
then
|
then
|
||||||
|
echo "searching: $checkDir"
|
||||||
|
else
|
||||||
|
echo "skipping non-dir: $checkDir"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
find $checkDir -name '*.dep' -print | while read depFile
|
find $checkDir -name '*.dep' -print | while read depFile
|
||||||
do
|
do
|
||||||
# check C++ and Flex files
|
# check C++ and Flex files
|
||||||
if [ ! -r "${depFile%dep}C" -a ! -r "${depFile%dep}L" ];
|
if [ ! -r "${depFile%dep}C" -a ! -r "${depFile%dep}L" ];
|
||||||
then
|
then
|
||||||
echo "${depFile%/[^/]*} ${depFile##*/}"
|
echo "rm $depFile"
|
||||||
[ "$optRemove" ] && rm -f $depFile
|
rm -f $depFile 2>/dev/null
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$optrmDir" ]
|
# remove empty dirs
|
||||||
|
if [ "$optRmdir" ]
|
||||||
then
|
then
|
||||||
for checkDir
|
# get subdirs ourselves so we can avoid particular directories
|
||||||
|
for dir in $(find $checkDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
|
||||||
do
|
do
|
||||||
if [ -d $checkDir ]
|
echo "check dir: $dir"
|
||||||
then
|
find $dir -depth -type d -empty -exec rmdir {} \; -print
|
||||||
echo "scan directory: $checkDir"
|
|
||||||
find $checkDir -depth -type d -empty -print -exec rmdir \{\} \;
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
Reference in New Issue
Block a user