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::control; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse Cwd; 27cdf0e10cSrcweiruse installer::converter; 28cdf0e10cSrcweiruse installer::exiter; 29cdf0e10cSrcweiruse installer::files; 30cdf0e10cSrcweiruse installer::globals; 31cdf0e10cSrcweiruse installer::pathanalyzer; 32cdf0e10cSrcweiruse installer::scriptitems; 33cdf0e10cSrcweiruse installer::systemactions; 34cdf0e10cSrcweir 35b274bc22SAndre Fischerour @ErrorMessages = undef; 36b274bc22SAndre Fischer 37cdf0e10cSrcweir######################################################### 38cdf0e10cSrcweir# Function that can be used for additional controls. 39cdf0e10cSrcweir# Search happens in $installer::globals::patharray. 40cdf0e10cSrcweir######################################################### 41cdf0e10cSrcweir 42cdf0e10cSrcweirsub check_needed_files_in_path 43cdf0e10cSrcweir{ 44cdf0e10cSrcweir my ( $filesref ) = @_; 45b274bc22SAndre Fischer 46b274bc22SAndre Fischer my $error = 0; 47b274bc22SAndre Fischer foreach my $onefile ( @{$filesref} ) 48cdf0e10cSrcweir { 49b274bc22SAndre Fischer $installer::logger::Info->printf("...... searching %s ...\n", $onefile); 50cdf0e10cSrcweir 51cdf0e10cSrcweir my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$onefile, $installer::globals::patharray , 0); 52cdf0e10cSrcweir 53cdf0e10cSrcweir if ( $$fileref eq "" ) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir $error = 1; 56cdf0e10cSrcweir installer::logger::print_error( "$onefile not found\n" ); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir else 59cdf0e10cSrcweir { 60b274bc22SAndre Fischer $installer::logger::Info->print( "\tFound: $$fileref\n" ); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir if ( $error ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Could not find all needed files in path!", "check_needed_files_in_path"); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir} 69cdf0e10cSrcweir 70cdf0e10cSrcweir######################################################### 71cdf0e10cSrcweir# Checking the local system 72cdf0e10cSrcweir# Checking existence of needed files in include path 73cdf0e10cSrcweir######################################################### 74cdf0e10cSrcweir 75cdf0e10cSrcweirsub check_system_path 76cdf0e10cSrcweir{ 77cdf0e10cSrcweir # The following files have to be found in the environment variable PATH 78cdf0e10cSrcweir # All platforms: zip 79cdf0e10cSrcweir # Windows only: "msiinfo.exe", "msidb.exe", "uuidgen.exe", "makecab.exe", "msitran.exe", "expand.exe" for msi database and packaging 80cdf0e10cSrcweir 81cdf0e10cSrcweir my $onefile; 82cdf0e10cSrcweir my $error = 0; 83cdf0e10cSrcweir my $pathvariable = $ENV{'PATH'}; 84cdf0e10cSrcweir my $local_pathseparator = $installer::globals::pathseparator; 85cdf0e10cSrcweir 86cdf0e10cSrcweir if( $^O =~ /cygwin/i ) 87cdf0e10cSrcweir { # When using cygwin's perl the PATH variable is POSIX style and ... 88cdf0e10cSrcweir $pathvariable = qx{cygpath -mp "$pathvariable"} ; 89cdf0e10cSrcweir # has to be converted to DOS style for further use. 90cdf0e10cSrcweir $local_pathseparator = ';'; 91cdf0e10cSrcweir } 92dfa12748SYuri Dario if( $^O =~ /os2/i ) 93dfa12748SYuri Dario { 94dfa12748SYuri Dario # has to be converted to DOS style for further use. 95dfa12748SYuri Dario $local_pathseparator = ';'; 96dfa12748SYuri Dario } 97cdf0e10cSrcweir my $patharrayref = installer::converter::convert_stringlist_into_array(\$pathvariable, $local_pathseparator); 98cdf0e10cSrcweir 99cdf0e10cSrcweir $installer::globals::patharray = $patharrayref; 100cdf0e10cSrcweir 101cdf0e10cSrcweir my @needed_files_in_path = (); 102cdf0e10cSrcweir 103cdf0e10cSrcweir if (($installer::globals::iswin) && ($installer::globals::iswindowsbuild)) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir @needed_files_in_path = ("zip.exe", "msiinfo.exe", "msidb.exe", "uuidgen.exe", "makecab.exe", "msitran.exe", "expand.exe"); 106cdf0e10cSrcweir } 107dfa12748SYuri Dario elsif ($installer::globals::iswin || $installer::globals::isos2) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir @needed_files_in_path = ("zip.exe"); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir else 112cdf0e10cSrcweir { 113cdf0e10cSrcweir @needed_files_in_path = ("zip"); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir foreach $onefile ( @needed_files_in_path ) 117cdf0e10cSrcweir { 118b274bc22SAndre Fischer $installer::logger::Info->printf("...... searching %s ...\n", $onefile); 119cdf0e10cSrcweir 120cdf0e10cSrcweir my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$onefile, $patharrayref , 0); 121cdf0e10cSrcweir 122cdf0e10cSrcweir if ( $$fileref eq "" ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir $error = 1; 125cdf0e10cSrcweir installer::logger::print_error( "$onefile not found\n" ); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir else 128cdf0e10cSrcweir { 129b274bc22SAndre Fischer $installer::logger::Info->print( "\tFound: $$fileref\n" ); 130cdf0e10cSrcweir # Saving the absolut path for msitran.exe. This is required for the determination of the checksum. 131cdf0e10cSrcweir if ( $onefile eq "msitran.exe" ) { $installer::globals::msitranpath = $$fileref; } 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir if ( $error ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Could not find all needed files in path!", "check_system_path"); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir # checking for epm, which has to be in the path or in the solver 141cdf0e10cSrcweir 142cdf0e10cSrcweir if (( $installer::globals::call_epm ) && (!($installer::globals::iswindowsbuild))) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir my $onefile = "epm"; 145cdf0e10cSrcweir my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onefile, $patharrayref , 0); 146cdf0e10cSrcweir if (!( $$fileref eq "" )) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir $installer::globals::epm_in_path = 1; 149cdf0e10cSrcweir 150cdf0e10cSrcweir if ( $$fileref =~ /^\s*\.\/epm\s*$/ ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir my $currentdir = cwd(); 153cdf0e10cSrcweir $$fileref =~ s/\./$currentdir/; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir $installer::globals::epm_path = $$fileref; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir # checking, if upx can be found in path 161cdf0e10cSrcweir 162cdf0e10cSrcweir if ( $installer::globals::iswindowsbuild ) { $installer::globals::upxfile = "upx.exe"; } 163cdf0e10cSrcweir else { $installer::globals::upxfile = "upx"; } 164cdf0e10cSrcweir 165cdf0e10cSrcweir my $upxfilename = $installer::globals::upxfile; 166cdf0e10cSrcweir my $upxfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$upxfilename, $patharrayref , 0); 167cdf0e10cSrcweir 168cdf0e10cSrcweir if (!( $$upxfileref eq "" )) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir $installer::globals::upx_in_path = 1; 171cdf0e10cSrcweir $installer::globals::upxfile = $$upxfileref; 172b274bc22SAndre Fischer $installer::logger::Info->print( "\tFound: $$upxfileref\n" ); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir} 176cdf0e10cSrcweir 177cdf0e10cSrcweir###################################################################### 178cdf0e10cSrcweir# Determining the version of file makecab.exe 179cdf0e10cSrcweir###################################################################### 180cdf0e10cSrcweir 181cdf0e10cSrcweirsub get_makecab_version 182cdf0e10cSrcweir{ 183cdf0e10cSrcweir my $makecabversion = -1; 184cdf0e10cSrcweir 185cdf0e10cSrcweir my $systemcall = "makecab.exe |"; 186cdf0e10cSrcweir my @makecaboutput = (); 187cdf0e10cSrcweir 188cdf0e10cSrcweir open (CAB, $systemcall); 189cdf0e10cSrcweir while (<CAB>) { push(@makecaboutput, $_); } 190cdf0e10cSrcweir close (CAB); 191cdf0e10cSrcweir 192cdf0e10cSrcweir my $returnvalue = $?; # $? contains the return value of the systemcall 193cdf0e10cSrcweir 194cdf0e10cSrcweir if ($returnvalue) 195cdf0e10cSrcweir { 196b274bc22SAndre Fischer $installer::logger::Global->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir else 199cdf0e10cSrcweir { 200b274bc22SAndre Fischer $installer::logger::Global->printf("Success: Executed \"%s\" successfully!\n", $systemcall); 201cdf0e10cSrcweir 202cdf0e10cSrcweir my $versionline = ""; 203cdf0e10cSrcweir 204cdf0e10cSrcweir for ( my $i = 0; $i <= $#makecaboutput; $i++ ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir if ( $makecaboutput[$i] =~ /\bVersion\b/i ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir $versionline = $makecaboutput[$i]; 209cdf0e10cSrcweir last; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212b274bc22SAndre Fischer 213b274bc22SAndre Fischer $installer::logger::Global->printf("%s\n", $versionline); 214cdf0e10cSrcweir 215cdf0e10cSrcweir if ( $versionline =~ /\bVersion\b\s+(\d+[\d\.]+\d+)\s+/ ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir $makecabversion = $1; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir # Only using the first number 221cdf0e10cSrcweir 222cdf0e10cSrcweir if ( $makecabversion =~ /^\s*(\d+?)\D*/ ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir $makecabversion = $1; 225cdf0e10cSrcweir } 226b274bc22SAndre Fischer 227b274bc22SAndre Fischer $installer::logger::Global->printf("Using version: %s\n", $makecabversion); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir return $makecabversion; 231cdf0e10cSrcweir} 232cdf0e10cSrcweir 233cdf0e10cSrcweir###################################################################### 234cdf0e10cSrcweir# Checking the version of file makecab.exe 235cdf0e10cSrcweir###################################################################### 236cdf0e10cSrcweir 237cdf0e10cSrcweirsub check_makecab_version 238cdf0e10cSrcweir{ 239cdf0e10cSrcweir # checking version of makecab.exe 240cdf0e10cSrcweir # Now it is guaranteed, that makecab.exe is in the path 241cdf0e10cSrcweir 242cdf0e10cSrcweir my $do_check = 1; 243cdf0e10cSrcweir 244cdf0e10cSrcweir my $makecabversion = get_makecab_version(); 245cdf0e10cSrcweir 246b274bc22SAndre Fischer $installer::logger::Global->printf("Tested version: %s\n", $installer::globals::controlledmakecabversion); 247cdf0e10cSrcweir 248cdf0e10cSrcweir if ( $makecabversion < 0 ) { $do_check = 0; } # version could not be determined 249cdf0e10cSrcweir 250cdf0e10cSrcweir if ( $do_check ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir if ( $makecabversion < $installer::globals::controlledmakecabversion ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir # warning for OOo, error for inhouse products 255cdf0e10cSrcweir if ( $installer::globals::isopensourceproduct ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir installer::logger::print_warning("Old version of makecab.exe. Found version: \"$makecabversion\", tested version: \"$installer::globals::controlledmakecabversion\"!\n"); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir else 260cdf0e10cSrcweir { 261cdf0e10cSrcweir installer::exiter::exit_program("makecab.exe too old. Found version: \"$makecabversion\", required version: \"$installer::globals::controlledmakecabversion\"!", "check_makecab_version"); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir } 265cdf0e10cSrcweir else 266cdf0e10cSrcweir { 267b274bc22SAndre Fischer $installer::logger::Global->print("Warning: No version check of makecab.exe\n"); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir} 270cdf0e10cSrcweir 271cdf0e10cSrcweir###################################################################### 272cdf0e10cSrcweir# Reading the environment variables for the pathes in ziplist. 273cdf0e10cSrcweir# solarpath, solarenvpath, solarcommonpath, os, osdef, pmiscpath 274cdf0e10cSrcweir###################################################################### 275cdf0e10cSrcweir 276cdf0e10cSrcweirsub check_system_environment 277cdf0e10cSrcweir{ 278cdf0e10cSrcweir my %variables = (); 279cdf0e10cSrcweir my $key; 280cdf0e10cSrcweir my $error = 0; 281cdf0e10cSrcweir 282cdf0e10cSrcweir foreach $key ( @installer::globals::environmentvariables ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir my $value = ""; 285cdf0e10cSrcweir if ( $ENV{$key} ) { $value = $ENV{$key}; } 286cdf0e10cSrcweir $variables{$key} = $value; 287cdf0e10cSrcweir 288cdf0e10cSrcweir if ( $value eq "" ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir installer::logger::print_error( "$key not set in environment\n" ); 291cdf0e10cSrcweir $error = 1; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir if ( $error ) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Environment variable not set!", "check_system_environment"); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir return \%variables; 301cdf0e10cSrcweir} 302cdf0e10cSrcweir 303cdf0e10cSrcweir 304b274bc22SAndre Fischersub prepare_error_processing () 305cdf0e10cSrcweir{ 306b274bc22SAndre Fischer @ErrorMessages = (); 307b274bc22SAndre Fischer} 308cdf0e10cSrcweir 309b274bc22SAndre Fischer=item filter_log_error ($relative_time, $log_id, $process_id, $message) 310cdf0e10cSrcweir 311b274bc22SAndre Fischer Process the given log message. Returns $message unaltered. 312b274bc22SAndre Fischer 313b274bc22SAndre Fischer=cut 314b274bc22SAndre Fischersub filter_log_error ($$$$) 315b274bc22SAndre Fischer{ 316b274bc22SAndre Fischer my ($relative_time, $log_id, $process_id, $message) = @_; 317b274bc22SAndre Fischer 318b274bc22SAndre Fischer if ($message =~ /\berror\b/i) 319b274bc22SAndre Fischer { 320b274bc22SAndre Fischer # Message contains the word "error". Now we have to find out if it is relevant. 321b274bc22SAndre Fischer 322b274bc22SAndre Fischer # Remove all filenames that contain the word "Error". 323b274bc22SAndre Fischer my $work_string = $message; 324e50a3cc3SAndre Fischer $work_string =~ s/Error\.(idt|mlf|ulf|idl|html|hpp|ipp)//g; 325cdf0e10cSrcweir 326b274bc22SAndre Fischer if ($work_string =~ /\bError\b/i) 327cdf0e10cSrcweir { 328b274bc22SAndre Fischer # This really is an error message. 329b274bc22SAndre Fischer push @ErrorMessages, {'relative_time' => $relative_time, 330b274bc22SAndre Fischer 'message' => $message}; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334b274bc22SAndre Fischer return $message; 335b274bc22SAndre Fischer} 336cdf0e10cSrcweir 337b274bc22SAndre Fischer 338b274bc22SAndre Fischer 339b274bc22SAndre Fischer 340b274bc22SAndre Fischersub printocessed_error_lines () 341b274bc22SAndre Fischer{ 342b274bc22SAndre Fischer my $lines = []; 343b274bc22SAndre Fischer 344b274bc22SAndre Fischer foreach my $line (@ErrorMessages) 345b274bc22SAndre Fischer { 346b274bc22SAndre Fischer push @$lines, sprintf(" %12.6f : %s", $line->{'relative_time'}, $line->{'message'}); 347b274bc22SAndre Fischer } 348b274bc22SAndre Fischer 349b274bc22SAndre Fischer return $lines; 350b274bc22SAndre Fischer} 351b274bc22SAndre Fischer 352b274bc22SAndre Fischer 353b274bc22SAndre Fischer 354b274bc22SAndre Fischer 355b274bc22SAndre Fischer=item check_logfile() 356b274bc22SAndre Fischer 357b274bc22SAndre Fischer Print all error messages (typically at the end) on the console. 358b274bc22SAndre Fischer 359b274bc22SAndre Fischer=cut 360b274bc22SAndre Fischersub check_logfile () 361b274bc22SAndre Fischer{ 362b274bc22SAndre Fischer my ($logfile) = @_; 363b274bc22SAndre Fischer 364b274bc22SAndre Fischer my @errors = (); 365b274bc22SAndre Fischer my @output = (); 366b274bc22SAndre Fischer 367b274bc22SAndre Fischer my $ignore_errors = ( ! $installer::globals::pro ) && ( $installer::globals::ignore_error_in_logfile ); 368b274bc22SAndre Fischer my $contains_errors = scalar @ErrorMessages > 0; 369b274bc22SAndre Fischer 370b274bc22SAndre Fischer # Format errors 371b274bc22SAndre Fischer if ($contains_errors) 372b274bc22SAndre Fischer { 373b274bc22SAndre Fischer push(@output, "\n"); 374b274bc22SAndre Fischer push(@output, "*********************************************************************\n"); 375b274bc22SAndre Fischer if ($ignore_errors) 376b274bc22SAndre Fischer { 377b274bc22SAndre Fischer push(@output, "The following errors in the log file were ignored:\n"); 378b274bc22SAndre Fischer } 379b274bc22SAndre Fischer else 380b274bc22SAndre Fischer { 381b274bc22SAndre Fischer push(@output, "ERROR: The following errors occured in packaging process:\n"); 382b274bc22SAndre Fischer } 383b274bc22SAndre Fischer push(@output, "\n"); 384b274bc22SAndre Fischer 385b274bc22SAndre Fischer foreach my $line (@ErrorMessages) 386b274bc22SAndre Fischer { 387b274bc22SAndre Fischer push @output, sprintf(" %12.6f : %s", $line->{'relative_time'}, $line->{'message'}); 388b274bc22SAndre Fischer } 389cdf0e10cSrcweir 390b274bc22SAndre Fischer push(@output, "*********************************************************************\n"); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393b274bc22SAndre Fischer # Claim success if there where no errors or if errors are treated as warnings. 394b274bc22SAndre Fischer if ( ! $contains_errors || $ignore_errors) 395b274bc22SAndre Fischer { 396b274bc22SAndre Fischer push(@output, "\n"); 397b274bc22SAndre Fischer push(@output, "***********************************************************\n"); 398b274bc22SAndre Fischer push(@output, "Successful packaging process!\n"); 399b274bc22SAndre Fischer push(@output, "***********************************************************\n"); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402b274bc22SAndre Fischer # Print the summary. 403cdf0e10cSrcweir installer::logger::include_header_into_logfile("Summary:"); 404cdf0e10cSrcweir my $force = 1; # print this message even in 'quiet' mode 405b274bc22SAndre Fischer foreach my $line (@output) 406cdf0e10cSrcweir { 407b274bc22SAndre Fischer $installer::logger::Info->print($line, $force); 408cdf0e10cSrcweir } 409b274bc22SAndre Fischer 410b274bc22SAndre Fischer # Delete the accumulated error messages. The @ErrorMessages will now contain 411b274bc22SAndre Fischer # lines caused by printing those error messages. 412b274bc22SAndre Fischer @ErrorMessages = (); 413b274bc22SAndre Fischer 414b274bc22SAndre Fischer @installer::globals::errorlogfileinfo = @output; 415cdf0e10cSrcweir 416b274bc22SAndre Fischer return $contains_error && ! $ignore_error; 417cdf0e10cSrcweir} 418cdf0e10cSrcweir 419cdf0e10cSrcweir############################################################# 420cdf0e10cSrcweir# Determining the ship installation directory 421cdf0e10cSrcweir############################################################# 422cdf0e10cSrcweir 423cdf0e10cSrcweirsub determine_ship_directory 424cdf0e10cSrcweir{ 425cdf0e10cSrcweir my ($languagesref) = @_; 426cdf0e10cSrcweir 427cdf0e10cSrcweir if (!( $ENV{'SHIPDRIVE'} )) { installer::exiter::exit_program("ERROR: SHIPDRIVE must be set for updater!", "determine_ship_directory"); } 428cdf0e10cSrcweir 429cdf0e10cSrcweir my $shipdrive = $ENV{'SHIPDRIVE'}; 430cdf0e10cSrcweir 431cdf0e10cSrcweir my $languagestring = $$languagesref; 432cdf0e10cSrcweir 433cdf0e10cSrcweir if (length($languagestring) > $installer::globals::max_lang_length ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir my $number_of_languages = installer::systemactions::get_number_of_langs($languagestring); 436cdf0e10cSrcweir chomp(my $shorter = `echo $languagestring | md5sum | sed -e "s/ .*//g"`); 437cdf0e10cSrcweir # $languagestring = $shorter; 438cdf0e10cSrcweir my $id = substr($shorter, 0, 8); # taking only the first 8 digits 439cdf0e10cSrcweir $languagestring = "lang_" . $number_of_languages . "_id_" . $id; 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir my $productstring = $installer::globals::product; 443cdf0e10cSrcweir my $productsubdir = ""; 444cdf0e10cSrcweir 445cdf0e10cSrcweir if ( $productstring =~ /^\s*(.+?)\_\_(.+?)\s*$/ ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir $productstring = $1; 448cdf0e10cSrcweir $productsubdir = $2; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir if ( $installer::globals::languagepack ) { $productstring = $productstring . "_languagepack"; } 452cdf0e10cSrcweir if ( $installer::globals::patch ) { $productstring = $productstring . "_patch"; } 453cdf0e10cSrcweir 454cdf0e10cSrcweir my $destdir = $shipdrive . $installer::globals::separator . $installer::globals::compiler . 455cdf0e10cSrcweir $installer::globals::productextension . $installer::globals::separator . 456cdf0e10cSrcweir $productstring . $installer::globals::separator; 457cdf0e10cSrcweir 458cdf0e10cSrcweir if ( $productsubdir ) { $destdir = $destdir . $productsubdir . $installer::globals::separator; } 459cdf0e10cSrcweir 460cdf0e10cSrcweir $destdir = $destdir . $installer::globals::installertypedir . $installer::globals::separator . 461cdf0e10cSrcweir $installer::globals::build . "_" . $installer::globals::lastminor . "_" . 462cdf0e10cSrcweir "native_inprogress-number_" . $languagestring . "\." . $installer::globals::buildid; 463cdf0e10cSrcweir 464b274bc22SAndre Fischer $installer::logger::Global->print("\n"); 465b274bc22SAndre Fischer $installer::logger::Global->printf("Setting ship directory: %s\n", $destdir); 466cdf0e10cSrcweir 467cdf0e10cSrcweir return $destdir; 468cdf0e10cSrcweir} 469cdf0e10cSrcweir 470cdf0e10cSrcweir############################################################# 471cdf0e10cSrcweir# Controlling if this is an official RE pack process 472cdf0e10cSrcweir############################################################# 473cdf0e10cSrcweir 474cdf0e10cSrcweirsub check_updatepack 475cdf0e10cSrcweir{ 476cdf0e10cSrcweir my $shipdrive = ""; 477cdf0e10cSrcweir my $filename = ""; 478cdf0e10cSrcweir my $infoline = ""; 479cdf0e10cSrcweir 480cdf0e10cSrcweir if ( $ENV{'UPDATER'} ) # the environment variable UPDATER has to be set 481cdf0e10cSrcweir { 482b274bc22SAndre Fischer $installer::logger::Global->print("\n"); 483b274bc22SAndre Fischer $installer::logger::Global->print("Environment variable UPDATER set\n"); 484cdf0e10cSrcweir 485cdf0e10cSrcweir if ( ! $ENV{'CWS_WORK_STAMP'} ) # the environment variable CWS_WORK_STAMP must not be set (set only in CWS) 486cdf0e10cSrcweir { 487b274bc22SAndre Fischer $installer::logger::Global->print("Environment variable CWS_WORK_STAMP not set\n"); 488cdf0e10cSrcweir 489cdf0e10cSrcweir if ( $ENV{'SHIPDRIVE'} ) # the environment variable SHIPDRIVE must be set 490cdf0e10cSrcweir { 491cdf0e10cSrcweir $shipdrive = $ENV{'SHIPDRIVE'}; 492b274bc22SAndre Fischer $installer::logger::Global->printf("Ship drive defined: %s\n", $shipdrive); 493cdf0e10cSrcweir 494cdf0e10cSrcweir if ( -d $shipdrive ) # SHIPDRIVE must be a directory 495cdf0e10cSrcweir { 496b274bc22SAndre Fischer $installer::logger::Global->print("Ship drive exists\n"); 497cdf0e10cSrcweir 498cdf0e10cSrcweir # try to write into $shipdrive 499cdf0e10cSrcweir 500*01a01bd6SAndre Fischer my $directory = $installer::globals::product . "_" . $installer::globals::compiler . "_" . $installer::globals::buildid . "_" . $installer::globals::languageproduct . "_test_$$"; 501cdf0e10cSrcweir $directory =~ s/\,/\_/g; # for the list of languages 502cdf0e10cSrcweir $directory =~ s/\-/\_/g; # for en-US, pt-BR, ... 503cdf0e10cSrcweir $directory = $shipdrive . $installer::globals::separator . $directory; 504cdf0e10cSrcweir 505b274bc22SAndre Fischer $installer::logger::Global->printf("Try to create directory: %s\n", $directory); 506cdf0e10cSrcweir 507cdf0e10cSrcweir # saving this directory for later removal 508cdf0e10cSrcweir $installer::globals::shiptestdirectory = $directory; 509cdf0e10cSrcweir 510cdf0e10cSrcweir if ( installer::systemactions::try_to_create_directory($directory)) 511cdf0e10cSrcweir { 512b274bc22SAndre Fischer $installer::logger::Global->print("Write access on Ship drive\n"); 513b274bc22SAndre Fischer $installer::logger::Global->print( 514b274bc22SAndre Fischer "Ship test directory %s was successfully created\n", 515b274bc22SAndre Fischer $installer::globals::shiptestdirectory); 516cdf0e10cSrcweir my $systemcall = "rmdir $directory"; 517cdf0e10cSrcweir my $returnvalue = system($systemcall); 518cdf0e10cSrcweir 519cdf0e10cSrcweir # 5th condition: No local build environment. 520cdf0e10cSrcweir # In this case the content of SOLARENV starts with the content of SOL_TMP 521cdf0e10cSrcweir 522cdf0e10cSrcweir my $solarenv = ""; 523cdf0e10cSrcweir my $sol_tmp; 524cdf0e10cSrcweir if ( $ENV{'SOLARENV'} ) { $solarenv = $ENV{'SOLARENV'}; } 525cdf0e10cSrcweir 526b274bc22SAndre Fischer $installer::logger::Global->printf("Environment variable SOLARENV: %s\n", $solarenv); 527cdf0e10cSrcweir 528cdf0e10cSrcweir if ( $ENV{'SOL_TMP'} ) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir $sol_tmp = $ENV{'SOL_TMP'}; 531cdf0e10cSrcweir $infoline = "Environment variable SOL_TMP: $sol_tmp\n"; 532cdf0e10cSrcweir } else { 533cdf0e10cSrcweir $infoline = "Environment variable SOL_TMP not set\n"; 534cdf0e10cSrcweir } 535b274bc22SAndre Fischer $installer::logger::Global->print($infoline); 536cdf0e10cSrcweir 537cdf0e10cSrcweir if ( defined $sol_tmp && ( $solarenv =~ /^\s*\Q$sol_tmp\E/ )) 538cdf0e10cSrcweir { 539b274bc22SAndre Fischer $installer::logger::Global->print("Content of SOLARENV starts with the content of SOL_TMP\: Local environment -\> No Updatepack\n"); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir else 542cdf0e10cSrcweir { 543b274bc22SAndre Fischer $installer::logger::Global->print("Content of SOLARENV does not start with the content of SOL_TMP: No local environment\n"); 544cdf0e10cSrcweir 545cdf0e10cSrcweir $installer::globals::updatepack = 1; # That's it 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir # Additional logging information for the temporary ship directory 549cdf0e10cSrcweir 550cdf0e10cSrcweir if ( -d $installer::globals::shiptestdirectory ) 551cdf0e10cSrcweir { 552b274bc22SAndre Fischer $installer::logger::Global->printf( 553b274bc22SAndre Fischer "Ship test directory %s still exists. Trying removal later again.\n", 554b274bc22SAndre Fischer $installer::globals::shiptestdirectory); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir else 557cdf0e10cSrcweir { 558b274bc22SAndre Fischer $installer::logger::Global->printf( 559b274bc22SAndre Fischer "Ship test directory %s was successfully removed.\n", 560b274bc22SAndre Fischer $installer::globals::shiptestdirectory); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir } 563cdf0e10cSrcweir else 564cdf0e10cSrcweir { 565b274bc22SAndre Fischer $installer::logger::Global->print("No write access on Ship drive\n"); 566b274bc22SAndre Fischer $installer::logger::Global->printf("Failed to create directory \n", $directory); 567b274bc22SAndre Fischer if ( defined $ENV{'BSCLIENT'} && ( uc $ENV{'BSCLIENT'} eq 'TRUE' ) ) 568b274bc22SAndre Fischer { 569cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No write access to SHIPDRIVE allthough BSCLIENT is set.", "check_updatepack"); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir } 572cdf0e10cSrcweir } 573cdf0e10cSrcweir else 574cdf0e10cSrcweir { 575b274bc22SAndre Fischer $installer::logger::Global->print("Ship drive not found: No updatepack\n"); 576cdf0e10cSrcweir } 577cdf0e10cSrcweir } 578cdf0e10cSrcweir else 579cdf0e10cSrcweir { 580b274bc22SAndre Fischer $installer::logger::Global->print("Environment variable SHIPDRIVE not set: No updatepack\n"); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir } 583cdf0e10cSrcweir else 584cdf0e10cSrcweir { 585b274bc22SAndre Fischer $installer::logger::Global->print("Environment variable CWS_WORK_STAMP defined: No updatepack\n"); 586cdf0e10cSrcweir } 587cdf0e10cSrcweir } 588cdf0e10cSrcweir 589b274bc22SAndre Fischer if ( $installer::globals::updatepack ) 590b274bc22SAndre Fischer { 591b274bc22SAndre Fischer $installer::logger::Global->print("Setting updatepack true\n"); 592b274bc22SAndre Fischer $installer::logger::Global->print("\n"); 593b274bc22SAndre Fischer } 594b274bc22SAndre Fischer else 595b274bc22SAndre Fischer { 596b274bc22SAndre Fischer $installer::logger::Global->print("\n"); 597b274bc22SAndre Fischer $installer::logger::Global->print("No updatepack\n"); 598b274bc22SAndre Fischer } 599cdf0e10cSrcweir 600cdf0e10cSrcweir} 601cdf0e10cSrcweir 602cdf0e10cSrcweir############################################################# 603cdf0e10cSrcweir# Reading the Windows list file for language encodings 604cdf0e10cSrcweir############################################################# 605cdf0e10cSrcweir 606cdf0e10cSrcweirsub read_encodinglist 607cdf0e10cSrcweir{ 608cdf0e10cSrcweir my ($patharrayref) = @_; 609cdf0e10cSrcweir 610cdf0e10cSrcweir my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$installer::globals::encodinglistname, $patharrayref , 0); 611cdf0e10cSrcweir 612cdf0e10cSrcweir if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Did not find Windows encoding list $installer::globals::encodinglistname!", "read_encodinglist"); } 613cdf0e10cSrcweir 614b274bc22SAndre Fischer $installer::logger::Global->printf("Found encoding file: %s\n", $$fileref); 615cdf0e10cSrcweir 616cdf0e10cSrcweir my $encodinglist = installer::files::read_file($$fileref); 617cdf0e10cSrcweir 618cdf0e10cSrcweir my %msiencoding = (); 619cdf0e10cSrcweir my %msilanguage = (); 620cdf0e10cSrcweir 621cdf0e10cSrcweir # Controlling the encoding list 622cdf0e10cSrcweir 623cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$encodinglist}; $i++ ) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir my $line = ${$encodinglist}[$i]; 626cdf0e10cSrcweir 627cdf0e10cSrcweir if ( $line =~ /^\s*\#/ ) { next; } # this is a comment line 628cdf0e10cSrcweir 629cdf0e10cSrcweir if ( $line =~ /^(.*?)(\#.*)$/ ) { $line = $1; } # removing comments after "#" 630cdf0e10cSrcweir 631cdf0e10cSrcweir if ( $line =~ /^\s*([\w-]+)\s*(\d+)\s*(\d+)\s*$/ ) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir my $onelanguage = $1; 634cdf0e10cSrcweir my $codepage = $2; 635cdf0e10cSrcweir my $windowslanguage = $3; 636cdf0e10cSrcweir 637cdf0e10cSrcweir $msiencoding{$onelanguage} = $codepage; 638cdf0e10cSrcweir $msilanguage{$onelanguage} = $windowslanguage; 639cdf0e10cSrcweir } 640cdf0e10cSrcweir else 641cdf0e10cSrcweir { 642cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Wrong syntax in Windows encoding list $installer::globals::encodinglistname : en-US 1252 1033 !", "read_encodinglist"); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir } 645cdf0e10cSrcweir 646cdf0e10cSrcweir $installer::globals::msiencoding = \%msiencoding; 647cdf0e10cSrcweir $installer::globals::msilanguage = \%msilanguage; 648cdf0e10cSrcweir 649cdf0e10cSrcweir # my $key; 650cdf0e10cSrcweir # foreach $key (keys %{$installer::globals::msiencoding}) { print "A Key: $key : Value: $installer::globals::msiencoding->{$key}\n"; } 651cdf0e10cSrcweir # foreach $key (keys %{$installer::globals::msilanguage}) { print "B Key: $key : Value: $installer::globals::msilanguage->{$key}\n"; } 652cdf0e10cSrcweir 653cdf0e10cSrcweir} 654cdf0e10cSrcweir 655cdf0e10cSrcweir############################################################# 656cdf0e10cSrcweir# Only for Windows and Linux (RPM)there is currently 657cdf0e10cSrcweir# a reliable mechanism to register extensions during 658cdf0e10cSrcweir# installation process. Therefore it is for all other 659cdf0e10cSrcweir# platforms forbidden to install oxt files into that 660cdf0e10cSrcweir# directory, in which they are searched for registration. 661cdf0e10cSrcweir############################################################# 662cdf0e10cSrcweir 663cdf0e10cSrcweirsub check_oxtfiles 664cdf0e10cSrcweir{ 665cdf0e10cSrcweir my ( $filesarray ) = @_; 666cdf0e10cSrcweir 667cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filesarray}; $i++ ) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir my $onefile = ${$filesarray}[$i]; 670cdf0e10cSrcweir 671cdf0e10cSrcweir if (( $onefile->{'Name'} ) && ( $onefile->{'Dir'} )) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir if (( $onefile->{'Name'} =~ /\.oxt\s*$/ ) && ( $onefile->{'Dir'} eq $installer::globals::extensioninstalldir )) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir installer::exiter::exit_program("There is currently only for Linux (RPM) and Windows a reliable mechanism to register extensions during installation.\nPlease remove file \"$onefile->{'gid'}\" from your installation set!\nYou can use \"\#ifdef WNT\" and \"\#ifdef LINUX\" in scp.", "check_oxtfiles"); 676cdf0e10cSrcweir } 677cdf0e10cSrcweir } 678cdf0e10cSrcweir } 679cdf0e10cSrcweir} 680cdf0e10cSrcweir 681cdf0e10cSrcweir############################################################# 682cdf0e10cSrcweir# Check if Java is available to create xpd installer 683cdf0e10cSrcweir############################################################# 684cdf0e10cSrcweir 685cdf0e10cSrcweirsub check_java_for_xpd 686cdf0e10cSrcweir{ 687cdf0e10cSrcweir my ( $allvariables ) = @_; 688cdf0e10cSrcweir 689cdf0e10cSrcweir if ( ! $installer::globals::solarjavaset ) { $allvariables->{'XPDINSTALLER'} = 0; } 690cdf0e10cSrcweir} 691cdf0e10cSrcweir 692cdf0e10cSrcweir#################################################################### 693cdf0e10cSrcweir# Setting global variable "$installer::globals::addchildprojects" 694cdf0e10cSrcweir#################################################################### 695cdf0e10cSrcweir 696cdf0e10cSrcweirsub set_addchildprojects 697cdf0e10cSrcweir{ 698cdf0e10cSrcweir my ($allvariables) = @_; 699cdf0e10cSrcweir 700cdf0e10cSrcweir if (( $allvariables->{'JAVAPRODUCT'} ) || 701cdf0e10cSrcweir ( $allvariables->{'ADAPRODUCT'} ) || 702cdf0e10cSrcweir ( $allvariables->{'UREPRODUCT'} ) || 703cdf0e10cSrcweir ( $allvariables->{'ADDREQUIREDPACKAGES'} )) { $installer::globals::addchildprojects = 1; } 704cdf0e10cSrcweir 705cdf0e10cSrcweir if ( $installer::globals::patch ) 706cdf0e10cSrcweir { 707cdf0e10cSrcweir $installer::globals::addchildprojects = 0; # no child projects for patches 708cdf0e10cSrcweir } 709cdf0e10cSrcweir 710b274bc22SAndre Fischer $installer::logger::Global->printf( 711b274bc22SAndre Fischer "Value of \$installer::globals::addchildprojects: %s\n", 712b274bc22SAndre Fischer $installer::globals::addchildprojects); 713cdf0e10cSrcweir} 714cdf0e10cSrcweir 715cdf0e10cSrcweir#################################################################### 716cdf0e10cSrcweir# Setting global variable "$installer::globals::addjavainstaller" 717cdf0e10cSrcweir#################################################################### 718cdf0e10cSrcweir 719cdf0e10cSrcweirsub set_addjavainstaller 720cdf0e10cSrcweir{ 721cdf0e10cSrcweir my ($allvariables) = @_; 722cdf0e10cSrcweir 723cdf0e10cSrcweir if ( $allvariables->{'JAVAINSTALLER'} ) { $installer::globals::addjavainstaller = 1; } 724cdf0e10cSrcweir 725cdf0e10cSrcweir if ( $installer::globals::patch ) { $installer::globals::addjavainstaller = 0; } 726cdf0e10cSrcweir if ( $installer::globals::languagepack ) { $installer::globals::addjavainstaller = 0; } 727cdf0e10cSrcweir if ( $allvariableshashref->{'XPDINSTALLER'} ) { $installer::globals::addjavainstaller = 0; } 728cdf0e10cSrcweir 729b274bc22SAndre Fischer $installer::logger::Global->printf( 730b274bc22SAndre Fischer "Value of \$installer::globals::addjavainstaller: %s\n", 731b274bc22SAndre Fischer $installer::globals::addjavainstaller); 732cdf0e10cSrcweir} 733cdf0e10cSrcweir 734cdf0e10cSrcweir####################################################################### 735cdf0e10cSrcweir# Setting global variable "$installer::globals::addsystemintegration" 736cdf0e10cSrcweir####################################################################### 737cdf0e10cSrcweir 738cdf0e10cSrcweirsub set_addsystemintegration 739cdf0e10cSrcweir{ 740cdf0e10cSrcweir my ($allvariables) = @_; 741cdf0e10cSrcweir 742cdf0e10cSrcweir if ( $allvariables->{'ADDSYSTEMINTEGRATION'} ) { $installer::globals::addsystemintegration = 1; } 743cdf0e10cSrcweir 744cdf0e10cSrcweir if ( $installer::globals::patch ) { $installer::globals::addsystemintegration = 0; } 745cdf0e10cSrcweir if ( $installer::globals::languagepack ) { $installer::globals::addsystemintegration = 0; } 746cdf0e10cSrcweir if (( $installer::globals::packageformat eq "native" ) || ( $installer::globals::packageformat eq "portable" )) { $installer::globals::addsystemintegration = 0; } 747cdf0e10cSrcweir 748b274bc22SAndre Fischer $installer::logger::Global->printf( 749b274bc22SAndre Fischer "Value of \$installer::globals::addsystemintegration: %s\n", 750b274bc22SAndre Fischer $installer::globals::addsystemintegration); 751cdf0e10cSrcweir} 752cdf0e10cSrcweir 753cdf0e10cSrcweir1; 754