602
|
1 |
#!perl
|
|
2 |
# Copyright (c) 2000-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 |
|
|
18 |
use strict;
|
|
19 |
use FindBin;
|
|
20 |
use lib "$FindBin::Bin";
|
|
21 |
use Getopt::Long;
|
|
22 |
use File::Path;
|
|
23 |
use IniData;
|
|
24 |
use RelData;
|
|
25 |
use RelTransfer::Export;
|
|
26 |
use CommandController;
|
|
27 |
|
|
28 |
|
|
29 |
#
|
|
30 |
# Globals.
|
|
31 |
#
|
|
32 |
|
|
33 |
my $verbose = 0;
|
|
34 |
my $dummy = 0;
|
|
35 |
my $force = 0;
|
|
36 |
my $ftpResume = 0;
|
|
37 |
my $iniData;
|
|
38 |
my $commandController;
|
|
39 |
my $envcomp;
|
|
40 |
my $envver;
|
|
41 |
my $examining;
|
|
42 |
my $excludeSource = 0;
|
|
43 |
my %failedExports;
|
|
44 |
my %goodExports;
|
|
45 |
my %alreadyExported;
|
|
46 |
|
|
47 |
#
|
|
48 |
# Main
|
|
49 |
#
|
|
50 |
|
|
51 |
ProcessCommandLine();
|
|
52 |
ExportEnvironment();
|
|
53 |
PrintReport();
|
|
54 |
|
|
55 |
#
|
|
56 |
# Subs.
|
|
57 |
#
|
|
58 |
|
|
59 |
sub ProcessCommandLine {
|
|
60 |
Getopt::Long::Configure ("bundling");
|
|
61 |
my $help;
|
|
62 |
GetOptions("h" => \$help, "v+" => \$verbose, "f" => \$force, "r" => \$ftpResume, "x" => \$examining, "d" => \$dummy, "e" => \$excludeSource);
|
|
63 |
|
|
64 |
if ($help) {
|
|
65 |
Usage(0);
|
|
66 |
}
|
|
67 |
|
|
68 |
$envcomp = lc($ARGV[0]);
|
|
69 |
$envver = $ARGV[1];
|
|
70 |
|
|
71 |
unless (defined $envcomp and defined $envver and $#ARGV = -1) {
|
|
72 |
print "Error: Invalid arguments\n";
|
|
73 |
Usage(1);
|
|
74 |
}
|
|
75 |
$iniData = IniData->New(undef,1);
|
|
76 |
$commandController = CommandController->New($iniData, 'ExportEnv');
|
|
77 |
#if ftp resume option is used override value in reltools.ini
|
|
78 |
if ($ftpResume) {
|
|
79 |
$iniData->FtpServerSupportsResume(1);
|
|
80 |
}
|
|
81 |
}
|
|
82 |
|
|
83 |
sub Usage {
|
|
84 |
my $exitCode = shift;
|
|
85 |
|
|
86 |
Utils::PrintDeathMessage($exitCode, "\nUsage: exportenv [options] <component> <external_version>
|
|
87 |
|
|
88 |
options:
|
|
89 |
|
|
90 |
-h help
|
|
91 |
-f force export overwriting if necessary
|
|
92 |
-r use FTP reconnect and resume transfer mode
|
|
93 |
-x confirm correct size of files on remote site rather than exporting them
|
|
94 |
-d dummy run (don't do anything) - assumes -v
|
|
95 |
-e exclude source
|
|
96 |
-v verbose output (-vv very verbose)\n");
|
|
97 |
}
|
|
98 |
|
|
99 |
sub ExportEnvironment {
|
|
100 |
my $relData = RelData->Open($iniData, $envcomp, $envver, $verbose);
|
|
101 |
my $env = $relData->Environment();
|
|
102 |
|
|
103 |
my $exporter = RelTransfer::Export->New(ini_data => $iniData,
|
|
104 |
force => $force,
|
|
105 |
dummy => $dummy,
|
|
106 |
excludeSource => $excludeSource,
|
|
107 |
verbose => $verbose);
|
|
108 |
|
|
109 |
unless ($examining) {
|
|
110 |
foreach my $comp (sort keys %{$env}) {
|
|
111 |
my $ver = $env->{$comp};
|
|
112 |
$exporter->CheckExportable($comp, $ver);
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
|
116 |
#do the export checking for errors
|
|
117 |
foreach my $comp (sort keys %{$env}) {
|
|
118 |
my $exported;
|
|
119 |
my $ver = $env->{$comp};
|
|
120 |
eval {
|
|
121 |
if ($examining) {
|
|
122 |
$exporter->ExamineExportedRelease($comp, $ver);
|
|
123 |
} else {
|
|
124 |
$exported = $exporter->TransferRelease($comp, $ver);
|
|
125 |
}
|
|
126 |
};
|
|
127 |
if ($@) {
|
|
128 |
print $@;
|
|
129 |
if ($@ =~ /cannot\s+connect/i) {
|
|
130 |
print "\nAborting export of $envcomp $envver environment\n";
|
|
131 |
last;
|
|
132 |
}
|
|
133 |
my $error = $@;
|
|
134 |
chomp $error;
|
|
135 |
$error =~ s/^error: ("?$comp $ver"? )?//i;
|
|
136 |
$failedExports{$comp}->{$ver} = $error;
|
|
137 |
} else {
|
|
138 |
if ($examining || $exported) {
|
|
139 |
push @{$goodExports{$comp}}, $ver;
|
|
140 |
} else {
|
|
141 |
push @{$alreadyExported{$comp}}, $ver;
|
|
142 |
}
|
|
143 |
}
|
|
144 |
}
|
|
145 |
}
|
|
146 |
|
|
147 |
sub PrintReport {
|
|
148 |
print "\n=========EXPORT SUMMARY==========\n";
|
|
149 |
|
|
150 |
my $tableData = [["Component", "Version", "status"]];
|
|
151 |
|
|
152 |
foreach my $comp (sort keys %goodExports) {
|
|
153 |
foreach my $ver (@{$goodExports{$comp}}) {
|
|
154 |
push (@$tableData, [$comp, $ver, 'successfully exported']);
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
foreach my $comp (sort keys %alreadyExported) {
|
|
159 |
foreach my $ver (@{$alreadyExported{$comp}}) {
|
|
160 |
push (@$tableData, [$comp, $ver, 'has already been exported']);
|
|
161 |
}
|
|
162 |
}
|
|
163 |
|
|
164 |
if (scalar @{$tableData} > 1) {
|
|
165 |
$iniData->TableFormatter->PrintTable($tableData, 1);
|
|
166 |
}
|
|
167 |
|
|
168 |
#handle failed exports
|
|
169 |
if (keys %failedExports) {
|
|
170 |
print "\n=========FAILED EXPORTS==========\n";
|
|
171 |
print "\nExport Failure Summary\n\n";
|
|
172 |
my $failureTableData = [["Component", "Version", "Failure reason"]];
|
|
173 |
foreach my $comp (sort keys %failedExports) {
|
|
174 |
foreach my $ver (sort keys %{$failedExports{$comp}}) {
|
|
175 |
push (@$failureTableData, [$comp, $ver, $failedExports{$comp}->{$ver}]);
|
|
176 |
}
|
|
177 |
}
|
|
178 |
$iniData->TableFormatter->PrintTable($failureTableData, 1);
|
|
179 |
print "\nError: Unable to export component release successfully\n";
|
|
180 |
}
|
|
181 |
else
|
|
182 |
{
|
|
183 |
if (keys %goodExports) {
|
|
184 |
print "\nEnvironment $envcomp $envver successfully exported\n";
|
|
185 |
} else {
|
|
186 |
print "\nNothing to do!\n";
|
|
187 |
}
|
|
188 |
}
|
|
189 |
}
|
|
190 |
|
|
191 |
__END__
|
|
192 |
|
|
193 |
=head1 NAME
|
|
194 |
|
|
195 |
ExportEnv - Exports the environment from which a component release was made.
|
|
196 |
|
|
197 |
=head1 SYNOPSIS
|
|
198 |
|
|
199 |
exportenv [options] <component> <version>
|
|
200 |
|
|
201 |
options:
|
|
202 |
|
|
203 |
-h help
|
|
204 |
-f force export overwriting if necessary
|
|
205 |
-r use FTP reconnect and resume transfer mode
|
|
206 |
-v verbose output (-vv very verbose)
|
|
207 |
-d dummy run (don't do anything) - assumes -v
|
|
208 |
-e exclude source
|
|
209 |
-x examine: confirm correct sizes of files on remote site rather than exporting them
|
|
210 |
|
|
211 |
=head1 DESCRIPTION
|
|
212 |
|
|
213 |
When a release is made, a description of the environment it was made from is stored with it.
|
|
214 |
C<ExportEnv> takes a component name and version number, reads the environment data for this
|
|
215 |
component and builds a list of component names and version numbers. It then encrypts these releases before sending them to the projects shared archive on a remote site.
|
|
216 |
|
|
217 |
Using the C<-f> option will force releases to be exported even if they already exist on the remote site (this only applies to components existing in the users export table)
|
|
218 |
|
|
219 |
If the C<-r> option is used and the FTP connection is dropped during the upload of a release, the tools will automatically reconnect to the FTP site and resume the upload. This feature may not be supported by some FTP servers.
|
|
220 |
|
|
221 |
Using C<-e> option will create a release without source.
|
|
222 |
|
|
223 |
=head1 KNOWN BUGS
|
|
224 |
|
|
225 |
None
|
|
226 |
|
|
227 |
=head1 COPYRIGHT
|
|
228 |
|
|
229 |
Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
230 |
All rights reserved.
|
|
231 |
This component and the accompanying materials are made available
|
|
232 |
under the terms of the License "Eclipse Public License v1.0"
|
|
233 |
which accompanies this distribution, and is available
|
|
234 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
235 |
|
|
236 |
Initial Contributors:
|
|
237 |
Nokia Corporation - initial contribution.
|
|
238 |
|
|
239 |
Contributors:
|
|
240 |
|
|
241 |
Description:
|
|
242 |
|
|
243 |
|
|
244 |
=cut
|