Revision: | 1.14 |
Committed: | Thu Jul 11 12:53:39 2002 UTC (22 years, 10 months ago) by sashby |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | V1_1_7, V1_1_6, V1_1_5, V1_2_0-cand3, V1_2_0-cand2, V1_2_0-cand1, V1_1_4, V1_1_3, V1_1_2, V1_1_0_reltag8, V1_1_0_reltag7, V1_1_0_reltag6, V1_1_1, V1_1_0_reltag5, V1_1_0_reltag4, V1_1_0_reltag3, V1_1_0_reltag2, V1_1_0_reltag1, V1_1_0_reltag, V1_0_3-p4, V1_1_0_cand3, V1_1_0_cand2, V1_1_0_cand1, HEAD_SM_071214, forV1_1_0, v103_xml_071106, V1_0_3-p3, V1_0_3-p2, V1_1_0, v110p1, V110p6, V110p5, V110p4, V110p3, before110xmlBRmerge, V110p2, V110p1, V1_0_4p1, V1_0_3-p1, V1_0_3, V1_0_2, V1_0_2_p1, v102p1, V1_0_1, V1_0_0, V1_pre0, SCRAM_V1, SCRAMV1_IMPORT, V0_19_7, V0_19_6, V0_19_6p1 |
Branch point for: | forBinLess_SCRAM, HEAD_BRANCH_SM_071214, v200branch, v103_with_xml, v103_branch, V1_pre1, SCRAM_V1_BRANCH |
Changes since 1.13: | +10 -3 lines |
Log Message: | Some changes to BuidlSystem and URL handling (for local CVS repo installations |
# | User | Rev | Content |
---|---|---|---|
1 | williamc | 1.1 | # |
2 | # standard url interface for cvs | ||
3 | # | ||
4 | williamc | 1.12 | # cvs urls |
5 | # | ||
6 | # cvs://server_name:/repository_location?passkey=xxx&auth=xxx&user=xxx | ||
7 | # &module=co_files | ||
8 | # | ||
9 | williamc | 1.9 | # Interface |
10 | williamc | 1.1 | #------------- |
11 | # new() : | ||
12 | williamc | 1.5 | # get(url,$dirname) : |
13 | williamc | 1.1 | |
14 | williamc | 1.4 | package URL::URL_cvs; |
15 | williamc | 1.1 | require 5.001; |
16 | use Utilities::CVSmodule; | ||
17 | williamc | 1.12 | use URL::URL_base; |
18 | williamc | 1.1 | use Carp; |
19 | williamc | 1.13 | use Cwd; |
20 | |||
21 | williamc | 1.12 | @ISA = qw(URL::URL_base); |
22 | williamc | 1.1 | |
23 | sub init { | ||
24 | my $self=shift; | ||
25 | $self->{cvsco}="co"; | ||
26 | } | ||
27 | |||
28 | sub setbase { | ||
29 | my $self=shift; | ||
30 | williamc | 1.7 | my $base=shift; |
31 | williamc | 1.1 | my $varhash=shift; |
32 | |||
33 | my $auth=$$varhash{'auth'}; | ||
34 | |||
35 | # a new cvs object | ||
36 | williamc | 1.13 | $self->{cvsobject}=Utilities::CVSmodule->new(); |
37 | williamc | 1.1 | $self->{cvsobject}->set_base($base); |
38 | $self->{cvsobject}->set_auth($auth); | ||
39 | if ( exists $$varhash{'user'} ) { | ||
40 | $self->{cvsobject}->set_user($$varhash{'user'}); | ||
41 | } | ||
42 | if ( exists $$varhash{'passkey'} ) { | ||
43 | $self->{cvsobject}->set_passkey($$varhash{'passkey'}); | ||
44 | } | ||
45 | if ( exists $$varhash{'method'} ) { | ||
46 | $self->{cvsco}=$$varhash{'method'}; | ||
47 | } | ||
48 | # Alternative dir name to co to | ||
49 | if ( exists $$varhash{'name'} ) { | ||
50 | $self->{dirname}=$$varhash{'name'}; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | sub get { | ||
55 | my $self=shift; | ||
56 | my $url=shift; | ||
57 | williamc | 1.6 | my $location=shift; |
58 | williamc | 1.13 | my $rv=""; |
59 | williamc | 1.1 | |
60 | williamc | 1.6 | use File::Basename; |
61 | sashby | 1.14 | my ($dir,$dirname)=($location=~/(.*)\/(.*)/); |
62 | # Check for type of auth. If local, we can skip the server entry: | ||
63 | if ($url->vars()->{'auth'} eq "local") | ||
64 | { | ||
65 | $self->setbase($url->path(),$url->vars()); | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | $self->setbase($url->servername().":/".$url->path(),$url->vars()); | ||
70 | } | ||
71 | williamc | 1.13 | if ( -f $location ) { |
72 | # must be a file to update | ||
73 | my $thisdir=cwd(); | ||
74 | chdir $dir or die "unable to enter directory $dir\n"; | ||
75 | $self->{cvsobject}->invokecvs("update"); | ||
76 | chdir $thisdir; | ||
77 | $rv=$location; | ||
78 | williamc | 1.12 | } |
79 | williamc | 1.13 | else { #a checkout |
80 | require Utilities::AddDir; | ||
81 | if ( $dir ne $location ) { | ||
82 | AddDir::adddir($dir); | ||
83 | } | ||
84 | |||
85 | my @cvscmd=($self->{cvsco}); | ||
86 | my $version=$url->param('version'); | ||
87 | my $module; | ||
88 | ($module=$url->param('module'))=~s/\/$//; | ||
89 | my $filename=""; | ||
90 | if ( $module=~/\/.?/ ) { | ||
91 | ($filename=$module)=~s/.*\///; | ||
92 | } | ||
93 | williamc | 1.1 | |
94 | williamc | 1.13 | push @cvscmd, ("-d", "$dirname"); |
95 | if ( $version && ($version ne "") ) { | ||
96 | williamc | 1.6 | push @cvscmd, ("-r", "$version"); |
97 | williamc | 1.13 | } |
98 | # | ||
99 | # Check to see we have a server and if so attempt the checkout | ||
100 | # | ||
101 | if ( ! defined $self->{cvsobject} ) { | ||
102 | $self->error("undefined cvs server for $module"); | ||
103 | } | ||
104 | else { | ||
105 | if ( ! defined $module ) { | ||
106 | $self->error("undefined module to checkout"); | ||
107 | } | ||
108 | else { | ||
109 | my $thisdir=cwd(); | ||
110 | chdir $dir or die "unable to enter directory $dir\n"; | ||
111 | $self->{cvsobject}->invokecvs(@cvscmd, $module); | ||
112 | chdir $thisdir; | ||
113 | if ( -e $location."/".$filename ) { | ||
114 | williamc | 1.12 | $rv=$location."/".$filename; |
115 | $rv=~s/\/$//; | ||
116 | williamc | 1.13 | } |
117 | elsif ( -d $location."/CVS" ) { | ||
118 | $rv=$location; | ||
119 | $rv=~s/\/$//; | ||
120 | } | ||
121 | else { | ||
122 | $self->error("Download failed for ".$url->url(). | ||
123 | " ".$location."/".$filename." does not exist\n"); | ||
124 | $rv=""; | ||
125 | } | ||
126 | } | ||
127 | williamc | 1.12 | } |
128 | williamc | 1.9 | } |
129 | williamc | 1.3 | return $rv; |
130 | williamc | 1.1 | } |