releasing/cbrtools/perl/MakeEnv
changeset 602 3145852acc89
equal deleted inserted replaced
600:6d08f4a05d93 602:3145852acc89
       
     1 #!perl
       
     2 # Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 # 
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 # 
       
    12 # Contributors:
       
    13 # 
       
    14 # Description:
       
    15 # 
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use FindBin;
       
    20 use lib "$FindBin::Bin";
       
    21 use Getopt::Long;
       
    22 use File::Path;
       
    23 use IniData;
       
    24 use EnvDb;
       
    25 use MrpData;
       
    26 use NotesCompiler;
       
    27 use MakeRel;
       
    28 use CommandController;
       
    29 
       
    30 
       
    31 #
       
    32 # Globals.
       
    33 #
       
    34 
       
    35 my $verbose = 0;
       
    36 my $notesSrc;
       
    37 my $mrpData;
       
    38 my $iniData = IniData->New();
       
    39 my $commandController = CommandController->New($iniData, 'MakeEnv');
       
    40 my $envDb;
       
    41 my $project;
       
    42 my $useCachedManifest;
       
    43 
       
    44 
       
    45 #
       
    46 # Main.
       
    47 #
       
    48 
       
    49 ProcessCommandLine();
       
    50 if (!CheckArchive()) {
       
    51   exit 1;
       
    52 }
       
    53 CheckEnvironment();
       
    54 MakeRel::MakeReleases($iniData, $envDb, $mrpData, $notesSrc, 'MakeEnv', $verbose, $project, $useCachedManifest);
       
    55 
       
    56 
       
    57 #
       
    58 # Subs.
       
    59 #
       
    60 
       
    61 sub ProcessCommandLine {
       
    62   Getopt::Long::Configure ("bundling");
       
    63   my $help;
       
    64   GetOptions("h" => \$help, "v+" => \$verbose, "n=s" => \$notesSrc, "w=s" => \$project, "useCachedManifest" =>\$useCachedManifest);
       
    65 
       
    66   if ($help) {
       
    67     Usage(0);
       
    68   }
       
    69 
       
    70   unless ($#ARGV == -1) {
       
    71     print "Error: Invalid arguments\n";
       
    72     Usage(1);
       
    73   }
       
    74 
       
    75   $envDb = EnvDb->Open($iniData, $verbose);
       
    76 }
       
    77 
       
    78 sub Usage {
       
    79   my $exitCode = shift;
       
    80 
       
    81   Utils::PrintDeathMessage($exitCode, "\nUsage: makeenv [options]
       
    82 
       
    83 options:
       
    84 
       
    85 -h                    help
       
    86 -n <notes_src_file>   compile all release notes using a single source file
       
    87 -v                    verbose output (-vv very verbose)
       
    88 -w <project>          make the release in given \"project\"\n");
       
    89 }
       
    90 
       
    91 sub CheckArchive {
       
    92   my $self = shift;
       
    93 
       
    94   my $env = $envDb->VersionInfo();
       
    95   my @components = map([$_, $env->{$_}], keys(%$env));
       
    96   my @pendingComps = grep($envDb->Status($_->[0]) == EnvDb::STATUS_PENDING_RELEASE, @components);
       
    97 
       
    98   my $good = 1;
       
    99   foreach my $comp (@pendingComps) {
       
   100     my $relDir = $iniData->PathData->LocalArchivePathForExistingOrNewComponent($comp->[0],$comp->[1],$project);
       
   101     if (-e $relDir) {
       
   102       print STDERR "Error: $relDir already exists\n";
       
   103       $good = 0;
       
   104     }
       
   105   }
       
   106 
       
   107   return $good;
       
   108 }
       
   109 
       
   110 sub CheckEnvironment {
       
   111   my $self = shift;
       
   112 
       
   113   (my $status, $mrpData, my $dirtyComps, my $unaccountedFiles, my $duplicates) = $envDb->CheckEnv(1);
       
   114   if (scalar (@$dirtyComps) > 0) {
       
   115     foreach my $comp (@$dirtyComps) {
       
   116       print "Error: $comp->{comp} $comp->{ver} is dirty\n"; 
       
   117     }
       
   118   }
       
   119   if (scalar (@$unaccountedFiles) > 0) {
       
   120     foreach my $line (@$unaccountedFiles) {
       
   121       print "Error: $line has unknown origin\n"; 
       
   122     }
       
   123   }
       
   124   if (scalar (@$duplicates) > 0) {
       
   125     foreach my $args (@$duplicates) {
       
   126       print "Error: $args->[1] attempting to release $args->[0] which has already been released by $args->[2]\n"; 
       
   127     }
       
   128   }
       
   129   if ($status == EnvDb::STATUS_CLEAN) {
       
   130     die "No components are pending release\n";
       
   131   }
       
   132   elsif ($status == EnvDb::STATUS_DIRTY) {
       
   133     die "Error: Release environment is dirty\n";
       
   134   }
       
   135 }
       
   136 
       
   137 
       
   138 __END__
       
   139 
       
   140 =head1 NAME
       
   141 
       
   142 MakeEnv - Make a release of an entire environment.
       
   143 
       
   144 =head1 SYNOPSIS
       
   145 
       
   146   makeenv [options]
       
   147 
       
   148 options:
       
   149 
       
   150   -h                    help
       
   151   -n <notes_src_file>   compile all release notes using a single source file
       
   152   -v                    verbose output (-vv  very verbose)
       
   153   -w <project>          make the release in given "project"
       
   154   --useCachedManifest   for internal use only *
       
   155 
       
   156 =head1 DESCRIPTION
       
   157 
       
   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.
       
   159 
       
   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.
       
   161 
       
   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>.
       
   163 
       
   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.
       
   165 
       
   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.
       
   167 
       
   168 =head1 KNOWN BUGS
       
   169 
       
   170 None.
       
   171 
       
   172 =head1 COPYRIGHT
       
   173 
       
   174  Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
   175  All rights reserved.
       
   176  This component and the accompanying materials are made available
       
   177  under the terms of the License "Eclipse Public License v1.0"
       
   178  which accompanies this distribution, and is available
       
   179  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
   180  
       
   181  Initial Contributors:
       
   182  Nokia Corporation - initial contribution.
       
   183  
       
   184  Contributors:
       
   185  
       
   186  Description:
       
   187  
       
   188 
       
   189 =cut