[1581] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Martial Mancip |
---|
| 5 | # Contact: Martial.Mancip__at__ipsl.jussieu.fr |
---|
| 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
| 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | # Documentation : |
---|
| 15 | # This script creates a tree of last configuration modipsl from a tar file previously produced by script_diff_model. |
---|
| 16 | # |
---|
[1583] | 17 | # After you have downloaded modipsl, you can copy a modipsl_name_of_the_save directory tree (from a saved tar file) in modipsl. |
---|
[1581] | 18 | # (Please, see script_diff_model documentation for information of how to get this file.) |
---|
| 19 | # You may use this script to download the same configuration with new files and modifications linked with this tarball. |
---|
| 20 | # |
---|
| 21 | # usage (in modipsl path) : |
---|
| 22 | # modipsl_path> util/script_recup_model modipsl_name_of_the_save |
---|
| 23 | # |
---|
| 24 | # After this whole configuration is backuped, you must use as usual ins_make and ins_job script |
---|
| 25 | # to installed all files depended on this new modipsl and the computer. |
---|
| 26 | # |
---|
| 27 | # Note : |
---|
| 28 | # It may not compile because of special post-installation (not versionning) for some component in model. |
---|
| 29 | # See "Actions related to the WORK directory for the OPA models" in model script to reproduce this post-installation. |
---|
| 30 | #- |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | MODIPSL_SAVE_NAME=$1 |
---|
| 34 | |
---|
| 35 | MODIPSL=${MODIPSL:=$(pwd)} |
---|
| 36 | |
---|
| 37 | DEBUG_mode=false |
---|
| 38 | |
---|
| 39 | function printDebugArray { |
---|
| 40 | if ( ${DEBUG_mode} ); then |
---|
| 41 | typeset nb_line i |
---|
| 42 | eval nb_line=\${#$1[@]} |
---|
| 43 | eval echo "$1 : " ${nb_line} |
---|
| 44 | (( i = 0 )) |
---|
| 45 | while [ $i -lt $nb_line ] ; do |
---|
| 46 | eval echo \${$1[$i]} |
---|
| 47 | (( i = i + 1 )) |
---|
| 48 | done |
---|
| 49 | fi |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | MODIPSL_SAVE=${MODIPSL}/${MODIPSL_SAVE_NAME} |
---|
| 53 | |
---|
| 54 | #typeset NbComponents ModelComponents ModelTags ModelSystems ModelServers ModelDirectories ModelLocalDirs ListPathComp ListPathFile ListPathRev ListPathBranch ListNewFiles ListModifFiles ListModifFilesDate Maxfiledate |
---|
| 55 | |
---|
[1586] | 56 | if [ ! -f ${MODIPSL_SAVE}/Last_log ] ; then |
---|
[1585] | 57 | echo "You need to give a valid tree in argument of this script." |
---|
| 58 | echo "usage (in modipsl path) :" |
---|
| 59 | echo "modipsl_path> util/script_recup_model modipsl_name_of_the_save" |
---|
| 60 | exit 1 |
---|
| 61 | fi |
---|
[1581] | 62 | |
---|
| 63 | ((i=1)) |
---|
| 64 | while read line ; do |
---|
| 65 | case $i in |
---|
| 66 | 1) |
---|
| 67 | echo $line | sed -e 's&Last Model in log : *&&g' |
---|
| 68 | ;; |
---|
| 69 | 2) |
---|
| 70 | NbComponents=$( echo $line | sed -e"s/ *components ://" ) |
---|
| 71 | echo $NbComponents |
---|
| 72 | ;; |
---|
| 73 | 3) |
---|
| 74 | set +A ModelComponents -- $line |
---|
| 75 | printDebugArray ModelComponents |
---|
| 76 | ;; |
---|
| 77 | 4) |
---|
| 78 | set +A ModelTags -- $line |
---|
| 79 | printDebugArray ModelTags |
---|
| 80 | ;; |
---|
| 81 | 5) |
---|
| 82 | set +A ModelSystems -- $line |
---|
| 83 | printDebugArray ModelSystems |
---|
| 84 | ;; |
---|
| 85 | 6) |
---|
[1597] | 86 | (( j = 0 )) |
---|
| 87 | set +A ModelServersProtect -- $line |
---|
| 88 | for comp in ${ModelComponents[@]}; do |
---|
| 89 | ModelServers[$j]=$( echo ${ModelServersProtect[$j]} | sed -e 's&:_:& &g' ) |
---|
| 90 | (( j = j + 1 )) |
---|
| 91 | done |
---|
[1581] | 92 | printDebugArray ModelServers |
---|
| 93 | ;; |
---|
| 94 | 7) |
---|
| 95 | set +A ModelDirectories -- $line |
---|
| 96 | printDebugArray ModelDirectories |
---|
| 97 | ;; |
---|
| 98 | 8) |
---|
| 99 | set +A ModelLocalDirs -- $line |
---|
| 100 | printDebugArray ModelLocalDirs |
---|
| 101 | ;; |
---|
| 102 | 9) |
---|
| 103 | set +A ListPathComp -- $line |
---|
| 104 | printDebugArray ListPathComp |
---|
| 105 | ;; |
---|
| 106 | 10) |
---|
| 107 | set +A ListPathFile -- $line |
---|
| 108 | printDebugArray ListPathFile |
---|
| 109 | ;; |
---|
| 110 | 11) |
---|
| 111 | set +A ListPathRev -- $( echo $line | sed -e 's%\([0-9][0-9]/[0-9][0-9]/[0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)%\1_\2%g' ) |
---|
| 112 | printDebugArray ListPathRev |
---|
| 113 | ;; |
---|
| 114 | 12) |
---|
| 115 | set +A ListPathBranch -- $line |
---|
| 116 | printDebugArray ListPathBranch |
---|
| 117 | ;; |
---|
| 118 | 13) |
---|
| 119 | set +A ListNewFiles -- $line |
---|
| 120 | printDebugArray ListNewFiles |
---|
| 121 | ;; |
---|
| 122 | 14) |
---|
| 123 | set +A ListModifFiles -- $line |
---|
| 124 | printDebugArray ListModifFiles |
---|
| 125 | ;; |
---|
| 126 | 15) |
---|
| 127 | set +A ListModifFilesDate -- $line |
---|
| 128 | printDebugArray ListModifFilesDate |
---|
| 129 | ;; |
---|
| 130 | 16) |
---|
| 131 | Maxfiledate=$line |
---|
| 132 | printDebugArray Maxfiledate |
---|
| 133 | ;; |
---|
| 134 | *) |
---|
| 135 | break |
---|
| 136 | ;; |
---|
| 137 | esac |
---|
| 138 | ((i=i+1)) |
---|
| 139 | done < ${MODIPSL_SAVE}/Last_log |
---|
| 140 | |
---|
| 141 | echo |
---|
| 142 | echo "read Last_log OK !" |
---|
| 143 | echo |
---|
| 144 | |
---|
| 145 | (( i = 0 )) |
---|
| 146 | for comp in ${ModelComponents[@]}; do |
---|
| 147 | tag=${ModelTags[$i]} |
---|
| 148 | echo $i $comp " : " $tag |
---|
| 149 | |
---|
[1597] | 150 | if [ X${ListPathComp[$i]} != Xerror ] ; then |
---|
| 151 | pathComp=${ListPathComp[$i]} |
---|
| 152 | filecomp=$( echo ${ListPathFile[$i]} | sed -e "s/_empty_//" ) |
---|
| 153 | SpathComp=${MODIPSL_SAVE}/${pathComp} |
---|
| 154 | echo "Path/file :" ${pathComp}/${filecomp} |
---|
[1581] | 155 | |
---|
[1597] | 156 | case ${ModelSystems[$i]} in |
---|
| 157 | svn) |
---|
| 158 | svn co -r ${ListPathRev[$i]} ${ModelServers[$i]}/${ListPathBranch[$i]}/${filecomp} ${pathComp}/${filecomp} |
---|
| 159 | ;; |
---|
| 160 | cvs) |
---|
| 161 | |
---|
| 162 | cd ${ModelLocalDirs[i]} |
---|
| 163 | if [ X${ModelDirectories[$i]} = X. ] ; then |
---|
[1581] | 164 | # rev=$( echo ${ListPathRev[$i]} | sed -e 's%\([0-9][0-9]\)/\([0-9][0-9]\)/\([0-9][0-9]\)_\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)%\3/\1/\2 \4%g' ) |
---|
[1597] | 165 | rev=$( echo ${ListPathRev[$i]} | sed -e 's%:"[0-9][0-9]/[0-9][0-9]/[0-9][0-9]_[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"%%g' ) |
---|
| 166 | eval cvs -d :pserver:${ModelServers[$i]} co -r "${rev}" ${comp} |
---|
| 167 | else |
---|
| 168 | rev=$( echo ${ListPathRev[$i]} | sed -e 's%:"[0-9][0-9]/[0-9][0-9]/[0-9][0-9]_[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"%%g' ) |
---|
| 169 | echo cvs -d :pserver:${ModelServers[$i]} co -r ${rev} -d ${ModelDirectories[$i]} ${comp} |
---|
| 170 | cvs -d :pserver:${ModelServers[$i]} co -r ${rev} -d ${ModelDirectories[$i]} ${comp} |
---|
| 171 | fi |
---|
| 172 | cd ${MODIPSL} |
---|
| 173 | |
---|
| 174 | ;; |
---|
| 175 | *) |
---|
| 176 | echo "error ${ModelSystems[$i]} is not recognized as a valid control version system for ${MODIPSL_SAVE}/Last_log." |
---|
| 177 | exit 1 |
---|
| 178 | ;; |
---|
| 179 | esac |
---|
| 180 | fi |
---|
[1581] | 181 | ((i=i+1)) |
---|
| 182 | done |
---|
| 183 | |
---|
| 184 | set +A ListRep -- $( find ${MODIPSL_SAVE} -mindepth 1 -type d \ |
---|
| 185 | -exec bash -c " echo "'{}'" | sed -e 's&"${MODIPSL_SAVE}"/&&' | tee -a >( sed -e 's&\(.*\)&"${MODIPSL}"/\1&' | xargs mkdir -p >> out_mkdir 2>&1 ) " \; ) |
---|
| 186 | printDebugArray ListRep |
---|
| 187 | rm out_mkdir |
---|
| 188 | |
---|
| 189 | (( i = 0 )) |
---|
| 190 | for comp in ${ModelComponents[@]}; do |
---|
| 191 | |
---|
[1597] | 192 | if [ X${ListPathComp[$i]} != Xerror ] ; then |
---|
| 193 | tag=${ModelTags[$i]} |
---|
| 194 | echo $i $comp " : " $tag |
---|
[1581] | 195 | |
---|
[1597] | 196 | pathComp=${ListPathComp[$i]} |
---|
| 197 | filecomp=$( echo ${ListPathFile[$i]} | sed -e "s/_empty_//" ) |
---|
| 198 | SpathComp=${MODIPSL_SAVE}/${pathComp} |
---|
| 199 | echo "Patch :" $( ls ${SpathComp} ) |
---|
| 200 | |
---|
| 201 | # Patch this model |
---|
| 202 | cd ${pathComp} |
---|
| 203 | case ${ModelSystems[$i]} in |
---|
| 204 | svn) |
---|
| 205 | patch -p0 -i ${SpathComp}/svn_diff |
---|
| 206 | ;; |
---|
| 207 | cvs) |
---|
| 208 | patch -p0 -i ${SpathComp}/cvs_diff |
---|
| 209 | ;; |
---|
| 210 | esac |
---|
| 211 | cd ${MODIPSL} |
---|
| 212 | fi |
---|
[1581] | 213 | ((i=i+1)) |
---|
| 214 | done |
---|
| 215 | |
---|
| 216 | # copy new files |
---|
| 217 | for file in ${ListNewFiles[@]} ; do |
---|
| 218 | echo "copy New file : " ${MODIPSL_SAVE}/$file $file |
---|
| 219 | cp -p ${MODIPSL_SAVE}/$file $file |
---|
| 220 | done |
---|