releasing/cbrtools/perl/PullEnv
author Zheng Shen <zheng.shen@nokia.com>
Wed, 27 Oct 2010 19:16:18 +0800
changeset 663 8e27d440923e
parent 602 3145852acc89
permissions -rw-r--r--
revert to 7c11c3d8d025

#!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 File::Path;
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, 'PullEnv');
my $comp;
my $ver;
my $externalIniDataFile;


#
# Main.
#

ProcessCommandLine();
PullEnv();


#
# 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: pullenv [options] <component> <version> <remote-reltools-ini-file>

options:

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

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


__END__

=head1 NAME

PullEnv - Copies a released environment from another archive.

=head1 SYNOPSIS

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

options:

  -h  help
  -f  if check fails, overwrite local 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 external environment, checks to see if the corresponding release directory exists in the local archive. If it does, each if is checked to ensure its modified time and size is that same as in the external 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