releasing/cbrtools/perl/PushEnv
author jjkang
Wed, 30 Jun 2010 11:35:58 +0800
changeset 607 378360dbbdba
parent 602 3145852acc89
permissions -rw-r--r--
Merge missed changeset 11 (raptor v2.14 and helium 10.0)

#!perl
# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of the License "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
# 
# Initial Contributors:
# Nokia Corporation - initial contribution.
# 
# Contributors:
# 
# Description:
# 
#

use strict;
use FindBin;
use lib "$FindBin::Bin";
use Getopt::Long;
use File::Copy;
use IniData;
use RelData;
use PathData;
use CommandController;
use PushPullRel;


#
# Globals.
#

my $verbose = 0;
my $force = 0;
my $iniData = IniData->New();
my $commandController = CommandController->New($iniData, 'PushEnv');
my $comp;
my $ver;
my $externalIniDataFile;


#
# Main.
#

ProcessCommandLine();
PushEnv();


#
# Subs.
#

sub ProcessCommandLine {
  Getopt::Long::Configure ("bundling");
  my $help;
  GetOptions('h' => \$help, 'f' => \$force, 'v+' => \$verbose);

  if ($help) {
    Usage(0);
  }

  $comp = shift @ARGV;
  $ver = shift @ARGV;
  $externalIniDataFile = shift @ARGV;

  unless (defined $comp and defined $ver and defined $externalIniDataFile and $#ARGV == -1) {
    print "Error: Invalid arguments\n";
    Usage(1);
  }

  unless (-e $externalIniDataFile) {
    die "Error: $externalIniDataFile does not exist\n";
  }
}

sub Usage {
  my $exitCode = shift;

  Utils::PrintDeathMessage($exitCode, "\nUsage: pushenv [options] <component> <version> <remote-site-reltools-ini-file>

options:

-h  help
-f  if check fails, overwrite external copy
-v  verbose output (-vv very verbose)\n");
}

sub PushEnv {
  my $ppr = new PushPullRel(
    $iniData,
    $externalIniDataFile,
    1, # pushing
    $verbose,
    $force
  );
  $ppr->TransferEnv($comp,$ver);
  $ppr->SummariseErrors;
}

__END__

=head1 NAME

PushEnv - Copies a released environment to another archive.

=head1 SYNOPSIS

  pushenv [options] <component> <version> <remote-site-reltools-ini-file>

options:

  -h  help
  -f  if check fails, overwrite external copy
  -v  verbose output (-vv very verbose)

=head1 DESCRIPTION

If two sites that share a common WAN want to have separate local archives, the commands C<PushEnv> and C<PullEnv> can be used to keep them in sync. They are similar is spirit to C<ExportEnv> and C<ImportEnv>, however the files are copied directly rather than being encrypted and placed on a shared repository.

For each component in the specified local environment, checks to see if the corresponding release directory exists on the remote site. If it does, each if is checked to ensure its modified time and size is that same as in the local archive. If the check fails an error is thrown (by default, unless the C<-f> switch is used). If is does not, the directory is created and the component is copied into it.

=head1 KNOWN BUGS

None.

=head1 COPYRIGHT

 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
 All rights reserved.
 This component and the accompanying materials are made available
 under the terms of the License "Eclipse Public License v1.0"
 which accompanies this distribution, and is available
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
 
 Initial Contributors:
 Nokia Corporation - initial contribution.
 
 Contributors:
 
 Description:
 

=cut