/var/lib/sorcery/modules/dl_handlers/dl_cvs
1 #!/bin/bash
2 #---------------------------------------------------------------------
3 ##
4 ##=head1 SYNOPSIS
5 ##
6 ## Download handler for downloading cvs urls.
7 ##
8 ##=head1 DESCRIPTION
9 ##
10 ## This file contains functions for I<downloading> files through cvs.
11 ##
12 ## In order for cvs urls to be downloaded, the I<cvs> spell must have been
13 ## cast. This script first determines if cvs has been installed before
14 ## attempting to download a cvs url.
15 ##
16 ##
17 ##=head1 COPYRIGHT
18 ##
19 ## Copyright 2002 by the Source Mage Team
20 ## Copyright 2005 by the Source Mage Team
21 ##
22 ##=head1 FUNCTIONS
23 ##
24 ##=over 4
25 ##
26 #---------------------------------------------------------------------
27
28 #---------------------------------------------------------------------
29 ##=item dl_get_cvs <url>
30 ##
31 ## Fetch the specified cvs url.
32 ##
33 ## This function always assumes that a tree is being downloaded (for now).
34 ## If there is a directory names $target, it is assumed that cvs should be
35 ## updating, not checking out. If the directory doesnt exist, then checkout
36 ## is assumed.
37 ##
38 ## Assume url is valid.
39 ##
40 ## No hints are defined currently.
41 ##
42 #---------------------------------------------------------------------
43 function dl_cvs_get() {
44 dl_command_check cvs || return 254
45
46 local target=$1
47 local url_list=$2
48 local hints=$3
49 local dl_target=$4
50 local dl_type=$5
51 local rc=1 url
52 local CVS_OPTIONS="-q -z3"
53
54 [[ $target ]] &&
55 dl_connect || return 255
56
57 for url in $url_list ; do
58 local URL CVS_ROOT CVS_MODULE CVS_TAG
59 url_cvs_crack $url
60
61 # if the target is a directory then its quite possible we're
62 # updating a tree rather than checking a new one out
63 if test -d $target; then
64 message "${MESSAGE_COLOR}Running cvs update...${DEFAULT_COLOR}"
65 if cd $target; then
66 cvs $CVS_OPTIONS update -d -r $CVS_TAG
67 rc=$?
68 cd ..
69 else
70 dl_disconnect
71 return 1
72 fi
73 else
74 message "${MESSAGE_COLOR}Running cvs checkout...${DEFAULT_COLOR}"
75 cvs $CVS_OPTIONS -d$CVS_ROOT checkout -r $CVS_TAG -d $target $CVS_MODULE
76 rc=$?
77 fi
78 [[ $rc == 0 ]] && break
79 done
80 dl_disconnect
81
82 eval "$dl_target=\"$target\""
83 eval "$dl_type=\"tree\""
84 return $rc
85 }
86
87
88
89 #---------------------------------------------------------------------
90 ##=back
91 ##
92 ##=head1 LICENSE
93 ##
94 ## This software is free software; you can redistribute it and/or modify
95 ## it under the terms of the GNU General Public License as published by
96 ## the Free Software Foundation; either version 2 of the License, or
97 ## (at your option) any later version.
98 ##
99 ## This software is distributed in the hope that it will be useful,
100 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
101 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102 ## GNU General Public License for more details.
103 ##
104 ## You should have received a copy of the GNU General Public License
105 ## along with this software; if not, write to the Free Software
106 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
107 ##
108 #---------------------------------------------------------------------