ENH: foamConfigurePaths : check that sed has done something

This commit is contained in:
mattijs
2010-10-19 17:46:21 +01:00
parent 17c42465b1
commit 0d470d124e

View File

@ -46,6 +46,17 @@ USAGE
} }
# Function to do replacement on file. Checks if any replacement has been done.
# inlineSed <file> <sedCommand> <description>
_inlineSed()
{
backup=`tempfile`
cp $1 $backup
sed -i -e "$2" $1
cmp $1 $backup || usage "Failed : $3"
}
[ -f etc/bashrc -a -f etc/settings.sh ] || usage "Please run from top-level directory of installation" [ -f etc/bashrc -a -f etc/settings.sh ] || usage "Please run from top-level directory of installation"
unset foamInstall projectName archOption paraviewInstall unset foamInstall projectName archOption paraviewInstall
@ -60,29 +71,39 @@ do
--foamInstall) --foamInstall)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
foamInstall="$2" foamInstall="$2"
echo "Replacing foamInstall setting by $foamInstall" echo "** foamInstall:$foamInstall"
sed -i -e '/^[^#]/s@foamInstall=.*@foamInstall='"$foamInstall@" etc/bashrc
_inlineSed \
etc/bashrc \
'/^[^#]/s@foamInstall=.*@foamInstall='"$foamInstall@" \
"Replacing foamInstall setting by $foamInstall"
shift 2 shift 2
;; ;;
--projectName) --projectName)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
projectName="$2" projectName="$2"
echo "Replacing WM_PROJECT_DIR setting by $projectName" _inlineSed \
sed -i -e '/^[^#]/s@WM_PROJECT_DIR=.*@WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName@" etc/bashrc etc/bashrc \
'/^[^#]/s@WM_PROJECT_DIR=.*@WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName@" \
"Replacing WM_PROJECT_DIR setting by $projectName"
shift 2 shift 2
;; ;;
--archOption) --archOption)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
archOption="$2" archOption="$2"
echo "Replacing WM_ARCH_OPTION setting by $archOption" _inlineSed \
sed -i -e '/^[^#]/s@: ${WM_ARCH_OPTION:=64}@WM_ARCH_OPTION='"$archOption@" etc/bashrc etc/bashrc \
'/^[^#]/s@: ${WM_ARCH_OPTION:=64}@WM_ARCH_OPTION='"$archOption@" \
"Replacing WM_ARCH_OPTION setting by $archOption"
shift 2 shift 2
;; ;;
--paraviewInstall) --paraviewInstall)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
paraviewInstall="$2" paraviewInstall="$2"
echo "Replacing ParaView_DIR setting by $paraviewInstall" _inlineSed \
sed -i -e '/^[^#]/s@ParaView_DIR=.*@ParaView_DIR='"$paraviewInstall@" etc/apps/paraview3/bashrc etc/apps/paraview3/bashrc \
'/^[^#]/s@ParaView_DIR=.*@ParaView_DIR='"$paraviewInstall@" \
"Replacing ParaView_DIR setting by $paraviewInstall"
shift 2 shift 2
;; ;;
*) *)
@ -97,11 +118,14 @@ done
#sed -i -e 's@WM_PROJECT=.*@WM_PROJECT='"$projectName@" etc/bashrc #sed -i -e 's@WM_PROJECT=.*@WM_PROJECT='"$projectName@" etc/bashrc
# Replace the WM_MPLIB always # Replace the WM_MPLIB always
echo "Replacing WM_MPLIB setting by SYSTEMOPENMPI" _inlineSed \
sed -i -e '/^[^#]/s@: ${WM_MPLIB:=.*}@WM_MPLIB=SYSTEMOPENMPI@' etc/bashrc etc/bashrc \
'/^[^#]/s@: ${WM_MPLIB:=.*}@WM_MPLIB=SYSTEMOPENMPI@' \
"Replacing WM_MPLIB setting by SYSTEMOPENMPI"
# Replace the compilerInstall always # Replace the compilerInstall always
echo "Replacing compilerInstall setting by system" _inlineSed \
sed -i -e '/^[^#]/s@: ${compilerInstall:=.*}@compilerInstall=system@' etc/settings.sh etc/settings.sh \
'/^[^#]/s@: ${compilerInstall:=.*}@compilerInstall=system@' \
"Replacing compilerInstall setting by system"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------