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