releasing/cbrtools/perl/PullEnv
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 14:05:41 +0800
changeset 713 7b7f0409fc00
parent 602 3145852acc89
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
#!perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use lib "$FindBin::Bin";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use Getopt::Long;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use File::Copy;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use File::Path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use PathData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use CommandController;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
use PushPullRel;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
# Globals.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
my $force = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
my $commandController = CommandController->New($iniData, 'PullEnv');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
my $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
my $externalIniDataFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
# Main.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
PullEnv();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
# Subs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  GetOptions('h' => \$help, 'f' => \$force, 'v+' => \$verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  $comp = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  $ver = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  $externalIniDataFile = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  unless (defined $comp and defined $ver and defined $externalIniDataFile and $#ARGV == -1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
    print "Error: Invalid arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  unless (-e $externalIniDataFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
    die "Error: $externalIniDataFile does not exist\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  Utils::PrintDeathMessage($exitCode, "\nUsage: pullenv [options] <component> <version> <remote-reltools-ini-file>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
-f  if check fails, overwrite local copy
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
-v  verbose output (-vv very verbose)\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
sub PullEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  my $ppr = new PushPullRel(
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    $iniData,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    $externalIniDataFile,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
    0, # pushing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    $verbose,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
    $force
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  $ppr->TransferEnv($comp,$ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  $ppr->SummariseErrors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
PullEnv - Copies a released environment from another archive.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
  pullenv [options] <component> <version> <remote-reltools-ini-file>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  -f  if check fails, overwrite local copy
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
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.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
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.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
=cut