ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/CVSmodule.pm
Revision: 1.7
Committed: Thu Jun 13 14:46:22 2002 UTC (22 years, 11 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: SFATEST
Changes since 1.6: +2 -5 lines
Log Message:
Finished download page CGI script.

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 williamc 1.4 package Utilities::CVSmodule;
19 williamc 1.1 require Exporter;
20 williamc 1.4 use Utilities::AddDir;
21     require 5.004;
22 williamc 1.1 @ISA= qw(Exporter);
23    
24     sub new {
25     my $class=shift;
26 williamc 1.4 my $self={};
27     bless $self, $class;
28 williamc 1.1 $self->{myenv}={};
29     $self->{cvs}='cvs';
30     # Reset All variables
31     $self->{auth}="";
32     $self->{passkey}="";
33     $self->{user}="";
34     $self->{base}="";
35 williamc 1.5 $self->set_passbase("/tmp/".$>."CVSmodule/.cvspass");
36 williamc 1.1 return $self;
37     }
38    
39     sub set_passbase {
40     my $self=shift;
41 williamc 1.4 my $file=shift;
42 williamc 1.1
43 williamc 1.4 my $dir;
44     ($dir=$file)=~s/(.*)\/.*/$1/;
45     AddDir::adddir($dir);
46     $self->{passbase}=$file;
47     $self->env("CVS_PASSFILE", $file);
48 williamc 1.1 }
49    
50     sub set_passkey {
51     use Utilities::SCRAMUtils;
52     $self=shift;
53     $self->{passkey}=shift;
54     my $file=$self->{passbase};
55     SCRAMUtils::updatelookup($file,
56     $self->{cvsroot}." ", $self->{passkey});
57     }
58    
59     sub set_base {
60     $self=shift;
61     $self->{base}=shift;
62     $self->_updatecvsroot();
63     }
64    
65     sub get_base {
66     }
67    
68     sub set_user {
69     $self=shift;
70     $self->{user}=shift;
71     if ( $self->{user} ne "" ) {
72     $self->{user}= $self->{user}.'@';
73     }
74     $self->_updatecvsroot();
75     }
76     sub set_auth {
77     $self=shift;
78     $self->{auth}=shift;
79     $self->{auth}=~s/^\:*(.*)\:*/\:$1\:/;
80     $self->_updatecvsroot();
81     }
82    
83     sub env {
84     $self=shift;
85     my $name=shift;
86     $self->{myenv}{$name}=shift;
87     }
88    
89     sub invokecvs {
90     $self=shift;
91     @cmds=@_;
92 sashby 1.7 # make sure weve got the right environment
93 williamc 1.1 foreach $key ( %{$self->{myenv}} ) {
94 williamc 1.4 $ENV{$key}=$self->{myenv}{$key};
95 williamc 1.1 }
96 sashby 1.7 # now perform the cvs command
97 williamc 1.6 return ( system( "$self->{cvs}" ,"-Q", "-d", "$self->{cvsroot}", @cmds ));
98 williamc 1.1 }
99    
100     sub _updatecvsroot {
101     my $self=shift;
102     $self->{cvsroot}=$self->{auth}.$self->{user}.$self->{base};
103 williamc 1.4 }
104    
105     sub cvsroot {
106     my $self=shift;
107     return $self->{cvsroot};
108 williamc 1.3 }
109    
110     sub repository {
111     my $self=shift;
112     return $self->{base};
113 williamc 1.1 }