Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

########################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# Module name   : rmMerge_process.pl
# Module type   : JATS Utility
# Compiler(s)   : Perl
# Environment(s): jats
#
# Description   : Transfer a package from New dpkg_archive to the old dpkg_archive
#                 
#
# Usage         : See POD at the end of this file
#
#......................................................................#

require 5.008_002;
use strict;
use warnings;

use Pod::Usage;
use Getopt::Long;

use JatsError;
use JatsRmApi;
use JatsSystem;
use FileUtils;
use ConfigurationFile;
use JatsProperties;
use File::Copy;
use DBI;
my $RM_DB;

my $opt_help=0;
my $opt_verbose=0;
my $opt_debug=0;
my $opt_replace;

my $VERSION = "1.0";
my $newDpkg = '/net/auawsaarc002/export/devl/dpkg_archive';
my $oldDpkg = '/export/devl/dpkg_archive';

my $pname;
my $pversion;

#-------------------------------------------------------------------------------
# Function        : Mainline Entry Point
#
# Description     :
#
# Inputs          :
#
my $result = GetOptions (
                "help:+"        => \$opt_help,
                "manual:3"      => \$opt_help,
                "verbose:+"     => \$opt_verbose,
                "debug:+"       => \$opt_debug,
                "replace!"      => \$opt_replace,
                );

                #
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
                #

#
#   Process help and manual options
#
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
pod2usage(-verbose => 1) if ( $opt_help == 2 );
pod2usage(-verbose => 2) if ( $opt_help > 2 );
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV != 1 );

#
#   Configure the error reporting rmMerge_process now that we have the user options
#
ErrorConfig( 'name'    =>'DPKG_TRANSFER',
             'verbose' => $opt_verbose,
             'debug' => $opt_debug,
            );

#
# 
$pname = $ARGV[0];  
$pversion = $ARGV[1];

#
#   Ensure the pakage exists in the 'pulse' dpkg_archive
#
testPath($newDpkg);
testPath($oldDpkg);
my $srcDir = testPath( catdir($newDpkg, $pname, $pversion));
my $dstDir = catdir ($oldDpkg, $pname);
my $dstPkg = catdir ($oldDpkg, $pname, $pversion);
Message("Source: $srcDir") ;
Message("Target: $dstDir");
Error ("Package aleady exists: $dstPkg ") if -x $dstPkg;
if ( ! -d $dstDir) {
    Message ("Create Package directory");
    mkdir $dstDir;
}
testPath( $dstDir );
System ('--Show','cp', '-a', $srcDir, $dstDir);
Error("Package not copied") unless -d $dstPkg;
 
#   Need to set the facl stuff - its not done by the 'cp' command 
System('setfacl', '-R', '-x', 'user:releasem',$dstPkg);
System('setfacl', '-R', '-x', 'user:buildadm',$dstPkg);
System('setfacl', '-R', '-x', 'group:ccperdev',$dstPkg);
System('setfacl', '-R', '-m', 'default:user:buildadm:rwx','-m','default:user::rwx','-m','mask::r-x',$dstPkg);
System('setfacl', '-R', '-m', 'user::r-X,group::r-X,other::r-X',$dstPkg);

#-------------------------------------------------------------------------------
# Function        : testPath 
#
# Description     : Test that a directory exists
#
# Inputs          : $path
#
# Returns         : 
#
sub testPath
{
    my ($path) = @_;
    Debug("Testing: $path");
    return $path if -d $path;
    Error ("Path not found: $path");
}

#-------------------------------------------------------------------------------
#   Documentation
#

=pod

=for htmltoc    GENERAL::ClearCase::

=head1 NAME

rmMerge_transfer_dpkg - Transfer package

=head1 SYNOPSIS

jats rmMerge_transfer_dpkg [options] PackageName PackageVersion

 Options:
    -help              - brief help message
    -help -help        - Detailed help message
    -man               - Full documentation

=head1 OPTIONS

=over 8

=item B<-help>

Print a brief help message and exits.

=item B<-help -help>

Print a detailed help message with an explanation for each option.

=back

=head1 EXAMPLE

jats rmMerge_transfer_dpkg PackageName PackageVersion

=cut