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 | # |
---|
17 | # After you have downloaded modipsl, you can copy a modipsl_name_of_the_save directory tree (from a saved tar file) in modipsl. |
---|
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 | |
---|
56 | if [ -f ${MODIPSL_SAVE}/Last_log ] ; then |
---|
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 |
---|
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) |
---|
86 | set +A ModelServers -- $line |
---|
87 | printDebugArray ModelServers |
---|
88 | ;; |
---|
89 | 7) |
---|
90 | set +A ModelDirectories -- $line |
---|
91 | printDebugArray ModelDirectories |
---|
92 | ;; |
---|
93 | 8) |
---|
94 | set +A ModelLocalDirs -- $line |
---|
95 | printDebugArray ModelLocalDirs |
---|
96 | ;; |
---|
97 | 9) |
---|
98 | set +A ListPathComp -- $line |
---|
99 | printDebugArray ListPathComp |
---|
100 | ;; |
---|
101 | 10) |
---|
102 | set +A ListPathFile -- $line |
---|
103 | printDebugArray ListPathFile |
---|
104 | ;; |
---|
105 | 11) |
---|
106 | 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' ) |
---|
107 | printDebugArray ListPathRev |
---|
108 | ;; |
---|
109 | 12) |
---|
110 | set +A ListPathBranch -- $line |
---|
111 | printDebugArray ListPathBranch |
---|
112 | ;; |
---|
113 | 13) |
---|
114 | set +A ListNewFiles -- $line |
---|
115 | printDebugArray ListNewFiles |
---|
116 | ;; |
---|
117 | 14) |
---|
118 | set +A ListModifFiles -- $line |
---|
119 | printDebugArray ListModifFiles |
---|
120 | ;; |
---|
121 | 15) |
---|
122 | set +A ListModifFilesDate -- $line |
---|
123 | printDebugArray ListModifFilesDate |
---|
124 | ;; |
---|
125 | 16) |
---|
126 | Maxfiledate=$line |
---|
127 | printDebugArray Maxfiledate |
---|
128 | ;; |
---|
129 | *) |
---|
130 | break |
---|
131 | ;; |
---|
132 | esac |
---|
133 | ((i=i+1)) |
---|
134 | done < ${MODIPSL_SAVE}/Last_log |
---|
135 | |
---|
136 | echo |
---|
137 | echo "read Last_log OK !" |
---|
138 | echo |
---|
139 | |
---|
140 | (( i = 0 )) |
---|
141 | for comp in ${ModelComponents[@]}; do |
---|
142 | tag=${ModelTags[$i]} |
---|
143 | echo $i $comp " : " $tag |
---|
144 | |
---|
145 | pathComp=${ListPathComp[$i]} |
---|
146 | filecomp=$( echo ${ListPathFile[$i]} | sed -e "s/_empty_//" ) |
---|
147 | SpathComp=${MODIPSL_SAVE}/${pathComp} |
---|
148 | echo "Path/file :" ${pathComp}/${filecomp} |
---|
149 | |
---|
150 | case ${ModelSystems[$i]} in |
---|
151 | svn) |
---|
152 | svn co -r ${ListPathRev[$i]} ${ModelServers[$i]}/${ListPathBranch[$i]}/${filecomp} ${pathComp}/${filecomp} |
---|
153 | ;; |
---|
154 | cvs) |
---|
155 | |
---|
156 | cd ${ModelLocalDirs[i]} |
---|
157 | if [ X${ModelDirectories[$i]} = X. ] ; then |
---|
158 | # 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' ) |
---|
159 | 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' ) |
---|
160 | eval cvs -d :pserver:${ModelServers[$i]} co -r "${rev}" ${comp} |
---|
161 | else |
---|
162 | 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' ) |
---|
163 | echo cvs -d :pserver:${ModelServers[$i]} co -r ${rev} -d ${ModelDirectories[$i]} ${comp} |
---|
164 | cvs -d :pserver:${ModelServers[$i]} co -r ${rev} -d ${ModelDirectories[$i]} ${comp} |
---|
165 | fi |
---|
166 | cd ${MODIPSL} |
---|
167 | |
---|
168 | ;; |
---|
169 | *) |
---|
170 | echo "error ${ModelSystems[$i]} is not recognized as a valid control version system for ${MODIPSL_SAVE}/Last_log." |
---|
171 | exit 1 |
---|
172 | ;; |
---|
173 | esac |
---|
174 | ((i=i+1)) |
---|
175 | done |
---|
176 | |
---|
177 | set +A ListRep -- $( find ${MODIPSL_SAVE} -mindepth 1 -type d \ |
---|
178 | -exec bash -c " echo "'{}'" | sed -e 's&"${MODIPSL_SAVE}"/&&' | tee -a >( sed -e 's&\(.*\)&"${MODIPSL}"/\1&' | xargs mkdir -p >> out_mkdir 2>&1 ) " \; ) |
---|
179 | printDebugArray ListRep |
---|
180 | rm out_mkdir |
---|
181 | |
---|
182 | (( i = 0 )) |
---|
183 | for comp in ${ModelComponents[@]}; do |
---|
184 | tag=${ModelTags[$i]} |
---|
185 | echo $i $comp " : " $tag |
---|
186 | |
---|
187 | pathComp=${ListPathComp[$i]} |
---|
188 | filecomp=$( echo ${ListPathFile[$i]} | sed -e "s/_empty_//" ) |
---|
189 | SpathComp=${MODIPSL_SAVE}/${pathComp} |
---|
190 | echo "Patch :" $( ls ${SpathComp} ) |
---|
191 | |
---|
192 | # Patch this model |
---|
193 | cd ${pathComp} |
---|
194 | case ${ModelSystems[$i]} in |
---|
195 | svn) |
---|
196 | patch -p0 -i ${SpathComp}/svn_diff |
---|
197 | ;; |
---|
198 | cvs) |
---|
199 | patch -p0 -i ${SpathComp}/cvs_diff |
---|
200 | ;; |
---|
201 | esac |
---|
202 | cd ${MODIPSL} |
---|
203 | ((i=i+1)) |
---|
204 | done |
---|
205 | |
---|
206 | # copy new files |
---|
207 | for file in ${ListNewFiles[@]} ; do |
---|
208 | echo "copy New file : " ${MODIPSL_SAVE}/$file $file |
---|
209 | cp -p ${MODIPSL_SAVE}/$file $file |
---|
210 | done |
---|