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