/var/lib/sorcery/modules/dl_handlers/dl_svn
1 #!/bin/bash
2 #---------------------------------------------------------------------
3 ##
4 ##=head1 COPYRIGHT
5 ##
6 ## Copyright 2004 by the Source Mage Team
7 ##
8 ##=head1 FUNCTIONS
9 ##
10 ##=over 4
11 ##
12 #---------------------------------------------------------------------
13
14
15 #---------------------------------------------------------------------
16 ##=item dl_get_svn <url>
17 ##
18 ## Fetch the specified svn url.
19 ##
20 ## This handler only supports tree downloads.
21 ##
22 #---------------------------------------------------------------------
23 function dl_svn_get() {
24 dl_command_check svn || return 254
25
26 local target=$1
27 local url_list=$2
28 local hints=$3
29 local dl_target=$4
30 local dl_type=$5
31 local url rc=0
32
33 [[ $target ]] &&
34 dl_connect || return 255
35
36 for url in $url_list; do
37 local URL SVN_ROOT SVN_MODULE SVN_TAG
38 url_crack "$url" "$hints"
39
40 local svn_args="--non-interactive "
41 if list_find "$hints" "parse_username" ; then
42 local USER_PASS=$(echo $SVN_ROOT|sed 's#.*//\(.*\)@.*#\1#')
43 local SVN_ROOT=$(echo $SVN_ROOT|sed 's#//\(.*\)@#//#')
44 local USER=${USER_PASS%:*};
45 local PASS=${USER_PASS#*:};
46 svn_args="$svn_args --username $USER --password $PASS"
47 fi
48
49 if list_find "$hints" no-check-certificate && [[ $(url_get_prefix "$url") == svn_https ]]; then
50 svn_args="$svn_args --trust-server-cert"
51 fi
52
53 local svn_format=$(head -1 $target/.svn/entries)
54 message "${MESSAGE_COLOR}Subversion working copy format: $svn_format${DEFAULT_COLOR}"
55 if (( ${svn_format:-100} <= 10 )); then
56 message "${MESSAGE_COLOR}Running svn upgrade...${DEFAULT_COLOR}"
57 echo svn upgrade $svn_args $target
58 svn upgrade $svn_args $target
59 fi
60
61 if test -d $target; then
62 message "${MESSAGE_COLOR}Running svn update...${DEFAULT_COLOR}"
63 echo svn update $svn_args -r $SVN_TAG $target
64 svn update $svn_args -r $SVN_TAG $target
65 rc=$?
66 eval "$dl_target=\"$target\""
67 else
68 message "${MESSAGE_COLOR}Running svn checkout...${DEFAULT_COLOR}"
69 echo svn checkout $svn_args -r $SVN_TAG $SVN_ROOT $SVN_MODULE
70 svn checkout $svn_args -r $SVN_TAG $SVN_ROOT $SVN_MODULE
71 rc=$?
72 eval "$dl_target=\"$SVN_MODULE\""
73 fi
74 [[ $rc == 0 ]] && break
75 done
76 dl_disconnect
77
78 eval "$dl_type=\"tree\""
79 return $rc
80 }
81
82 #---------------------------------------------------------------------
83 ##=back
84 ##
85 ##=head1 LICENSE
86 ##
87 ## This software is free software; you can redistribute it and/or modify
88 ## it under the terms of the GNU General Public License as published by
89 ## the Free Software Foundation; either version 2 of the License, or
90 ## (at your option) any later version.
91 ##
92 ## This software is distributed in the hope that it will be useful,
93 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
94 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95 ## GNU General Public License for more details.
96 ##
97 ## You should have received a copy of the GNU General Public License
98 ## along with this software; if not, write to the Free Software
99 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
100 ##
101 #---------------------------------------------------------------------