19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::downloadsigner; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::exiter; 27cdf0e10cSrcweiruse installer::files; 28cdf0e10cSrcweiruse installer::globals; 29cdf0e10cSrcweiruse installer::logger; 30cdf0e10cSrcweiruse installer::pathanalyzer; 31cdf0e10cSrcweir 32cdf0e10cSrcweir############################################ 33cdf0e10cSrcweir# Parameter Operations 34cdf0e10cSrcweir############################################ 35cdf0e10cSrcweir 36cdf0e10cSrcweirsub usage 37cdf0e10cSrcweir{ 38cdf0e10cSrcweir print <<Ende; 39cdf0e10cSrcweir-------------------------------------------------------------------------------- 40cdf0e10cSrcweirmake_download V1.0 41cdf0e10cSrcweirThe following parameter are needed: 42cdf0e10cSrcweir-d: Full path to the file containing the follow-me info or to a directory 43cdf0e10cSrcweir containing the follow-me info files. In the latter case, all follow-me 44cdf0e10cSrcweir info files are evaluated. If a directory is used, the successfully used 45cdf0e10cSrcweir follow-me info files are renamed using a string "success". Files with 46cdf0e10cSrcweir this string are ignored in repeated processes using "-d" with a 47cdf0e10cSrcweir directory. 48cdf0e10cSrcweir 49cdf0e10cSrcweirThe following parameter are optional: 50cdf0e10cSrcweir-nodownload: Only signing, no creation of download sets (Windows only) 51cdf0e10cSrcweir-useminor: Important for installation sets, created without minor set 52cdf0e10cSrcweir-writetotemp: Necessary, if you do not want to write into solver 53cdf0e10cSrcweir This can be caused by missing privileges (Windows only) 54cdf0e10cSrcweir-internalcabinet: Not only the cabinet files are signed, but also all 55cdf0e10cSrcweir files included in the cabinet files (Windows only). 56cdf0e10cSrcweir 57cdf0e10cSrcweir-sign: Uses signing mechanism to sign installation sets 58cdf0e10cSrcweirIf \"-sign\" is set, the following two parameter are required: 59cdf0e10cSrcweir-pfx: Full path to the pfx file 60cdf0e10cSrcweir-pw: Full path to the file, containing the pfx password. 61cdf0e10cSrcweir 62cdf0e10cSrcweirExamples: 63cdf0e10cSrcweir 64cdf0e10cSrcweirSpecifying an installation set (with "-d"): 65cdf0e10cSrcweir 66cdf0e10cSrcweirperl make_download.pl -d <followmeinfofilename> 67cdf0e10cSrcweir 68cdf0e10cSrcweirperl make_download.pl -d <followmeinfofilename> 69cdf0e10cSrcweir -sign 70cdf0e10cSrcweir -pfx <pfxfilename> 71cdf0e10cSrcweir -pw <passwordfilename> 72cdf0e10cSrcweir 73cdf0e10cSrcweiror without specifying an installation set: 74cdf0e10cSrcweir 75cdf0e10cSrcweirperl make_download.pl -d <followmedirectory> 76cdf0e10cSrcweir -sign 77cdf0e10cSrcweir -pfx <pfxfilename> 78cdf0e10cSrcweir -pw <passwordfilename> 79cdf0e10cSrcweir-------------------------------------------------------------------------------- 80cdf0e10cSrcweirEnde 81cdf0e10cSrcweir exit(-1); 82cdf0e10cSrcweir} 83cdf0e10cSrcweir 84cdf0e10cSrcweir##################################### 85cdf0e10cSrcweir# Reading parameter 86cdf0e10cSrcweir##################################### 87cdf0e10cSrcweir 88cdf0e10cSrcweirsub getparameter 89cdf0e10cSrcweir{ 90cdf0e10cSrcweir while ( $#ARGV >= 0 ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir my $param = shift(@ARGV); 93cdf0e10cSrcweir 94cdf0e10cSrcweir if ($param eq "-d") { $installer::globals::followmeinfofilename = shift(@ARGV); } 95cdf0e10cSrcweir elsif ($param eq "-pw") { $installer::globals::pwfile = shift(@ARGV); } 96cdf0e10cSrcweir elsif ($param eq "-pfx") { $installer::globals::pfxfile = shift(@ARGV); } 97cdf0e10cSrcweir elsif ($param eq "-sign") { $installer::globals::dosign = 1; } 98cdf0e10cSrcweir elsif ($param eq "-nodownload") { $installer::globals::nodownload = 1; } 99cdf0e10cSrcweir elsif ($param eq "-writetotemp") { $installer::globals::writetotemp = 1; } 100cdf0e10cSrcweir elsif ($param eq "-useminor") { $installer::globals::useminor = 1; } 101cdf0e10cSrcweir elsif ($param eq "-internalcabinet") { $installer::globals::internal_cabinet_signing = 1; } 102cdf0e10cSrcweir else 103cdf0e10cSrcweir { 104cdf0e10cSrcweir installer::logger::print_error( "unknown parameter: $param" ); 105cdf0e10cSrcweir usage(); 106cdf0e10cSrcweir exit(-1); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir} 110cdf0e10cSrcweir 111cdf0e10cSrcweir##################################### 112cdf0e10cSrcweir# Controlling required parameter 113cdf0e10cSrcweir##################################### 114cdf0e10cSrcweir 115cdf0e10cSrcweirsub checkparameter 116cdf0e10cSrcweir{ 117cdf0e10cSrcweir if ( $installer::globals::followmeinfofilename eq "" ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir installer::logger::print_error( "Error: Required parameter is missing: -d\n" ); 120cdf0e10cSrcweir usage(); 121cdf0e10cSrcweir exit(-1); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir if ( $installer::globals::dosign ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir # -pfx and -pw have to be set 127cdf0e10cSrcweir if ( $installer::globals::pfxfile eq "" ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir installer::logger::print_error( "Error: If \"-sign\" is set, a pfx file has to be specified: -pfx\n" ); 130cdf0e10cSrcweir usage(); 131cdf0e10cSrcweir exit(-1); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir # -pfx and -pw have to be set 135cdf0e10cSrcweir if ( $installer::globals::pwfile eq "" ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir installer::logger::print_error( "Error: If \"-sign\" is set, a password file has to be specified: -pw\n" ); 138cdf0e10cSrcweir usage(); 139cdf0e10cSrcweir exit(-1); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir # and both files have to exist 143cdf0e10cSrcweir if ( ! -f $installer::globals::pfxfile ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir installer::logger::print_error( "Error: pfx file \"$installer::globals::pfxfile\" does not exist.\n" ); 146cdf0e10cSrcweir usage(); 147cdf0e10cSrcweir exit(-1); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir if ( ! -f $installer::globals::pwfile ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir installer::logger::print_error( "Error: Password file \"$installer::globals::pwfile\" does not exist (-pw).\n" ); 153cdf0e10cSrcweir usage(); 154cdf0e10cSrcweir exit(-1); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir } 157cdf0e10cSrcweir} 158cdf0e10cSrcweir 159cdf0e10cSrcweir############################################# 160cdf0e10cSrcweir# Setting the temporary path for the download 161cdf0e10cSrcweir# and signing process 162cdf0e10cSrcweir############################################# 163cdf0e10cSrcweir 164cdf0e10cSrcweirsub set_temp_path 165cdf0e10cSrcweir{ 166cdf0e10cSrcweir my $temppath = ""; 167cdf0e10cSrcweir my $pid = $$; # process id 168cdf0e10cSrcweir my $time = time(); # time 169cdf0e10cSrcweir my $helperdir = "unpackdir_" . $pid . $time; 170cdf0e10cSrcweir 171cdf0e10cSrcweir if (( $ENV{'TMP'} ) || ( $ENV{'TEMP'} )) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir if ( $ENV{'TMP'} ) { $temppath = $ENV{'TMP'}; } 174cdf0e10cSrcweir elsif ( $ENV{'TEMP'} ) { $temppath = $ENV{'TEMP'}; } 175cdf0e10cSrcweir $temppath =~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes and backslashes 176cdf0e10cSrcweir $temppath = $temppath . $installer::globals::separator . $helperdir; 177cdf0e10cSrcweir 178cdf0e10cSrcweir if( $^O =~ /cygwin/i ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir $temppath = qx{cygpath -w "$temppath"}; 181cdf0e10cSrcweir $temppath =~ s/\\/\//g; 182cdf0e10cSrcweir $temppath =~ s/\s*$//g; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir installer::systemactions::create_directory_structure($temppath); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir else 188cdf0e10cSrcweir { 189cdf0e10cSrcweir installer::logger::print_error( "Error: TMP and TEMP not defined. This is required for this process.\n" ); 190cdf0e10cSrcweir usage(); 191cdf0e10cSrcweir exit(-1); 192cdf0e10cSrcweir } 193*b274bc22SAndre Fischer 194*b274bc22SAndre Fischer $installer::logger::Info->print("\n"); 195*b274bc22SAndre Fischer $installer::logger::Info->printf("\n... using output path: %s ...\n", $temppath); 196cdf0e10cSrcweir 197cdf0e10cSrcweir push(@installer::globals::removedirs, $temppath); 198cdf0e10cSrcweir 199cdf0e10cSrcweir return $temppath; 200cdf0e10cSrcweir} 201cdf0e10cSrcweir 202cdf0e10cSrcweir############################################# 203cdf0e10cSrcweir# Setting output pathes to temp directory 204cdf0e10cSrcweir# This are the: 205cdf0e10cSrcweir# unpackpath and the loggingdir 206cdf0e10cSrcweir############################################# 207cdf0e10cSrcweir 208cdf0e10cSrcweirsub set_output_pathes_to_temp 209cdf0e10cSrcweir{ 210cdf0e10cSrcweir my ($followmeinfohash, $temppath) = @_; 211cdf0e10cSrcweir 212cdf0e10cSrcweir $followmeinfohash->{'loggingdir'} = $temppath . $installer::globals::separator; 213cdf0e10cSrcweir $installer::globals::unpackpath = $temppath; 214cdf0e10cSrcweir} 215cdf0e10cSrcweir 216cdf0e10cSrcweir############################################# 217cdf0e10cSrcweir# Setting the minor into the pathes. This is 218cdf0e10cSrcweir# required, if the original installation set 219cdf0e10cSrcweir# was created without minor 220cdf0e10cSrcweir# Value is always saved in 221cdf0e10cSrcweir# $installer::globals::lastminor 222cdf0e10cSrcweir# which is saved in the follow_me file 223cdf0e10cSrcweir############################################# 224cdf0e10cSrcweir 225cdf0e10cSrcweirsub set_minor_into_pathes 226cdf0e10cSrcweir{ 227cdf0e10cSrcweir my ($followmeinfohash, $temppath) = @_; 228*b274bc22SAndre Fischer 229*b274bc22SAndre Fischer $installer::logger::Info->print("\n"); 230*b274bc22SAndre Fischer $installer::logger::Info->printf("... forcing into minor: %s ...\n", $installer::globals::lastminor); 231cdf0e10cSrcweir 232cdf0e10cSrcweir my @pathnames = ("bin", "doc", "inc", "lib", "pck", "res", "xml"); 233cdf0e10cSrcweir my $sourcename = "src"; 234cdf0e10cSrcweir my $srcpath = $installer::globals::separator . $sourcename . $installer::globals::separator; 235cdf0e10cSrcweir 236cdf0e10cSrcweir if ( $installer::globals::minor ne "" ) 237cdf0e10cSrcweir { 238*b274bc22SAndre Fischer $installer::logger::Info->print("\n"); 239*b274bc22SAndre Fischer $installer::logger::Info->printf("... already defined minor: %s -> ignoring parameter \"-useminor\" ...\n" , $installer::globals::minor); 240cdf0e10cSrcweir return; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir # Affected pathes: 244cdf0e10cSrcweir # $contenthash{'installlogdir'} 245cdf0e10cSrcweir # $contenthash{'includepatharray'} 246cdf0e10cSrcweir # $installer::globals::unpackpath 247cdf0e10cSrcweir # $installer::globals::idttemplatepath 248cdf0e10cSrcweir # $installer::globals::idtlanguagepath 249cdf0e10cSrcweir 250cdf0e10cSrcweir installer::logger::include_header_into_logfile("Changing saved pathes to add the minor"); 251*b274bc22SAndre Fischer $installer::logger::Lang->print("Old pathes:\n"); 252*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$followmeinfohash->{'installlogdir'}: %s\n", $followmeinfohash->{'installlogdir'}); 253*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$installer::globals::unpackpath: %s\n", $installer::globals::unpackpath); 254*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$installer::globals::idttemplatepath: %s\n", $installer::globals::idttemplatepath); 255*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$installer::globals::idtlanguagepath: %s\n", $installer::globals::idtlanguagepath); 256*b274bc22SAndre Fischer $installer::logger::Lang->printf("Include pathes:\n"); 257*b274bc22SAndre Fischer foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) 258*b274bc22SAndre Fischer { 259*b274bc22SAndre Fischer $installer::logger::Lang->print($path); 260*b274bc22SAndre Fischer } 261cdf0e10cSrcweir 262cdf0e10cSrcweir foreach $onepath ( @pathnames ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir my $oldvalue = $installer::globals::separator . $onepath . $installer::globals::separator; 265cdf0e10cSrcweir my $newvalue = $installer::globals::separator . $onepath . "\." . $installer::globals::lastminor . $installer::globals::separator; 266cdf0e10cSrcweir 267cdf0e10cSrcweir if (( $followmeinfohash->{'installlogdir'} =~ /\Q$oldvalue\E/ ) && ( ! ( $followmeinfohash->{'installlogdir'} =~ /\Q$srcpath\E/ ))) { $followmeinfohash->{'installlogdir'} =~ s/\Q$oldvalue\E/$newvalue/; } 268cdf0e10cSrcweir if (( $installer::globals::unpackpath =~ /\Q$oldvalue\E/ ) && ( ! ( $installer::globals::unpackpath =~ /\Q$srcpath\E/ ))) { $installer::globals::unpackpath =~ s/\Q$oldvalue\E/$newvalue/; } 269cdf0e10cSrcweir if (( $installer::globals::idttemplatepath =~ /\Q$oldvalue\E/ ) && ( ! ( $installer::globals::idttemplatepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idttemplatepath =~ s/\Q$oldvalue\E/$newvalue/; } 270cdf0e10cSrcweir if (( $installer::globals::idtlanguagepath =~ /\Q$oldvalue\E/ ) && ( ! ( $installer::globals::idtlanguagepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idtlanguagepath =~ s/\Q$oldvalue\E/$newvalue/; } 271cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) { if (( $path =~ /\Q$oldvalue\E/ ) && ( ! ( $path =~ /\Q$srcpath\E/ ))) { $path =~ s/\Q$oldvalue\E/$newvalue/; } } 272cdf0e10cSrcweir 273cdf0e10cSrcweir # Checking for the end of the path 274cdf0e10cSrcweir $oldvalue = $installer::globals::separator . $onepath; 275cdf0e10cSrcweir $newvalue = $installer::globals::separator . $onepath . "\." . $installer::globals::lastminor; 276cdf0e10cSrcweir 277cdf0e10cSrcweir if (( $followmeinfohash->{'installlogdir'} =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $followmeinfohash->{'installlogdir'} =~ /\Q$srcpath\E/ ))) { $followmeinfohash->{'installlogdir'} =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 278cdf0e10cSrcweir if (( $installer::globals::unpackpath =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $installer::globals::unpackpath =~ /\Q$srcpath\E/ ))) { $installer::globals::unpackpath =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 279cdf0e10cSrcweir if (( $installer::globals::idttemplatepath =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $installer::globals::idttemplatepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idttemplatepath =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 280cdf0e10cSrcweir if (( $installer::globals::idtlanguagepath =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $installer::globals::idtlanguagepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idtlanguagepath =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 281cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir if (( $path =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $path =~ /\Q$srcpath\E/ ))) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir $path =~ s/\Q$oldvalue\E\s*$/$newvalue/; 286cdf0e10cSrcweir $path = $path . "\n"; 287cdf0e10cSrcweir } 288cdf0e10cSrcweir } 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir # And now can follow the replacement for the source path "src". Subdirs like "bin" in the source tree 292cdf0e10cSrcweir # must not get the minor. This is instead "src.m9/instsetoo_native/common.pro/bin/..." 293cdf0e10cSrcweir # Directory "src" can never be the end of the path 294cdf0e10cSrcweir 295cdf0e10cSrcweir my $newsrcpath = $installer::globals::separator . $sourcename . "\." . $installer::globals::lastminor . $installer::globals::separator; 296cdf0e10cSrcweir 297cdf0e10cSrcweir if ( $followmeinfohash->{'installlogdir'} =~ /\Q$srcpath\E/ ) { $followmeinfohash->{'installlogdir'} =~ s/\Q$srcpath\E/$newsrcpath/; } 298cdf0e10cSrcweir if ( $installer::globals::unpackpath =~ /\Q$srcpath\E/ ) { $installer::globals::unpackpath =~ s/\Q$srcpath\E/$newsrcpath/; } 299cdf0e10cSrcweir if ( $installer::globals::idttemplatepath =~ /\Q$srcpath\E/ ) { $installer::globals::idttemplatepath =~ s/\Q$srcpath\E/$newsrcpath/; } 300cdf0e10cSrcweir if ( $installer::globals::idtlanguagepath =~ /\Q$srcpath\E/ ) { $installer::globals::idtlanguagepath =~ s/\Q$srcpath\E/$newsrcpath/; } 301cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) { if ( $path =~ /\Q$srcpath\E/ ) { $path =~ s/\Q$srcpath\E/$newsrcpath/; } } 302cdf0e10cSrcweir 303*b274bc22SAndre Fischer $installer::logger::Lang->print("\n"); 304*b274bc22SAndre Fischer $installer::logger::Lang->print("New pathes:\n"); 305*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$followmeinfohash->{'installlogdir'}: %s\n", $followmeinfohash->{'installlogdir'}); 306*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$installer::globals::unpackpath: %s\n", $installer::globals::unpackpath); 307*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$installer::globals::idttemplatepath: %s\n", $installer::globals::idttemplatepath); 308*b274bc22SAndre Fischer $installer::logger::Lang->printf("\$installer::globals::idtlanguagepath: %s\n", $installer::globals::idtlanguagepath); 309*b274bc22SAndre Fischer $installer::logger::Lang->printf("Include pathes:\n"); 310*b274bc22SAndre Fischer foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) 311*b274bc22SAndre Fischer { 312*b274bc22SAndre Fischer $installer::logger::Lang->print($path); 313*b274bc22SAndre Fischer } 314cdf0e10cSrcweir} 315cdf0e10cSrcweir 316cdf0e10cSrcweir############################################# 317cdf0e10cSrcweir# Setting the name of the log file 318cdf0e10cSrcweir############################################# 319cdf0e10cSrcweir 320cdf0e10cSrcweirsub setlogfilename 321cdf0e10cSrcweir{ 322cdf0e10cSrcweir if ( $installer::globals::dosign ) { $installer::globals::logfilename = "sign_and_download_" . $installer::globals::logfilename; } 323cdf0e10cSrcweir else { $installer::globals::logfilename = "download_" . $installer::globals::logfilename; } 324cdf0e10cSrcweir # reset the log file 325cdf0e10cSrcweir @installer::globals::logfileinfo = (); 326cdf0e10cSrcweir} 327cdf0e10cSrcweir 328cdf0e10cSrcweir######################################################### 329cdf0e10cSrcweir# Checking, if this is a task in a cws or 330cdf0e10cSrcweir# on the master. Simple check of naming schema: 331cdf0e10cSrcweir# CWS: follow_me_DEV300_m40_de.log 332cdf0e10cSrcweir# Master: follow_me_4_DEV300_m40_en-US.log 333cdf0e10cSrcweir######################################################### 334cdf0e10cSrcweir 335cdf0e10cSrcweirsub check_cws_build 336cdf0e10cSrcweir{ 337cdf0e10cSrcweir my ( $filename ) = @_; 338cdf0e10cSrcweir 339cdf0e10cSrcweir my $iscws = 1; 340cdf0e10cSrcweir 341cdf0e10cSrcweir if ( $filename =~ /follow_me_\d+_/ ) { $iscws = 0; } 342cdf0e10cSrcweir # if ( $filename =~ /log_\d+_/ ) { $iscws = 0; } 343cdf0e10cSrcweir 344cdf0e10cSrcweir return $iscws; 345cdf0e10cSrcweir} 346cdf0e10cSrcweir 347cdf0e10cSrcweir######################################################### 348cdf0e10cSrcweir# Reading a specific key from a follow-me file 349cdf0e10cSrcweir######################################################### 350cdf0e10cSrcweir 351cdf0e10cSrcweirsub get_property_from_file 352cdf0e10cSrcweir{ 353cdf0e10cSrcweir my ($followmefile, $key) = @_; 354cdf0e10cSrcweir 355cdf0e10cSrcweir my $value = ""; 356cdf0e10cSrcweir 357cdf0e10cSrcweir my $filecontent = installer::files::read_file($followmefile); 358cdf0e10cSrcweir 359cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir if ( ${$filecontent}[$i] =~ /^\s*\Q$key\E\s*\:\s*(.*?)\s*$/ ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir $value = $1; 364cdf0e10cSrcweir last; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir return $value; 369cdf0e10cSrcweir} 370cdf0e10cSrcweir 371cdf0e10cSrcweir######################################################### 372cdf0e10cSrcweir# Publishing the content of the product list 373cdf0e10cSrcweir######################################################### 374cdf0e10cSrcweir 375cdf0e10cSrcweirsub publishproductlist 376cdf0e10cSrcweir{ 377cdf0e10cSrcweir my ($infofilelist) = @_; 378cdf0e10cSrcweir 379*b274bc22SAndre Fischer $installer::logger::Info->print("\n"); 380*b274bc22SAndre Fischer $installer::logger::Info->printf("... found products: ...\n"); 381cdf0e10cSrcweir 382cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$infofilelist}; $i++ ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir my $onefile = ${$infofilelist}[$i]; 385cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$onefile); 386*b274bc22SAndre Fischer $installer::logger::Info->printf("...... $onefile ...\n"); 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389*b274bc22SAndre Fischer $installer::logger::Info->printf("\n"); 390cdf0e10cSrcweir} 391cdf0e10cSrcweir 392cdf0e10cSrcweir######################################################### 393cdf0e10cSrcweir# Filtering all files, that have correct minor 394cdf0e10cSrcweir# and work stamp. 395cdf0e10cSrcweir# Master: follow_me_4_DEV300_m40_en-US.log 396cdf0e10cSrcweir######################################################### 397cdf0e10cSrcweir 398cdf0e10cSrcweirsub filter_all_files_with_correct_settings 399cdf0e10cSrcweir{ 400cdf0e10cSrcweir my ($allfollowmefiles) = @_; 401cdf0e10cSrcweir 402cdf0e10cSrcweir my @allfiles = (); 403cdf0e10cSrcweir my @allfiles2 = (); 404cdf0e10cSrcweir my $maxhash = (); 405cdf0e10cSrcweir 406cdf0e10cSrcweir my $minor = ""; 407cdf0e10cSrcweir my $workstamp = ""; 408cdf0e10cSrcweir 409cdf0e10cSrcweir if ( $ENV{'WORK_STAMP'} ) { $workstamp = $ENV{'WORK_STAMP'}; } 410cdf0e10cSrcweir if ( $ENV{'UPDMINOR'} ) { $minor = $ENV{'UPDMINOR'}; } 411cdf0e10cSrcweir 412cdf0e10cSrcweir if ( $minor eq "" ) { installer::exiter::exit_program("ERROR: Environment variable \"UPDMINOR\" not set!", "filter_all_files_with_correct_settings"); } 413cdf0e10cSrcweir if ( $workstamp eq "" ) { installer::exiter::exit_program("ERROR: Environment variable \"WORK_STAMP\" not set!", "filter_all_files_with_correct_settings"); } 414cdf0e10cSrcweir 415cdf0e10cSrcweir foreach my $onefile ( @{$allfollowmefiles} ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir if (( $onefile =~ /_\Q$minor\E_/i ) && ( $onefile =~ /_\Q$workstamp\E_/i )) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir push(@allfiles, $onefile); 420cdf0e10cSrcweir 421cdf0e10cSrcweir # also collecting maximum hash 422cdf0e10cSrcweir 423cdf0e10cSrcweir if ( $onefile =~ /follow_me_(\d+)_\Q$workstamp\E_\Q$minor\E_([-\w]+)\.log\s*$/i ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir my $sequence = $1; 426cdf0e10cSrcweir my $lang = $2; 427cdf0e10cSrcweir 428cdf0e10cSrcweir if (( ! exists($maxhash{$lang})) || ( $maxhash{$lang} < $sequence )) { $maxhash{$lang} = $sequence; } 429cdf0e10cSrcweir } 430cdf0e10cSrcweir } 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir # second run, because of sequence numbers 434cdf0e10cSrcweir 435cdf0e10cSrcweir foreach my $onefile ( @allfiles ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir if ( $onefile =~ /follow_me_(\d+)_\Q$workstamp\E_\Q$minor\E_([-\w]+)\.log\s*$/i ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir my $sequence = $1; 440cdf0e10cSrcweir my $lang = $2; 441cdf0e10cSrcweir 442cdf0e10cSrcweir if ( $sequence == $maxhash{$lang} ) { push(@allfiles2, $onefile); } 443cdf0e10cSrcweir } 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir return ( \@allfiles2 ); 447cdf0e10cSrcweir} 448cdf0e10cSrcweir 449cdf0e10cSrcweir######################################################### 450cdf0e10cSrcweir# Creating a list of products, that need to be signed 451cdf0e10cSrcweir# or for which download sets need to be created. 452cdf0e10cSrcweir######################################################### 453cdf0e10cSrcweir 454cdf0e10cSrcweirsub createproductlist 455cdf0e10cSrcweir{ 456cdf0e10cSrcweir # If "-d" specifies an installation set, there is only one product 457cdf0e10cSrcweir 458cdf0e10cSrcweir my @infofilelist = (); 459cdf0e10cSrcweir my @infofilelist2 = (); 460cdf0e10cSrcweir 461cdf0e10cSrcweir if ( -f $installer::globals::followmeinfofilename ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir push(@infofilelist, $installer::globals::followmeinfofilename); 464cdf0e10cSrcweir # Saving info, that this is a file 465cdf0e10cSrcweir $installer::globals::followme_from_directory = 0; 466cdf0e10cSrcweir } 467cdf0e10cSrcweir elsif ( -d $installer::globals::followmeinfofilename ) 468cdf0e10cSrcweir { 469*b274bc22SAndre Fischer $installer::logger::Info->printf("\n"); 470*b274bc22SAndre Fischer $installer::logger::Info->printf("... reading directory: %s ...\n", $installer::globals::followmeinfofilename); 471cdf0e10cSrcweir $installer::globals::followmeinfofilename =~ s/$installer::globals::separator\s*$//; 472cdf0e10cSrcweir my $allfollowmefiles = installer::systemactions::find_file_with_file_extension("log", $installer::globals::followmeinfofilename); 473cdf0e10cSrcweir 474cdf0e10cSrcweir if ( ! ( $#{$allfollowmefiles} > -1 )) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir installer::logger::print_error( "Error: Nothing to do! No follow-me file in directory \"$installer::globals::followmeinfofilename\"!.\n" ); 477cdf0e10cSrcweir usage(); 478cdf0e10cSrcweir exit(-1); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir # Saving info, that this is a directory 482cdf0e10cSrcweir $installer::globals::followme_from_directory = 1; 483cdf0e10cSrcweir 484cdf0e10cSrcweir # Collect all possible installation sets 485cdf0e10cSrcweir # CWS: All installation sets 486cdf0e10cSrcweir # Master: All installation sets with same major, minor and buildid. Additionally using the highest number. 487cdf0e10cSrcweir 488cdf0e10cSrcweir my $iscws = check_cws_build(${$allfollowmefiles}[0]); 489cdf0e10cSrcweir 490cdf0e10cSrcweir if ( $iscws ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir # Simply read all follow-me files and check existence of installation sets 493cdf0e10cSrcweir foreach my $onefile ( @{$allfollowmefiles} ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir my $fullfilename = $installer::globals::followmeinfofilename . $installer::globals::separator . $onefile; 496cdf0e10cSrcweir my $installdir = get_property_from_file($fullfilename, "finalinstalldir"); 497cdf0e10cSrcweir if (( $installdir ne "" ) && ( -d $installdir )) { push(@infofilelist2, $fullfilename); } 498cdf0e10cSrcweir } 499cdf0e10cSrcweir } 500cdf0e10cSrcweir else 501cdf0e10cSrcweir { 502cdf0e10cSrcweir $allfollowmefiles = filter_all_files_with_correct_settings($allfollowmefiles); 503cdf0e10cSrcweir 504cdf0e10cSrcweir foreach my $onefile ( @{$allfollowmefiles} ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir my $fullfilename = $installer::globals::followmeinfofilename . $installer::globals::separator . $onefile; 507cdf0e10cSrcweir # Check, if installation set still exists 508cdf0e10cSrcweir my $installdir = get_property_from_file($fullfilename, "finalinstalldir"); 509cdf0e10cSrcweir if (( $installdir ne "" ) && ( -d $installdir )) { push(@infofilelist2, $fullfilename); } 510cdf0e10cSrcweir } 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir # Removing all files, starting with "follow_me_success_" in their names. This have already been used successfully. 514cdf0e10cSrcweir 515cdf0e10cSrcweir foreach my $onefile ( @infofilelist2 ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir if ( $onefile =~ /follow_me_success_/ ) { next; } 518cdf0e10cSrcweir push(@infofilelist, $onefile); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir # Checking, if there is content in the list 522cdf0e10cSrcweir if ( ! ( $#infofilelist > -1 )) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir installer::logger::print_error( "Error: Nothing to do! No installation set found for follow-me files in directory \"$installer::globals::followmeinfofilename\"!.\n" ); 525cdf0e10cSrcweir usage(); 526cdf0e10cSrcweir exit(-1); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir } 529cdf0e10cSrcweir else 530cdf0e10cSrcweir { 531cdf0e10cSrcweir installer::logger::print_error( "Error: Nothing to do! \"$installer::globals::followmeinfofilename\" is no file and no directory (-d).\n" ); 532cdf0e10cSrcweir usage(); 533cdf0e10cSrcweir exit(-1); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir return \@infofilelist; 537cdf0e10cSrcweir} 538cdf0e10cSrcweir 539cdf0e10cSrcweir############################################# 540cdf0e10cSrcweir# Logging the content of the download hash 541cdf0e10cSrcweir############################################# 542cdf0e10cSrcweir 543cdf0e10cSrcweirsub logfollowmeinfohash 544cdf0e10cSrcweir{ 545cdf0e10cSrcweir my ( $followmehash ) = @_; 546cdf0e10cSrcweir 547*b274bc22SAndre Fischer $installer::logger::Info->printf("\n"); 548*b274bc22SAndre Fischer $installer::logger::Info->printf("*****************************************\n"); 549*b274bc22SAndre Fischer $installer::logger::Info->printf("Content of follow-me info file:\n"); 550*b274bc22SAndre Fischer $installer::logger::Info->printf("finalinstalldir: %s\n", $followmehash->{'finalinstalldir'}); 551*b274bc22SAndre Fischer $installer::logger::Info->printf("downloadname: %s\n", $followmehash->{'downloadname'}); 552*b274bc22SAndre Fischer $installer::logger::Info->printf("languagestring: %s\n", $followmehash->{'languagestring'}); 553*b274bc22SAndre Fischer foreach my $lang ( @{$followmehash->{'languagesarray'}} ) 554*b274bc22SAndre Fischer { 555*b274bc22SAndre Fischer $installer::logger::Info->printf("languagesarray: %s\n", $lang); 556*b274bc22SAndre Fischer } 557*b274bc22SAndre Fischer foreach my $path ( @{$followmehash->{'includepatharray'}} ) 558*b274bc22SAndre Fischer { 559*b274bc22SAndre Fischer $installer::logger::Info->printf("includepatharray: %s\n", $path); 560*b274bc22SAndre Fischer } 561*b274bc22SAndre Fischer foreach my $key ( sort keys %{$followmehash->{'allvariableshash'}} ) 562*b274bc22SAndre Fischer { 563*b274bc22SAndre Fischer $installer::logger::Info->printf("allvariableshash: %s : %s\n", 564*b274bc22SAndre Fischer $key, 565*b274bc22SAndre Fischer $followmehash->{'allvariableshash'}->{$key}); 566*b274bc22SAndre Fischer } 567cdf0e10cSrcweir} 568cdf0e10cSrcweir 569cdf0e10cSrcweir######################################################################## 570cdf0e10cSrcweir# Renaming the follow me info file, if it was successfully used. 571cdf0e10cSrcweir# This can only be done, if the parameter "-d" was used with a 572cdf0e10cSrcweir# directory, not a name. In this case the repeated use of parameter 573cdf0e10cSrcweir# "-d" with this directory has to ignore this already successfully 574cdf0e10cSrcweir# used file. 575cdf0e10cSrcweir######################################################################## 576cdf0e10cSrcweir 577cdf0e10cSrcweirsub rename_followme_infofile 578cdf0e10cSrcweir{ 579cdf0e10cSrcweir my ( $filename ) = @_; 580cdf0e10cSrcweir 581cdf0e10cSrcweir my $newfilename = $filename; 582cdf0e10cSrcweir $newfilename =~ s/follow_me_/follow_me_success_/; # including "_success" after "follow_me" 583cdf0e10cSrcweir 584cdf0e10cSrcweir if ( $filename ne $newfilename ) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir my $returnvalue = rename($filename, $newfilename); 587*b274bc22SAndre Fischer if ( $returnvalue ) 588*b274bc22SAndre Fischer { 589*b274bc22SAndre Fischer $installer::logger::Info->printf("\n"); 590*b274bc22SAndre Fischer $installer::logger::Info->printf("... renamed file \"%s\" to \"%s\" ...\n", $filename, $newfilename); 591*b274bc22SAndre Fischer } 592cdf0e10cSrcweir } 593cdf0e10cSrcweir} 594cdf0e10cSrcweir 595cdf0e10cSrcweir1; 596