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