Revision: | 1.11 |
Committed: | Wed Feb 15 17:14:18 2006 UTC (19 years, 2 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_3-p1, V1_0_3 |
Branch point for: | forBinLess_SCRAM, HEAD_BRANCH_SM_071214, v200branch, v103_with_xml |
Changes since 1.10: | +1 -1 lines |
Log Message: | Download works properly again... |
# | Content |
---|---|
1 | =head1 NAME |
2 | |
3 | Utilities::CVSmodule - A wrapper around CVS. |
4 | |
5 | =head1 SYNOPSIS |
6 | |
7 | my $obj = Utilities::CVSmodule->new(); |
8 | |
9 | =head1 DESCRIPTION |
10 | |
11 | Configure the CVSmodule object to access a CVS repository and then |
12 | invokecvs() commands as required. |
13 | |
14 | =head1 METHODS |
15 | |
16 | =over |
17 | |
18 | =item C<new()> |
19 | |
20 | A new cvs modules object. |
21 | |
22 | =item C<set_base(base)> |
23 | |
24 | Set a base from which to read (i.e server name/path). |
25 | |
26 | =item C<set_auth(type)> |
27 | |
28 | Set authentication method e.g pserver, kserver, ext etc. |
29 | |
30 | =item C<set_user(username)> |
31 | |
32 | Set a username for authentication if required. |
33 | |
34 | =item C<set_passbase(file)> |
35 | |
36 | Override the default CVS_PASSFILE for pserver client. |
37 | |
38 | =item C<set_passkey(encrypted)> |
39 | |
40 | For pserver method - set a password (encrypted). |
41 | |
42 | =item C<invokecvs(@cmds)> |
43 | |
44 | Invoke a cvs command supplied in @cmds. |
45 | |
46 | =item C<repository()> |
47 | |
48 | Return a string to indicate the repository. |
49 | |
50 | =cut |
51 | |
52 | =back |
53 | |
54 | =head1 AUTHOR |
55 | |
56 | Originally written by Christopher Williams. |
57 | |
58 | =head1 MAINTAINER |
59 | |
60 | Shaun ASHBY |
61 | |
62 | =cut |
63 | |
64 | package Utilities::CVSmodule; |
65 | require Exporter; |
66 | use Utilities::AddDir; |
67 | require 5.004; |
68 | @ISA= qw(Exporter); |
69 | |
70 | sub new { |
71 | my $class=shift; |
72 | my $self={}; |
73 | bless $self, $class; |
74 | $self->{myenv}={}; |
75 | $self->{cvs}='cvs'; |
76 | # Reset All variables |
77 | $self->{auth}=""; |
78 | $self->{passkey}=""; |
79 | $self->{user}=""; |
80 | $self->{base}=""; |
81 | $self->set_passbase("/tmp/".$>."CVSmodule/.cvspass"); |
82 | return $self; |
83 | } |
84 | |
85 | sub set_passbase { |
86 | my $self=shift; |
87 | my $file=shift; |
88 | |
89 | my $dir; |
90 | ($dir=$file)=~s/(.*)\/.*/$1/; |
91 | AddDir::adddir($dir); |
92 | $self->{passbase}=$file; |
93 | $self->env("CVS_PASSFILE", $file); |
94 | } |
95 | |
96 | sub set_passkey { |
97 | use Utilities::SCRAMUtils; |
98 | $self=shift; |
99 | $self->{passkey}=shift; |
100 | my $file=$self->{passbase}; |
101 | SCRAMUtils::updatelookup($file, |
102 | $self->{cvsroot}." ", $self->{passkey}); |
103 | } |
104 | |
105 | sub set_base { |
106 | $self=shift; |
107 | $self->{base}=shift; |
108 | $self->_updatecvsroot(); |
109 | } |
110 | |
111 | sub get_base { |
112 | } |
113 | |
114 | sub set_user { |
115 | $self=shift; |
116 | $self->{user}=shift; |
117 | if ( $self->{user} ne "" ) { |
118 | $self->{user}= $self->{user}.'@'; |
119 | } |
120 | $self->_updatecvsroot(); |
121 | } |
122 | sub set_auth { |
123 | $self=shift; |
124 | $self->{auth}=shift; |
125 | $self->{auth}=~s/^\:*(.*)\:*/\:$1\:/; |
126 | |
127 | $self->_updatecvsroot(); |
128 | } |
129 | |
130 | sub env { |
131 | $self=shift; |
132 | my $name=shift; |
133 | $self->{myenv}{$name}=shift; |
134 | } |
135 | |
136 | sub invokecvs { |
137 | $self=shift; |
138 | @cmds=@_; |
139 | # make sure weve got the right environment |
140 | foreach $key ( %{$self->{myenv}} ) { |
141 | $ENV{$key}=$self->{myenv}{$key}; |
142 | } |
143 | # now perform the cvs command |
144 | return ( system( "$self->{cvs}" ,"-Q", "-d", "$self->{cvsroot}", @cmds )); |
145 | } |
146 | |
147 | sub _updatecvsroot { |
148 | my $self=shift; |
149 | $self->{cvsroot}=$self->{auth}.$self->{user}.$self->{base}; |
150 | } |
151 | |
152 | sub cvsroot { |
153 | my $self=shift; |
154 | return $self->{cvsroot}; |
155 | } |
156 | |
157 | sub repository { |
158 | my $self=shift; |
159 | return $self->{base}; |
160 | } |