ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
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

File Contents

# Content
1 #
2 # standard url interface for cvs
3 #
4 # cvs urls
5 #
6 # cvs://server_name:/repository_location?passkey=xxx&auth=xxx&user=xxx
7 # &module=co_files
8 #
9 # Interface
10 #-------------
11 # new() :
12 # get(url,$dirname) :
13
14 package URL::URL_cvs;
15 require 5.001;
16 use Utilities::CVSmodule;
17 use URL::URL_base;
18 use Carp;
19 use Cwd;
20
21 @ISA = qw(URL::URL_base);
22
23 sub init {
24 my $self=shift;
25 $self->{cvsco}="co";
26 }
27
28 sub setbase {
29 my $self=shift;
30 my $base=shift;
31 my $varhash=shift;
32
33 my $auth=$$varhash{'auth'};
34
35 # a new cvs object
36 $self->{cvsobject}=Utilities::CVSmodule->new();
37 $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 my $location=shift;
58 my $rv="";
59
60 use File::Basename;
61 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 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 }
79 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
94 push @cvscmd, ("-d", "$dirname");
95 if ( $version && ($version ne "") ) {
96 push @cvscmd, ("-r", "$version");
97 }
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 $rv=$location."/".$filename;
115 $rv=~s/\/$//;
116 }
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 }
128 }
129 return $rv;
130 }