ClearCase-Region

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Makefile.PL
README
MANIFEST
examples/Region.cfg
examples/Vob.cfg
examples/co_backup
examples/Region_test
examples/Vob_test
examples/main_cos
t/01Region.t
LICENSE
lib/ClearCase/Region.pm
lib/ClearCase/Region_Cfg_Parser.pm
lib/ClearCase/Vob.pm
lib/ClearCase/Vob_Cfg_Parser.pm
lib/co_backup.conf
lib/main_cos.conf
lib/Region_test.conf
lib/Vob_test.conf
docs/Creating_Reuseable_Perl_Scripts.doc
docs/Creating_Reuseable_Perl_Scripts.htm
docs/Creating_Reuseable_Perl_Scripts_files/filelist.xml
docs/Creating_Reuseable_Perl_Scripts_files/image001.wmz
docs/Creating_Reuseable_Perl_Scripts_files/image002.gif
docs/Creating_Reuseable_Perl_Scripts_files/image003.wmz
docs/Creating_Reuseable_Perl_Scripts_files/image004.gif

README  view on Meta::CPAN

by executing:

    perl -I. Region_test

or

	perl -I. Vob_test

The scripts in the examples directory use Log4perl configuration files that
get installed along with the modules.  These configuration files are
co_backup.conf, main_cos.conf, Region_test.conf and Vob_test.conf.  These
*.conf files will create a log named 'test.log' in the current directory
whenever the corresponding script is executed.

