15 #Contributors: |
15 #Contributors: |
16 # |
16 # |
17 #Description: Cleaned version. |
17 #Description: Cleaned version. |
18 #============================================================================ |
18 #============================================================================ |
19 |
19 |
20 use strict; # strict naming rules |
20 use strict; # strict naming rules |
21 use Cwd; # figuring out directories |
21 use Cwd; # figuring out directories |
22 use Data::Dumper; # debugging purposes |
22 use Data::Dumper; # debugging purposes |
23 use XML::Simple; # for using xml parser |
23 use XML::Simple; # for using xml parser |
24 use File::Copy; # for copying files |
24 use File::Copy; # for copying files |
25 use SOAP::Lite; # SOAP interface for s60build server |
25 use Getopt::Long; # parameter handling |
26 use Getopt::Long; # parameter handling |
|
27 Getopt::Long::Configure( "bundling_override","ignore_case_always" ); |
26 Getopt::Long::Configure( "bundling_override","ignore_case_always" ); |
28 # uncomment to get SOAP debug traces |
27 use File::Temp qw/ tempdir /; # for creating unique temp directories |
29 # use SOAP::Lite +trace => 'debug'; |
28 |
|
29 # uncomment to get temp dir debug traces |
|
30 $File::Temp::DEBUG = 1; |
30 |
31 |
31 # variables for commandline params |
32 # variables for commandline params |
32 my( $param_help, # print help |
33 my( $param_help, # print help |
33 $param_server, # manually select server |
34 $param_server, # manually select server |
34 $param_release_path, # where are the releases located in the server |
35 $param_release_path, # where are the releases located in the server |
35 $param_debug, # parameter for controlling extra debug prints |
36 $param_debug, # parameter for controlling extra debug prints |
36 $param_latest, # just grab the latest build (requires product name) |
37 $param_latest, # just grab the latest build (requires product name) |
37 $param_keepgoing, # continue even if dependency is missing |
38 $param_keepgoing, # continue even if dependency is missing |
38 $param_print_only, # do nothing but print system calls |
39 $param_print_only, # do nothing but print system calls |
39 $param_skipITD, # do not extract internal, testsources and documentation |
40 $param_skipITD, # do not extract internal, testsources and documentation |
40 $param_emuenv, # extract only emulator environment |
41 $param_emuenv, # extract only emulator environment |
41 $param_start_directly,# starts extracting directly without waiting user acceptance |
42 $param_start_directly,# starts extracting directly without waiting user acceptance |
42 $param_product, # manually insert product name |
43 $param_product, # manually insert product name |
43 $param_skip_deps, # do not extract dependencies |
44 $param_skip_deps, # do not extract dependencies |
44 $param_grace, # do not check for grace access |
45 $param_grace, # do not check for grace access |
45 $param_no_soap, # dont use soap connection |
46 @param_exclude, # exclude list |
46 @param_exclude, # exclude list |
47 @param_include, # include list |
47 @param_include ); # include list |
48 @force_include, # force include list |
|
49 $param_all ); # extract all zips |
48 |
50 |
49 # read commandline parameters |
51 # read commandline parameters |
50 my $result = GetOptions('help' => \$param_help, # print help |
52 my $result = GetOptions('help' => \$param_help, # print help |
51 'h' => \$param_help, # print help |
53 'h' => \$param_help, # print help |
52 'latest' => \$param_latest, # just grab the latest build (requires product name) |
54 'latest' => \$param_latest, # just grab the latest build (requires product name) |
53 'server=s' => \$param_server, # manually select server |
55 'server=s' => \$param_server, # manually select server |
54 'path=s' => \$param_release_path, # extract this release directly |
56 'path=s' => \$param_release_path, # extract this release directly |
55 'verbose' => \$param_debug, # verbose debug print |
57 'verbose' => \$param_debug, # verbose debug print |
56 'k' => \$param_keepgoing, # continue even if there is any problems |
58 'k' => \$param_keepgoing, # continue even if there is any problems |
57 'p' => \$param_print_only, # do nothing but print system calls |
59 'p' => \$param_print_only, # do nothing but print system calls |
58 'skipitd' => \$param_skipITD, # Deprecated: do not extract internal, testsources and documentation |
60 'skipitd' => \$param_skipITD, # Deprecated: do not extract internal, testsources and documentation |
59 'emu' => \$param_emuenv, # Deprecated: extract only emulator environment |
61 'emu' => \$param_emuenv, # Deprecated: extract only emulator environment |
60 'start' => \$param_start_directly, # starts extracting directly without waiting user acceptance |
62 'start' => \$param_start_directly, # starts extracting directly without waiting user acceptance |
61 'product=s' => \$param_product, # manually insert product name |
63 'product=s' => \$param_product, # manually insert product name |
62 'x=s' => \@param_exclude, # filer list for excluding zips |
64 'x=s' => \@param_exclude, # filer list for excluding zips |
63 'exclude=s' => \@param_exclude, # filer list for excluding zips |
65 'exclude=s' => \@param_exclude, # filer list for excluding zips |
64 'i=s' => \@param_include, # filer list for including zips |
66 'i=s' => \@param_include, # filer list for including zips |
65 'include=s' => \@param_include, # filer list for including zips |
67 'include=s' => \@param_include, # filer list for including zips |
66 'nodeps' => \$param_skip_deps, # do not extract dependencies |
68 'f=s' => \@force_include, # filer list for including zips if default tag is false |
67 'grace' => \$param_grace, # try to DL from GRACE |
69 'force=s' => \@force_include, # filer list for including zips if default tag is false |
68 'nosoap' => \$param_no_soap ); # dont try using SOAP for s60builds server |
70 'all' => \$param_all, # extract all zip whether default tag is true or false |
|
71 'nodeps' => \$param_skip_deps, # do not extract dependencies |
|
72 'grace' => \$param_grace); # try to DL from GRACE |
69 |
73 |
70 # enums for error situations |
74 # enums for error situations |
71 my $warning = 1; |
75 my $warning = 1; |
72 my $promptUser = 2; |
76 my $promptUser = 2; |
73 my $dependencyMissing = 3; |
77 my $dependencyMissing = 3; |
74 my $cannotContinue = 4; |
78 my $cannotContinue = 4; |
75 |
79 |
76 # common global variables |
80 # common global variables |
77 my $metaDataXml; # path to metadata file |
81 my $metaDataXml; # path to metadata file |
78 my $currentReleaseXml; # path to currentRelease.xml if exists |
82 my $currentReleaseXml; # path to currentRelease.xml if exists |
79 my $pathToReleaseFolder; # path to server that has releases |
83 my $pathToReleaseFolder; # path to server that has releases |
80 my $defaultServiceName; # default name for service (s60rnd) |
84 my $defaultServiceName; # default name for service (s60rnd) |
81 my $pathToUnzip; # path to unzip tool |
85 my $pathToUnzip; # path to unzip tool |
82 my $tmpDlDir; # path to temp dir where we'll DL packages to |
86 my $tmpDlDir; # path to temp dir where we'll DL packages to |
83 my $tmpDir; # path to temp dir where we extract packages from |
87 my $tmpDir; # path to temp dir where we extract packages from |
84 my $returnValue; # holds the error codes coming from 7-zip |
88 my $returnValue; # holds the error codes coming from 7-zip |
85 my $graceServer; # path to local grace server if accessible |
89 my $graceServer; # path to local grace server if accessible |
86 my $logFile; # log file for troubleshooting |
90 my $logFile; # log file for troubleshooting |
87 my %packageHash; # hash containing zips to extract |
91 my %packageHash; # hash containing zips to extract |
88 my @finalZipList; # contains final list of files to unzip |
92 my @finalZipList; # contains final list of files to unzip |
89 my $getEnvVersion; # version of this getenv script |
93 my $getEnvVersion; # version of this getenv script |
90 my $soapConnection; # holding boolean value wheter we have connection s60builds server |
|
91 my $soapSessionID; # holds the session ID received from SOAP server |
|
92 my $defaultPathToServer; # default value for the server |
94 my $defaultPathToServer; # default value for the server |
93 my $soapServiceURL = undef; |
|
94 |
95 |
95 # list of GRACE samba shares - must match to @graceNameList |
96 # list of GRACE samba shares - must match to @graceNameList |
96 my @graceList = (); |
97 my @hydraList = (); |
97 # must match to @graceList |
98 # must match to @graceList |
98 my @graceNameList = (); |
99 my @hydraNameList = (); |
99 |
100 |
100 #these 2 lists need to match |
101 #these 2 lists need to match |
101 my @serviceList = (); |
102 my @serviceList = (); |
102 my @serviceNameList = (); |
103 my @serviceNameList = (); |
103 |
104 |
134 } |
135 } |
135 ValidateInputs( ); |
136 ValidateInputs( ); |
136 printLog( "Following release we will extract: $metaDataXml" ); |
137 printLog( "Following release we will extract: $metaDataXml" ); |
137 PrintFinalWarning( ); |
138 PrintFinalWarning( ); |
138 DownloadRelease( ); |
139 DownloadRelease( ); |
139 # if we have SOAP connection we should end it |
|
140 if( $soapConnection ) { |
|
141 my $sessionInfo = EndSoapConnection( ); |
|
142 print "\n\n".$sessionInfo->{'Info'}."\n\n" if( $sessionInfo->{'Info'} ); |
|
143 } |
|
144 |
140 |
145 exit 0; |
141 exit 0; |
146 |
142 |
147 |
143 |
148 sub ValidateInputs { |
144 sub ValidateInputs { |
149 print_help( ) if ( $param_help ); |
145 print_help( ) if ( $param_help ); |
150 |
146 |
151 # try to get version info from s60builds SOAP server |
147 if( @param_exclude and @param_include ) { |
152 my $versionInfoFromServer = GetSoapVersion( ) if( !$param_no_soap ); |
148 HandleError( "you cant specify include and exclude lists at the same time!", $cannotContinue ); |
153 if( $versionInfoFromServer ) { |
149 } |
154 # we have access to SOAP server |
150 |
155 printLog( "SOAP: access OK" ); |
151 # checking wheter we are in root of the substituted drive (if -start param is not specified) |
156 $soapConnection = 1; |
152 if( ! $param_start_directly and |
157 |
153 ! getcwd =~ /[a-zA-Z]:\// and |
158 # lets not start soap if prompt only is defined |
154 $param_keepgoing ) { |
159 $soapConnection = 0 if $param_print_only; |
155 HandleError( "You should run getenv only in root of the substituted drive\nYou can use -k as keep going parameter if you think it is ok to proceed", $cannotContinue ); |
160 |
156 } |
161 printLog( "SOAP: latest OK version: ".$versionInfoFromServer->{'LatestOK'}->{'Version'} ); |
157 |
162 printLog( "SOAP: latest OK date: ".$versionInfoFromServer->{'LatestOK'}->{'Date'} ); |
158 # ok we are in root. Is the drive empty? |
163 printLog( "SOAP: latest version: ".$versionInfoFromServer->{'Latest'}->{'Version'} ); |
159 my $xmlFile = 0; |
164 printLog( "SOAP: latest date: ".$versionInfoFromServer->{'Latest'}->{'Date'} ); |
160 my $driveEmpty = 1; |
165 |
161 |
166 # compare version nmbrs and prompt user if outdated getenv |
162 opendir( ROOT, "/" ) or HandleError( "cant read root dir: $!", $warning ); |
167 if( $getEnvVersion < $versionInfoFromServer->{'LatestOK'}->{'Version'} ) { |
163 my @filesFound = readdir( ROOT ); |
168 HandleError( "Your getenv is outdated and can not be usedanymore\nPlease get newer from the server.", $cannotContinue ); |
164 closedir( ROOT ); |
169 } |
165 foreach my $file( @filesFound ) { |
|
166 next if $file =~ /^\.[\.]?$/; |
|
167 next if $file =~ /getenv/; |
|
168 $xmlFile = 1 if $file =~ /.*metadata.*\.xml/; |
|
169 $xmlFile = 1 if $file =~ /currentRelease\.xml/; |
|
170 $driveEmpty = 0; |
|
171 } |
|
172 |
|
173 printLog( "xml files: $xmlFile" ); |
|
174 printLog( "drive empty: $driveEmpty" ); |
|
175 |
|
176 # if drive is not empty and no xmls found ==> print warning (if -start param not specified) |
|
177 if( ! $param_start_directly and ! $xmlFile and ! $driveEmpty ) { |
|
178 HandleError( "The drive you are about to extract environment is not empty!\nHit CTRL-C to break now or <enter> to continue", $promptUser ); |
|
179 } |
|
180 |
|
181 # if there is valid metadata.xml in root, params like path or latest doesn't make any sense |
|
182 if( $xmlFile ) { |
|
183 foreach my $file( @filesFound ) { |
|
184 if( $file =~ /.*metadata(_(\d*))?.xml$/i ) { |
|
185 print "metadata file found!\n"; |
|
186 if( ValidateXmlFile( getcwd.$file ) ) { |
|
187 $metaDataXml = getcwd.$file; |
|
188 last; |
|
189 } |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 if( $metaDataXml ) { |
|
195 if( $param_latest or $param_release_path ) { |
|
196 print "It doesnt make sense to use 'path' or 'latest' parameter while having metadata.xml in root!\n\n"; |
|
197 print_help( ); |
|
198 exit 0; |
|
199 } |
|
200 |
|
201 # we should ask correct grace share if xmlfile !server !start |
|
202 if( !$param_server and ! $param_start_directly ) { |
|
203 print "For your convenience it is recommended to use HYDRA samba share close to you.\n"; |
|
204 # prompt user wheter he wants to use GRACE |
|
205 my $networkAccessVerified = 0; |
|
206 while( $networkAccessVerified eq 0 ) { |
|
207 my $wantedServer = FixPaths( $hydraList[ ReturnMenuIndex( "Please select share closest to you", @hydraNameList ) ] ); |
|
208 |
|
209 if( $wantedServer eq FixPaths( $hydraList[0] ) ) { |
|
210 HandleError( "Please notice that access to $hydraList[0] will be removed from wk50 onwards. Now would be perfect time to get yourself a GRACE access.", $promptUser ); |
|
211 } |
|
212 |
|
213 printLog( "selected: $wantedServer - accessing.." ); |
|
214 if( opendir( GRACETEST, $wantedServer ) ) { |
|
215 printLog( "connection tested OK" ); |
|
216 $networkAccessVerified = 1; |
|
217 $pathToReleaseFolder = $wantedServer; |
|
218 } |
|
219 else { |
|
220 print "Unable to access $wantedServer\nPlease select another network share.\n"; |
|
221 } |
|
222 } |
|
223 } |
|
224 |
|
225 # in case we have metadata in \ and -start defined, look grace automatically |
|
226 elsif( !$param_server and $param_start_directly ) { |
|
227 $pathToReleaseFolder = FindGraceServer( ); |
|
228 } |
|
229 } |
|
230 |
|
231 # ToDo: if there is not metadata.xml in root check if we have already env. Possibly update? |
|
232 |
|
233 # is 'path' parameter is used, find out (wheter there exists) valid metadata.xml |
|
234 if( $param_release_path ) { |
|
235 if( $param_latest or $param_product ) { |
|
236 print "It doesnt make sense to use 'path' or 'latest' parameter while having metadata.xml in root!\n\n"; |
|
237 print_help( ); |
|
238 exit 0; |
|
239 } |
|
240 $metaDataXml = FixPaths( $param_release_path ); |
|
241 $metaDataXml .= SearchValidXml( $metaDataXml ); |
|
242 printLog( "setting metadata: $metaDataXml" ); |
|
243 } |
|
244 |
|
245 # handle server parameter |
|
246 # simply just verify accessablility and fix path |
|
247 if( $param_server ) { |
|
248 $pathToReleaseFolder = FixPaths( $param_server ); |
|
249 opendir( OPENTEST, $pathToReleaseFolder ) or HandleError( "Unable to access given server path: $pathToReleaseFolder\n$!", $cannotContinue ); |
|
250 closedir( OPENTEST ); |
|
251 } |
|
252 |
|
253 # param_latest is used to just get latest release - requires product |
|
254 if( $param_latest ) { |
|
255 if( $param_product ) { |
|
256 $param_product = FixPaths( $param_product ); |
|
257 |
|
258 # once the network share is unavailable then tries to find grace share |
|
259 $pathToReleaseFolder = FindGraceServer( ); |
|
260 |
|
261 opendir( RELDIR, $pathToReleaseFolder.$defaultServiceName.$param_product ) or die "unable to open $pathToReleaseFolder$defaultServiceName$param_product\n$!"; |
|
262 # scan all xml files to @files_found |
|
263 # salmarko starts |
|
264 my @files_found = grep { /^pf_|^S60_|^dfs_/i } readdir RELDIR; |
|
265 # salmarko ends |
|
266 close RELDIR; |
|
267 |
|
268 if( @files_found ) { |
|
269 foreach( reverse sort ( @files_found ) ) { |
|
270 # we only want to get the last dir name.. |
|
271 s/.*\///i; |
|
272 my $productToDl = $pathToReleaseFolder.$defaultServiceName.$param_product; |
|
273 $productToDl .= FixPaths( $_ ); |
|
274 print "Searching metadata.xml files from $productToDl\n" if $param_debug; |
|
275 |
|
276 $metaDataXml = SearchValidXml( $productToDl ) ; |
|
277 if( $metaDataXml ) { |
|
278 $metaDataXml = $productToDl.$metaDataXml; |
|
279 printLog( "selected xml: $metaDataXml" ); |
|
280 last; |
|
281 } |
|
282 } |
|
283 } |
|
284 else { |
|
285 HandleError( "cannot find releases from $pathToReleaseFolder$defaultServiceName$param_product", $cannotContinue ); |
|
286 } |
170 } |
287 } |
171 else { |
288 else { |
172 printLog( "SOAP: we dont have SOAP access" ); |
289 die "If you specify -latest parameter you have to define -product also!\n"; |
173 $soapConnection = 0; |
290 } |
174 } |
291 } |
175 |
292 |
176 if( @param_exclude and @param_include ) { |
293 # use wizard to find out what to DL |
177 HandleError( "you cant specify include and exclude lists at the same time!", $cannotContinue ); |
294 if( ! $metaDataXml ) { |
178 } |
295 printLog( "Not enought valid inputs provided - running wizard..." ); |
179 |
296 RunWizard( ); |
180 # checking wheter we are in root of the substituted drive (if -start param is not specified) |
297 } |
181 if( ! $param_start_directly and |
298 |
182 ! getcwd =~ /[a-zA-Z]:\// and |
299 # check wheter metadata and currentRelease adds up |
183 $param_keepgoing ) { |
300 if( -e FixPaths( getcwd )."currentRelease.xml") { |
184 HandleError( "You should run getenv only in root of the substituted drive\nYou can use -k as keep going parameter if you think it is ok to proceed", $cannotContinue ); |
301 printLog( "CurrenRelease.xml exists. Checking wheter update is possible" ); |
185 } |
302 |
186 |
303 # compare service, product and release with xml files |
187 # ok we are in root. Is the drive empty? |
304 my $CurrentRelXmlParser = new XML::Simple( ); |
188 my $xmlFile = 0; |
305 my $currentReleaseData = $CurrentRelXmlParser->XMLin( FixPaths( getcwd )."currentRelease.xml" ); |
189 my $driveEmpty = 1; |
306 |
190 |
307 my $xmlParser = new XML::Simple( ); |
191 opendir( ROOT, "/" ) or HandleError( "cant read root dir: $!", $warning ); |
308 my $xmlData = $xmlParser->XMLin( $metaDataXml ); |
192 my @filesFound = readdir( ROOT ); |
309 |
193 closedir( ROOT ); |
|
194 foreach my $file( @filesFound ) { |
|
195 next if $file =~ /^\.[\.]?$/; |
|
196 next if $file =~ /getenv/; |
|
197 $xmlFile = 1 if $file =~ /.*metadata.*\.xml/; |
|
198 $xmlFile = 1 if $file =~ /currentRelease\.xml/; |
|
199 $driveEmpty = 0; |
|
200 } |
|
201 |
|
202 printLog( "xml files: $xmlFile" ); |
|
203 printLog( "drive empty: $driveEmpty" ); |
|
204 |
|
205 # if drive is not empty and no xmls found ==> print warning (if -start param not specified) |
|
206 if( ! $param_start_directly and ! $xmlFile and ! $driveEmpty ) { |
|
207 HandleError( "The drive you are about to extract environment is not empty!\nHit CTRL-C to break now or <enter> to continue", $promptUser ); |
|
208 } |
|
209 |
|
210 # if there is valid metadata.xml in root, params like path or latest doesn't make any sense |
|
211 if( $xmlFile ) { |
|
212 foreach my $file( @filesFound ) { |
|
213 if( $file =~ /.*metadata(_(\d*))?.xml$/i ) { |
|
214 print "metadata file found!\n"; |
|
215 if( ValidateXmlFile( getcwd.$file ) ) { |
|
216 $metaDataXml = getcwd.$file; |
|
217 last; |
|
218 } |
|
219 } |
|
220 } |
|
221 } |
|
222 |
|
223 if( $metaDataXml ) { |
|
224 if( $param_latest or $param_release_path ) { |
|
225 print "It doesnt make sense to use 'path' or 'latest' parameter while having metadata.xml in root!\n\n"; |
|
226 print_help( ); |
|
227 exit 0; |
|
228 } |
|
229 |
|
230 # we should ask correct grace share if xmlfile !server !start |
|
231 if( !$param_server and ! $param_start_directly ) { |
|
232 print "For your convenience it is recommended to use GRACE samba share close to you.\n"; |
|
233 # prompt user wheter he wants to use GRACE |
|
234 my $networkAccessVerified = 0; |
|
235 while( $networkAccessVerified eq 0 ) { |
|
236 my $wantedServer = FixPaths( $graceList[ ReturnMenuIndex( "Please select share closest to you", @graceNameList ) ] ); |
|
237 |
|
238 if( $wantedServer eq FixPaths( $graceList[0] ) ) { |
|
239 HandleError( "Please notice that access to $graceList[0] will be removed from wk50 onwards. Now would be perfect time to get yourself a GRACE access.", $promptUser ); |
|
240 } |
|
241 |
|
242 printLog( "selected: $wantedServer - accessing.." ); |
|
243 if( opendir( GRACETEST, $wantedServer ) ) { |
|
244 printLog( "connection tested OK" ); |
|
245 $networkAccessVerified = 1; |
|
246 $pathToReleaseFolder = $wantedServer; |
|
247 } |
|
248 else { |
|
249 print "Unable to access $wantedServer\nPlease select another network share.\n"; |
|
250 } |
|
251 } |
|
252 } |
|
253 |
|
254 # in case we have metadata in \ and -start defined, look grace automatically |
|
255 elsif( !$param_server and $param_start_directly ) { |
|
256 $pathToReleaseFolder = FindGraceServer( ); |
|
257 } |
|
258 } |
|
259 |
|
260 # ToDo: if there is not metadata.xml in root check if we have already env. Possibly update? |
|
261 |
|
262 # is 'path' parameter is used, find out (wheter there exists) valid metadata.xml |
|
263 if( $param_release_path ) { |
|
264 if( $param_latest or $param_product ) { |
|
265 print "It doesnt make sense to use 'path' or 'latest' parameter while having metadata.xml in root!\n\n"; |
|
266 print_help( ); |
|
267 exit 0; |
|
268 } |
|
269 $metaDataXml = FixPaths( $param_release_path ); |
|
270 $metaDataXml .= SearchValidXml( $metaDataXml ); |
|
271 printLog( "setting metadata: $metaDataXml" ); |
|
272 } |
|
273 |
|
274 # handle server parameter |
|
275 # simply just verify accessablility and fix path |
|
276 if( $param_server ) { |
|
277 $pathToReleaseFolder = FixPaths( $param_server ); |
|
278 opendir( OPENTEST, $pathToReleaseFolder ) or HandleError( "Unable to access given server path: $pathToReleaseFolder\n$!", $cannotContinue ); |
|
279 closedir( OPENTEST ); |
|
280 } |
|
281 |
|
282 # param_latest is used to just get latest release - requires product |
|
283 if( $param_latest ) { |
|
284 if( $param_product ) { |
|
285 $param_product = FixPaths( $param_product ); |
|
286 |
|
287 # once the network share is unavailable then tries to find grace share |
|
288 $pathToReleaseFolder = FindGraceServer( ); |
|
289 |
|
290 opendir( RELDIR, $pathToReleaseFolder.$defaultServiceName.$param_product ) or die "unable to open $pathToReleaseFolder$defaultServiceName$param_product\n$!"; |
|
291 # scan all xml files to @files_found |
|
292 # salmarko starts |
310 # salmarko starts |
293 my @files_found = grep { /^pf_|^S60_|^dfs_/i } readdir RELDIR; |
311 my $currentRelease = ''; |
294 # salmarko ends |
312 my $newRelease = ''; |
295 close RELDIR; |
313 |
296 |
314 if ( !defined $xmlData->{releaseDetails}->{dependsOf}->{service}->{name} ) { # no dependencies, lets compare current to new |
297 if( @files_found ) { |
315 # compare services |
298 foreach( reverse sort ( @files_found ) ) { |
316 if( $currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name} ne |
299 # we only want to get the last dir name.. |
317 $xmlData->{releaseDetails}->{releaseID}->{service}->{name} ) { |
300 s/.*\///i; |
318 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{releaseID}->{service}->{name} . |
301 my $productToDl = $pathToReleaseFolder.$defaultServiceName.$param_product; |
319 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name}, $cannotContinue ); |
302 $productToDl .= FixPaths( $_ ); |
320 } |
303 print "Searching metadata.xml files from $productToDl\n" if $param_debug; |
321 # compare products |
304 |
322 if( $currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name} ne |
305 $metaDataXml = SearchValidXml( $productToDl ) ; |
323 $xmlData->{releaseDetails}->{releaseID}->{product}->{name} ) { |
306 if( $metaDataXml ) { |
324 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{releaseID}->{product}->{name} . |
307 $metaDataXml = $productToDl.$metaDataXml; |
325 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name}, $cannotContinue ); |
308 printLog( "selected xml: $metaDataXml" ); |
326 } |
309 last; |
327 printLog( "service and product matches.. checking release" ); |
310 } |
328 |
311 } |
329 $currentRelease = $currentReleaseData->{releaseDetails}->{releaseID}->{release}->{name}; |
312 } |
330 $newRelease = $xmlData->{releaseDetails}->{releaseID}->{release}->{name}; |
313 else { |
331 } |
314 HandleError( "cannot find releases from $pathToReleaseFolder$defaultServiceName$param_product", $cannotContinue ); |
332 else{ |
315 } |
333 # compare services |
316 } |
334 if( $currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name} ne |
317 else { |
335 $xmlData->{releaseDetails}->{dependsOf}->{service}->{name} ) { |
318 die "If you specify -latest parameter you have to define -product also!\n"; |
336 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{dependsOf}->{service}->{name} . |
319 } |
337 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name}, $cannotContinue ); |
320 } |
338 } |
321 |
339 # compare products |
322 # use wizard to find out what to DL |
340 if( $currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name} ne |
323 if( ! $metaDataXml ) { |
341 $xmlData->{releaseDetails}->{dependsOf}->{product}->{name} ) { |
324 printLog( "Not enought valid inputs provided - running wizard..." ); |
342 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{dependsOf}->{product}->{name} . |
325 RunWizard( ); |
343 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name}, $cannotContinue ); |
326 } |
344 } |
327 |
345 printLog( "service and product matches.. checking release" ); |
328 # check wheter metadata and currentRelease adds up |
346 |
329 if( -e FixPaths( getcwd )."currentRelease.xml") { |
347 # compare releases |
330 printLog( "CurrenRelease.xml exists. Checking wheter update is possible" ); |
348 $currentRelease = $currentReleaseData->{releaseDetails}->{releaseID}->{release}->{name}; |
331 |
349 $newRelease = $xmlData->{releaseDetails}->{dependsOf}->{release}->{name}; |
332 # compare service, product and release with xml files |
350 |
333 my $CurrentRelXmlParser = new XML::Simple( ); |
351 if ( $currentRelease =~ m/^(S60_\d_\d+_\d{6})/i or $currentRelease =~ m/^(pf_\d{4}_\d{6})/ ) { |
334 my $currentReleaseData = $CurrentRelXmlParser->XMLin( FixPaths( getcwd )."currentRelease.xml" ); |
352 $currentRelease = $1; |
335 |
353 } |
336 my $xmlParser = new XML::Simple( ); |
354 else { |
337 my $xmlData = $xmlParser->XMLin( $metaDataXml ); |
355 HandleError( "Current release info unknown or missing: $currentRelease", $cannotContinue ); |
338 |
356 } |
339 # salmarko starts |
357 |
340 my $currentRelease = ''; |
358 if ( $newRelease =~ m/^(S60_\d_\d+_\d{6})/i or $newRelease =~ m/^(pf_\d{4}_\d{6})/ ) { |
341 my $newRelease = ''; |
359 $newRelease = $1; |
342 |
360 } |
343 if ( !defined $xmlData->{releaseDetails}->{dependsOf}->{service}->{name} ) { # no dependencies, lets compare current to new |
361 else { |
344 # compare services |
362 HandleError( "New release info unknown or missing: $newRelease", $cannotContinue ); |
345 if( $currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name} ne |
363 } |
346 $xmlData->{releaseDetails}->{releaseID}->{service}->{name} ) { |
364 } |
347 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{releaseID}->{service}->{name} . |
365 |
348 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name}, $cannotContinue ); |
366 printLog( "current release: $currentRelease" ); |
349 } |
367 printLog( "release to extract: $newRelease" ); |
350 # compare products |
368 #salmarko ends |
351 if( $currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name} ne |
369 |
352 $xmlData->{releaseDetails}->{releaseID}->{product}->{name} ) { |
370 if( $currentRelease ne $newRelease ) { |
353 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{releaseID}->{product}->{name} . |
371 HandleError( "Can not extract $newRelease release on top of $currentRelease", $cannotContinue ); |
354 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name}, $cannotContinue ); |
372 } |
355 } |
373 printLog( "release matches - update possible" ); |
356 printLog( "service and product matches.. checking release" ); |
374 |
357 |
375 $currentRelease = FixPaths( getcwd )."currentRelease.xml"; |
358 $currentRelease = $currentReleaseData->{releaseDetails}->{releaseID}->{release}->{name}; |
376 } |
359 $newRelease = $xmlData->{releaseDetails}->{releaseID}->{release}->{name}; |
377 # check wheter we can use c-disc as temp |
360 } |
378 my $df = getFreeDisk( $ENV{'TEMP'} ); |
361 else{ |
379 |
362 # compare services |
380 if( $df > 2147483648 && $df < 2147483648000 ) { |
363 if( $currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name} ne |
381 printLog( "amount of free space seems sane: $df" ); |
364 $xmlData->{releaseDetails}->{dependsOf}->{service}->{name} ) { |
382 $tmpDir = FixPaths( tempdir( CLEANUP => 0 ) ); |
365 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{dependsOf}->{service}->{name} . |
383 printLog( "setting tmpDir: $tmpDir" ); |
366 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name}, $cannotContinue ); |
384 $tmpDlDir = FixPaths( tempdir( CLEANUP => 0 ) ); |
367 } |
385 printLog( "setting tmpDlDir: $tmpDlDir" ); |
368 # compare products |
386 } |
369 if( $currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name} ne |
|
370 $xmlData->{releaseDetails}->{dependsOf}->{product}->{name} ) { |
|
371 HandleError( "Can not extract ".$xmlData->{releaseDetails}->{dependsOf}->{product}->{name} . |
|
372 " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name}, $cannotContinue ); |
|
373 } |
|
374 printLog( "service and product matches.. checking release" ); |
|
375 |
|
376 # compare releases |
|
377 $currentRelease = $currentReleaseData->{releaseDetails}->{releaseID}->{release}->{name}; |
|
378 $newRelease = $xmlData->{releaseDetails}->{dependsOf}->{release}->{name}; |
|
379 |
|
380 if ( $currentRelease =~ m/^(S60_\d_\d+_\d{6})/i or $currentRelease =~ m/^(pf_\d{4}_\d{6})/ ) { |
|
381 $currentRelease = $1; |
|
382 } |
|
383 else { |
|
384 HandleError( "Current release info unknown or missing: $currentRelease", $cannotContinue ); |
|
385 } |
|
386 |
|
387 if ( $newRelease =~ m/^(S60_\d_\d+_\d{6})/i or $newRelease =~ m/^(pf_\d{4}_\d{6})/ ) { |
|
388 $newRelease = $1; |
|
389 } |
|
390 else { |
|
391 HandleError( "New release info unknown or missing: $newRelease", $cannotContinue ); |
|
392 } |
|
393 } |
|
394 |
|
395 printLog( "current release: $currentRelease" ); |
|
396 printLog( "release to extract: $newRelease" ); |
|
397 # salmarko ends |
|
398 |
|
399 if( $currentRelease ne $newRelease ) { |
|
400 HandleError( "Can not extract $newRelease release on top of $currentRelease", $cannotContinue ); |
|
401 } |
|
402 printLog( "release matches - update possible" ); |
|
403 |
|
404 $currentRelease = FixPaths( getcwd )."currentRelease.xml"; |
|
405 } |
|
406 } |
387 } |
407 |
388 |
408 |
389 |
409 # Make sure paths are as perl likes 'em |
390 # Make sure paths are as perl likes 'em |
410 # change '\' ==> '/' and make sure last char is / |
391 # change '\' ==> '/' and make sure last char is / |