ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/CVSmodule.pm
Revision: 1.6
Committed: Wed Nov 1 16:43:10 2000 UTC (24 years, 6 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_19_5, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1, V0_19_0, V0_18_5, V0_18_4, V_18_3_TEST, VO_18_3, V0_18_2, V0_18_1
Branch point for: V0_19_4_B
Changes since 1.5: +1 -1 lines
Log Message:
Make cvs really quiet

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     # $self->{cvs}='/usr/local/bin/cvs';
31     # Reset All variables
32     $self->{auth}="";
33     $self->{passkey}="";
34     $self->{user}="";
35     $self->{base}="";
36 williamc 1.4 # $self->{passbase}=$ENV{HOME}."/.cvspass";
37 williamc 1.5 $self->set_passbase("/tmp/".$>."CVSmodule/.cvspass");
38 williamc 1.1 return $self;
39     }
40    
41     sub set_passbase {
42     my $self=shift;
43 williamc 1.4 my $file=shift;
44 williamc 1.1
45 williamc 1.4 my $dir;
46     ($dir=$file)=~s/(.*)\/.*/$1/;
47     AddDir::adddir($dir);
48     $self->{passbase}=$file;
49     $self->env("CVS_PASSFILE", $file);
50 williamc 1.1 }
51    
52     sub set_passkey {
53     use Utilities::SCRAMUtils;
54     $self=shift;
55     $self->{passkey}=shift;
56     my $file=$self->{passbase};
57     SCRAMUtils::updatelookup($file,
58     $self->{cvsroot}." ", $self->{passkey});
59     }
60    
61     sub set_base {
62     $self=shift;
63     $self->{base}=shift;
64     $self->_updatecvsroot();
65     }
66    
67     sub get_base {
68     }
69    
70     sub set_user {
71     $self=shift;
72     $self->{user}=shift;
73     if ( $self->{user} ne "" ) {
74     $self->{user}= $self->{user}.'@';
75     }
76     $self->_updatecvsroot();
77     }
78     sub set_auth {
79     $self=shift;
80     $self->{auth}=shift;
81     $self->{auth}=~s/^\:*(.*)\:*/\:$1\:/;
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 williamc 1.4 $ENV{$key}=$self->{myenv}{$key};
97 williamc 1.1 }
98     #now perform the cvs command
99     #print ( join ' ', ( $self->{cvs}, "-d", $self->{cvsroot}, @cmds, "\n" ));
100 williamc 1.6 return ( system( "$self->{cvs}" ,"-Q", "-d", "$self->{cvsroot}", @cmds ));
101 williamc 1.1 }
102    
103     sub _updatecvsroot {
104     my $self=shift;
105     $self->{cvsroot}=$self->{auth}.$self->{user}.$self->{base};
106 williamc 1.4 }
107    
108     sub cvsroot {
109     my $self=shift;
110     return $self->{cvsroot};
111 williamc 1.3 }
112    
113     sub repository {
114     my $self=shift;
115     return $self->{base};
116 williamc 1.1 }