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 IniData;
|
|
23 |
use EnvDb;
|
|
24 |
use CommandController;
|
|
25 |
use Utils;
|
|
26 |
|
|
27 |
#
|
|
28 |
# Constants.
|
|
29 |
#
|
|
30 |
|
|
31 |
my $KMissingFileName = Utils::PrependEpocRoot("\\__missing.txt");
|
|
32 |
my $KCompsFileName = Utils::PrependEpocRoot("\\__comps.txt");
|
|
33 |
|
|
34 |
|
|
35 |
#
|
|
36 |
# Globals.
|
|
37 |
#
|
|
38 |
|
|
39 |
my $verbose = 0;
|
|
40 |
my $noIgnores = 0;
|
|
41 |
my $fileName;
|
|
42 |
my $iniData = IniData->New();
|
|
43 |
my $commandController = CommandController->New($iniData, 'MakeSnapShot');
|
|
44 |
my $force;
|
|
45 |
|
|
46 |
#
|
|
47 |
# Main.
|
|
48 |
#
|
|
49 |
|
|
50 |
ProcessCommandLine();
|
|
51 |
MakeSnapShot();
|
|
52 |
|
|
53 |
|
|
54 |
#
|
|
55 |
# Subs.
|
|
56 |
#
|
|
57 |
|
|
58 |
sub ProcessCommandLine {
|
|
59 |
Getopt::Long::Configure ('bundling');
|
|
60 |
my $help;
|
|
61 |
GetOptions('h' => \$help, 'i' => \$noIgnores, 'v+' => \$verbose, 'f' => \$force);
|
|
62 |
|
|
63 |
if ($help) {
|
|
64 |
Usage(0);
|
|
65 |
}
|
|
66 |
|
|
67 |
$fileName = shift @ARGV;
|
|
68 |
|
|
69 |
unless ($fileName and scalar(@ARGV) == 0) {
|
|
70 |
print "Error: Invalid number of arguments\n";
|
|
71 |
Usage(1);
|
|
72 |
}
|
|
73 |
|
|
74 |
unless ($fileName =~ /\.zip$/i) {
|
|
75 |
$fileName .= '.zip';
|
|
76 |
}
|
|
77 |
Utils::AbsoluteFileName(\$fileName);
|
|
78 |
}
|
|
79 |
|
|
80 |
sub Usage {
|
|
81 |
my $exitCode = shift;
|
|
82 |
|
|
83 |
Utils::PrintDeathMessage($exitCode, "\nUsage: makesnapshot [options] <snap_shot_file_name>
|
|
84 |
|
|
85 |
options:
|
|
86 |
|
|
87 |
-h help
|
|
88 |
-i include files that are normally ignored (e.g. \\epoc32\\build\\...)
|
|
89 |
-f (deprecated)
|
|
90 |
-v verbose output (-vv very verbose)\n");
|
|
91 |
}
|
|
92 |
|
|
93 |
sub MakeSnapShot {
|
|
94 |
if (-e $fileName) {
|
|
95 |
die "Error: \"$fileName\" already exists\n";
|
|
96 |
}
|
|
97 |
my $envDb = EnvDb->Open($iniData, $verbose);
|
|
98 |
my $compsPendingRelease = $envDb->ComponentsPendingRelease();
|
|
99 |
if (scalar (keys %$compsPendingRelease) > 0) {
|
|
100 |
die "Error: Can't make a snap shot of an environment contains components that are pending release\n";
|
|
101 |
}
|
|
102 |
(my $overallStatus, undef, my $dirtyComps, my $unaccountedFiles, my $duplicates) = $envDb->CheckEnv(1, $noIgnores);
|
|
103 |
if ($overallStatus == EnvDb::STATUS_CLEAN) {
|
|
104 |
print "Environment clean, aborting snap shot creation\n";
|
|
105 |
return;
|
|
106 |
}
|
|
107 |
if (scalar (@$duplicates) > 0) {
|
|
108 |
die "Error: Unexpected duplicates\n";
|
|
109 |
}
|
|
110 |
my @dirtyFiles;
|
|
111 |
foreach my $thisUnaccountedFile (@$unaccountedFiles) {
|
|
112 |
push (@dirtyFiles, Utils::RemoveEpocRoot($thisUnaccountedFile));
|
|
113 |
}
|
|
114 |
my @missingFiles;
|
|
115 |
foreach my $thisComp (@$dirtyComps) {
|
|
116 |
my $binaryList = $envDb->ListBins($thisComp->{comp});
|
|
117 |
shift @$binaryList; # Throw away list header;
|
|
118 |
foreach my $thisFile (@$binaryList) {
|
|
119 |
if ($thisFile->[1] eq EnvDb::STATUS_STRING_FAILED) {
|
|
120 |
push (@dirtyFiles, Utils::RemoveEpocRoot($thisFile->[0]));
|
|
121 |
}
|
|
122 |
elsif ($thisFile->[1] eq EnvDb::STATUS_STRING_MISSING) {
|
|
123 |
push (@missingFiles, Utils::RemoveEpocRoot($thisFile->[0]));
|
|
124 |
}
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
open (MISSING, ">$KMissingFileName") or die "Error: Couldn't open \"$KMissingFileName\" for writing\n";
|
|
129 |
foreach my $thisFile (@missingFiles) {
|
|
130 |
print MISSING "$thisFile\n";
|
|
131 |
}
|
|
132 |
close (MISSING);
|
|
133 |
push (@dirtyFiles, Utils::RemoveEpocRoot($KMissingFileName));
|
|
134 |
|
|
135 |
my $versionInfo = $envDb->VersionInfo();
|
|
136 |
open (COMPS, ">$KCompsFileName") or die "Error: Couldn't open \"$KCompsFileName\" for writing\n";
|
|
137 |
foreach my $thisComp (sort keys %$versionInfo) {
|
|
138 |
print COMPS "$thisComp $versionInfo->{$thisComp}\n";
|
|
139 |
}
|
|
140 |
close (COMPS);
|
|
141 |
push (@dirtyFiles, Utils::RemoveEpocRoot($KCompsFileName));
|
|
142 |
|
|
143 |
Utils::ZipList($fileName, \@dirtyFiles, $verbose, 0, Utils::EpocRoot());
|
|
144 |
Utils::SetFileReadOnly($fileName);
|
|
145 |
|
|
146 |
unlink ($KMissingFileName) or die "Error: Couldn't delete \"$KMissingFileName\": $!\n";
|
|
147 |
unlink ($KCompsFileName) or die "Error: Couldn't delete \"$KMissingFileName\": $!\n";
|
|
148 |
|
|
149 |
print "Snapshot \"$fileName\" successfully made\n";
|
|
150 |
}
|
|
151 |
|
|
152 |
__END__
|
|
153 |
|
|
154 |
=head1 NAME
|
|
155 |
|
|
156 |
MakeSnapShot - Captures all dirty files in an environment into a user specified zip file that can be used to reproduce the environment.
|
|
157 |
|
|
158 |
=head1 SYNOPSIS
|
|
159 |
|
|
160 |
makesnapshot [options] <snap_shot_file_name>
|
|
161 |
|
|
162 |
options:
|
|
163 |
|
|
164 |
-h help
|
|
165 |
-i include files that are normally ignored (e.g. \epoc32\build\...)
|
|
166 |
-v verbose output (-vv very verbose)
|
|
167 |
|
|
168 |
=head1 DESCRIPTION
|
|
169 |
|
|
170 |
The release tools exist to make it relatively straight forward to share binary files in a controlled way. In order to acheive a suitable level of control, a fair amount of rigor is imposed on users when they are making releases. There are times when this is inappropriate. For example, if a user wants to temporarily capture the current state of their environment. The commands C<MakeSnapShot> and C<InstallSnapShot> exist to make it easy to accurately capture the current state of an environment, and subsequently revert to it, without the overhead of doing a full environment release. Snap shots should only be used in preference to full environment releases when there is a B<temporary> need to capture an environment, because:
|
|
171 |
|
|
172 |
=over 4
|
|
173 |
|
|
174 |
=item 1
|
|
175 |
|
|
176 |
No mechansims are provided for exporting or importing snap shots.
|
|
177 |
|
|
178 |
=item 2
|
|
179 |
|
|
180 |
No release notes are provided with snap shots.
|
|
181 |
|
|
182 |
=item 3
|
|
183 |
|
|
184 |
The contents of snap shots are inherently dirty - they consist of all the files that could not be accounted for with proper releases. Reliance on snap shots as a means of distributing software would therefore eventually become a self defeating activity since the snap shot files would get larger and larger over time.
|
|
185 |
|
|
186 |
=back
|
|
187 |
|
|
188 |
C<MakeSnapShot> generates a zip file that contains all the dirty files currently present in the environment. It makes no attempt to understand which component own which files. It also stores some metadata in the zip file; a list of the component versions currently installed, and a list of files that are currently missing from the environment. This can subsequently be used by C<InstallSnapShot> to revert to the snap shot state.
|
|
189 |
|
|
190 |
=head1 STATUS
|
|
191 |
|
|
192 |
Supported. If you find a problem, please report it to us.
|
|
193 |
|
|
194 |
=head1 KNOWN BUGS
|
|
195 |
|
|
196 |
None.
|
|
197 |
|
|
198 |
=head1 COPYRIGHT
|
|
199 |
|
|
200 |
Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
201 |
All rights reserved.
|
|
202 |
This component and the accompanying materials are made available
|
|
203 |
under the terms of the License "Eclipse Public License v1.0"
|
|
204 |
which accompanies this distribution, and is available
|
|
205 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
206 |
|
|
207 |
Initial Contributors:
|
|
208 |
Nokia Corporation - initial contribution.
|
|
209 |
|
|
210 |
Contributors:
|
|
211 |
|
|
212 |
Description:
|
|
213 |
|
|
214 |
|
|
215 |
=cut
|