docs/Creating_Reuseable_Perl_Scripts.htm  view on Meta::CPAN

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>in Perl scripts that will be
using the Region.pm module.<span style='mso-spacerun:yes'>  </span>This module
must either be installed in one of @INC directories, or specified in one of the
$PERL5LIB directories.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>The Region.pm class module
and the associated sample scripts (Region_test, co_backup and main_cos) all use
the Log::Log4perl Class.<span style='mso-spacerun:yes'>  </span>Log::Log4perl
is freely available from CPAN and SourceForge (<a
href="http://log4perl.sourceforge.net/">http://log4perl.sourceforge.net</a>).<span
style='mso-spacerun:yes'>  </span>The Log::Log4perl module requires the
Log::Dispatch bundle as well.<span style='mso-spacerun:yes'>  </span>If you
don’t have Log::Log4perl, use the CPAN module or PPM to upgrade your Perl
environment prior to using these programs.<o:p></o:p></span></p>

<h1><![if !supportLists]><span style='font-size:10.0pt;font-family:Helvetica;
mso-fareast-font-family:Helvetica'><span style='mso-list:Ignore'>10.<span

docs/Creating_Reuseable_Perl_Scripts.htm  view on Meta::CPAN

would have to be modified to include an accessor method as well.<o:p></o:p></span></p>

<h1><![if !supportLists]><span style='font-size:10.0pt;font-family:Helvetica;
mso-fareast-font-family:Helvetica'><span style='mso-list:Ignore'>11.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp; </span></span></span><![endif]><span
style='font-size:10.0pt;font-family:Helvetica;mso-bidi-font-family:Arial'>Sample
program using both the ClearCase Region and Vob<o:p></o:p></span></h1>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt'>The sample program, co_backup
(available from CPAN), demonstrates the use of both the Region class and the
Vob class to create a reuseable Perl script. The co_backup Perl script creates
a compress cpio backup of all checked out files in all dynamic views.<span
style='mso-spacerun:yes'>  </span>Hence, the co_backup script can be used to
back up files that are being worked on by developers (in dynamic views) –
without having to back up the entire view.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>In addition, this script only
cares about the ‘active’ releases (or views).<span style='mso-spacerun:yes'> 
</span>The co_backup script uses the Vob object to determine which releases
(branches) are active for a VOB.<span style='mso-spacerun:yes'>  </span>The
co_backup script assumes that all developer’s views follow a naming convention “&lt;login&gt;_&lt;subregion&gt;_&lt;relno&gt;”.<span
style='mso-spacerun:yes'>  </span>Then by starting in the /view directory, all
developer’s views can be listed using:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>cleartool lsview –short ‘*_${subregion}_${relno}’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>Of course, if your company
has a different naming convention, then this line will need to change.<span
style='mso-spacerun:yes'>  </span>The co_backup script will start the
developer’s view (if required).<span style='mso-spacerun:yes'>  </span>The list
of active releases is used to determine which developer’s views to back
up.<span style='mso-spacerun:yes'>  </span>So, for the “market_unix_region”
listed above, only the developer’s views:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_tr_1’<o:p></o:p></span></p>

docs/Creating_Reuseable_Perl_Scripts.htm  view on Meta::CPAN

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_ma_5’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_ma_6’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>will be backed up (provided
there is some checked out files).<span style='mso-spacerun:yes'>  </span>When
the co_backup program is executed on the ClearCase server in the
credit_unix_region, the developer’s views:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_cr_2’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_cr_3’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_cr_4’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>‘*_cr_5’<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>will be backed up.<span
style='mso-spacerun:yes'>  </span>Hence, the co_backup script is reuseable in
different regions.<span style='mso-spacerun:yes'>  </span>If the co_backup
script encounters an error, like a bad view, it logs the error message to:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><span style='mso-tab-count:
1'>            </span>$HOME/logs/${subregion}${relno}.${vob}.backup.log<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'>using the class
Log::Log4perl.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<h1><![if !supportLists]><span style='font-size:10.0pt;font-family:Helvetica;
mso-fareast-font-family:Helvetica'><span style='mso-list:Ignore'>12.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp; </span></span></span><![endif]><span
style='font-size:10.0pt;font-family:Helvetica;mso-bidi-font-family:Arial'>Summary<o:p></o:p></span></h1>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt'>A Perl script can be designed
so that it is completely reuseable between sites.<span
style='mso-spacerun:yes'>  </span>The reuseable Perl script uses one or more
instances of Objects created from a Perl Classes.<span
style='mso-spacerun:yes'>  </span>The Perl Classes are mostly reuseable.<span
style='mso-spacerun:yes'>  </span>For the co_backup script, this can be
represented as:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><!--[if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75"
 style='width:394.5pt;height:273pt' o:ole="">
 <v:imagedata src="Creating_Reuseable_Perl_Scripts_files/image013.wmz" o:title=""/>
</v:shape><![endif]--><![if !vml]><img border=0 width=526 height=364
src="Creating_Reuseable_Perl_Scripts_files/image014.gif" v:shapes="_x0000_i1030"><![endif]><!--[if gte mso 9]><xml>
 <o:OLEObject Type="Embed" ProgID="Visio.Drawing.6" ShapeID="_x0000_i1030"

examples/co_backup  view on Meta::CPAN

#!/usr/local/bin/perl -w

#
#	Create backup for view check-outs for all active releases
#

use strict;

use Cwd;
use Log::Log4perl;
use ClearCase::Region;
use ClearCase::Vob;

sub mainprog

examples/co_backup  view on Meta::CPAN

		#
		# $PATH	= $ENV{PATH};
		# $ENV{PATH}		= "/usr/atria/bin:$PATH";
	}
	else {
		$HOME = "C:";
	}
	$BACKUP	= "$HOME/logs";

	foreach $dir (@INC) {
		if ( -f "$dir/co_backup.conf" ) {
			$configFile = "$dir/co_backup.conf";
			$configFile_found = 1;
			last;
		}
	}
	croak("Error: co_backup.conf not found in any \@INC directory\n")
		unless $configFile_found;
	
	Log::Log4perl->init($configFile);
	$logger = Log::Log4perl->get_logger("Main");

	chdir("/view");

	@subregions = Region->subregions();
	if ($#subregions < 0) {
			$logger->error("Error: No subregions are defined in Region.cfg\n");

examples/co_backup  view on Meta::CPAN


		foreach $vob (@vobs) {
			$myvob = Vob->new($subregion, $vob);
			@active_rels = $myvob->active_rels();
			foreach $relno (@active_rels) {
				$cX = $subregion . '_' . $relno;

				# Appenders
				$appender = Log::Log4perl::Appender->new(
					"Log::Dispatch::File",
					filename => "$HOME/logs/${cX}.${vob}.backup.log",
					mode => "append",
				);
				$logger->add_appender($appender);

				# Layouts
				$layout = Log::Log4perl::Layout::PatternLayout->new(
							"%d %p> %F{1}:%L %M - %m%n");
				$appender->layout($layout);

				@viewtag_array = `cleartool lsview -short '*_${cX}'`;
				chomp(@viewtag_array);
				if ($#viewtag_array < 0) {
					next;
				}
				if (! open(OUTFILE, ">> $HOME/logs/${cX}.${vob}.backup.list")) {
					$logger->error("Cannot open file $HOME/logs/${cX}.${vob}.backup.list.  Error: $!\n");
				}
				foreach $viewtag (@viewtag_array) {
					if (! (-d ${viewtag})) {
						$logger->error("Bad view ${viewtag}.  Error: $!\n");
						next;
					}
					open(LSPRIV, "cleartool lsprivate -tag ${viewtag} -inv ${vobdir}/${vob} -co -short |");
					while ($fn = <LSPRIV>) {
						$fn =~ s/\/view\///;
						chomp($fn);

examples/co_backup  view on Meta::CPAN

						if ( -d ${fn} ) {
							next;
						}
						if ( -f ${fn} ) {
							print OUTFILE "${fn}\n";
						}
					}
					close(LSPRIV);
				}
				close(OUTFILE);
				$retval = system("cat $HOME/logs/${cX}.${vob}.backup.list |/usr/bin/cpio -ocL | compress > ${BACKUP}/${cX}.${vob}.cpio.Z");
				if ($retval != 0) {
					$logger->error("Cannot create ${BACKUP}/${cX}.${vob}.cpio.Z.  Error: $!\n");
				}
			}
		}
	}
}

###############################################################################
#	Main



( run in 0.808 second using v1.01-cache-2.11-cpan-49f99fa48dc )