releasing/cbrtools/perl/PrepEnv
author jascui
Wed, 17 Nov 2010 13:27:16 +0800
changeset 686 3e502c8c584c
parent 602 3145852acc89
permissions -rw-r--r--
Update release information and product version.
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 Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use PrepRel;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use CommandController;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
# Constants.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
use constant UPDATED => 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
use constant UNCHANGED => 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
# Globals.
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
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
my $newMrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
my $inputFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
my $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
my $intVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
my $commandController = CommandController->New($iniData, 'PrepEnv');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
my $envDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
my $mode;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
my $samemrps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
my $fixedIntVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
my $printlatestversion;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
my $skipPendingRelease;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
# Main.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
PrepEnv();
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
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
# Subs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  GetOptions("h" => \$help, "v+" => \$verbose, "m" => \$samemrps, "i=s" => \$fixedIntVer, "l" => \$printlatestversion, "p" => \$skipPendingRelease);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
    Usage(0);
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
  $inputFile = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
  unless ($#ARGV == -1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
  if ($printlatestversion && $inputFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
    print "Error: can't use -l with an input file\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  if ($skipPendingRelease && $inputFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
    print "Error: can't use -p with an input file\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  Utils::PrintDeathMessage($exitCode, "\nUsage: prepenv [options] [<input_file_name>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
-v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
-m          don't query for MRP location (assume same as previously)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
-i <number> use this internal version number for each component
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
Options only valid in interactive mode:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
-l          print latest version number
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
-p          skip those components that are pending release
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
Note: if prepenv is failing to recognise some components are dirty,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
run 'envinfo -f' then run 'prepenv' again.\n");
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
sub PrepEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  if (defined $inputFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
    HandleInputFile();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
    HandleInteractive();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
sub HandleInputFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
  open (IN, $inputFile) or die "Error: Couldn't open $inputFile: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
  my $numEntriesUpdated = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  my $numEntriesAdded = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  my $numErrors = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
  my $lineNum = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
  while (my $line = <IN>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
    ++$lineNum;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    # Remove line feed, white space and comments.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
    $line =~ s/^\s*$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
    $line =~ s/#.*//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
    if ($line eq '') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
      # Nothing left.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
    local @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
    @ARGV = split (/\s+/, $line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
    my $mrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
    GetOptions("m=s" => \$mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
    (my $comp, my $ver, my $intVer) = @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
    unless (defined $comp and defined $ver and $#ARGV <= 2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
      die "Error: Line $lineNum contains invalid arguments in \"$inputFile\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
    $intVer ||= undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
    $mrpName ||= undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
    if (!defined $mrpName && $samemrps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
      eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
        $mrpName = $envDb->MrpName($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
      };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
      if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
        die "Error: Could not get MRP location for \"$comp\", because $@\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
    if (!defined $intVer && $fixedIntVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
      $intVer = $fixedIntVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
    my $updating = $envDb->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
    if ($verbose) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
      if (defined $updating) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
	print "Updating $comp $ver...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
	print "Adding $comp $ver...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
    eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
      PrepRel::PrepRel($iniData, $envDb, $comp, $ver, $intVer, $mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
      print $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
      ++$numErrors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    elsif (defined $updating) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
      ++$numEntriesUpdated;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
      ++$numEntriesAdded;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
  close (IN);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
  print "$numEntriesAdded component(s) added, $numEntriesUpdated component(s) updated, $numErrors error(s)\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
sub HandleInteractive {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
  my $verInfo = $envDb->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  my $numUpdatedEntries = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
  my $numUnchangedEntries = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
  foreach my $thisComp (sort keys %{$verInfo}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
    my $thisStatus = $envDb->Status($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
    if ($thisStatus == EnvDb::STATUS_DIRTY or $thisStatus == EnvDb::STATUS_DIRTY_SOURCE or ($thisStatus == EnvDb::STATUS_PENDING_RELEASE && !$skipPendingRelease)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
      my $action = DoInteraction($thisComp, $verInfo->{$thisComp});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
      if ($action == UPDATED) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
        ++$numUpdatedEntries;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
        ++$numUnchangedEntries;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
  print "$numUpdatedEntries component(s) updated, $numUnchangedEntries component(s) unchanged\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
  if ($numUpdatedEntries + $numUnchangedEntries == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
    my $pendingReleaseString = $skipPendingRelease?"":" or pending release";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
    print <<ENDGIBBER;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
No components appeared dirty$pendingReleaseString. If you were expecting to see more dirty 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
components, run 'envinfo -f' then run prepenv again.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
ENDGIBBER
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
sub DoInteraction {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
  my $modified = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
  ShowLatestVer($comp) if $printlatestversion;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
  print "$comp version [$ver] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
  my $newVer = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
  chomp $newVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
  if ($newVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
    $modified = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
    undef $newVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
  my $newIntVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
  if ($fixedIntVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
    $newIntVer = $fixedIntVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
    my $intVer = $envDb->InternalVersion($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
    print "$comp internal version ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
    if (defined $intVer and !defined $newVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
      print "[$intVer] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
    $newIntVer = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
    chomp $newIntVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
    if ($newIntVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
      $modified = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
      undef $newIntVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
  my $mrpName = $envDb->MrpName($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
  my $newMrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
  if ($samemrps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
    $newMrpName = $mrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
    print "$comp mrp name [$mrpName] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
    $newMrpName = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
    chomp $newMrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
    if ($newMrpName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
      $modified = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
      undef $newMrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
  my $return = UNCHANGED;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
  if ($modified) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
    eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
      PrepRel::PrepRel($iniData, $envDb, $comp, $newVer, $newIntVer, $newMrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
      print $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
      $return = UPDATED;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
  print "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
  return $return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
sub ShowLatestVer {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
  my $reldata = RelData->OpenSet($iniData, $comp, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
  if ($reldata) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
    my $reldatum = $reldata->[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
    if ($reldatum) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
      print "$comp: Latest version: ".$reldatum->Version . " (internal version ".$reldatum->InternalVersion.")\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
      return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
  print "No previous versions.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
PrepEnv - Prepares an environment for release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
  prepenv [options] [<input_file_name>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
  -i  <internal> use this internal version number instead of prompting
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
  -m  don't prompt for MRP location
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
Options valid only in interactive mode:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
  -l  show latest version number
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
  -p  skip those components that are pending release
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
Before an environment can be released, the status of each component that needs to be released must be set to I<pending release> and the new versions and F<mrp> names must be specified. C<PrepEnv> provides two ways of manipulating this information in the environment database:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
=item 1 Interactively
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
If no arguments are given to C<PrepEnv>, it will enter an interactive mode asking for version, internal version and mrp name for each component in the database with a status of I<dirty> or I<binaries clean, source dirty> (or I<pending release> unless -p is specified). It won't ask for internal version or MRP name if you have used the -i or -m respectively. The current value of each will be presented in square brackets. Hitting I<return> will preserve the current value. If all the current values are selected for a particular component, it's environment database entry will not be changed, otherwise the values will be updated and its status will be set to I<pending release>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
=item 3 Via an input file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
The name of an input file may be specified as an argument. The structure of each line in the file must be as follows:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
 <component_name> <version> [<internal_version>] [-m <mrp_name>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
Note, you can optionally specify internal version (assuming the F<reltools.ini> keyword C<require_internal_versions> has not been specified) and F<mrp> name. You can also optionally specify a new F<mrp> name, but to distinguish this from an internal version you much precede it with '-m'.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
Note, C<PrepEnv> (and its counterpart C<PrepRel>) do nothing more than update your the environment database. You can execute these commands as many times as you like before running C<MakeEnv> to actually release the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
C<PrepEnv> does not always identify dirty components correctly. If you've just made a component dirty, then run C<prepenv> immediately afterwards, it will not notice that dirty component. To solve this you should run C<EnvInfo -f> before running C<PrepEnv>. C<PrepEnv> will then ask you about components correctly. This is a deliberate design decision: otherwise, C<PrepEnv> would have to do a slow environment scan before prompting you. Normally, you'll have run C<envinfo -f> first, so the environment scan is redundant.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
=cut