releasing/cbrtools/perl/MakeEnv
author kelvzhu
Mon, 18 Oct 2010 16:16:46 +0800
changeset 655 3f65fd25dfd4
parent 602 3145852acc89
permissions -rw-r--r--
sync up SVN codes
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::Path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use EnvDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use MrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use NotesCompiler;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use MakeRel;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
use CommandController;
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 $notesSrc;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my $mrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
my $commandController = CommandController->New($iniData, 'MakeEnv');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
my $envDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
my $project;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
my $useCachedManifest;
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
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
# Main.
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
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
if (!CheckArchive()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  exit 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
CheckEnvironment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
MakeRel::MakeReleases($iniData, $envDb, $mrpData, $notesSrc, 'MakeEnv', $verbose, $project, $useCachedManifest);
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
# Subs.
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
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
  GetOptions("h" => \$help, "v+" => \$verbose, "n=s" => \$notesSrc, "w=s" => \$project, "useCachedManifest" =>\$useCachedManifest);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
    Usage(0);
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
  unless ($#ARGV == -1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    print "Error: Invalid arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  $envDb = EnvDb->Open($iniData, $verbose);
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
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  Utils::PrintDeathMessage($exitCode, "\nUsage: makeenv [options]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
-h                    help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
-n <notes_src_file>   compile all release notes using a single source file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
-v                    verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
-w <project>          make the release in given \"project\"\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 CheckArchive {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  my $env = $envDb->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  my @components = map([$_, $env->{$_}], keys(%$env));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  my @pendingComps = grep($envDb->Status($_->[0]) == EnvDb::STATUS_PENDING_RELEASE, @components);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  my $good = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  foreach my $comp (@pendingComps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
    my $relDir = $iniData->PathData->LocalArchivePathForExistingOrNewComponent($comp->[0],$comp->[1],$project);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
    if (-e $relDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
      print STDERR "Error: $relDir already exists\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
      $good = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
  return $good;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
sub CheckEnvironment {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
  (my $status, $mrpData, my $dirtyComps, my $unaccountedFiles, my $duplicates) = $envDb->CheckEnv(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  if (scalar (@$dirtyComps) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
    foreach my $comp (@$dirtyComps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
      print "Error: $comp->{comp} $comp->{ver} is dirty\n"; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  if (scalar (@$unaccountedFiles) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
    foreach my $line (@$unaccountedFiles) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
      print "Error: $line has unknown origin\n"; 
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
  if (scalar (@$duplicates) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
    foreach my $args (@$duplicates) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
      print "Error: $args->[1] attempting to release $args->[0] which has already been released by $args->[2]\n"; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  if ($status == EnvDb::STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
    die "No components are pending release\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
  elsif ($status == EnvDb::STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    die "Error: Release environment is dirty\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
MakeEnv - Make a release of an entire environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
  makeenv [options]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
  -h                    help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
  -n <notes_src_file>   compile all release notes using a single source file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  -v                    verbose output (-vv  very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  -w <project>          make the release in given "project"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
  --useCachedManifest   for internal use only *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
C<MakeEnv> is a tool that can generate one or more releases in such a way that the entire environment from which they were released can reliably be reproduced when doing a corresponding C<GetEnv> (not this is B<not> a guarantee that C<MakeRel> can make). The reliability of environment reproduction is achieved by scanning the F<\epoc32> tree before making a release to ensure that each file present has a known origin. This may be either within an existing release, or within releases that are about to be made. Releases that are about to be made must have their environment database status set to C<pending release> using either C<PrepRel> or C<PrepEnv>. C<MakeEnv> will not proceed until the overall status of the release environment is C<pending release>. The current overall status of an environment can be found using C<EnvInfo> with the C<-f> switch.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
Once the release environment is C<pending release>, C<MakeEnv> can be executed. If no arguments are provided, it will make releases of each component with C<pending release> status using the version information and F<mrp> file name store in the environment database. It is possible to override the release notes source file to be used for all releases via the C<-n> switch. This may be useful, for example, if the source in the components being released hasn't changed, but an underlying break in binary compatibility is being absorbed, as they can all be assigned the same release note.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
The C<-w> switch specifies the location to make the releases. If you use this argument, you should specify the name of an archive as specified in your F<reltools.ini> file. If you don't use this argument, the releases will go into the first archive listed in your F<reltools.ini>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
See the document I<Making Releases> for more complete coverage of the process of making releases in general. See also the documentation on C<ValidateEnv> which can identify components that have not changed since the last time they were released, and so do not need to be released again.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
* When using the C<--useCachedManifest> switch C<MakeEnv> will check too see if a cached manifest file already exists for each component.  Cached manifest files are created by  C<ValidateRel>.  If a cached manifest file is found it will used for the component release.  If no manifest file is found, or the C<--useChachedManifest> switch has not been specified then a new manifest file will be generated from the component's MRP file.  This functionality is useful for automated build systems, as it avoids the process of duplicating manifest files.  Note that evalid checksums are not recalculated for cached manifest files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
=cut