ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/CVSmodule.pm
Revision: 1.8
Committed: Thu Jul 11 12:53:39 2002 UTC (22 years, 10 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: 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: V1_pre1, SCRAM_V1_BRANCH
Changes since 1.7: +3 -1 lines
Log Message:
Some changes to BuidlSystem and URL handling (for local CVS repo installations

File Contents

# Content
1 # CVS wrapper
2 # -----------
3 # Configure the CVSmodule object to access a CVS repository and then
4 # invokecvs() commands as required.
5 #
6 # Interface
7 # ---------
8 # new() : A new cvs modules
9 # set_base(base) : Set a base from which to read (i.e server name/path)
10 # set_auth(type) : Set authentication method e.g pserver, kserver, ext etc.
11 # set_user(username) : set a username for authentication if required
12 # set_passbase(file) : Override the default CVS_PASSFILE for pserver client
13 # set_passkey(encrypted) : For pserver method - set a password
14 # (encrypted)
15 # invokecvs(@cmds) : invoke a cvs command supplied in @cmds
16 # repository : return a string to indicate the repository
17 #
18
19 package Utilities::CVSmodule;
20 require Exporter;
21 use Utilities::AddDir;
22 require 5.004;
23 @ISA= qw(Exporter);
24
25 sub new {
26 my $class=shift;
27 my $self={};
28 bless $self, $class;
29 $self->{myenv}={};
30 $self->{cvs}='cvs';
31 # Reset All variables
32 $self->{auth}="";
33 $self->{passkey}="";
34 $self->{user}="";
35 $self->{base}="";
36 $self->set_passbase("/tmp/".$>."CVSmodule/.cvspass");
37 return $self;
38 }
39
40 sub set_passbase {
41 my $self=shift;
42 my $file=shift;
43
44 my $dir;
45 ($dir=$file)=~s/(.*)\/.*/$1/;
46 AddDir::adddir($dir);
47 $self->{passbase}=$file;
48 $self->env("CVS_PASSFILE", $file);
49 }
50
51 sub set_passkey {
52 use Utilities::SCRAMUtils;
53 $self=shift;
54 $self->{passkey}=shift;
55 my $file=$self->{passbase};
56 SCRAMUtils::updatelookup($file,
57 $self->{cvsroot}." ", $self->{passkey});
58 }
59
60 sub set_base {
61 $self=shift;
62 $self->{base}=shift;
63 $self->_updatecvsroot();
64 }
65
66 sub get_base {
67 }
68
69 sub set_user {
70 $self=shift;
71 $self->{user}=shift;
72 if ( $self->{user} ne "" ) {
73 $self->{user}= $self->{user}.'@';
74 }
75 $self->_updatecvsroot();
76 }
77 sub set_auth {
78 $self=shift;
79 $self->{auth}=shift;
80 $self->{auth}=~s/^\:*(.*)\:*/\:$1\:/;
81
82 $self->_updatecvsroot();
83 }
84
85 sub env {
86 $self=shift;
87 my $name=shift;
88 $self->{myenv}{$name}=shift;
89 }
90
91 sub invokecvs {
92 $self=shift;
93 @cmds=@_;
94 # make sure weve got the right environment
95 foreach $key ( %{$self->{myenv}} ) {
96 $ENV{$key}=$self->{myenv}{$key};
97 }
98 # now perform the cvs command
99 return ( system( "$self->{cvs}" ,"-Q", "-d", "$self->{cvsroot}", @cmds ));
100 }
101
102 sub _updatecvsroot {
103 my $self=shift;
104 $self->{cvsroot}=$self->{auth}.$self->{user}.$self->{base};
105 }
106
107 sub cvsroot {
108 my $self=shift;
109 return $self->{cvsroot};
110 }
111
112 sub repository {
113 my $self=shift;
114 return $self->{base};
115 }