ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/CVSmodule.pm
Revision: 1.3.4.1
Committed: Fri Aug 4 09:08:37 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
CVS Tags: V0_14_0
Changes since 1.3: +0 -0 lines
Log Message:
add module from dev

File Contents

# User Rev Content
1 williamc 1.2 # CVS wrapper
2     # -----------
3     # Configure the CVSmodule object to access a CVS repository and then
4     # invokecvs() commands as required.
5 williamc 1.1 #
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 williamc 1.3 # repository : return a string to indicate the repository
17 williamc 1.1 #
18     package CVSmodule;
19     require 5.001;
20     require Exporter;
21     @ISA= qw(Exporter);
22    
23     sub new {
24     my $class=shift;
25     $self={};
26     $self->{myenv}={};
27     $self->{cvs}='cvs';
28     # $self->{cvs}='/usr/local/bin/cvs';
29     # Reset All variables
30     $self->{auth}="";
31     $self->{passkey}="";
32     $self->{user}="";
33     $self->{base}="";
34     $self->{passbase}=$ENV{HOME}."/.cvspass";
35     bless $self, $class;
36     return $self;
37     }
38    
39     sub set_passbase {
40     my $self=shift;
41     my $dir=shift;
42    
43     $self->{passbase}=$dir;
44     $self->env("CVS_PASSFILE", $dir);
45     }
46    
47     sub set_passkey {
48     use Utilities::SCRAMUtils;
49     $self=shift;
50     $self->{passkey}=shift;
51     my $file=$self->{passbase};
52     SCRAMUtils::updatelookup($file,
53     $self->{cvsroot}." ", $self->{passkey});
54     }
55    
56     sub set_base {
57     $self=shift;
58     $self->{base}=shift;
59     $self->_updatecvsroot();
60     }
61    
62     sub get_base {
63     }
64    
65     sub set_user {
66     $self=shift;
67     $self->{user}=shift;
68     if ( $self->{user} ne "" ) {
69     $self->{user}= $self->{user}.'@';
70     }
71     $self->_updatecvsroot();
72     }
73     sub set_auth {
74     $self=shift;
75     $self->{auth}=shift;
76     $self->{auth}=~s/^\:*(.*)\:*/\:$1\:/;
77     $self->_updatecvsroot();
78     }
79    
80     sub env {
81     $self=shift;
82     my $name=shift;
83     $self->{myenv}{$name}=shift;
84     }
85    
86     sub invokecvs {
87     $self=shift;
88     @cmds=@_;
89     #make sure weve got the right environment
90     foreach $key ( %{$self->{myenv}} ) {
91     $ENV{$key}=$self->{myenv}{$key}
92     }
93     #now perform the cvs command
94     #print ( join ' ', ( $self->{cvs}, "-d", $self->{cvsroot}, @cmds, "\n" ));
95     system( "$self->{cvs}" , "-d", "$self->{cvsroot}", @cmds );
96     }
97    
98     sub _updatecvsroot {
99     my $self=shift;
100     $self->{cvsroot}=$self->{auth}.$self->{user}.$self->{base};
101 williamc 1.3 }
102    
103     sub repository {
104     my $self=shift;
105     return $self->{base};
106 williamc 1.1 }