1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24package installer::download; 25 26use File::Spec; 27use installer::exiter; 28use installer::files; 29use installer::globals; 30use installer::logger; 31use installer::pathanalyzer; 32use installer::remover; 33use installer::systemactions; 34 35use strict; 36 37BEGIN { # This is needed so that Cygwin's perl evaluates ACLs 38 # (needed for correctly evaluating the -x test.) 39 if( $^O =~ /cygwin/i ) { 40 require filetest; import filetest "access"; 41 } 42} 43 44################################################################## 45# Including the lowercase product name into the script template 46################################################################## 47 48sub put_productname_into_script 49{ 50 my ($scriptfile, $variableshashref) = @_; 51 52 my $productname = $variableshashref->{'PRODUCTNAME'}; 53 $productname = lc($productname); 54 $productname =~ s/\.//g; # openoffice.org -> openofficeorg 55 $productname =~ s/\s*//g; 56 57 $installer::logger::Lang->printf("Adding productname %s into download shell script\n", $productname); 58 59 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 60 { 61 ${$scriptfile}[$i] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; 62 } 63} 64 65######################################################### 66# Including the linenumber into the script template 67######################################################### 68 69sub put_linenumber_into_script 70{ 71 my ( $scriptfile ) = @_; 72 73 my $linenumber = $#{$scriptfile} + 2; 74 75 $installer::logger::Lang->printf("Adding linenumber %d into download shell script\n", $linenumber); 76 77 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 78 { 79 ${$scriptfile}[$i] =~ s/LINENUMBERPLACEHOLDER/$linenumber/; 80 } 81} 82 83######################################################### 84# Determining the name of the new scriptfile 85######################################################### 86 87sub determine_scriptfile_name 88{ 89 my ( $filename ) = @_; 90 91 $installer::globals::downloadfileextension = ".sh"; 92 $filename = $filename . $installer::globals::downloadfileextension; 93 $installer::globals::downloadfilename = $filename; 94 95 $installer::logger::Lang->printf("Setting download shell script file name to %s\n", $filename); 96 97 return $filename; 98} 99 100######################################################### 101# Saving the script file in the installation directory 102######################################################### 103 104sub save_script_file 105{ 106 my ($directory, $newscriptfilename, $scriptfile) = @_; 107 108 $newscriptfilename = $directory . $installer::globals::separator . $newscriptfilename; 109 installer::files::save_file($newscriptfilename, $scriptfile); 110 111 $installer::logger::Lang->printf("Saving script file %s\n", $newscriptfilename); 112 113 if ( ! $installer::globals::iswindowsbuild ) 114 { 115 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1"; 116 system($localcall); 117 } 118 119 return $newscriptfilename; 120} 121 122######################################################### 123# Including checksum and size into script file 124######################################################### 125 126sub put_checksum_and_size_into_script 127{ 128 my ($scriptfile, $sumout) = @_; 129 130 my $checksum = ""; 131 my $size = ""; 132 133 if ( $sumout =~ /^\s*(\d+)\s+(\d+)\s*$/ ) 134 { 135 $checksum = $1; 136 $size = $2; 137 } 138 else 139 { 140 installer::exiter::exit_program("ERROR: Incorrect return value from /usr/bin/sum: $sumout", "put_checksum_and_size_into_script"); 141 } 142 143 $installer::logger::Lang->printf( 144 "Adding checksum %s and size %s into download shell script\n", $checksum, $size); 145 146 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 147 { 148 ${$scriptfile}[$i] =~ s/CHECKSUMPLACEHOLDER/$checksum/; 149 ${$scriptfile}[$i] =~ s/DISCSPACEPLACEHOLDER/$size/; 150 } 151 152} 153 154######################################################### 155# Calling md5sum 156######################################################### 157 158sub call_md5sum 159{ 160 my ($filename) = @_; 161 162 my $md5sumfile = "/usr/bin/md5sum"; 163 164 if ( ! -f $md5sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/md5sum", "call_md5sum"); } 165 166 my $systemcall = "$md5sumfile $filename |"; 167 168 my $md5sumoutput = ""; 169 170 open (SUM, "$systemcall"); 171 $md5sumoutput = <SUM>; 172 close (SUM); 173 174 my $returnvalue = $?; # $? contains the return value of the systemcall 175 176 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 177 178 if ($returnvalue) 179 { 180 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 181 } 182 else 183 { 184 $installer::logger::Lang->print("Success: Executed \"%s\" successfully!\n", $systemcall); 185 } 186 187 return $md5sumoutput; 188} 189 190######################################################### 191# Calling md5sum 192######################################################### 193 194sub get_md5sum 195{ 196 my ($md5sumoutput) = @_; 197 198 my $md5sum; 199 200 if ( $md5sumoutput =~ /^\s*(\w+?)\s+/ ) 201 { 202 $md5sum = $1; 203 } 204 else 205 { 206 installer::exiter::exit_program("ERROR: Incorrect return value from /usr/bin/md5sum: $md5sumoutput", "get_md5sum"); 207 } 208 209 $installer::logger::Lang->printf("Setting md5sum: %s\n", $md5sum); 210 211 return $md5sum; 212} 213 214######################################################### 215# Determining checksum and size of tar file 216######################################################### 217 218sub call_sum 219{ 220 my ($filename, $getuidlibrary) = @_; 221 222 my $systemcall = "/usr/bin/sum $filename |"; 223 224 my $sumoutput = ""; 225 226 open (SUM, "$systemcall"); 227 $sumoutput = <SUM>; 228 close (SUM); 229 230 my $returnvalue = $?; # $? contains the return value of the systemcall 231 232 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 233 234 if ($returnvalue) 235 { 236 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 237 } 238 else 239 { 240 $installer::logger::Lang->printf("Success: Executed \"%s\" successfully!\n", $systemcall); 241 } 242 243 $sumoutput =~ s/\s+$filename\s$//; 244 return $sumoutput; 245} 246 247######################################################### 248# Searching for the getuid.so in the solver 249######################################################### 250 251sub get_path_for_library 252{ 253 my ($includepatharrayref) = @_; 254 255 my $getuidlibraryname = "getuid.so"; 256 257 my $getuidlibraryref = ""; 258 259 if ( $installer::globals::include_pathes_read ) 260 { 261 $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0); 262 } 263 else 264 { 265 $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$getuidlibraryname, $includepatharrayref, 0); 266 } 267 268 if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_path_for_library"); } 269 270 return $$getuidlibraryref; 271} 272 273######################################################### 274# Include the tar file into the script 275######################################################### 276 277sub include_tar_into_script 278{ 279 my ($scriptfile, $temporary_tarfile) = @_; 280 281 my $systemcall = "cat $temporary_tarfile >> $scriptfile && rm $temporary_tarfile"; 282 my $returnvalue = system($systemcall); 283 284 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 285 286 if ($returnvalue) 287 { 288 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 289 } 290 else 291 { 292 $installer::logger::Lang->printf("Success: Executed \"%s\" successfully!\n", $systemcall); 293 } 294 return $returnvalue; 295} 296 297######################################################### 298# Create a tar file from the binary package 299######################################################### 300 301sub tar_package 302{ 303 my ( $installdir, $tarfilename, $getuidlibrary) = @_; 304 305 my $ldpreloadstring = ""; 306 307 if (($ENV{'FAKEROOT'} ne "no") && ($ENV{'FAKEROOT'} ne "")) { 308 $ldpreloadstring = $ENV{'FAKEROOT'}; 309 } else { 310 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } 311 } 312 313 my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - * > $tarfilename"; 314 315 my $returnvalue = system($systemcall); 316 317 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 318 319 if ($returnvalue) 320 { 321 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 322 } 323 else 324 { 325 $installer::logger::Lang->printf("Success: Executed \"\" successfully!\n", $systemcall); 326 } 327 328 my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1"; 329 $returnvalue = system($localcall); 330 331 return ( -s $tarfilename ); 332} 333 334######################################################### 335# Creating a tar.gz file 336######################################################### 337 338sub create_tar_gz_file_from_package 339{ 340 my ($installdir, $getuidlibrary) = @_; 341 342 my $alldirs = installer::systemactions::get_all_directories($installdir); 343 my $onedir = ${$alldirs}[0]; 344 $installdir = $onedir; 345 346 my $allfiles = installer::systemactions::get_all_files_from_one_directory($installdir); 347 348 for ( my $i = 0; $i <= $#{$allfiles}; $i++ ) 349 { 350 my $onefile = ${$allfiles}[$i]; 351 my $systemcall = "cd $installdir; rm $onefile"; 352 my $returnvalue = system($systemcall); 353 354 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 355 356 if ($returnvalue) 357 { 358 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 359 } 360 else 361 { 362 $installer::logger::Lang->printf("Success: Executed \"%s\" successfully!\n", $systemcall); 363 } 364 } 365 366 $alldirs = installer::systemactions::get_all_directories($installdir); 367 my $packagename = ${$alldirs}[0]; # only taking the first Solaris package 368 if ( $packagename eq "" ) { installer::exiter::exit_program("ERROR: Could not find package in directory $installdir!", "determine_packagename"); } 369 370 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packagename); 371 372 $installer::globals::downloadfileextension = ".tar.gz"; 373 my $targzname = $packagename . $installer::globals::downloadfileextension; 374 $installer::globals::downloadfilename = $targzname; 375 376 my $ldpreloadstring = ""; 377 378 if (($ENV{'FAKEROOT'} ne "no") && ($ENV{'FAKEROOT'} ne "")) { 379 $ldpreloadstring = $ENV{'FAKEROOT'}; 380 } else { 381 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } 382 } 383 384 my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - $packagename | gzip > $targzname"; 385 $installer::logger::Info->printf("... %s ...\n", $systemcall); 386 387 my $returnvalue = system($systemcall); 388 389 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 390 391 if ($returnvalue) 392 { 393 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 394 } 395 else 396 { 397 $installer::logger::Lang->printf("Success: Executed \"%s\" successfully!\n", $systemcall); 398 } 399} 400 401######################################################### 402# Setting type of installation 403######################################################### 404 405sub get_installation_type 406{ 407 my $type = ""; 408 409 if ( $installer::globals::languagepack ) { $type = "langpack"; } 410 else { $type = "install"; } 411 412 return $type; 413} 414 415######################################################### 416# Setting installation languages 417######################################################### 418 419sub get_downloadname_language 420{ 421 my ($languagestringref) = @_; 422 423 my $languages = $$languagestringref; 424 425 if ( $installer::globals::added_english ) 426 { 427 $languages =~ s/en-US_//; 428 $languages =~ s/_en-US//; 429 } 430 431 # en-US is default language and can be removed therefore 432 # for one-language installation sets 433 434 # if ( $languages =~ /^\s*en-US\s*$/ ) 435 # { 436 # $languages = ""; 437 # } 438 439 if ( length ($languages) > $installer::globals::max_lang_length ) 440 { 441 $languages = 'multi'; 442 } 443 444 return $languages; 445} 446 447######################################################### 448# Setting download name 449######################################################### 450 451sub get_downloadname_productname 452{ 453 my ($allvariables) = @_; 454 455 my $start; 456 457 if ( $allvariables->{'AOODOWNLOADNAMEPREFIX'} ) 458 { 459 $start = $allvariables->{'AOODOWNLOADNAMEPREFIX'}; 460 } 461 else 462 { 463 $start = "Apache_OpenOffice"; 464 if ( $allvariables->{'PRODUCTNAME'} eq "OpenOffice" ) 465 { 466 if ( $allvariables->{'POSTVERSIONEXTENSION'} eq "SDK" ) 467 { 468 $start .= "-SDK"; 469 } 470 } 471 472 if ( $allvariables->{'PRODUCTNAME'} eq "AOO-Developer-Build" ) 473 { 474 if ( $allvariables->{'POSTVERSIONEXTENSION'} eq "SDK" ) 475 { 476 $start .= "-Dev-SDK"; 477 } 478 else 479 { 480 $start .= "-Dev"; 481 } 482 } 483 484 if ( $allvariables->{'PRODUCTNAME'} eq "URE" ) 485 { 486 $start .= "-URE"; 487 } 488 } 489 490 return $start; 491} 492 493######################################################### 494# Setting download version 495######################################################### 496 497sub get_download_version 498{ 499 my ($allvariables) = @_; 500 501 my $version = ""; 502 503 my $devproduct = 0; 504 if (( $allvariables->{'DEVELOPMENTPRODUCT'} ) && ( $allvariables->{'DEVELOPMENTPRODUCT'} == 1 )) { $devproduct = 1; } 505 506 my $cwsproduct = 0; 507 # the environment variable CWS_WORK_STAMP is set only in CWS 508 if ( $ENV{'CWS_WORK_STAMP'} ) { $cwsproduct = 1; } 509 510 if (( $cwsproduct ) || ( $devproduct )) # use "DEV300m75" 511 { 512 my $source = uc($installer::globals::build); # DEV300 513 my $localminor = ""; 514 if ( $installer::globals::minor ne "" ) { $localminor = $installer::globals::minor; } 515 else { $localminor = $installer::globals::lastminor; } 516 $version = $source . $localminor; 517 } 518 else # use 3.2.0rc1 519 { 520 $version = $allvariables->{'PRODUCTVERSION'}; 521 if (( $allvariables->{'ABOUTBOXPRODUCTVERSION'} ) && ( $allvariables->{'ABOUTBOXPRODUCTVERSION'} ne "" )) { $version = $allvariables->{'ABOUTBOXPRODUCTVERSION'}; } 522 if (( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) && ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ne "" )) { $version = $version . $allvariables->{'SHORT_PRODUCTEXTENSION'}; } 523 } 524 525 return $version; 526} 527 528############################################################### 529# Set date string, format: yymmdd 530############################################################### 531 532sub set_date_string 533{ 534 my ($allvariables) = @_; 535 536 my $datestring = ""; 537 538 my $devproduct = 0; 539 if (( $allvariables->{'DEVELOPMENTPRODUCT'} ) && ( $allvariables->{'DEVELOPMENTPRODUCT'} == 1 )) { $devproduct = 1; } 540 541 my $cwsproduct = 0; 542 # the environment variable CWS_WORK_STAMP is set only in CWS 543 if ( $ENV{'CWS_WORK_STAMP'} ) { $cwsproduct = 1; } 544 545 my $releasebuild = 1; 546 if (( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) && ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ne "" )) { $releasebuild = 0; } 547 548 if (( ! $devproduct ) && ( ! $cwsproduct ) && ( ! $releasebuild )) 549 { 550 my @timearray = localtime(time); 551 552 my $day = $timearray[3]; 553 my $month = $timearray[4] + 1; 554 my $year = $timearray[5] + 1900; 555 556 if ( $month < 10 ) { $month = "0" . $month; } 557 if ( $day < 10 ) { $day = "0" . $day; } 558 559 $datestring = $year . $month . $day; 560 } 561 562 return $datestring; 563} 564 565################################################################# 566# Setting the platform name for download 567################################################################# 568 569sub get_download_platformname 570{ 571 my $platformname = ""; 572 573 if ( $installer::globals::islinuxbuild ) 574 { 575 $platformname = "Linux"; 576 } 577 elsif ( $installer::globals::issolarisbuild ) 578 { 579 $platformname = "Solaris"; 580 } 581 elsif ( $installer::globals::iswindowsbuild ) 582 { 583 $platformname = "Win"; 584 } 585 elsif ( $installer::globals::isfreebsdbuild ) 586 { 587 $platformname = "FreeBSD"; 588 } 589 elsif ( $installer::globals::ismacbuild ) 590 { 591 $platformname = "MacOS"; 592 } 593 else 594 { 595 # $platformname = $installer::globals::packageformat; 596 $platformname = $installer::globals::compiler; 597 } 598 599 return $platformname; 600} 601 602######################################################### 603# Setting the architecture for the download name 604######################################################### 605 606sub get_download_architecture 607{ 608 my $arch = ""; 609 610 if(( $installer::globals::compiler =~ /^unxlngi/ ) 611 || ( $installer::globals::compiler =~ /^unxmac.i/ ) 612 || ( $installer::globals::issolarisx86build ) 613 || ( $installer::globals::iswindowsbuild )) 614 { 615 $arch = "x86"; 616 } 617 elsif(( $installer::globals::compiler =~ /^unxlngx/ ) 618 || ( $installer::globals::compiler =~ /^unxmaccx/ )) 619 { 620 $arch = "x86-64"; 621 } 622 elsif ( $installer::globals::issolarissparcbuild ) 623 { 624 $arch = "Sparc"; 625 } 626 elsif(( $installer::globals::compiler =~ /^unxmacxp/ ) 627 || ( $installer::globals::compiler =~ /^unxlngppc/ )) 628 { 629 $arch = "PPC"; 630 } 631 632 return $arch; 633} 634 635######################################################### 636# Setting the installation type for the download name 637######################################################### 638 639sub get_install_type 640{ 641 my ($allvariables) = @_; 642 643 my $type = ""; 644 645 if ( $installer::globals::languagepack ) 646 { 647 $type = "langpack"; 648 649 if ( $installer::globals::islinuxrpmbuild ) 650 { 651 $type = $type . "-rpm"; 652 } 653 654 if ( $installer::globals::islinuxdebbuild ) 655 { 656 $type = $type . "-deb"; 657 } 658 659 if ( $installer::globals::packageformat eq "archive" ) 660 { 661 $type = $type . "-arc"; 662 } 663 } 664 else 665 { 666 $type = "install"; 667 668 if ( $installer::globals::islinuxrpmbuild ) 669 { 670 $type = $type . "-rpm"; 671 } 672 673 if ( $installer::globals::islinuxdebbuild ) 674 { 675 $type = $type . "-deb"; 676 } 677 678 if ( $installer::globals::packageformat eq "archive" ) 679 { 680 $type = $type . "-arc"; 681 } 682 683 if (( $allvariables->{'WITHJREPRODUCT'} ) && ( $allvariables->{'WITHJREPRODUCT'} == 1 )) 684 { 685 $type = $type . "-wJRE"; 686 } 687 688 } 689 690 return $type; 691} 692 693######################################################### 694# Setting installation addons 695######################################################### 696 697sub get_downloadname_addon 698{ 699 my $addon = ""; 700 701 if ( $installer::globals::islinuxdebbuild ) { $addon = $addon . "_deb"; } 702 703 if ( $installer::globals::product =~ /_wJRE\s*$/ ) { $addon = "_wJRE"; } 704 705 return $addon; 706} 707 708######################################################### 709# Looking for versionstring in version.info 710# This has to be the only content of this file. 711######################################################### 712 713sub get_versionstring 714{ 715 my ( $versionfile ) = @_; 716 717 my $versionstring = ""; 718 719 for ( my $i = 0; $i <= $#{$versionfile}; $i++ ) 720 { 721 my $oneline = ${$versionfile}[$i]; 722 723 if ( $oneline =~ /^\s*\#/ ) { next; } # comment line 724 if ( $oneline =~ /^\s*\"\s*(.*?)\s*\"\s*$/ ) 725 { 726 $versionstring = $1; 727 last; 728 } 729 } 730 731 return $versionstring; 732} 733 734######################################################### 735# Returning the current product version 736# This has to be defined in file "version.info" 737# in directory $installer::globals::ooouploaddir 738######################################################### 739 740sub get_current_version 741{ 742 my $versionstring = ""; 743 my $filename = "version.info"; 744 # $filename = $installer::globals::ooouploaddir . $installer::globals::separator . $filename; 745 746 if ( -f $filename ) 747 { 748 $installer::logger::Lang->printf("File %s exists. Trying to find current version.\n", $filename); 749 my $versionfile = installer::files::read_file($filename); 750 $versionstring = get_versionstring($versionfile); 751 $installer::logger::Lang->printf("Setting version string: %s\n", $versionstring); 752 } 753 else 754 { 755 $installer::logger::Lang->printf("File %s does not exist. No version setting in download file name.\n", $filename); 756 } 757 758 $installer::globals::oooversionstring = $versionstring; 759 760 return $versionstring; 761} 762 763############################################################################################### 764# Setting the download file name 765# Syntax: 766# (PRODUCTNAME)_(VERSION)_(TIMESTAMP)_(OS)_(ARCH)_(INSTALLTYPE)_(LANGUAGE).(FILEEXTENSION) 767# Rules: 768# Timestamp only for Beta and Release Candidate 769############################################################################################### 770 771sub set_download_filename 772{ 773 my ($languagestringref, $allvariables) = @_; 774 775 my $start = get_downloadname_productname($allvariables); 776 my $versionstring = get_download_version($allvariables); 777 my $date = set_date_string($allvariables); 778 my $platform = get_download_platformname(); 779 my $architecture = get_download_architecture(); 780 my $type = get_install_type($allvariables); 781 my $language = get_downloadname_language($languagestringref); 782 783 # Setting the extension happens automatically 784 785 my $filename = $start . "_" . $versionstring . "_" . $date . "_" . $platform . "_" . $architecture . "_" . $type . "_" . $language; 786 787 $filename =~ s/\_\_/\_/g; # necessary, if $versionstring or $platform or $language are empty 788 $filename =~ s/\_\s*$//; # necessary, if $language and $addon are empty 789 790 $installer::globals::ooodownloadfilename = $filename; 791 792 return $filename; 793} 794 795######################################################### 796# Creating a tar.gz file 797######################################################### 798 799sub create_tar_gz_file_from_directory 800{ 801 my ($installdir, $getuidlibrary, $downloaddir, $downloadfilename) = @_; 802 803 my $packdir = $installdir; 804 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packdir); 805 my $changedir = $installdir; 806 installer::pathanalyzer::get_path_from_fullqualifiedname(\$changedir); 807 808 my $ldpreloadstring = ""; 809 810 if (($ENV{'FAKEROOT'} ne "no") && ($ENV{'FAKEROOT'} ne "")) { 811 $ldpreloadstring = $ENV{'FAKEROOT'}; 812 } else { 813 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } 814 } 815 816 $installer::globals::downloadfileextension = ".tar.gz"; 817 $installer::globals::downloadfilename = $downloadfilename . $installer::globals::downloadfileextension; 818 my $targzname = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename; 819 820 my $systemcall = "cd $changedir; $ldpreloadstring tar -cf - $packdir | gzip > $targzname"; 821 822 my $returnvalue = system($systemcall); 823 824 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 825 826 if ($returnvalue) 827 { 828 $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall); 829 } 830 else 831 { 832 $installer::logger::Lang->printf("Success: Executed \"%s\" successfully!\n", $systemcall); 833 } 834 835 return $targzname; 836} 837 838######################################################### 839# Setting the variables in the download name 840######################################################### 841 842sub resolve_variables_in_downloadname 843{ 844 my ($allvariables, $downloadname, $languagestringref) = @_; 845 846 # Typical name: soa-{productversion}-{extension}-bin-{os}-{languages} 847 848 my $productversion = $allvariables->{'PRODUCTVERSION'}; 849 $productversion = "" unless defined $productversion; 850 $downloadname =~ s/\{productversion\}/$productversion/; 851 852 my $packageversion = $allvariables->{'PACKAGEVERSION'}; 853 $packageversion = "" unless defined $packageversion; 854 $downloadname =~ s/\{packageversion\}/$packageversion/; 855 856 my $extension = $allvariables->{'SHORT_PRODUCTEXTENSION'}; 857 $extension = "" unless defined $extension; 858 $extension = lc($extension); 859 $downloadname =~ s/\{extension\}/$extension/; 860 861 my $os = ""; 862 if ( $installer::globals::iswindowsbuild ) { $os = "windows"; } 863 elsif ( $installer::globals::issolarissparcbuild ) { $os = "solsparc"; } 864 elsif ( $installer::globals::issolarisx86build ) { $os = "solia"; } 865 elsif ( $installer::globals::islinuxbuild ) { $os = "linux"; } 866 elsif ( $installer::globals::compiler =~ /unxmac.i/ ) { $os = "macosi"; } 867 elsif ( $installer::globals::compiler =~ /unxmac.x/ ) { $os = "macosx"; } 868 elsif ( $installer::globals::compiler =~ /unxmacxp/ ) { $os = "macosp"; } 869 else { $os = ""; } 870 $downloadname =~ s/\{os\}/$os/; 871 872 my $languages = $$languagestringref; 873 $downloadname =~ s/\{languages\}/$languages/; 874 875 $downloadname =~ s/\-\-\-/\-/g; 876 $downloadname =~ s/\-\-/\-/g; 877 $downloadname =~ s/\-\s*$//; 878 879 return $downloadname; 880} 881 882################################################################## 883# Windows: Replacing one placeholder with the specified value 884################################################################## 885 886sub replace_one_variable 887{ 888 my ($templatefile, $placeholder, $value) = @_; 889 890 $installer::logger::Lang->printf("Replacing %s by %s in nsi file\n", $placeholder, $value); 891 892 for ( my $i = 0; $i <= $#{$templatefile}; $i++ ) 893 { 894 ${$templatefile}[$i] =~ s/$placeholder/$value/g; 895 } 896 897} 898 899######################################################################################## 900# Converting a string to a unicode string 901######################################################################################## 902 903sub convert_to_unicode 904{ 905 my ($string) = @_; 906 907 my $unicodestring = ""; 908 909 my $stringlength = length($string); 910 911 for ( my $i = 0; $i < $stringlength; $i++ ) 912 { 913 $unicodestring = $unicodestring . substr($string, $i, 1); 914 $unicodestring = $unicodestring . chr(0); 915 } 916 917 return $unicodestring; 918} 919 920################################################################## 921# Windows: Including the product name into nsi template 922################################################################## 923 924sub put_windows_productname_into_template 925{ 926 my ($templatefile, $variableshashref) = @_; 927 928 my $productname = $variableshashref->{'PRODUCTNAME'}; 929 $productname =~ s/\.//g; # OpenOffice.org -> OpenOfficeorg 930 931 replace_one_variable($templatefile, "PRODUCTNAMEPLACEHOLDER", $productname); 932} 933 934################################################################## 935# Windows: Including the path to the banner.bmp into nsi template 936################################################################## 937 938sub put_banner_bmp_into_template 939{ 940 my ($templatefile, $includepatharrayref, $allvariables) = @_; 941 942 # my $filename = "downloadbanner.bmp"; 943 if ( ! $allvariables->{'DOWNLOADBANNER'} ) { installer::exiter::exit_program("ERROR: DOWNLOADBANNER not defined in product definition!", "put_banner_bmp_into_template"); } 944 my $filename = $allvariables->{'DOWNLOADBANNER'}; 945 946 my $completefilenameref = ""; 947 948 if ( $installer::globals::include_pathes_read ) 949 { 950 $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0); 951 } 952 else 953 { 954 $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0); 955 } 956 957 if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_banner_bmp_into_template"); } 958 959 if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; } 960 961 replace_one_variable($templatefile, "BANNERBMPPLACEHOLDER", $$completefilenameref); 962} 963 964################################################################## 965# Windows: Including the path to the welcome.bmp into nsi template 966################################################################## 967 968sub put_welcome_bmp_into_template 969{ 970 my ($templatefile, $includepatharrayref, $allvariables) = @_; 971 972 # my $filename = "downloadbitmap.bmp"; 973 if ( ! $allvariables->{'DOWNLOADBITMAP'} ) { installer::exiter::exit_program("ERROR: DOWNLOADBITMAP not defined in product definition!", "put_welcome_bmp_into_template"); } 974 my $filename = $allvariables->{'DOWNLOADBITMAP'}; 975 976 my $completefilenameref = ""; 977 978 if ( $installer::globals::include_pathes_read ) 979 { 980 $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0); 981 } 982 else 983 { 984 $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0); 985 } 986 987 if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_welcome_bmp_into_template"); } 988 989 if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; } 990 991 replace_one_variable($templatefile, "WELCOMEBMPPLACEHOLDER", $$completefilenameref); 992} 993 994################################################################## 995# Windows: Including the path to the setup.ico into nsi template 996################################################################## 997 998sub put_setup_ico_into_template 999{ 1000 my ($templatefile, $includepatharrayref, $allvariables) = @_; 1001 1002 # my $filename = "downloadsetup.ico"; 1003 if ( ! $allvariables->{'DOWNLOADSETUPICO'} ) { installer::exiter::exit_program("ERROR: DOWNLOADSETUPICO not defined in product definition!", "put_setup_ico_into_template"); } 1004 my $filename = $allvariables->{'DOWNLOADSETUPICO'}; 1005 1006 my $completefilenameref = ""; 1007 1008 if ( $installer::globals::include_pathes_read ) 1009 { 1010 $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0); 1011 } 1012 else 1013 { 1014 $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0); 1015 } 1016 1017 if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_setup_ico_into_template"); } 1018 1019 if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; } 1020 1021 replace_one_variable($templatefile, "SETUPICOPLACEHOLDER", $$completefilenameref); 1022} 1023 1024################################################################## 1025# Windows: Including the publisher into nsi template 1026################################################################## 1027 1028sub put_publisher_into_template ($$) 1029{ 1030 my ($templatefile, $variables) = @_; 1031 1032 my $publisher = $variables->{'OOOVENDOR'}; 1033 $publisher = "" unless defined $publisher; 1034 1035 replace_one_variable($templatefile, "PUBLISHERPLACEHOLDER", $publisher); 1036} 1037 1038################################################################## 1039# Windows: Including the web site into nsi template 1040################################################################## 1041 1042sub put_website_into_template ($$) 1043{ 1044 my ($templatefile, $variables) = @_; 1045 1046 my $website = $variables->{'STARTCENTER_INFO_URL'}; 1047 $website = "" unless defined $website; 1048 1049 replace_one_variable($templatefile, "WEBSITEPLACEHOLDER", $website); 1050} 1051 1052################################################################## 1053# Windows: Including the Java file name into nsi template 1054################################################################## 1055 1056sub put_javafilename_into_template 1057{ 1058 my ($templatefile, $variableshashref) = @_; 1059 1060 my $javaversion = ""; 1061 1062 if ( $variableshashref->{'WINDOWSJAVAFILENAME'} ) { $javaversion = $variableshashref->{'WINDOWSJAVAFILENAME'}; } 1063 1064 replace_one_variable($templatefile, "WINDOWSJAVAFILENAMEPLACEHOLDER", $javaversion); 1065} 1066 1067################################################################## 1068# Windows: Including the product version into nsi template 1069################################################################## 1070 1071sub put_windows_productversion_into_template 1072{ 1073 my ($templatefile, $variableshashref) = @_; 1074 1075 my $productversion = $variableshashref->{'PRODUCTVERSION'}; 1076 1077 replace_one_variable($templatefile, "PRODUCTVERSIONPLACEHOLDER", $productversion); 1078} 1079 1080################################################################## 1081# Windows: Including the product version into nsi template 1082################################################################## 1083 1084sub put_windows_productpath_into_template 1085{ 1086 my ($templatefile, $variableshashref, $languagestringref, $localnsisdir) = @_; 1087 1088 my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'}; 1089 1090 my $locallangs = $$languagestringref; 1091 $locallangs =~ s/_/ /g; 1092 if (length($locallangs) > $installer::globals::max_lang_length) { $locallangs = "multi lingual"; } 1093 1094 if ( ! $installer::globals::languagepack ) { $productpath = $productpath . " (" . $locallangs . ")"; } 1095 1096 replace_one_variable($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath); 1097} 1098 1099################################################################## 1100# Windows: Including download file name into nsi template 1101################################################################## 1102 1103sub put_outputfilename_into_template 1104{ 1105 my ($templatefile, $downloadname) = @_; 1106 1107 $installer::globals::downloadfileextension = ".exe"; 1108 $downloadname = $downloadname . $installer::globals::downloadfileextension; 1109 $installer::globals::downloadfilename = $downloadname; 1110 1111 replace_one_variable($templatefile, "DOWNLOADNAMEPLACEHOLDER", $downloadname); 1112} 1113 1114################################################################## 1115# Windows: Generating the file list in nsi file format 1116################################################################## 1117 1118sub get_file_list 1119{ 1120 my ( $basedir ) = @_; 1121 1122 my @filelist = (); 1123 1124 my $alldirs = installer::systemactions::get_all_directories($basedir); 1125 unshift(@{$alldirs}, $basedir); # $basedir is the first directory in $alldirs 1126 1127 for ( my $i = 0; $i <= $#{$alldirs}; $i++ ) 1128 { 1129 my $onedir = ${$alldirs}[$i]; 1130 1131 # Syntax: 1132 # SetOutPath "$INSTDIR" 1133 1134 my $relativedir = $onedir; 1135 $relativedir =~ s/\Q$basedir\E//; 1136 1137 my $oneline = " " . "SetOutPath" . " " . "\"\$INSTDIR" . $relativedir . "\"" . "\n"; 1138 1139 if ( $^O =~ /cygwin/i ) { 1140 $oneline =~ s/\//\\/g; 1141 } 1142 push(@filelist, $oneline); 1143 1144 # Collecting all files in the specific directory 1145 1146 my $files = installer::systemactions::get_all_files_from_one_directory($onedir); 1147 1148 for ( my $j = 0; $j <= $#{$files}; $j++ ) 1149 { 1150 my $onefile = ${$files}[$j]; 1151 1152 my $fileline = " " . "File" . " " . "\"" . $onefile . "\"" . "\n"; 1153 1154 if ( $^O =~ /cygwin/i ) { 1155 $fileline =~ s/\//\\/g; 1156 } 1157 push(@filelist, $fileline); 1158 } 1159 } 1160 1161 return \@filelist; 1162} 1163 1164################################################################## 1165# Windows: Including list of all files into nsi template 1166################################################################## 1167 1168sub put_filelist_into_template 1169{ 1170 my ($templatefile, $installationdir) = @_; 1171 1172 my $filelist = get_file_list($installationdir); 1173 1174 my $filestring = ""; 1175 1176 for ( my $i = 0; $i <= $#{$filelist}; $i++ ) 1177 { 1178 $filestring = $filestring . ${$filelist}[$i]; 1179 } 1180 1181 $filestring =~ s/\s*$//; 1182 1183 replace_one_variable($templatefile, "ALLFILESPLACEHOLDER", $filestring); 1184} 1185 1186################################################################## 1187# Windows: NSIS uses specific language names 1188################################################################## 1189 1190sub nsis_language_converter 1191{ 1192 my ($language) = @_; 1193 1194 my $nsislanguage = ""; 1195 1196 # Assign language used by NSIS. 1197 # The files "$nsislanguage.nsh" and "$nsislanguage.nlf" 1198 # are needed in the NSIS environment. 1199 # Directory: <NSIS-Dir>/Contrib/Language files 1200 if ( $language eq "en-US" ) { $nsislanguage = "English"; } 1201 elsif ( $language eq "af" ) { $nsislanguage = "Afrikaans"; } 1202 elsif ( $language eq "sq" ) { $nsislanguage = "Albanian"; } 1203 elsif ( $language eq "ar" ) { $nsislanguage = "Arabic"; } 1204 elsif ( $language eq "hy" ) { $nsislanguage = "Armenian"; } 1205 elsif ( $language eq "ast" ) { $nsislanguage = "Asturian"; } 1206 elsif ( $language eq "eu" ) { $nsislanguage = "Basque"; } 1207 elsif ( $language eq "bg" ) { $nsislanguage = "Bulgarian"; } 1208 elsif ( $language eq "ca" ) { $nsislanguage = "Catalan"; } 1209 elsif ( $language eq "hr" ) { $nsislanguage = "Croatian"; } 1210 elsif ( $language eq "cs" ) { $nsislanguage = "Czech"; } 1211 elsif ( $language eq "da" ) { $nsislanguage = "Danish"; } 1212 elsif ( $language eq "nl" ) { $nsislanguage = "Dutch"; } 1213 elsif ( $language eq "en-GB" ) { $nsislanguage = "English"; } 1214 elsif ( $language eq "et" ) { $nsislanguage = "Estonian"; } 1215 elsif ( $language eq "fa" ) { $nsislanguage = "Farsi"; } 1216 elsif ( $language eq "fi" ) { $nsislanguage = "Finnish"; } 1217 elsif ( $language eq "fr" ) { $nsislanguage = "French"; } 1218 elsif ( $language eq "gl" ) { $nsislanguage = "Galician"; } 1219 elsif ( $language eq "de" ) { $nsislanguage = "German"; } 1220 elsif ( $language eq "el" ) { $nsislanguage = "Greek"; } 1221 elsif ( $language eq "he" ) { $nsislanguage = "Hebrew"; } 1222 elsif ( $language eq "hi" ) { $nsislanguage = "Hindi"; } 1223 elsif ( $language eq "hu" ) { $nsislanguage = "Hungarian"; } 1224 elsif ( $language eq "is" ) { $nsislanguage = "Icelandic"; } 1225 elsif ( $language eq "id" ) { $nsislanguage = "Indonesian"; } 1226 elsif ( $language eq "it" ) { $nsislanguage = "Italian"; } 1227 elsif ( $language eq "ja" ) { $nsislanguage = "Japanese"; } 1228 elsif ( $language eq "ko" ) { $nsislanguage = "Korean"; } 1229 elsif ( $language eq "lv" ) { $nsislanguage = "Latvian"; } 1230 elsif ( $language eq "lt" ) { $nsislanguage = "Lithuanian"; } 1231 elsif ( $language eq "de-LU" ) { $nsislanguage = "Luxembourgish"; } 1232 elsif ( $language eq "mk" ) { $nsislanguage = "Macedonian"; } 1233 elsif ( $language eq "mn" ) { $nsislanguage = "Mongolian"; } 1234 elsif ( $language eq "nb" ) { $nsislanguage = "Norwegian"; } 1235 elsif ( $language eq "no" ) { $nsislanguage = "Norwegian"; } 1236 elsif ( $language eq "no-NO" ) { $nsislanguage = "Norwegian"; } 1237 elsif ( $language eq "nn" ) { $nsislanguage = "NorwegianNynorsk"; } 1238 elsif ( $language eq "pl" ) { $nsislanguage = "Polish"; } 1239 elsif ( $language eq "pt" ) { $nsislanguage = "Portuguese"; } 1240 elsif ( $language eq "pt-BR" ) { $nsislanguage = "PortugueseBR"; } 1241 elsif ( $language eq "ro" ) { $nsislanguage = "Romanian"; } 1242 elsif ( $language eq "ru" ) { $nsislanguage = "Russian"; } 1243 elsif ( $language eq "gd" ) { $nsislanguage = "ScotsGaelic"; } 1244 elsif ( $language eq "sr" ) { $nsislanguage = "Serbian"; } 1245 elsif ( $language eq "sr-SP" ) { $nsislanguage = "Serbian"; } 1246 elsif ( $language eq "sh" ) { $nsislanguage = "SerbianLatin"; } 1247 elsif ( $language eq "zh-CN" ) { $nsislanguage = "SimpChinese"; } 1248 elsif ( $language eq "sl" ) { $nsislanguage = "Slovenian"; } 1249 elsif ( $language eq "sk" ) { $nsislanguage = "Slovak"; } 1250 elsif ( $language eq "es" ) { $nsislanguage = "Spanish"; } 1251 elsif ( $language eq "sv" ) { $nsislanguage = "Swedish"; } 1252 elsif ( $language eq "th" ) { $nsislanguage = "Thai"; } 1253 elsif ( $language eq "zh-TW" ) { $nsislanguage = "TradChinese"; } 1254 elsif ( $language eq "tr" ) { $nsislanguage = "Turkish"; } 1255 elsif ( $language eq "uk" ) { $nsislanguage = "Ukrainian"; } 1256 elsif ( $language eq "vi" ) { $nsislanguage = "Vietnamese"; } 1257 elsif ( $language eq "cy" ) { $nsislanguage = "Welsh"; } 1258 else 1259 { 1260 $installer::logger::Lang->printf("NSIS language_converter : Could not find nsis language for %s!\n", $language); 1261 $nsislanguage = "English"; 1262 } 1263 1264 return $nsislanguage; 1265} 1266 1267################################################################## 1268# Windows: Including list of all languages into nsi template 1269################################################################## 1270 1271sub put_language_list_into_template 1272{ 1273 my ($templatefile, $languagesarrayref) = @_; 1274 1275 my $alllangstring = ""; 1276 my %nsislangs; 1277 1278 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ ) 1279 { 1280 my $onelanguage = ${$languagesarrayref}[$i]; 1281 my $nsislanguage = nsis_language_converter($onelanguage); 1282 $nsislangs{$nsislanguage}++; 1283 } 1284 1285 foreach my $nsislanguage ( keys(%nsislangs) ) 1286 { 1287 # Syntax: !insertmacro MUI_LANGUAGE "English" 1288 my $langstring = "\!insertmacro MUI_LANGUAGE_PACK " . $nsislanguage . "\n"; 1289 if ( $nsislanguage eq "English" ) 1290 { 1291 $alllangstring = $langstring . $alllangstring; 1292 } 1293 else 1294 { 1295 $alllangstring = $alllangstring . $langstring; 1296 } 1297 } 1298 1299 $alllangstring =~ s/\s*$//; 1300 1301 replace_one_variable($templatefile, "ALLLANGUAGESPLACEHOLDER", $alllangstring); 1302} 1303 1304################################################################## 1305# Windows: Collecting all identifier from mlf file 1306################################################################## 1307 1308sub get_identifier 1309{ 1310 my ( $mlffile ) = @_; 1311 1312 my @identifier = (); 1313 1314 for ( my $i = 0; $i <= $#{$mlffile}; $i++ ) 1315 { 1316 my $oneline = ${$mlffile}[$i]; 1317 1318 if ( $oneline =~ /^\s*\[(.+)\]\s*$/ ) 1319 { 1320 my $identifier = $1; 1321 push(@identifier, $identifier); 1322 } 1323 } 1324 1325 return \@identifier; 1326} 1327 1328############################################################## 1329# Returning the complete block in all languages 1330# for a specified string 1331############################################################## 1332 1333sub get_language_block_from_language_file 1334{ 1335 my ($searchstring, $languagefile) = @_; 1336 1337 my @language_block = (); 1338 1339 for ( my $i = 0; $i <= $#{$languagefile}; $i++ ) 1340 { 1341 if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ ) 1342 { 1343 my $counter = $i; 1344 1345 push(@language_block, ${$languagefile}[$counter]); 1346 $counter++; 1347 1348 while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ ))) 1349 { 1350 push(@language_block, ${$languagefile}[$counter]); 1351 $counter++; 1352 } 1353 1354 last; 1355 } 1356 } 1357 1358 return \@language_block; 1359} 1360 1361############################################################## 1362# Returning a specific language string from the block 1363# of all translations 1364############################################################## 1365 1366sub get_language_string_from_language_block 1367{ 1368 my ($language_block, $language) = @_; 1369 1370 my $newstring = ""; 1371 1372 for ( my $i = 0; $i <= $#{$language_block}; $i++ ) 1373 { 1374 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) 1375 { 1376 $newstring = $1; 1377 last; 1378 } 1379 } 1380 1381 if ( $newstring eq "" ) 1382 { 1383 $language = "en-US"; # defaulting to English 1384 1385 for ( my $i = 0; $i <= $#{$language_block}; $i++ ) 1386 { 1387 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) 1388 { 1389 $newstring = $1; 1390 last; 1391 } 1392 } 1393 } 1394 1395 return $newstring; 1396} 1397 1398################################################################## 1399# Windows: Replacing strings in NSIS nsh file 1400# nsh file syntax: 1401# !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis auswählen" 1402################################################################## 1403 1404sub replace_identifier_in_nshfile 1405{ 1406 my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_; 1407 1408 $newstring =~ s/\\r/\$\\r/g; # \r -> $\r in modern nsis versions 1409 $newstring =~ s/\\n/\$\\n/g; # \n -> $\n in modern nsis versions 1410 1411 for ( my $i = 0; $i <= $#{$nshfile}; $i++ ) 1412 { 1413 if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ ) 1414 { 1415 my $oldstring = $1; 1416 ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/; 1417 $installer::logger::Lang->printf("NSIS replacement in %s (%s): \-\> %s\n", 1418 $nshfilename, 1419 $onelanguage, 1420 $oldstring, 1421 $newstring); 1422 } 1423 } 1424} 1425 1426################################################################## 1427# Windows: Replacing strings in NSIS nlf file 1428# nlf file syntax (2 lines): 1429# # ^DirSubText 1430# Zielverzeichnis 1431################################################################## 1432 1433sub replace_identifier_in_nlffile 1434{ 1435 my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_; 1436 1437 for ( my $i = 0; $i <= $#{$nlffile}; $i++ ) 1438 { 1439 if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ ) 1440 { 1441 my $next = $i+1; 1442 my $oldstring = ${$nlffile}[$next]; 1443 ${$nlffile}[$next] = $newstring . "\n"; 1444 $oldstring =~ s/\s*$//; 1445 $installer::logger::Lang->printf("NSIS replacement in %s (%s): %s \-\> %s\n", 1446 $nlffilename, 1447 $onelanguage, 1448 $oldstring, 1449 $newstring); 1450 } 1451 } 1452} 1453 1454################################################################## 1455# Windows: Translating the NSIS nsh and nlf file 1456################################################################## 1457 1458sub translate_nsh_nlf_file 1459{ 1460 my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_; 1461 1462 # Analyzing the mlf file, collecting all Identifier 1463 my $allidentifier = get_identifier($mlffile); 1464 1465 $onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US"); 1466 for ( my $i = 0; $i <= $#{$allidentifier}; $i++ ) 1467 { 1468 my $identifier = ${$allidentifier}[$i]; 1469 my $language_block = get_language_block_from_language_file($identifier, $mlffile); 1470 my $newstring = get_language_string_from_language_block($language_block, $onelanguage); 1471 1472 # removing mask 1473 $newstring =~ s/\\\'/\'/g; 1474 1475 replace_identifier_in_nshfile($nshfile, $identifier, $newstring, $nshfilename, $onelanguage); 1476 replace_identifier_in_nlffile($nlffile, $identifier, $newstring, $nlffilename, $onelanguage); 1477 } 1478} 1479 1480################################################################## 1481# Converting utf 16 file to utf 8 1482################################################################## 1483 1484sub convert_utf16_to_utf8 1485{ 1486 my ( $filename ) = @_; 1487 1488 my @localfile = (); 1489 1490 my $savfilename = $filename . "_before.utf16"; 1491 installer::systemactions::copy_one_file($filename, $savfilename); 1492 1493# open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8"); 1494# open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8"); 1495 open( IN, "<:encoding(UTF16-LE)", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8"); 1496 while ( my $line = <IN> ) 1497 { 1498 push @localfile, $line; 1499 } 1500 close( IN ); 1501 1502 if ( open( OUT, ">:utf8", $filename ) ) 1503 { 1504 print OUT @localfile; 1505 close(OUT); 1506 } 1507 1508 $savfilename = $filename . "_before.utf8"; 1509 installer::systemactions::copy_one_file($filename, $savfilename); 1510} 1511 1512################################################################## 1513# Converting utf 8 file to utf 16 1514################################################################## 1515 1516sub convert_utf8_to_utf16 1517{ 1518 my ( $filename ) = @_; 1519 1520 my @localfile = (); 1521 1522 my $savfilename = $filename . "_after.utf8"; 1523 installer::systemactions::copy_one_file($filename, $savfilename); 1524 1525 open( IN, "<:utf8", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16"); 1526 while (my $line = <IN>) 1527 { 1528 push @localfile, $line; 1529 } 1530 close( IN ); 1531 1532 if ( open( OUT, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) ) 1533 { 1534 print OUT @localfile; 1535 close(OUT); 1536 } 1537 1538 $savfilename = $filename . "_after.utf16"; 1539 installer::systemactions::copy_one_file($filename, $savfilename); 1540} 1541 1542################################################################## 1543# Converting text string to utf 16 1544################################################################## 1545 1546sub convert_textstring_to_utf16 1547{ 1548 my ( $textstring, $localnsisdir, $shortfilename ) = @_; 1549 1550 my $filename = $localnsisdir . $installer::globals::separator . $shortfilename; 1551 my @filecontent = (); 1552 push(@filecontent, $textstring); 1553 installer::files::save_file($filename, \@filecontent); 1554 convert_utf8_to_utf16($filename); 1555 my $newfile = installer::files::read_file($filename); 1556 my $utf16string = ""; 1557 if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; } 1558 1559 return $utf16string; 1560} 1561 1562################################################################## 1563# Windows: Copying NSIS language files to local nsis directory 1564################################################################## 1565 1566sub copy_and_translate_nsis_language_files 1567{ 1568 my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_; 1569 1570 my $nlffilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Language\ files" . $installer::globals::separator; 1571 my $nshfilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Modern\ UI" . $installer::globals::separator . "Language files" . $installer::globals::separator; 1572 1573 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ ) 1574 { 1575 my $onelanguage = ${$languagesarrayref}[$i]; 1576 my $nsislanguage = nsis_language_converter($onelanguage); 1577 1578 # Copying the nlf file 1579 my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf"; 1580 if ( ! -f $sourcepath ) { installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); } 1581 my $nlffilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nlf"; 1582 if ( $^O =~ /cygwin/i ) { $nlffilename =~ s/\//\\/g; } 1583 installer::systemactions::copy_one_file($sourcepath, $nlffilename); 1584 1585 # Copying the nsh file 1586 # In newer nsis versions, the nsh file is located next to the nlf file 1587 $sourcepath = $nshfilepath . $nsislanguage . "\.nsh"; 1588 if ( ! -f $sourcepath ) 1589 { 1590 # trying to find the nsh file next to the nlf file 1591 $sourcepath = $nlffilepath . $nsislanguage . "\.nsh"; 1592 if ( ! -f $sourcepath ) 1593 { 1594 installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); 1595 } 1596 } 1597 my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh"; 1598 if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; } 1599 installer::systemactions::copy_one_file($sourcepath, $nshfilename); 1600 1601 # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN 1602 #convert_utf16_to_utf8($nshfilename); 1603 #convert_utf16_to_utf8($nlffilename); 1604 my $nshfile = installer::files::read_file($nshfilename); 1605 replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN"); 1606 1607 # find the ulf file for translation 1608 my $mlffile = get_translation_file($allvariables); 1609 1610 # Translate the files 1611 my $nlffile = installer::files::read_file($nlffilename); 1612 translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage); 1613 1614 installer::files::save_file($nshfilename, $nshfile); 1615 installer::files::save_file($nlffilename, $nlffile); 1616 1617 #convert_utf8_to_utf16($nshfilename); 1618 #convert_utf8_to_utf16($nlffilename); 1619 } 1620 1621} 1622 1623################################################################## 1624# Windows: Including the nsis path into the nsi template 1625################################################################## 1626 1627sub put_nsis_path_into_template 1628{ 1629 my ($templatefile, $nsisdir) = @_; 1630 1631 replace_one_variable($templatefile, "NSISPATHPLACEHOLDER", $nsisdir); 1632} 1633 1634################################################################## 1635# Windows: Including the output path into the nsi template 1636################################################################## 1637 1638sub put_output_path_into_template 1639{ 1640 my ($templatefile, $downloaddir) = @_; 1641 1642 if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; } 1643 1644 replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir); 1645} 1646 1647################################################################## 1648# Windows: Finding the path to the nsis SDK 1649################################################################## 1650 1651sub get_path_to_nsis_sdk 1652{ 1653 my $nsispath = ""; 1654 1655 if ( $ENV{'NSIS_PATH'} ) 1656 { 1657 $nsispath = $ENV{'NSIS_PATH'}; 1658 } 1659 if ( $nsispath eq "" ) 1660 { 1661 $installer::logger::Info->print("... no Environment variable \"NSIS_PATH\"!\n"); 1662 } 1663 elsif ( ! -d $nsispath ) 1664 { 1665 installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk"); 1666 } 1667 1668 return $nsispath; 1669} 1670 1671################################################################## 1672# Windows: Executing NSIS to create the installation set 1673################################################################## 1674 1675sub call_nsis 1676{ 1677 my ( $nsispath, $nsifile ) = @_; 1678 1679 my $makensisexe = $nsispath . $installer::globals::separator . "makensis.exe"; 1680 1681 $installer::logger::Info->printf("... starting %s ... \n", $makensisexe); 1682 1683 if( $^O =~ /cygwin/i ) { $nsifile =~ s/\\/\//g; } 1684 1685 my $systemcall = "$makensisexe $nsifile |"; 1686 1687 $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 1688 1689 my @nsisoutput = (); 1690 1691 open (NSI, "$systemcall"); 1692 while (<NSI>) {push(@nsisoutput, $_); } 1693 close (NSI); 1694 1695 my $returnvalue = $?; # $? contains the return value of the systemcall 1696 1697 if ($returnvalue) 1698 { 1699 $installer::logger::Lang->printf("ERROR: %s !\n", $systemcall); 1700 } 1701 else 1702 { 1703 $installer::logger::Lang->printf("Success: %s\n", $systemcall); 1704 } 1705 1706 foreach my $line (@nsisoutput) 1707 { 1708 $installer::logger::Lang->print($line); 1709 } 1710} 1711 1712################################################################################# 1713# Replacing one variable in one files 1714################################################################################# 1715 1716sub replace_one_variable_in_translationfile 1717{ 1718 my ($translationfile, $variable, $searchstring) = @_; 1719 1720 for ( my $i = 0; $i <= $#{$translationfile}; $i++ ) 1721 { 1722 ${$translationfile}[$i] =~ s/\%$searchstring/$variable/g; 1723 } 1724} 1725 1726################################################################################# 1727# Replacing the variables in the translation file 1728################################################################################# 1729 1730sub replace_variables 1731{ 1732 my ($translationfile, $variableshashref) = @_; 1733 1734 foreach my $key (keys %{$variableshashref}) 1735 { 1736 my $value = $variableshashref->{$key}; 1737 1738 # special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'} 1739 if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; } 1740 1741 replace_one_variable_in_translationfile($translationfile, $value, $key); 1742 } 1743} 1744 1745######################################################### 1746# Getting the translation file for the nsis installer 1747######################################################### 1748 1749sub get_translation_file 1750{ 1751 my ($allvariableshashref) = @_; 1752 my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename . ".uulf"; 1753 if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); } 1754 my $translationfile = installer::files::read_file($translationfilename); 1755 replace_variables($translationfile, $allvariableshashref); 1756 1757 $installer::logger::Lang->printf("Reading translation file: %s\n", $translationfilename); 1758 1759 return $translationfile; 1760} 1761 1762#################################################### 1763# Removing English, if it was added before 1764#################################################### 1765 1766sub remove_english_for_nsis_installer 1767{ 1768 my ($languagestringref, $languagesarrayref) = @_; 1769 1770 # $$languagestringref =~ s/en-US_//; 1771 # shift(@{$languagesarrayref}); 1772 1773 @{$languagesarrayref} = ("en-US"); # only English for NSIS installer! 1774} 1775 1776#################################################### 1777# Creating link tree for upload 1778#################################################### 1779 1780sub create_link_tree 1781{ 1782 my ($sourcedownloadfile, $destfilename, $versionstring) = @_; 1783 1784 if ( ! $installer::globals::ooouploaddir ) { installer::exiter::exit_program("ERROR: Directory for AOO upload not defined!", "create_link_tree"); } 1785 my $versiondir = $installer::globals::ooouploaddir . $installer::globals::separator . $versionstring; 1786 $installer::logger::Lang->printf("Directory for the link: %s\n", $versiondir); 1787 1788 if ( ! -d $versiondir ) { installer::systemactions::create_directory_structure($versiondir); } 1789 1790 # inside directory $versiondir all links have to be created 1791 my $linkdestination = $versiondir . $installer::globals::separator . $destfilename; 1792 1793 # If there is an older version of this file (link), it has to be removed 1794 if ( -f $linkdestination ) { unlink($linkdestination); } 1795 1796 $installer::logger::Lang->printf("Creating hard link from %s to %s\n", $sourcedownloadfile, $linkdestination); 1797 installer::systemactions::hardlink_one_file($sourcedownloadfile, $linkdestination); 1798} 1799 1800####################################################### 1801# Setting supported platform for Sun OpenOffice.org 1802# builds 1803####################################################### 1804 1805sub is_supported_platform 1806{ 1807 my $is_supported = 0; 1808 1809 if (( $installer::globals::islinuxrpmbuild ) || 1810 ( $installer::globals::issolarissparcbuild ) || 1811 ( $installer::globals::issolarisx86build ) || 1812 ( $installer::globals::iswindowsbuild )) 1813 { 1814 $is_supported = 1; 1815 } 1816 1817 return $is_supported; 1818} 1819 1820#################################################### 1821# Creating download installation sets 1822#################################################### 1823 1824sub create_download_sets 1825{ 1826 my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_; 1827 1828 $installer::logger::Info->print("\n"); 1829 $installer::logger::Info->print("******************************************\n"); 1830 $installer::logger::Info->print("... creating download installation set ...\n", 1); 1831 $installer::logger::Info->print("******************************************\n"); 1832 1833 installer::logger::include_header_into_logfile("Creating download installation sets:"); 1834 1835 # special handling for installation sets, to which English was added automatically 1836 if ( $installer::globals::added_english ) { remove_english_for_nsis_installer($languagestringref, $languagesarrayref); } 1837 1838 my $firstdir = $installationdir; 1839 installer::pathanalyzer::get_path_from_fullqualifiedname(\$firstdir); 1840 1841 my $lastdir = $installationdir; 1842 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$lastdir); 1843 1844 if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ } 1845 else { $lastdir = $lastdir . "_download_inprogress"; } 1846 1847 # removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed" 1848 1849 my $downloaddir = $firstdir . $lastdir; 1850 1851 if ( -d $downloaddir ) { installer::systemactions::remove_complete_directory($downloaddir); } 1852 1853 my $olddir = $downloaddir; 1854 $olddir =~ s/_inprogress/_witherror/; 1855 if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); } 1856 1857 $olddir = $downloaddir; 1858 $olddir =~ s/_inprogress//; 1859 if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); } 1860 1861 # creating the new directory 1862 1863 installer::systemactions::create_directory($downloaddir); 1864 1865 $installer::globals::saveinstalldir = $downloaddir; 1866 1867 # evaluating the name of the download file 1868 1869 if ( $allvariableshashref->{'AOODOWNLOADNAME'} ) 1870 { 1871 $downloadname = set_download_filename($languagestringref, $allvariableshashref); 1872 } 1873 else 1874 { 1875 $downloadname = resolve_variables_in_downloadname($allvariableshashref, $downloadname, $languagestringref); 1876 } 1877 1878 if ( ! $installer::globals::iswindowsbuild ) # Unix specific part 1879 { 1880 1881 # getting the path of the getuid.so (only required for Solaris and Linux) 1882 my $getuidlibrary = ""; 1883 if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild )) { $getuidlibrary = get_path_for_library($includepatharrayref); } 1884 1885 if ( $allvariableshashref->{'AOODOWNLOADNAME'} ) 1886 { 1887 my $downloadfile = create_tar_gz_file_from_directory($installationdir, $getuidlibrary, $downloaddir, $downloadname); 1888 } 1889 else 1890 { 1891 # find and read setup script template 1892 my $scriptfilename = "downloadscript.sh"; 1893 1894 my $scriptref = ""; 1895 1896 if ( $installer::globals::include_pathes_read ) 1897 { 1898 $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0); 1899 } 1900 else 1901 { 1902 $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$scriptfilename, $includepatharrayref, 0); 1903 } 1904 1905 if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); } 1906 my $scriptfile = installer::files::read_file($$scriptref); 1907 1908 $installer::logger::Lang->printf("Found script file %s: %s \n", $scriptfilename, $$scriptref); 1909 1910 # add product name into script template 1911 put_productname_into_script($scriptfile, $allvariableshashref); 1912 1913 # replace linenumber in script template 1914 put_linenumber_into_script($scriptfile); 1915 1916 # create tar file 1917 my $temporary_tarfile_name = $downloaddir . $installer::globals::separator . 'installset.tar'; 1918 my $size = tar_package($installationdir, $temporary_tarfile_name, $getuidlibrary); 1919 installer::exiter::exit_program("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size; 1920 1921 # calling sum to determine checksum and size of the tar file 1922 my $sumout = call_sum($temporary_tarfile_name); 1923 1924 # writing checksum and size into scriptfile 1925 put_checksum_and_size_into_script($scriptfile, $sumout); 1926 1927 # saving the script file 1928 my $newscriptfilename = determine_scriptfile_name($downloadname); 1929 $newscriptfilename = save_script_file($downloaddir, $newscriptfilename, $scriptfile); 1930 1931 $installer::logger::Info->printf("... including installation set into %s ... \n", $newscriptfilename); 1932 # Append tar file to script 1933 include_tar_into_script($newscriptfilename, $temporary_tarfile_name); 1934 } 1935 } 1936 else # Windows specific part 1937 { 1938 my $localnsisdir = installer::systemactions::create_directories("nsis", $languagestringref); 1939 # push(@installer::globals::removedirs, $localnsisdir); 1940 1941 # find nsis in the system 1942 my $nsispath = get_path_to_nsis_sdk(); 1943 1944 if ( $nsispath eq "" ) { 1945 # If nsis is not found just skip the rest of this function 1946 # and do not create the NSIS file. 1947 $installer::logger::Lang->print("\n"); 1948 $installer::logger::Lang->printf("No NSIS SDK found. Skipping the generation of NSIS file.\n"); 1949 $installer::logger::Info->print("... no NSIS SDK found. Skipping the generation of NSIS file ... \n"); 1950 return $downloaddir; 1951 } 1952 1953 # copy language files into nsis directory and translate them 1954 copy_and_translate_nsis_language_files($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref); 1955 1956 # find and read the nsi file template 1957 my $templatefilename = "downloadtemplate.nsi"; 1958 1959 my $templateref = ""; 1960 1961 if ( $installer::globals::include_pathes_read ) 1962 { 1963 $templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$templatefilename, $includepatharrayref, 0); 1964 } 1965 else 1966 { 1967 $templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$templatefilename, $includepatharrayref, 0); 1968 } 1969 1970 if ($$templateref eq "") { installer::exiter::exit_program("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); } 1971 my $templatefile = installer::files::read_file($$templateref); 1972 1973 # add product name into script template 1974 put_windows_productname_into_template($templatefile, $allvariableshashref); 1975 put_banner_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref); 1976 put_welcome_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref); 1977 put_setup_ico_into_template($templatefile, $includepatharrayref, $allvariableshashref); 1978 put_publisher_into_template($templatefile, $allvariableshashref); 1979 put_website_into_template($templatefile, $allvariableshashref); 1980 put_javafilename_into_template($templatefile, $allvariableshashref); 1981 put_windows_productversion_into_template($templatefile, $allvariableshashref); 1982 put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir); 1983 put_outputfilename_into_template($templatefile, $downloadname); 1984 put_filelist_into_template($templatefile, $installationdir); 1985 put_language_list_into_template($templatefile, $languagesarrayref); 1986 put_nsis_path_into_template($templatefile, $localnsisdir); 1987 put_output_path_into_template($templatefile, $downloaddir); 1988 1989 my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile); 1990 1991 $installer::logger::Info->printf("... created NSIS file %s ... \n", $nsifilename); 1992 1993 # starting the NSIS SDK to create the download file 1994 call_nsis($nsispath, $nsifilename); 1995 } 1996 1997 return $downloaddir; 1998} 1999 2000#################################################### 2001# Creating AOO upload tree 2002#################################################### 2003 2004sub create_download_link_tree 2005{ 2006 my ($downloaddir, $languagestringref, $allvariableshashref) = @_; 2007 2008 $installer::logger::Info->print("\n"); 2009 $installer::logger::Info->print("******************************************\n"); # 2010 $installer::logger::Info->print("... creating download hard link ...\n"); 2011 $installer::logger::Info->print("******************************************\n"); 2012 2013 installer::logger::include_header_into_logfile("Creating download hard link:"); 2014 $installer::logger::Lang->print("\n"); 2015 $installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, start"); 2016 2017 if ( is_supported_platform() ) 2018 { 2019 my $versionstring = ""; 2020 # Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ? 2021 2022 if ( ! $installer::globals::oooversionstring ) { $versionstring = get_current_version(); } 2023 else { $versionstring = $installer::globals::oooversionstring; } 2024 2025 # Is $versionstring empty? If yes, there is nothing to do now. 2026 2027 $installer::logger::Lang->printf("Version string is set to: %s\n", $versionstring); 2028 2029 if ( $versionstring ) 2030 { 2031 # Now the downloadfilename has to be set (if not already done) 2032 my $destdownloadfilename = ""; 2033 if ( ! $installer::globals::ooodownloadfilename ) { $destdownloadfilename = set_download_filename($languagestringref, $versionstring, $allvariableshashref); } 2034 else { $destdownloadfilename = $installer::globals::ooodownloadfilename; } 2035 2036 if ( $destdownloadfilename ) 2037 { 2038 $destdownloadfilename = $destdownloadfilename . $installer::globals::downloadfileextension; 2039 2040 $installer::logger::Lang->printf("Setting destination download file name: %s\n", $destdownloadfilename); 2041 2042 my $sourcedownloadfile = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename; 2043 2044 $installer::logger::Lang->printf("Setting source download file name: %s\n", $sourcedownloadfile); 2045 2046 create_link_tree($sourcedownloadfile, $destdownloadfilename, $versionstring); 2047 # my $md5sumoutput = call_md5sum($downloadfile); 2048 # my $md5sum = get_md5sum($md5sumoutput); 2049 2050 } 2051 } 2052 else 2053 { 2054 $installer::logger::Lang->printf("Version string is empty. Nothing to do!\n"); 2055 } 2056 } 2057 else 2058 { 2059 $installer::logger::Lang->printf("Platform not used for hard linking. Nothing to do!\n"); 2060 } 2061 2062 $installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, stop"); 2063} 2064 20651; 2066