releasing/cbrtools/perl/PrepRel.pm
changeset 602 3145852acc89
equal deleted inserted replaced
600:6d08f4a05d93 602:3145852acc89
       
     1 # Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 # 
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 # 
       
    11 # Contributors:
       
    12 # 
       
    13 # Description:
       
    14 # 
       
    15 #
       
    16 
       
    17 package PrepRel;
       
    18 
       
    19 use strict;
       
    20 use IniData;
       
    21 use MrpData;
       
    22 use Utils;
       
    23 
       
    24 
       
    25 #
       
    26 # Public.
       
    27 #
       
    28 
       
    29 sub PrepRel {
       
    30   my $iniData = shift;
       
    31   my $envDb = shift;
       
    32   my $comp = shift;
       
    33   my $ver = shift;
       
    34   my $intVer = shift;
       
    35   my $mrpName = shift;
       
    36 
       
    37   $envDb->CheckCompName($comp);
       
    38   die "Error: $ver is not a valid version number\n" if (defined $ver && !$ver);
       
    39   die "Error: $intVer is not a valid internal version number\n" 
       
    40     if (defined $intVer && !$intVer);
       
    41 
       
    42   if (not defined $ver and not defined $intVer and not defined $mrpName) {
       
    43     RemoveDbEntry($envDb, $comp);
       
    44     return;
       
    45   }
       
    46 
       
    47   my $updating = 0;
       
    48   if (not defined $ver) {
       
    49     $ver = $envDb->Version($comp);
       
    50     if (not defined $ver) {
       
    51       die "Error: $comp not installed; could not work out what version to use. Please specify a version number.\n";
       
    52     }
       
    53     elsif ($envDb->Status($comp) != EnvDb::STATUS_PENDING_RELEASE) {
       
    54       die "Error: New version not specified\n";
       
    55     }
       
    56     else {
       
    57       $updating = 1;
       
    58     }
       
    59   }
       
    60   else {
       
    61     my $currentVer = $envDb->Version($comp);
       
    62     if (defined $currentVer) {
       
    63       if (lc($ver) eq $currentVer) {
       
    64 	$updating = 1;
       
    65       }
       
    66     }
       
    67     my $relDir = $iniData->PathData->LocalArchivePathForExistingOrNewComponent($comp,$ver);
       
    68     if (-e $relDir) {
       
    69       die "Error: $comp $ver already exists\n";
       
    70     }
       
    71   }
       
    72 
       
    73   if (not defined $intVer and $iniData->RequireInternalVersions() and not $updating) {
       
    74     die "Error: Internal version number not specified for $comp $ver\n";
       
    75   }
       
    76 
       
    77   if (defined $mrpName) {
       
    78     Utils::CheckExists($mrpName);
       
    79     Utils::AbsoluteFileName(\$mrpName);
       
    80     
       
    81     if($iniData->HasMappings()) {
       
    82       $mrpName = $iniData->PerformReverseMapOnFileName($mrpName);
       
    83     }
       
    84     
       
    85     $mrpName = Utils::RemoveSourceRoot($mrpName);
       
    86   }
       
    87   else {
       
    88     my $currentVersion = $envDb->Version($comp);
       
    89     unless (defined $currentVersion) {
       
    90       die "Error: Mrp name not specified for $comp $ver\n";
       
    91     }
       
    92   }
       
    93 
       
    94   $envDb->SetVersion($comp, $ver);
       
    95   $envDb->SetStatus($comp, EnvDb::STATUS_PENDING_RELEASE);
       
    96   if (defined $mrpName) {
       
    97     $envDb->SetMrpName($comp, $mrpName);
       
    98   }
       
    99   if (defined $intVer) {
       
   100     $envDb->SetInternalVersion($comp, $intVer);
       
   101   }
       
   102   $envDb->GenerateEmptySignature($comp, $ver);
       
   103 }
       
   104 
       
   105 
       
   106 #
       
   107 # Private.
       
   108 #
       
   109 
       
   110 sub RemoveDbEntry {
       
   111   my $envDb = shift;
       
   112   my $comp = shift;
       
   113   my $ver = $envDb->Version($comp);
       
   114   if (defined $ver) {
       
   115     print "Remove environment database entry for $comp? [y/n] ";
       
   116     my $response = <STDIN>;
       
   117     chomp $response;
       
   118     if ($response =~ /^y$/i) {
       
   119       $envDb->DeleteSignature($comp, $ver);
       
   120       $envDb->SetVersion($comp, undef);
       
   121     }
       
   122     else {
       
   123       die "Remove aborted\n";
       
   124     }
       
   125   }
       
   126   else {
       
   127     die "Error: $comp not installed\n";
       
   128   }
       
   129 }
       
   130 
       
   131 
       
   132 1;
       
   133 
       
   134 =head1 NAME
       
   135 
       
   136 PrepRel.pm - Provides an interface to edit the environment database to prepare a component for release.
       
   137 
       
   138 =head1 WARNING!
       
   139 
       
   140 This is NOT the documentation for the command C<PrepRel>. This documentation refers to the internal release tools module called F<PrepRel.pm>. 
       
   141 
       
   142 For the PrepRel command documentation, you'll need to explicitly specify the path to the C<PrepRel> command,
       
   143 
       
   144 =head1 INTERFACE
       
   145 
       
   146 =head2 PrepRel
       
   147 
       
   148 Expects to be passed an C<IniData> reference, an C<EnvDb> reference, a component name. May optionally be passed in addition a version, an internal version and an F<mrp> file name. If no version parameter is specified, the component's database entry is removed. Otherwise the component's database entry is updates with the information provided, and its status set to C<STATUS_PENDING_RELEASE>.
       
   149 
       
   150 =head1 KNOWN BUGS
       
   151 
       
   152 None.
       
   153 
       
   154 =head1 COPYRIGHT
       
   155 
       
   156  Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
   157  All rights reserved.
       
   158  This component and the accompanying materials are made available
       
   159  under the terms of the License "Eclipse Public License v1.0"
       
   160  which accompanies this distribution, and is available
       
   161  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
   162  
       
   163  Initial Contributors:
       
   164  Nokia Corporation - initial contribution.
       
   165  
       
   166  Contributors:
       
   167  
       
   168  Description:
       
   169  
       
   170 
       
   171 =cut