releasing/cbrtools/perl/CopyRel.pm
author Zheng Shen <zheng.shen@nokia.com>
Tue, 20 Jul 2010 15:02:28 +0800
changeset 617 3a747a240983
parent 602 3145852acc89
permissions -rw-r--r--
ROM Tools 12.2.0.4 Postlinker 2.2.5 Revert package_definition.xml to changeset 360bd6b35136
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) 2004-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
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
# CopyRelease - contains fuctions to copy a release in an archive
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
package CopyRel;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use PushPullRel;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
BEGIN {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
  @CopyRel::ISA=('PushPullRel');
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
sub new {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
  my $class = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
  my $inidata = shift; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
  my $force = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
  my $verbose = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
  my $project = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
  my $self = bless {}, (ref $class || $class);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
  $self->{iniData} = $inidata;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
  $self->{force} = $force;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  $self->{verbose} = $verbose;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
  $self->{project} = $project;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  $self->{errors} = [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
  return $self;
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
sub CopyRelease {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  my $component = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
  my $versionToCopy = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  my $version = shift; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  my $internalVersion = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  my $releaseDir = $self->ObtainReleaseDir($component, $versionToCopy);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  my $releaseCopyDir;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  # Obtain the release copy directory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  if(defined $self->{project}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
    $releaseCopyDir = $self->{iniData}->PathData->LocalArchivePathForNewComponent($component, $version, $self->{project});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
    $releaseCopyDir = $releaseDir; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
    $releaseCopyDir =~ s/$versionToCopy$/$version/; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
  eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
    # Preform the copying of files
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    $self->PerformCopying($component, $versionToCopy, $releaseCopyDir, $releaseDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
    if($versionToCopy !~ /^$version$/i || $versionToCopy !~ /^$internalVersion$/i){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
      # Update the reldata so that the release number is correct...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
      $self->UpdateRelData($component, $version, $internalVersion);
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
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    print "$@";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
    $self->_AddError($@);
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
sub UpdateRelData {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  my $component = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  my $version = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  my $internalVersion = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
  my $reldata;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  if (!($reldata = RelData->Open($self->{iniData}, $component, $version, 0))) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    die "ERROR: Couldn't open version '$version' of '$component'";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  $reldata->UpdateProject($self->{project});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  $reldata->UpdateInternalVersion("$internalVersion");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  my $env = $reldata->Environment;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
  foreach my $thisComp (sort keys %{$env}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
    if($thisComp =~ /$component/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
      $env->{$thisComp} = $version;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
  $reldata->UpdateEnv($env);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
sub ObtainReleaseDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  my $component = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
  my $version = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  my $releaseDir;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  if (!($releaseDir = $self->{iniData}->PathData->LocalArchivePathForExistingComponent($component, $version))) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
    die "ERROR: Couldn't locate component '$component' at version '$version'";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  return $releaseDir;
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
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
CopyRel.pm - Class for copying a release version.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
Provides an API to create a new release version which is a copy of an another release. This class extends the methods provide by PushPullRel.pm to enable the copying of a release version.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
=head2 New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
Creates a new object of this class. Takes four parameters. 1) An IniData object corresponding
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
to your local repository. 2) Force (overwrites). 3) Verbose.  4) Project name to uses, which is associated to archive paths as set the reltools.ini.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
=head2 CopyRelease
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
Takes component name, verson to copy, new version and new internal version. Is used to initiate the copying of a release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
=head2 UpdateRelData
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
Takes component name, version and internal version. Is used to update the reldata of a newly copied release so that the release version information is correct in the reldata file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
=head2 ObtainReleaseDir
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
Takes component name and version. Is used to get the release dir using the component name and version as input.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
 Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
=cut
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179