releasing/cbrtools/perl/MakeRel.pm
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 14:05:41 +0800
changeset 713 7b7f0409fc00
parent 602 3145852acc89
permissions -rw-r--r--
merge
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 MakeRel;
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 File::Path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use File::Spec;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use File::Basename;
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 RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use CatData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
use Symbian::CBR::Component::Manifest;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
use Cwd;
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
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
sub MakeReleases {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
  my $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
  $self->{iniData} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
  $self->{envDb} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
  $self->{mrpData} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
  $self->{notesSrc} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  $self->{toolName} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  $self->{project} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  $self->{useCachedManifest} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
  bless $self, "MakeRel";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
  if (scalar(@{$self->{mrpData}}) == 0) { # Abort if there's nothing to do.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
    return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
  if (!$self->CheckArchive()) { # Abort if any of the releases already exist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
    return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  my $versionInfo = $self->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
    $self->GenerateReleaseFiles($versionInfo);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
    print $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
    if($self->{toolName} =~ /MakeEnv/i){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
      print "\nError: Unable to create environment successfully, archive might be corrupted.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
      print "\nError: Unable to create component release successfully, archive might be corrupted.\n";
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
    $self->Cleanup();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  # Now that we know all releases have been successfully made, update the environment database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  foreach my $thisMrpData (@{$self->{mrpData}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    my $comp = $thisMrpData->Component();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
    my $ver = $thisMrpData->ExternalVersion();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
    $self->{envDb}->SetVersion($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
    $self->{envDb}->GenerateSignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    $self->{envDb}->SetMrpName($comp, $thisMrpData->MrpName());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
    $self->{envDb}->SetStatus($comp, EnvDb::STATUS_CLEAN);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  }
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
sub VersionInfo {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  # Get a copy of the current version information from the environment database and update it with the new versions.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  my $versionInfo = $self->{envDb}->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  foreach my $thisMrpData (@{$self->{mrpData}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    $versionInfo->{lc($thisMrpData->Component())} = $thisMrpData->ExternalVersion();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  return $versionInfo;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
sub CheckArchive {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  my $good = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  foreach my $thisMrpData (@{$self->{mrpData}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
    if (!$self->CheckDirs($thisMrpData)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
      $good = 0; # Continue and check the rest
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
  return $good;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
sub GenerateReleaseFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
  my $versionInfo = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  my $numMrps = scalar(@{$self->{mrpData}});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  foreach my $thisMrpData (@{$self->{mrpData}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
    $self->MakeDirs($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
    $self->ZipSource($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
    $self->ZipBinaries($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
    $self->ZipExports($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
    $self->WriteRelData($thisMrpData, $versionInfo);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
    $self->WriteManifest($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
    # This line must come after the others, because with a project-based archive path configuration it relies on
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
    # LocalArchivePathForNewOrExistingComponent finding the directories created above.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
    my $comp = $thisMrpData->Component();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
    my $extVer = $thisMrpData->ExternalVersion();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
    my $intVer = $thisMrpData->InternalVersion();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
    unless (defined $intVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
      $intVer = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    my $relDir = $self->LocalArchivePath($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
    Utils::SetFileReadOnly($relDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
    print "Made $comp $extVer $intVer\n";
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
sub ComponentDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
  require Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
  confess("Obsolete method called");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
sub ReleaseDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
  require Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
  confess("Obsolete method called");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
sub CheckDirs {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  my $relDir = $self->LocalArchivePath($mrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  if (-e $relDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
    print STDERR "Error: $relDir already exists\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
    return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
  return 1;
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
sub MakeDirs {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
  my $relDir = $self->LocalArchivePath($mrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
  unless (-e $relDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
    Utils::MakeDir($relDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
sub ZipSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
  my @categories = @{$mrpData->SourceCategories()};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
  my $zipName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
  foreach my $category (@categories) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
    my @sourceFiles = @{$mrpData->Source($category)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
    if (@sourceFiles) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
      $zipName = $self->LocalArchivePath($mrpData) . "\\source".uc($category).".zip";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
      Utils::ZipSourceList($zipName, \@sourceFiles, $self->{verbose}, Utils::SourceRoot(), $self->{iniData});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
      Utils::SetFileReadOnly($zipName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
  if ($self->{verbose} > 1 and not defined $zipName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
    print "No source for " . $mrpData->Component() . "\n";
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
sub ZipBinaries {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
  foreach my $thisBinCat (@{$mrpData->BinaryCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
    my $bins = $mrpData->Binaries($thisBinCat);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
    if ($bins and scalar(@$bins) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
      my $zipName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
      if ($thisBinCat eq 'unclassified') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
        $zipName = $self->LocalArchivePath($mrpData) . "\\binaries.zip";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
        $zipName = $self->LocalArchivePath($mrpData) . "\\binaries_$thisBinCat.zip";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
      Utils::ZipList($zipName, $bins, $self->{verbose}, 0, Utils::EpocRoot());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
      Utils::SetFileReadOnly($zipName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
sub ZipExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
  foreach my $thisExportCat (@{$mrpData->ExportCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
    my $exports = $mrpData->Exports($thisExportCat);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
    if ($exports and scalar(@$exports) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
      my $zipName = $self->LocalArchivePath($mrpData) . "\\exports".uc($thisExportCat).".zip";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
      Utils::ZipList($zipName, $exports, $self->{verbose}, 0, Utils::EpocRoot());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
      Utils::SetFileReadOnly($zipName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
      # Need to create an exports<CAT>.txt file which details necessary info...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
      my $txtName = $self->LocalArchivePath($mrpData) . "\\exports".uc($thisExportCat).".txt";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
      CatData->New($self->{iniData}, $txtName, $mrpData, uc($thisExportCat));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
sub WriteRelData {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
  my $versionInfo = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
  my $notesSource = $self->{notesSrc};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
  if (defined $notesSource) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
    Utils::CheckExists($notesSource);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
    Utils::CheckIsFile($notesSource);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
    $notesSource = Utils::PrependSourceRoot($mrpData->NotesSource());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
  my $relData = RelData->New($self->{iniData}, $mrpData, $notesSource, $versionInfo, $self->{toolName}, $self->{verbose}, undef, $self->{project}); # undef = dontPersist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
sub WriteManifest {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
  my $componentName = $mrpData->Component();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
  my $manifest = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
  if ($self->{useCachedManifest}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
    #Check if manifest file is available in temp location
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
    my $manifestTempFile = File::Spec->catfile( File::Spec->tmpdir(), "manifest_".$componentName.".xml" );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
    if (-e $manifestTempFile ) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
      #Construct manifest object from the manifest file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
      $manifest = Symbian::CBR::Component::Manifest->new( $manifestTempFile );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
      #Delete the temp manifest file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
      my $unlinkCount = 100;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
      while(-e $manifestTempFile and $unlinkCount > 0){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
        unlink($manifestTempFile) or print "Warning: unlink $manifestTempFile failed[$unlinkCount].\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
        $unlinkCount--;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
      if ( $unlinkCount == 0 ) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
        die "Error: unlink $manifestTempFile failed.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
      }
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
  if (!defined $manifest) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
    my $mrpName = Utils::RelativeToAbsolutePath( $mrpData->MrpName(), $mrpData->{iniData}, SOURCE_RELATIVE );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
    #Construct manifest object from MRP file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
    $manifest = Symbian::CBR::Component::Manifest->new( $mrpName );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
  #Save the manifest file to the archive release location for the component
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
  $manifest->Save ( $self->LocalArchivePath($mrpData) );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
sub Cleanup {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
  if ($self->{verbose}) { print "Cleaning up...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
  foreach my $thisMrpData (@{$self->{mrpData}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
    my $relDir = $self->LocalArchivePath($thisMrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
    if (-e $relDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
      if ($self->{verbose}) { print "Deleting $relDir...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
      my $origDir = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
      chdir(dirname($relDir)); #If you try to rmtree a UNC path the cwd must also be a UNC path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
      rmtree ($relDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
      chdir($origDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
  }
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
sub LocalArchivePath {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
  my $name = $mrpData->Component();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
  my $ver = $mrpData->ExternalVersion();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
  if (not exists $self->{pathCache}->{$name}->{$ver}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
    $self->{pathCache}->{$name}->{$ver} = $self->{iniData}->PathData->LocalArchivePathForExistingOrNewComponent($name, $ver, $self->{project});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
  return $self->{pathCache}->{$name}->{$ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
MakeRel.pm - Provides an interface for making releases.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
=head2 MakeReleases
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
Expects to be passed an C<IniData> reference, an C<EnvDb> reference, a reference to a list of C<MrpData> objects, the name of a notes source file, the name of the tool using C<MakeRel> and a verbosity level. Firstly, the binary files referred to by the C<MrpData> objects are cross checked to ensure that more than one component isn't attempting to release the same file. Dies if this is the case. Secondly, generates release directories and files for each C<MrpData> object. Thirdly, updates local signature files and the environment database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
=cut