Changeset 12569 for utils/CI/sette/all_functions.sh
- Timestamp:
- 2020-03-18T12:22:56+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/CI/sette/all_functions.sh
r11161 r12569 91 91 usage=" if value is a string ths is neede syntax : ./set_namelist namelist_name var_name \"new_value\" " 92 92 93 # sync MYSRC files (input CFG and CFG_ST) 94 sync_config() { 95 if [ ${SYNC_CONFIGS} == "yes" ]; then 96 97 lREF=$3/$1 # reference 98 lCFG=$3/$2 # target 99 100 echo '-------------------------------------------------------------------------------' 101 echo ' SOURCE AND CONFIG FILES SYNCHRONISATION ' 102 echo '' 103 echo "configuration $lCFG/MY_SRC will be synchronised with $lREF/MY_SRC" 104 echo '' 105 # synchronise MY_SRC if $lCFG directory exist 106 if [ -d $lREF/MY_SRC ] && [ -d $lCFG ] ; then 107 108 if [ -d $lCFG/MY_SRC ] ; then 109 110 # Manage case number of file in MY_SRC changes 111 # find number of file only in $lCFG/MY_SRC 112 FCFG=`diff -r $lREF/MY_SRC $lCFG/MY_SRC | grep "Only in $lCFG/MY_SRC" | awk '{print $4}'` 113 114 # if more than 0, trigger a cleaning as Makenemo do not properly manage this case. 115 if [ ! -z "$FCFG" ]; then 116 echo '' 117 echo "$lCFG contains a different file list than $lREF :" 118 diff -r $lREF/MY_SRC $lCFG/MY_SRC | grep "Only in $lCFG/MY_SRC" | awk '{print $4}' 119 echo "Synchronisation is not enough because Makenemo does not handle well case where a file in MY_SRC is removed" 120 echo "Therefore, we need to clean $lCFG before starting runing it" 121 echo '' 122 CLEAN_CONFIGS="yes" 123 fi 124 fi 125 126 # synchronisation $lREF/MY_SRC directory (and delete file in target location if needed) 127 rsync -a --delete $lREF/MY_SRC/ $lCFG/MY_SRC 128 129 # rsync keep preserve the modification time stamp. 130 # To avoid case where a file in MY_SRC is replace by an older file, we touch the file 131 touch $lCFG/MY_SRC/* 132 fi 133 134 echo '' 135 echo "configuration $lCFG/EXP00 will be synchronised with $lREF/EXPREF" 136 echo "(links are skipped)" 137 echo '' 138 # synchronize EXPREF 139 if [ -d $lREF/EXPREF ] && [ -d $lCFG/EXP00 ] ; then 140 rsync -a --no-links $lREF/EXPREF/ $lCFG/EXP00/. 141 fi 142 echo '-------------------------------------------------------------------------------' 143 fi 144 } 145 146 # clean _ST config (input CFG CFG_ST TYPE (test or ref)) 147 clean_config() { 148 if [ ${CLEAN_CONFIGS} == "yes" ]; then 149 lREF=$1 150 lCFG=$2 151 lTYP=$3 152 echo '' 153 echo '-------------------------------------------------------------------------------' 154 echo ' CLEANING CONFIGURATION ' 155 echo '' 156 echo "./makenemo -n $lCFG -a/-r $lREF clean" 157 echo '' 158 if [ ${lTYP} == 'tests' ]; then 159 ./makenemo -n $lCFG -a $lREF clean 160 elif [ ${lTYP} == 'cfgs' ]; then 161 ./makenemo -n $lCFG -r $lREF clean 162 else 163 echo 'ERROR in the cleaning process'; exit 42 164 fi 165 echo '' 166 echo "$lCFG configuration has been cleaned" 167 echo '' 168 echo '-------------------------------------------------------------------------------' 169 fi 170 } 171 93 172 # define validation dir 94 173 set_valid_dir () { 95 LANG=en_US 96 REVISION_NB=`LC_MESSAGES=${LANG} ${SVN_CMD} info ${SETTE_DIR}/.. | grep "Last Changed Rev" | awk '{print $NF}'` 174 REVISION_NB=`${SVN_CMD} info ${SETTE_DIR}/.. | grep "Last Changed Rev" | awk '{print $NF}'` 97 175 if [ ${#REVISION_NB} -eq 0 ] 98 176 then … … 156 234 LINEVAR=$( grep -s -n "$VAR_NAME" ${EXE_DIR}/$NAMREF | awk -F: '{ { print $1} }' ) 157 235 echo " $VAR_NAME found in ${EXE_DIR}/$NAMREF at line $LINEVAR " >> ${SETTE_DIR}/output.sette 236 158 237 # search for namelist group name 159 238 NAMGRP=$( head -n$LINEVAR ${EXE_DIR}/$NAMREF | grep --line-buffered "^&nam" | tail -1 | awk -F" " '{ { print $1} }' ) 160 239 echo " variable $VAR_NAME will be added in $NAMGRP namelist-group of namelist file ${EXE_DIR}/$1 " >> ${SETTE_DIR}/output.sette 240 241 # check if namelist group present in namelist_cfg 242 # if missing group is added at the end of namelist_cfg 243 NGRP=$(grep ${NAMGRP} ${EXE_DIR}/$1 | wc -l ) 244 if [ ${NGRP} -eq 0 ]; then 245 echo '' >> ${SETTE_DIR}/output.sette 246 echo "+++++ Group ${NAMGRP} containing ${2} is missing in ${EXE_DIR}/$1 +++++ " >> ${SETTE_DIR}/output.sette 247 echo "+++++ Group ${NAMGRP} is added in ${EXE_DIR}/$1 +++++ " >> ${SETTE_DIR}/output.sette 248 echo '' >> ${SETTE_DIR}/output.sette 249 echo "&${NAMGRP}" >> ${EXE_DIR}/$1 250 echo "/" >> ${EXE_DIR}/$1 251 fi 252 161 253 # Add $VARNAME in namelist file ${EXE_DIR}/$1 in namelist group $NAMGRP 162 254 # on mac osx, replace sed --posix by gsed (available with mac port) 163 255 sed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp || gsed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp 256 164 257 # if file not empty replace ${EXE_DIR}/$1 165 258 if [ -s ${EXE_DIR}/$1.tmp ] ; then 166 259 mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1 167 260 else
Note: See TracChangeset
for help on using the changeset viewer.