1 | #!/bin/bash |
---|
2 | # N.B. run this script on EXTERNAL directory!!! |
---|
3 | |
---|
4 | set -u |
---|
5 | |
---|
6 | if [ $# -ne 4 ]; then |
---|
7 | echo "Usage: $0 vendor_branch nemo_vendor_old new username" |
---|
8 | echo "first argument: vendor name (for example: IOIPSL)" |
---|
9 | echo "second argument: old tag name of the vendor in NEMO vendors deposit (for example: v2_1_9 or 53)" |
---|
10 | echo "third argument: definition of the tag or the revision number of the vendor to be updated (for example: v2_2_1 or 114)" |
---|
11 | echo "fourth argument: user login name" |
---|
12 | echo |
---|
13 | echo "run this script on EXTERNAL/svn_tools directory" |
---|
14 | echo |
---|
15 | echo |
---|
16 | echo "examples" |
---|
17 | echo |
---|
18 | echo "./update_vendor.sh IOIPSL v2_1_9 v2_2_1 smasson" |
---|
19 | echo "./update_vendor.sh XMLF90 53 114 smasson" |
---|
20 | echo "./update_vendor.sh XMLIO_SERVER 53 114 smasson" |
---|
21 | echo "./update_vendor.sh AGRIF 00 1988 smasson" |
---|
22 | |
---|
23 | exit 1 |
---|
24 | fi |
---|
25 | |
---|
26 | vendor_branch=$1 |
---|
27 | nemo_vendor_old=$2 |
---|
28 | new=$3 |
---|
29 | username=$4 |
---|
30 | |
---|
31 | #- |
---|
32 | #----------------------------------------------------------------------------------- |
---|
33 | # path definitions... could need to be changed... |
---|
34 | #----------------------------------------------------------------------------------- |
---|
35 | #- |
---|
36 | |
---|
37 | #- My projet url |
---|
38 | svn_nemo_vendor=svn+ssh://$username@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/vendors/$vendor_branch |
---|
39 | |
---|
40 | #- EXTERNAL directory in which we want to merge vendors |
---|
41 | svn_external=svn+ssh://$username@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL |
---|
42 | |
---|
43 | #- Vendor project original url |
---|
44 | case $vendor_branch in |
---|
45 | IOIPSL) vendor_url=http://forge.ipsl.jussieu.fr/igcmg/svn/$vendor_branch/tags ;; |
---|
46 | AGRIF) vendor_url=http://forge.ipsl.jussieu.fr/nemo/svn/trunk/$vendor_branch ;; |
---|
47 | XMLF90) vendor_url=http://forge.ipsl.jussieu.fr/ioserver/svn/$vendor_branch ;; |
---|
48 | XMLIO_SERVER) vendor_url=http://forge.ipsl.jussieu.fr/ioserver/svn/XMLIO_SERVER/trunk ;; |
---|
49 | fcm) echo "url of fcm undefined..." ; exit 2 ;; |
---|
50 | *) echo "wrong definition of the vendor name..." ; exit 3 ;; |
---|
51 | esac |
---|
52 | |
---|
53 | #- get a tag or a revision?? |
---|
54 | if [ "$vendor_branch" = "IOIPSL" ] |
---|
55 | then |
---|
56 | rev_or_tag="tag" |
---|
57 | else |
---|
58 | rev_or_tag="rev" |
---|
59 | fi |
---|
60 | |
---|
61 | #- |
---|
62 | #----------------------------------------------------------------------------------- |
---|
63 | # end of path definitions... |
---|
64 | #----------------------------------------------------------------------------------- |
---|
65 | #- |
---|
66 | echo |
---|
67 | echo "########################################################" |
---|
68 | echo "# #" |
---|
69 | echo "# run this script in EXTERNAL/svn_tools directory!!! #" |
---|
70 | echo "# #" |
---|
71 | echo "########################################################" |
---|
72 | echo |
---|
73 | |
---|
74 | #- checkout new vendor version without the .svn directories (-> use export instead of checkout) and put it in a working_directory |
---|
75 | echo |
---|
76 | echo "Downloading $vendor_branch tag $new into working_directory..." |
---|
77 | echo |
---|
78 | [[ ( -d working_directory ) || ( -f working_directory ) ]] && rm -rf working_directory # cleaning |
---|
79 | if [ "$rev_or_tag" = "tag" ] |
---|
80 | then |
---|
81 | svn export $vendor_url/$new working_directory # specify the tag path |
---|
82 | else |
---|
83 | svn export -r $new $vendor_url working_directory # specify the revision number |
---|
84 | fi |
---|
85 | |
---|
86 | #- update the vendor deposit: |
---|
87 | #- 1) create a clean version of the current version (take care od added and removed file) and commit it |
---|
88 | #- 2) tag it with a new name $nemo_vendor_new |
---|
89 | if [ "$rev_or_tag" = "tag" ] |
---|
90 | then |
---|
91 | nemo_vendor_new=$new |
---|
92 | else |
---|
93 | nemo_vendor_new=r_$new |
---|
94 | fi |
---|
95 | echo |
---|
96 | echo "updating $vendor_branch/current and tagging this new version as $vendor_branch/$nemo_vendor_new" |
---|
97 | echo |
---|
98 | ./svn_load_dirs.pl -t $nemo_vendor_new $svn_nemo_vendor current working_directory |
---|
99 | #- |
---|
100 | #- merge old and new version of $vendor_branch in $svn_external/$vendor_branch |
---|
101 | #- |
---|
102 | echo |
---|
103 | echo "##############################################" |
---|
104 | echo |
---|
105 | echo "merge old and new version of $vendor_branch in $svn_external/$vendor_branch" |
---|
106 | echo "if everything is ok you should execute the folling command:" |
---|
107 | echo |
---|
108 | echo "svn merge $svn_nemo_vendor/$nemo_vendor_old $svn_nemo_vendor/current ../$vendor_branch" |
---|
109 | |
---|
110 | echo |
---|
111 | echo |
---|
112 | echo "##############################################" |
---|
113 | echo |
---|
114 | echo "Commiting the merge of $vendor_branch changes toward $svn_external/$vendor_branch" |
---|
115 | echo "if everything is ok you should execute the folling command:" |
---|
116 | echo |
---|
117 | echo "svn ci --message \"merging $vendor_branch/$nemo_vendor_new into the EXTERNAL deposit\" ../$vendor_branch" |
---|
118 | echo |
---|
119 | echo |
---|
120 | |
---|
121 | |
---|
122 | ## NOTE : after a merge we have conflicts |
---|
123 | ## to resole them it is necessary to do, for example : svn resolved IOIPSL/directory with conflits |
---|
124 | |
---|
125 | ## NOTE : if you have a good merge then you have to committ: |
---|
126 | ## cd $tmp_dir/IOIPSL |
---|
127 | ## svn status ../IOIPSL |
---|
128 | ## svn ci --username $username --message "merge IOIPSL version $nemo_vendor_new" |
---|
129 | |
---|
130 | exit 0 |
---|
131 | |
---|