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