releasing/cbrtools/perl/PrepRel.pm
author jjkang
Fri, 25 Jun 2010 19:56:45 +0800
changeset 604 b33dd54aaa52
parent 602 3145852acc89
permissions -rw-r--r--
add cpptoolsplat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
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
package PrepRel;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use MrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
# Public.
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
sub PrepRel {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
  my $iniData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
  my $envDb = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
  my $intVer = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
  my $mrpName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
  $envDb->CheckCompName($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
  die "Error: $ver is not a valid version number\n" if (defined $ver && !$ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
  die "Error: $intVer is not a valid internal version number\n" 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
    if (defined $intVer && !$intVer);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  if (not defined $ver and not defined $intVer and not defined $mrpName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
    RemoveDbEntry($envDb, $comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
    return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
  my $updating = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
  if (not defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
    $ver = $envDb->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
    if (not defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
      die "Error: $comp not installed; could not work out what version to use. Please specify a version number.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
    elsif ($envDb->Status($comp) != EnvDb::STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
      die "Error: New version not specified\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
      $updating = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
    my $currentVer = $envDb->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
    if (defined $currentVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
      if (lc($ver) eq $currentVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
	$updating = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
    my $relDir = $iniData->PathData->LocalArchivePathForExistingOrNewComponent($comp,$ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
    if (-e $relDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
      die "Error: $comp $ver already exists\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  if (not defined $intVer and $iniData->RequireInternalVersions() and not $updating) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
    die "Error: Internal version number not specified for $comp $ver\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
  if (defined $mrpName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
    Utils::CheckExists($mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
    Utils::AbsoluteFileName(\$mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
    if($iniData->HasMappings()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
      $mrpName = $iniData->PerformReverseMapOnFileName($mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
    $mrpName = Utils::RemoveSourceRoot($mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
    my $currentVersion = $envDb->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
    unless (defined $currentVersion) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
      die "Error: Mrp name not specified for $comp $ver\n";
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  $envDb->SetVersion($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  $envDb->SetStatus($comp, EnvDb::STATUS_PENDING_RELEASE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  if (defined $mrpName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
    $envDb->SetMrpName($comp, $mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  if (defined $intVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
    $envDb->SetInternalVersion($comp, $intVer);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
  $envDb->GenerateEmptySignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
}
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
# Private.
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 RemoveDbEntry {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  my $envDb = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
  my $ver = $envDb->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  if (defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
    print "Remove environment database entry for $comp? [y/n] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
    my $response = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
    chomp $response;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
    if ($response =~ /^y$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
      $envDb->DeleteSignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
      $envDb->SetVersion($comp, undef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
      die "Remove aborted\n";
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
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
    die "Error: $comp not installed\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
PrepRel.pm - Provides an interface to edit the environment database to prepare a component for release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
=head1 WARNING!
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
This is NOT the documentation for the command C<PrepRel>. This documentation refers to the internal release tools module called F<PrepRel.pm>. 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
For the PrepRel command documentation, you'll need to explicitly specify the path to the C<PrepRel> command,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
=head2 PrepRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   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>.
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