|
1 #!perl |
|
2 # Copyright (c) 2004-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 # Description: |
|
18 # CopyRelease - contains fuctions to copy a release in an archive |
|
19 # |
|
20 |
|
21 package CopyRel; |
|
22 |
|
23 use strict; |
|
24 use RelData; |
|
25 use PushPullRel; |
|
26 |
|
27 BEGIN { |
|
28 @CopyRel::ISA=('PushPullRel'); |
|
29 }; |
|
30 |
|
31 sub new { |
|
32 my $class = shift; |
|
33 my $inidata = shift; |
|
34 my $force = shift; |
|
35 my $verbose = shift; |
|
36 my $project = shift; |
|
37 |
|
38 my $self = bless {}, (ref $class || $class); |
|
39 |
|
40 $self->{iniData} = $inidata; |
|
41 $self->{force} = $force; |
|
42 $self->{verbose} = $verbose; |
|
43 $self->{project} = $project; |
|
44 $self->{errors} = []; |
|
45 |
|
46 return $self; |
|
47 } |
|
48 |
|
49 sub CopyRelease { |
|
50 my $self = shift; |
|
51 my $component = shift; |
|
52 my $versionToCopy = shift; |
|
53 my $version = shift; |
|
54 my $internalVersion = shift; |
|
55 |
|
56 my $releaseDir = $self->ObtainReleaseDir($component, $versionToCopy); |
|
57 my $releaseCopyDir; |
|
58 |
|
59 # Obtain the release copy directory |
|
60 if(defined $self->{project}){ |
|
61 $releaseCopyDir = $self->{iniData}->PathData->LocalArchivePathForNewComponent($component, $version, $self->{project}); |
|
62 } |
|
63 else{ |
|
64 $releaseCopyDir = $releaseDir; |
|
65 $releaseCopyDir =~ s/$versionToCopy$/$version/; |
|
66 } |
|
67 |
|
68 eval { |
|
69 |
|
70 # Preform the copying of files |
|
71 $self->PerformCopying($component, $versionToCopy, $releaseCopyDir, $releaseDir); |
|
72 |
|
73 if($versionToCopy !~ /^$version$/i || $versionToCopy !~ /^$internalVersion$/i){ |
|
74 # Update the reldata so that the release number is correct... |
|
75 $self->UpdateRelData($component, $version, $internalVersion); |
|
76 } |
|
77 }; |
|
78 |
|
79 if ($@) { |
|
80 print "$@"; |
|
81 $self->_AddError($@); |
|
82 } |
|
83 } |
|
84 |
|
85 sub UpdateRelData { |
|
86 my $self = shift; |
|
87 my $component = shift; |
|
88 my $version = shift; |
|
89 my $internalVersion = shift; |
|
90 |
|
91 my $reldata; |
|
92 |
|
93 if (!($reldata = RelData->Open($self->{iniData}, $component, $version, 0))) { |
|
94 die "ERROR: Couldn't open version '$version' of '$component'"; |
|
95 } |
|
96 |
|
97 $reldata->UpdateProject($self->{project}); |
|
98 $reldata->UpdateInternalVersion("$internalVersion"); |
|
99 |
|
100 my $env = $reldata->Environment; |
|
101 |
|
102 foreach my $thisComp (sort keys %{$env}) { |
|
103 |
|
104 if($thisComp =~ /$component/i) { |
|
105 $env->{$thisComp} = $version; |
|
106 } |
|
107 } |
|
108 |
|
109 $reldata->UpdateEnv($env); |
|
110 } |
|
111 |
|
112 sub ObtainReleaseDir { |
|
113 my $self = shift; |
|
114 my $component = shift; |
|
115 my $version = shift; |
|
116 |
|
117 my $releaseDir; |
|
118 |
|
119 if (!($releaseDir = $self->{iniData}->PathData->LocalArchivePathForExistingComponent($component, $version))) { |
|
120 die "ERROR: Couldn't locate component '$component' at version '$version'"; |
|
121 } |
|
122 |
|
123 return $releaseDir; |
|
124 } |
|
125 |
|
126 1; |
|
127 |
|
128 __END__ |
|
129 |
|
130 =head1 NAME |
|
131 |
|
132 CopyRel.pm - Class for copying a release version. |
|
133 |
|
134 =head1 DESCRIPTION |
|
135 |
|
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. |
|
137 |
|
138 =head1 INTERFACE |
|
139 |
|
140 =head2 New |
|
141 |
|
142 Creates a new object of this class. Takes four parameters. 1) An IniData object corresponding |
|
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. |
|
144 |
|
145 =head2 CopyRelease |
|
146 |
|
147 Takes component name, verson to copy, new version and new internal version. Is used to initiate the copying of a release. |
|
148 |
|
149 =head2 UpdateRelData |
|
150 |
|
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. |
|
152 |
|
153 =head2 ObtainReleaseDir |
|
154 |
|
155 Takes component name and version. Is used to get the release dir using the component name and version as input. |
|
156 |
|
157 =head1 KNOWN BUGS |
|
158 |
|
159 None. |
|
160 |
|
161 =head1 COPYRIGHT |
|
162 |
|
163 Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
164 All rights reserved. |
|
165 This component and the accompanying materials are made available |
|
166 under the terms of the License "Eclipse Public License v1.0" |
|
167 which accompanies this distribution, and is available |
|
168 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
169 |
|
170 Initial Contributors: |
|
171 Nokia Corporation - initial contribution. |
|
172 |
|
173 Contributors: |
|
174 |
|
175 Description: |
|
176 |
|
177 |
|
178 =cut |
|
179 |