releasing/cbrtools/perl/GetSource
author lorewang
Mon, 22 Nov 2010 10:56:31 +0800
changeset 700 c22eff170fac
parent 602 3145852acc89
permissions -rw-r--r--
update from trunk
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 IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use EnvDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use CommandController;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
# Globals.
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
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
my $overwrite = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
my $commandController = CommandController->New($iniData, 'GetSource');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
my $envDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
my $installDir = "\\";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
# Main.
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
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
GetSource();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
# Subs.
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
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  GetOptions('h' => \$help, 'i=s' => \$installDir, 'o' => \$overwrite, 'v+' => \$verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  $comp = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  $ver = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  unless ($#ARGV == -1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  Utils::CheckDirectoryName($installDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  if (defined $comp and not defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
    $ver = $envDb->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    unless (defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
      die "Error: $comp not installed\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
  Utils::PrintDeathMessage($exitCode, "\nUsage: getsource [options] [<component> [<version>]]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
-i  <install_directory>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
-o  overwrite any existing source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
-v  verbose output (-vv very verbose)\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
sub GetSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  if (defined $comp) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
    UnpackSource($comp, $ver, $installDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
    print "About to unpack the source for the entire environment. Continue? [y/n] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
    my $response = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
    if ($response =~ /^y$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
      my $versionInfo = $envDb->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
      foreach my $thisComp (sort keys %{$versionInfo}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
        eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
          UnpackSource($thisComp, $versionInfo->{$thisComp}, $installDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
        };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
        if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
          print $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
sub UnpackSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
  my $dir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  print "Getting source for $comp $ver...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  $envDb->UnpackSource($comp, $ver, $dir, $overwrite, 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
GetSource - Installs the source code from a component release into the current environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
  getsource [options] [<component> [<version>]]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
  -i  <install_directory>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
  -o  overwrite any existing source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
Releases are generally made containing both source and binaries. By default, tools like C<GetEnv> and C<GetRel> only unpack the binaries. C<GetSource> provides a means of installing the source when it is required (e.g. for debugging purposes).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
If only a component name is specified, the source for the currently installed version of the component is unpacked into the root of the current drive. If the source code for a version of a component that is not currently installed is required, then specify both the version and a directory in which the source should be unpacked (this will be created if it does not already exist). If no arguments are specified, the source to all the installed components is unpacked into the root of the current drive.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
=cut