foreach (@dirs) {
next if !-d "$_";
- my $cmd = "find \"$_\" -xdev -type f -size +$size -exec ls -lLG {} \\;";
+
+ my $lsOpts = $ARCHITECTURE eq 'solaris' ? '-loL' : '-lLG';
+ my $cmd = "find \"$_\" -xdev -type f -size +$size -exec ls $lsOpts {} \\;";
my @lines = `$cmd`;
foreach (@lines) {
my %info;
#if (/\S+\s+\d+\s+(\S+)\s+(\d+).*\"\.\/(.*)\"/) {
- if (/\S+\s+\d+\s+(\S+)\s+\S+ \S+\s+(\d+)\s+\S+\s+\d+\s+\S+\s+(\S+)/){
+ if (/\S+\s+\d+\s+(\S+)\s+(\d+)\s+\S+\s+\S+\s+\d+\s+(.*)/) {
$info {user} = $1;
$info {filesize} = $2;
$info {filename} = $3;
my $bytes_in_meg = 1048576;
my $block_size = 512;
my $size_in_meg = 1;
-my %opts;
+my %opts = (
+ size => 1
+);
my $result = GetOptions (
\%opts,
'size=i',
);
-my @dirs = @ARGV || '.';
-my $size = $opts {size} ? $opts {size} * $bytes_in_meg / $block_size : 4096;
+my @dirs = @ARGV > 0 ? @ARGV : '.';
+my $size = $opts{size} ? $opts{size} * $bytes_in_meg / $block_size : 4096;
+my @files;
# Now do the find
-verbose "Directory:\t$_"
+verbose "Directory:\t@dirs";
-foreach (@dirs) {
- verbose "Size:\t\t$size_in_meg Meg ($size blocks)";
+for (@dirs) {
+ verbose "Size:\t\t$opts{size} Meg ($size blocks)";
verbose "Top:\t\t$top";
my $head = $top ? "cat" : "head -$top";
- my @files = Bigfiles $size, @dirs;
-} # for each
+ @files = Bigfiles $size, @dirs;
+} # for
-foreach (@files) {
+for (sort {$b->{filesize} <=> $a->{filesize}} @files) {
my %info = %{$_};
+ last if $top-- == 0;
+
print "${info {filesize}}\t${info {user}}\t${info {filename}}\n";
-} # foreach
+} # for
my ($clearpid, $clearin, $clearout, $oldHandler, $cleartool);
-our $VIEW_DRIVE = $ENV{CLEARCASE_VIEW_DRIVE} || 'M';
+our $VIEW_DRIVE = 'M';
our $VOB_MOUNT = 'vob';
our $WIN_VOB_PREFIX = '\\';
our $SFX = $ENV{CLEARCASE_XN_SFX} ? $ENV{CLEARCASE_XN_SFX} : '@@';
# We can go to the registry pretty easy in Cygwin but I'm not sure how to do
# that in plain old Windows. Most people either have Clearcase installed on
# the C drive or commonly on the D drive on servers. So we'll look at both.
- $CCHOME = 'C:\\Program Files (x86)\\ibm\\RationalSDLC\\Clearcase';
+ $CCHOME = 'C:\\IBMRational\\RationalSDLC\\Clearcase';
- $CCHOME = 'D:\\Program Files (x86)\\ibm\\RationalSDLC\\Clearcase'
+ $CCHOME = 'D:\\IBMRational\\RationalSDLC\\Clearcase'
unless -d $CCHOME;
error 'Unable to figure out where Clearcase is installed', 1
# to use these Clearcase objects say in a web page where the server is often
# run as a plain user who does not have cleartool in their path.
unless ($cleartool) {
- if ($ARCHITECTURE =~ /Win/i or $ARCHITECTURE eq 'cygwin') {
+ if ($ARCHITECTURE =~ /Win/ or $ARCHITECTURE eq 'cygwin') {
$cleartool = 'cleartool';
} elsif (-x '/opt/rational/clearcase/bin/cleartool') {
$cleartool = '/opt/rational/clearcase/bin/cleartool';
"mkfolder $comment -in " . $class->{parent} . ' ' . $name . '@' . $pvob->tag
);
- return $class->updateFolderInfo;
+ return if $status;
+
+ ($status, @output) = $class->updateFolderInfo;
+
+ return $status ? undef : $class;
} # new
sub name () {
return $self;
} # updateFolderInfo
+
1;
=head1 DEPENDENCIES
use strict;
use warnings;
-# Would be better represented by use parent "Clearcase::Vob" but we're
-# working with old versions of Perl here...
-use base 'Clearcase::Vob';
+use parent 'Clearcase::Vob';
use Carp;
croak 'Clearcase::UCM::Pvob: Must specify pvob tag' unless $tag;
$class = bless {
- tag => $tag,
+ tag => $tag,
+ ucmproject => 1,
}, $class; # bless
$class->updateVobInfo;
return $class;
} # new
-sub create (;$$$%) {
- my ($self, $host, $vbs, $comment, %opts) = @_;
-
-=pod
-
-=head2 create
-
-Creates a pvob
-
-Parameters:
-
-=for html <blockquote>
-
-=over
-
-=item none
-
-=back
-
-=for html </blockquote>
-
-Returns:
-
-=for html <blockquote>
-
-=over
-
-=item none
-
-=back
-
-=for html </blockquote>
-
-=cut
-
- $opts{ucmproject} = undef;
-
- return $self->SUPER::create ($host, $vbs, $comment, %opts);
-} # create
-
sub tag() {
my ($self) = @_;
use Clearcase;
use Display;
-sub new ($) {
- my ($class, $tag) = @_;
+sub new ($;$) {
+ my ($class, $tag, $region) = @_;
=pod
my $self = bless { tag => $tag }, $class;
- $self->updateViewInfo;
+ $self->updateViewInfo ($region);
return $self;
} # new
return $self->{tag};
} # tag
-# Alias name to tag
-sub name() {
- goto &tag;
-} # name
-
sub text_mode () {
my ($self) = @_;
} # exists
sub create (;$$$) {
- my ($self, $host, $vws, $opts) = @_;
+ my ($self, $host, $vws, $region) = @_;
=pod
=cut
+ $region ||= $Clearcase::CC->region;
+
if ($self->exists) {
- $self->updateViewInfo;
+ $self->updateViewInfo ($region);
return (0, ())
} # if
my ($status, @output);
- $opts ||= '';
-
if ($host && $vws) {
- ($status, @output) = $Clearcase::CC->execute(
- "mkview -tag $self->{tag} $opts " .
- "-host $host -hpath $vws -gpath $vws $vws"
- );
+ ($status, @output) =
+ $Clearcase::CC->execute ("mkview -tag $self->{tag} -region $region "
+ . "-host $host -hpath $vws -gpath $vws $vws");
} else {
# Note this requires that -stgloc's work and that using -auto is not a
# problem.
- ($status, @output) = $Clearcase::CC->execute(
- "mkview -tag $self->{tag} $opts -stgloc -auto"
- );
+ ($status, @output) =
+ $Clearcase::CC->execute ("mkview -tag $self->{tag} -stgloc -auto");
} # if
- $self->updateViewInfo;
+ $self->updateViewInfo ($region);
return ($status, @output);
} # create
-# TODO Is this used?
sub createUCM ($$) {
- my ($self, $stream, $pvob) = @_;
+ my ($self, $stream, $pvob, $region) = @_;
=pod
=cut
- return (0, ()) if $self->exists;
+ $region ||= $Clearcase::CC->region;
+
+ return (0, ())
+ if $self->exists;
# Update object members
- $self->{pvob} = $pvob;
+ $self->{stream} = $stream;
+ $self->{pvob} = $pvob;
# Need to create the view
my ($status, @output) =
return ($status, @output)
if $status;
- $self->updateViewInfo;
+ $self->updateViewInfo ($region);
return ($status, @output);
} # createUCM
=cut
- return (0, ()) unless $self->exists;
+ return (0, ())
+ unless $self->exists;
my ($status, @output);
if ($self->dynamic) {
- $self->stop;
-
($status, @output) = $Clearcase::CC->execute (
"rmview -force -tag $self->{tag}"
);
return ($status, @output);
} # set
-sub updateViewInfo () {
- my ($self) = @_;
+sub updateViewInfo ($$) {
+ my ($self, $region) = @_;
+
+ $region ||= $Clearcase::CC->region;
my ($status, @output) = $Clearcase::CC->execute (
- "lsview -long -properties -full $self->{tag}"
+ "lsview -region $region -long -properties -full $self->{tag}"
);
# Assuming this view is an empty shell of an object that the user may possibly
} # for
if ($host && $vbs) {
+ $additionalOpts .= '-ucmproject' if $self->{ucmproject};
+
($status, @output) = $Clearcase::CC->execute (
"mkvob -tag $self->{tag} $comment $additionalOpts -host $host -hpath $vbs "
. "-gpath $vbs $vbs");
while () {
my $key;
- while (not defined ($key = ReadKey -1)) { }
+ while (not defined ($key = ReadKey -1)) { }
if ($key =~ /(\r|\n)/) {
print "\n";
# View related functions
function setview {
if [ $ARCHITECTURE = 'cygwin' ]; then
- if [[ $1 = -* ]]; then
- echo "The setview command with options is not supported on Windows"
- return
- fi
-
+ if [[ $1 = -* ]]; then
+ echo "The setview command with options is not supported on Windows"
+ return
+ fi
+
# Save off where we are
back=$PWD
fi
# Setup $VOBTAG_PREFIX
- mount -f -o binary $CLEARCASE_VIEW_DRIVE:/$1 $LINUX_VOBTAG_PREFIX
+ mount -f -o binary M:/$1 $LINUX_VOBTAG_PREFIX
# Start a bash shell
bash
--- /dev/null
+#!/usr/bin/perl\r
+use strict;\r
+use warnings;\r
+\r
+use Getopt::Long;\r
+use Pod::Usage; \r
+\r
+use FindBin;\r
+\r
+use lib "$FindBin::Bin/../lib";\r
+\r
+use Display;\r
+use Machines::MySQL;\r
+use Utils;\r
+\r
+my %opts = (\r
+ usage => sub { podusage() } ,\r
+ hostname => $ENV{HOST} || 'localhost',\r
+ username => $ENV{USERNAME} ? $ENV{USERNAME} : $ENV{USER},\r
+ password => $ENV{PASSWORD},\r
+ database => 0,\r
+);\r
+\r
+sub AddSystems($) {\r
+ my ($machines) = @_;\r
+\r
+ my @machines = $machines->ReadSystemsFile;\r
+\r
+ for (@machines) {\r
+ my ($err, $msg) = $machines->AddSystem(%$_);\r
+\r
+ error ($msg) if $err;\r
+ } # for\r
+} # AddSystems\r
+\r
+GetOptions (\r
+ \%opts,\r
+ 'usage',\r
+ 'host=s',\r
+ 'username=s',\r
+ 'password=s',\r
+ 'database',\r
+ 'filename=s',\r
+);\r
+\r
+my $machines;\r
+\r
+unless ($opts{database}) {\r
+ require Machines; Machines->import;\r
+\r
+ $machines = Machines->new(filename => $opts{filename});\r
+} else {\r
+ require Machines::MySQL; Machines::MySQL->import;\r
+\r
+ $machines = Machines::MySQL->new;\r
+} # if\r
+\r
+#for ($machines->select ("os = '2.4.21-50.Elsmp'")) {\r
+\r
+if (ref($machines) eq 'Machines') {\r
+ display "From file:";\r
+} elsif (ref($machines) eq 'Machines::MySQL') {\r
+ display "From database";\r
+} # if\r
+\r
+my %records = $machines->select;\r
+\r
+for (sort keys %records) {\r
+ display "Would execute command on $_ ($records{$_}{model})";\r
+} # for\r
+\r
+display "done";\r
-[no]uc|m: Perform UCM Clearcase tests (Default: noucm)
-[no]clean: Cleanup after yourself (Default: clean)
-if -ucm is specified then the following additional parameters should be set:
-
- -username: Username to connect to Clearquest with (Can set CQ_USERNAME)
- -password: Password to use to connect to Clearquest (CQ_PASSWORD)
- -weburl: Web URL to use for enabling Clearcase -> Clearquest
- connection (CQ_WEBURL - Do not specify the trailing
- "/oslc")
- -database: Clearquest database to enable (CQ_DATABASE)
- -dbset: Clearquest DBSet (CQ_DBSET)
- -provider: Name of provider (Default: CQPROV)
-
=head1 DESCRIPTION
Clearcase smoke tests. Perform simple Clearcase operations to validate that
use Cwd;
use FindBin;
use Getopt::Long;
-use Pod::Usage;
+#use Term::ANSIColor qw(:constants);
use lib "$FindBin::Bin/../lib";
);
for (sort keys %opts) {
- next if /help/ || /usage/ || /password/;
-
if (ref $opts{$_} eq 'ARRAY') {
my $name = $_;
-
- for (@{$opts{$_}}) {
- $log->msg("$name:\t$_") if $_;
- } # for
+ $log->msg("$name:\t$_") for @{$opts{$_}};
} else {
- if ($opts{$_}) {
- $log->msg("$_:\t$opts{$_}");
- } else {
- $log->msg("$_:\t<undef>");
- } # if
+ $log->msg("$_:\t$opts{$_}");
} # if
} # for
($status, @output) = $Clearcase::CC->execute('cd');
- $log->err('Unable to perform cd command', 1) if $status;
-
$log->msg('Unmounting vob ' . $vob->tag);
($status, @output) = $vob->umount;
- if ($status) {
- $log->err('Unable to unmount vob ' . $vob->tag);
- } else {
- $log->msg('Umounted vob ' . $vob->tag);
- } # if
-
$log->msg('Removing vob ' . $vob->tag);
($status, @output) = $vob->remove;
- if ($status) {
- $log->err("Failed to execute command " .
- $Clearcase::CC->lastcmd . "\n" .
- join "\t\n", @output);
- } # if
-
$log->log($_) for @output;
return $status;
return $status;
} # SetView
-sub StopView($) {
- my ($view) = @_;
-
- $log->msg('Stopping view ' . $view->tag);
-
- my ($status, @output) = $view->stop;
-
- $log->log($_) for @output;
-
- return $status;
-} # StopView
-
sub DestroyView($) {
my ($view) = @_;
($rc, @output) = $test_activity->remove;
$status += $rc;
-
+
$log->log($_) for @output;
# Need to remove baselines from streams first using rebase (Devstream)
$log->log($_) for @output;
$status += DestroyView($test_intview);
-
+
$log->msg('Removing '. $test_devstream->name);
($rc, @output) = $test_devstream->remove;
($status, @output) = $Clearcase::CC->execute("cd $dir");
- $log->log($_) for @output;
+ if ($status != 0) {
+ $log->log($_) for @output;
+ } # if
return $status;
} # SetupTest
-sub SetupAttributeTypes() {
- my @CC_CMI_Types = qw(CONTEXT TASK PROVIDERS);
-
- my $status = SetView($test_intview);
-
- return $status if $status;
-
- for (@CC_CMI_Types) {
- my $cmd = "mkattype -nc -vtype string CC_CMI_$_";
-
- my ($rc, @output) = $Clearcase::CC->execute($cmd);
-
- $status += $rc;
-
- $log->log($_) for @output;
- } # for
-
- return $status;
-} # SetupAttributeTypes
-
-sub CRMRegister() {
- my $cmd = "crmregister add -database $opts{database} -connection RDE "
- . "-url $opts{weburl} -username $opts{username} "
- . "-password $opts{password}";
-
- my ($status, @output) = Execute $cmd;
-
- $log->log($_) for @output;
-
- return $status;
-} # CRMRegister
-
-sub MakeCMProvider() {
- my $cmd = 'mkcmprovider -vob ' . $test_pvob->tag
- . '-type cmcq -version V1_0 -description '
- . '"RDE CMI CQ Provider" '
- . '-connection baseurl:' . $opts{weburl} . " $opts{provider}";
-
- my ($status, @output) = $Clearcase::CC->execute($cmd);
-
- $log->log($_) for @output;
-
- return $status;
-} # MakeCMProvider
-
sub SetupUCMTest() {
my $status;
- $log->msg("Register RDE://$opts{username}\@$opts{database}");
-
- $status = CRMRegister;
-
- $log->err("Unable to register RDE://$opts{username}\@$opts{database} - Check logfile", $status)
- if $status;
+ $log->msg("Creating UCM Pvob $Clearcase::VOBTAG_PREFIX/tc.pvob");
- $log->msg("Creating UCM Pvob ${Clearcase::VOBTAG_PREFIX}tc.pvob");
-
- ($status, $test_pvob) = CreatePvob("${Clearcase::VOBTAG_PREFIX}tc.pvob");
-
- MountVob $test_pvob;
+ ($status, $test_pvob) = CreatePvob("$Clearcase::VOBTAG_PREFIX/tc.pvob");
return $status;
} # SetupUCMTest
$test_project = Clearcase::UCM::Project->new('tc.project', $test_folder, $test_pvob);
$test_project->remove if $test_project->exists;
-
+
$log->msg('Creating UCM Project tc.project');
my ($status, @output) = $test_project->create;
$status += CreateUCMIntStream;
$status += CreateUCMDevStream;
$status += CreateUCMIntView;
- $status += SetupAttributeTypes;
$status += CreateUCMDevView;
$status += CreateUCMComponent;
$status += AddModifiableComponent;
my $conf_file = "$FindBin::Bin/$script.conf";
my $status = 0;
-$opts{help} = sub { pod2usage };
-$opts{usage} = sub { pod2usage (-verbose => 2)};
-$opts{base} = 1;
-$opts{clean} = 1;
-$opts{username} = $ENV{CQ_USERNAME};
-$opts{password} = $ENV{CQ_PASSWORD};
-$opts{weburl} = $ENV{CQ_WEBURL};
-
-$opts{weburl} .= $opts{weburl} ? "/oslc" : undef;
-$opts{database} = $ENV{CQ_DATABASE};
-$opts{dbset} = $ENV{CQ_DBSET};
-$opts{provider} = $ENV{CQ_PROVIDER} || 'CQPROV';
+$opts{base} = 1;
+$opts{clean} = 1;
GetOptions(
\%opts,
'base!',
'ucm!',
'clean!',
- 'username=s',
- 'database=s',
- 'dbset=s',
- 'provider',
-) || pod2usage;
+) or Usage;
# Read the config file
if (-f $conf_file) {
$opts{$_} = $default_opts{$_} if !$opts{$_};
} # for
-# Check CQ parameters
-if ($opts{ucm}) {
- for ('username', 'password', 'weburl', 'database', 'dbset', 'provider') {
- pod2usage "In UCM mode you must specify -$_" unless $opts{$_};
- } # for
-} # if
-
$log->msg("$script: Start");
LogOpts;
# Since we are creating private vobs (to avoid complications with having to
# know and code the registry password when making public vobs), we'll simply
# change $Clearcase::VOBTAG_PREFIX
-if ($ARCHITECTURE !~ /win/i) {
- $Clearcase::VOBTAG_PREFIX = $ENV{TMP} . '/' || '/tmp';
-} # if
+$Clearcase::VOBTAG_PREFIX = $ENV{TMP} || '/tmp';
if ($opts{base}) {
- $status = SetupTest "${Clearcase::VOBTAG_PREFIX}tc.vob", 'tc.view';
+ $status = SetupTest "$Clearcase::VOBTAG_PREFIX/tc.vob", 'tc.view';
if ($status == 0) {
$status += RunTests;
} # if
# Note if we are doing UCM tests then we need the view and vob here...
- $status += Cleanup($test_view, $test_vob) if $opts{clean} && !$opts{ucm};
+ $status += Cleanup($test_view, $test_vob) if $opts{clean} and !$opts{ucm};
if ($status != 0) {
$log->err("$script: Failed (Base Clearcase)");
L<Getopt::Long|Getopt::Long>
+L<Term::ANSIColor|Term::ANSIColor>
+
=head2 ClearSCM Perl Modules
-=begin man
+=begin man
Clearcase
Clearcase::Element
RCLC_name => 'Test RCLC',
Prod_Arch1 => 'testcode : N/A',
work_product_name => '10 - Software',
- #Engr_target => 'Test Engineering Target',
+ Engr_target => 'Test Engineering Target',
work_code_name => 'RAN-RW2',
);
$log->msg('Enable tc.project for integration with Clearquest');
-$test_pvob = Clearcase::UCM::Pvob->new("${Clearcase::VOBTAG_PREFIX}tc.pvob");
+$test_pvob = Clearcase::UCM::Pvob->new("${Clearcase::VOBTAG_PREFIX}/tc.pvob");
$test_project = Clearcase::UCM::Project->new('tc.project', 'tc.folder', $test_pvob);
my ($rc, @output) = $test_project->change("-force -crmenable $opts{CQ_DATABASE}");