releasing/cbrtools/perl/PushEnv
author Zheng Shen <zheng.shen@nokia.com>
Tue, 20 Jul 2010 15:02:28 +0800
changeset 617 3a747a240983
parent 602 3145852acc89
permissions -rw-r--r--
ROM Tools 12.2.0.4 Postlinker 2.2.5 Revert package_definition.xml to changeset 360bd6b35136

#!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