1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: download.pm,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer
::download
;
35 use installer
::exiter
;
37 use installer
::globals
;
38 use installer
::logger
;
39 use installer
::pathanalyzer
;
40 use installer
::remover
;
41 use installer
::systemactions
;
43 BEGIN { # This is needed so that cygwin's perl evaluates ACLs
44 # (needed for correctly evaluating the -x test.)
45 if( $^O
=~ /cygwin/i ) {
46 require filetest
; import filetest
"access";
50 ##################################################################
51 # Including the lowercase product name into the script template
52 ##################################################################
54 sub put_productname_into_script
56 my ($scriptfile, $variableshashref) = @_;
58 my $productname = $variableshashref->{'PRODUCTNAME'};
59 $productname = lc($productname);
60 $productname =~ s/\.//g; # openoffice.org -> openofficeorg
61 $productname =~ s/\s*//g;
63 my $infoline = "Adding productname $productname into download shell script\n";
64 push( @installer::globals
::logfileinfo
, $infoline);
66 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
68 ${$scriptfile}[$i] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/;
72 #########################################################
73 # Including the linenumber into the script template
74 #########################################################
76 sub put_linenumber_into_script
78 my ( $scriptfile ) = @_;
80 my $linenumber = $#{$scriptfile} + 2;
82 my $infoline = "Adding linenumber $linenumber into download shell script\n";
83 push( @installer::globals
::logfileinfo
, $infoline);
85 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
87 ${$scriptfile}[$i] =~ s/LINENUMBERPLACEHOLDER/$linenumber/;
91 #########################################################
92 # Determining the name of the new scriptfile
93 #########################################################
95 sub determine_scriptfile_name
97 my ( $filename ) = @_;
99 $installer::globals
::downloadfileextension
= ".sh";
100 $filename = $filename . $installer::globals
::downloadfileextension
;
101 $installer::globals
::downloadfilename
= $filename;
103 my $infoline = "Setting download shell script file name to $filename\n";
104 push( @installer::globals
::logfileinfo
, $infoline);
109 #########################################################
110 # Saving the script file in the installation directory
111 #########################################################
115 my ($directory, $newscriptfilename, $scriptfile) = @_;
117 $newscriptfilename = $directory . $installer::globals
::separator
. $newscriptfilename;
118 installer
::files
::save_file
($newscriptfilename, $scriptfile);
120 my $infoline = "Saving script file $newscriptfilename\n";
121 push( @installer::globals
::logfileinfo
, $infoline);
123 if ( ! $installer::globals
::iswindowsbuild
)
125 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";
129 return $newscriptfilename;
132 #########################################################
133 # Including checksum and size into script file
134 #########################################################
136 sub put_checksum_and_size_into_script
138 my ($scriptfile, $sumout) = @_;
143 if ( $sumout =~ /^\s*(\d+)\s+(\d+)\s*$/ )
150 installer
::exiter
::exit_program
("ERROR: Incorrect return value from /usr/bin/sum: $sumout", "put_checksum_and_size_into_script");
153 my $infoline = "Adding checksum $checksum and size $size into download shell script\n";
154 push( @installer::globals
::logfileinfo
, $infoline);
156 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
158 ${$scriptfile}[$i] =~ s/CHECKSUMPLACEHOLDER/$checksum/;
159 ${$scriptfile}[$i] =~ s/DISCSPACEPLACEHOLDER/$size/;
164 #########################################################
166 #########################################################
172 $md5sumfile = "/usr/bin/md5sum";
174 if ( ! -f
$md5sumfile ) { installer
::exiter
::exit_program
("ERROR: No file /usr/bin/md5sum", "call_md5sum"); }
176 my $systemcall = "$md5sumfile $filename |";
178 my $md5sumoutput = "";
180 open (SUM
, "$systemcall");
181 $md5sumoutput = <SUM
>;
184 my $returnvalue = $?
; # $? contains the return value of the systemcall
186 my $infoline = "Systemcall: $systemcall\n";
187 push( @installer::globals
::logfileinfo
, $infoline);
191 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
192 push( @installer::globals
::logfileinfo
, $infoline);
196 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
197 push( @installer::globals
::logfileinfo
, $infoline);
200 return $md5sumoutput;
203 #########################################################
205 #########################################################
209 ($md5sumoutput) = @_;
213 if ( $md5sumoutput =~ /^\s*(\w+?)\s+/ )
219 installer
::exiter
::exit_program
("ERROR: Incorrect return value from /usr/bin/md5sum: $md5sumoutput", "get_md5sum");
222 my $infoline = "Setting md5sum: $md5sum\n";
223 push( @installer::globals
::logfileinfo
, $infoline);
228 #########################################################
229 # Determining checksum and size of tar file
230 #########################################################
234 my ($filename, $getuidlibrary) = @_;
236 my $systemcall = "/usr/bin/sum $filename |";
240 open (SUM
, "$systemcall");
244 my $returnvalue = $?
; # $? contains the return value of the systemcall
246 my $infoline = "Systemcall: $systemcall\n";
247 push( @installer::globals
::logfileinfo
, $infoline);
251 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
252 push( @installer::globals
::logfileinfo
, $infoline);
256 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
257 push( @installer::globals
::logfileinfo
, $infoline);
260 $sumoutput =~ s/\s+$filename\s$//;
264 #########################################################
265 # Searching for the getuid.so in the solver
266 #########################################################
268 sub get_path_for_library
270 my ($includepatharrayref) = @_;
272 my $getuidlibraryname = "getuid.so";
274 my $getuidlibraryref = "";
276 if ( $installer::globals
::include_pathes_read
)
278 $getuidlibraryref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$getuidlibraryname, $includepatharrayref, 0);
282 $getuidlibraryref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath_classic
(\
$getuidlibraryname, $includepatharrayref, 0);
285 if ($$getuidlibraryref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find $getuidlibraryname!", "get_path_for_library"); }
287 return $$getuidlibraryref;
290 #########################################################
291 # Include the tar file into the script
292 #########################################################
294 sub include_tar_into_script
296 my ($scriptfile, $temporary_tarfile) = @_;
298 my $systemcall = "cat $temporary_tarfile >> $scriptfile && rm $temporary_tarfile";
299 my $returnvalue = system($systemcall);
301 my $infoline = "Systemcall: $systemcall\n";
302 push( @installer::globals
::logfileinfo
, $infoline);
306 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
307 push( @installer::globals
::logfileinfo
, $infoline);
311 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
312 push( @installer::globals
::logfileinfo
, $infoline);
317 #########################################################
318 # Create a tar file from the binary package
319 #########################################################
323 my ( $installdir, $tarfilename, $getuidlibrary) = @_;
325 my $ldpreloadstring = "";
326 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
328 my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - * > $tarfilename";
330 my $returnvalue = system($systemcall);
332 my $infoline = "Systemcall: $systemcall\n";
333 push( @installer::globals
::logfileinfo
, $infoline);
337 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
338 push( @installer::globals
::logfileinfo
, $infoline);
342 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
343 push( @installer::globals
::logfileinfo
, $infoline);
346 my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1";
347 $returnvalue = system($localcall);
349 return ( -s
$tarfilename );
352 #########################################################
353 # Creating a tar.gz file
354 #########################################################
356 sub create_tar_gz_file_from_package
358 my ($installdir, $getuidlibrary) = @_;
361 my $alldirs = installer
::systemactions
::get_all_directories
($installdir);
362 my $onedir = ${$alldirs}[0];
363 $installdir = $onedir;
365 my $allfiles = installer
::systemactions
::get_all_files_from_one_directory
($installdir);
367 for ( my $i = 0; $i <= $#{$allfiles}; $i++ )
369 my $onefile = ${$allfiles}[$i];
370 my $systemcall = "cd $installdir; rm $onefile";
371 my $returnvalue = system($systemcall);
373 $infoline = "Systemcall: $systemcall\n";
374 push( @installer::globals
::logfileinfo
, $infoline);
378 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
379 push( @installer::globals
::logfileinfo
, $infoline);
383 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
384 push( @installer::globals
::logfileinfo
, $infoline);
388 $alldirs = installer
::systemactions
::get_all_directories
($installdir);
389 $packagename = ${$alldirs}[0]; # only taking the first Solaris package
390 if ( $packagename eq "" ) { installer
::exiter
::exit_program
("ERROR: Could not find package in directory $installdir!", "determine_packagename"); }
392 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$packagename);
394 $installer::globals
::downloadfileextension
= ".tar.gz";
395 my $targzname = $packagename . $installer::globals
::downloadfileextension
;
396 $installer::globals
::downloadfilename
= $targzname;
397 my $ldpreloadstring = "";
398 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
400 $systemcall = "cd $installdir; $ldpreloadstring tar -cf - $packagename | gzip > $targzname";
401 print "... $systemcall ...\n";
403 my $returnvalue = system($systemcall);
405 $infoline = "Systemcall: $systemcall\n";
406 push( @installer::globals
::logfileinfo
, $infoline);
410 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
411 push( @installer::globals
::logfileinfo
, $infoline);
415 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
416 push( @installer::globals
::logfileinfo
, $infoline);
420 #########################################################
421 # Setting type of installation
422 #########################################################
424 sub get_installation_type
428 if ( $installer::globals
::languagepack
) { $type = "langpack"; }
429 else { $type = "install"; }
434 #########################################################
435 # Setting installation languages
436 #########################################################
438 sub get_downloadname_language
440 my ($languagestringref) = @_;
442 my $languages = $$languagestringref;
444 if ( $installer::globals
::added_english
)
446 $languages =~ s/en-US_//;
447 $languages =~ s/_en-US//;
450 # en-US is default language and can be removed therefore
451 # for one-language installation sets
453 if ( $languages =~ /^\s*en-US\s*$/ )
459 if ( length ($languages) > $installer::globals
::max_lang_length
)
461 $languages = 'multi';
467 #########################################################
468 # Setting download name, first part
469 #########################################################
471 sub get_downloadname_start
473 my ($allvariables) = @_;
476 if ( $allvariables->{'PRODUCTNAME'} eq "BrOffice.org" ) { $start = "BrOo"; }
481 #########################################################
482 # Setting installation addons
483 #########################################################
485 sub get_downloadname_addon
489 if ( $installer::globals
::islinuxdebbuild
) { $addon = $addon . "_deb"; }
491 if ( $installer::globals
::product
=~ /_wJRE\s*$/ ) { $addon = "_wJRE"; }
496 #########################################################
497 # Looking for versionstring in version.info
498 # This has to be the only content of this file.
499 #########################################################
501 sub get_versionstring
503 my ( $versionfile ) = @_;
505 my $versionstring = "";
507 for ( my $i = 0; $i <= $#{$versionfile}; $i++ )
509 my $oneline = ${$versionfile}[$i];
511 if ( $oneline =~ /^\s*\#/ ) { next; } # comment line
512 if ( $oneline =~ /^\s*\"\s*(.*?)\s*\"\s*$/ )
519 return $versionstring;
522 #########################################################
523 # Returning the current product version
524 # This has to be defined in file "version.info"
525 # in directory $installer::globals::ooouploaddir
526 #########################################################
528 sub get_current_version
531 my $versionstring = "";
532 my $filename = "version.info";
533 # $filename = $installer::globals::ooouploaddir . $installer::globals::separator . $filename;
537 $infoline = "File $filename exists. Trying to find current version.\n";
538 push( @installer::globals
::logfileinfo
, $infoline);
539 my $versionfile = installer
::files
::read_file
($filename);
540 $versionstring = get_versionstring
($versionfile);
541 $infoline = "Setting version string: $versionstring\n";
542 push( @installer::globals
::logfileinfo
, $infoline);
546 $infoline = "File $filename does not exist. No version setting in download file name.\n";
547 push( @installer::globals
::logfileinfo
, $infoline);
550 $installer::globals
::oooversionstring
= $versionstring;
552 return $versionstring;
555 #########################################################
556 # Determining the download file name
558 # OOo_2.0.2rc1_060213_Solarisx86_install_de
559 # OOo_2.0.2rc1_060213_LinuxIntel_langpack_zh-TW
560 # OOo_2.0.2rc1_060213_SolarisSparc_install_zh-TW_wJRE
561 # OOo_2.0.2rc1_060213_Win32Intel_install_zh-TW_wJRE
562 # OOo_2.0.157_LinuxIntel_install_de
564 #########################################################
566 sub set_download_filename
568 my ($languagestringref, $allvariables) = @_;
570 my $start = get_downloadname_start
($allvariables);
571 # my $versionstring = get_current_version();
572 my $versionstring = "";
573 my $date = installer
::logger
::set_installation_date
();
574 if ( $installer::globals
::product
=~ /_Dev\s*$/ ) { $date = ""; }
575 my $platform = installer
::worker
::get_platform_name
();
576 my $type = get_installation_type
();
577 my $language = get_downloadname_language
($languagestringref);
578 my $addon = get_downloadname_addon
();
580 if ( $installer::globals
::product
=~ /_Dev\s*$/ )
583 if ( $installer::globals
::minor
ne "" ) { $localminor = $installer::globals
::minor
; }
584 else { $localminor = $installer::globals
::lastminor
; }
585 if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; }
586 $versionstring = $allvariables->{'PRODUCTVERSION'} . "." . $localminor;
590 if ( $allvariables->{'PACKAGEVERSION'} )
592 $versionstring = $allvariables->{'PACKAGEVERSION'};
596 my $filename = $start . "_" . $versionstring . "_" . $date . "_" . $platform . "_" . $type . "_" . $language . $addon;
598 $filename =~ s/\_\_/\_/g; # necessary, if $versionstring or $platform or $language are empty
599 $filename =~ s/\_\s*$//; # necessary, if $language and $addon are empty
601 $installer::globals
::ooodownloadfilename
= $filename;
606 #########################################################
607 # Creating a tar.gz file
608 #########################################################
610 sub create_tar_gz_file_from_directory
612 my ($installdir, $getuidlibrary, $downloaddir, $downloadfilename) = @_;
616 my $packdir = $installdir;
617 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$packdir);
618 my $changedir = $installdir;
619 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$changedir);
621 my $ldpreloadstring = "";
622 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
624 $installer::globals
::downloadfileextension
= ".tar.gz";
625 $installer::globals
::downloadfilename
= $downloadfilename . $installer::globals
::downloadfileextension
;
626 my $targzname = $downloaddir . $installer::globals
::separator
. $installer::globals
::downloadfilename
;
628 $systemcall = "cd $changedir; $ldpreloadstring tar -cf - $packdir | gzip > $targzname";
630 my $returnvalue = system($systemcall);
632 $infoline = "Systemcall: $systemcall\n";
633 push( @installer::globals
::logfileinfo
, $infoline);
637 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
638 push( @installer::globals
::logfileinfo
, $infoline);
642 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
643 push( @installer::globals
::logfileinfo
, $infoline);
649 #########################################################
650 # Setting the variables in the download name
651 #########################################################
653 sub resolve_variables_in_downloadname
655 my ($allvariables, $downloadname, $languagestringref) = @_;
657 # Typical name: soa-{productversion}-{extension}-bin-{os}-{languages}
659 my $productversion = "";
660 if ( $allvariables->{'PRODUCTVERSION'} ) { $productversion = $allvariables->{'PRODUCTVERSION'}; }
661 $downloadname =~ s/\{productversion\}/$productversion/;
663 my $ppackageversion = "";
664 if ( $allvariables->{'PACKAGEVERSION'} ) { $packageversion = $allvariables->{'PACKAGEVERSION'}; }
665 $downloadname =~ s/\{packageversion\}/$packageversion/;
668 if ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) { $extension = $allvariables->{'SHORT_PRODUCTEXTENSION'}; }
669 $extension = lc($extension);
670 $downloadname =~ s/\{extension\}/$extension/;
673 if ( $installer::globals
::iswindowsbuild
) { $os = "windows"; }
674 elsif ( $installer::globals
::issolarissparcbuild
) { $os = "solsparc"; }
675 elsif ( $installer::globals
::issolarisx86build
) { $os = "solia"; }
676 elsif ( $installer::globals
::islinuxbuild
) { $os = "linux"; }
677 elsif ( $installer::globals
::compiler
=~ /unxmacxi/ ) { $os = "macosxi"; }
678 elsif ( $installer::globals
::compiler
=~ /unxmacxp/ ) { $os = "macosxp"; }
680 $downloadname =~ s/\{os\}/$os/;
682 my $languages = $$languagestringref;
683 $downloadname =~ s/\{languages\}/$languages/;
685 $downloadname =~ s/\-\-\-/\-/g;
686 $downloadname =~ s/\-\-/\-/g;
687 $downloadname =~ s/\-\s*$//;
689 return $downloadname;
692 ##################################################################
693 # Windows: Replacing one placeholder with the specified value
694 ##################################################################
696 sub replace_one_variable
698 my ($templatefile, $placeholder, $value) = @_;
700 my $infoline = "Replacing $placeholder by $value in nsi file\n";
701 push( @installer::globals
::logfileinfo
, $infoline);
703 for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
705 ${$templatefile}[$i] =~ s/$placeholder/$value/g;
710 ########################################################################################
711 # Converting a string to a unicode string
712 ########################################################################################
714 sub convert_to_unicode
718 my $unicodestring = "";
720 my $stringlength = length($string);
722 for ( my $i = 0; $i < $stringlength; $i++ )
724 $unicodestring = $unicodestring . substr($string, $i, 1);
725 $unicodestring = $unicodestring . chr(0);
728 return $unicodestring;
731 ##################################################################
732 # Windows: Setting nsis version is necessary because of small
733 # changes in nsis from version 2.0.4 to 2.3.1
734 ##################################################################
740 my $searchstring = "\$\{LangFileString\}"; # occurs only in nsis 2.3.1 or similar
742 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
744 if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ )
746 # this is nsis 2.3.1 or similar
747 $installer::globals
::nsis231
= 1;
748 $installer::globals
::unicodensis
= 0;
753 # checking unicode version
754 $searchstring = convert_to_unicode
($searchstring);
756 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
758 if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ )
760 # this is nsis 2.3.1 or similar
761 $installer::globals
::nsis231
= 1;
762 $installer::globals
::unicodensis
= 1;
767 if ( ! $installer::globals
::nsis231
) { $installer::globals
::nsis204
= 1; }
770 ##################################################################
771 # Windows: Including the product name into nsi template
772 ##################################################################
774 sub put_windows_productname_into_template
776 my ($templatefile, $variableshashref) = @_;
778 my $productname = $variableshashref->{'PRODUCTNAME'};
779 $productname =~ s/\.//g; # OpenOffice.org -> OpenOfficeorg
781 replace_one_variable
($templatefile, "PRODUCTNAMEPLACEHOLDER", $productname);
784 ##################################################################
785 # Windows: Including the path to the banner.bmp into nsi template
786 ##################################################################
788 sub put_banner_bmp_into_template
790 my ($templatefile, $includepatharrayref, $allvariables) = @_;
792 # my $filename = "downloadbanner.bmp";
793 if ( ! $allvariables->{'DOWNLOADBANNER'} ) { installer
::exiter
::exit_program
("ERROR: DOWNLOADBANNER not defined in product definition!", "put_banner_bmp_into_template"); }
794 my $filename = $allvariables->{'DOWNLOADBANNER'};
796 my $completefilenameref = "";
798 if ( $installer::globals
::include_pathes_read
)
800 $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$filename, $includepatharrayref, 0);
804 $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath_classic
(\
$filename, $includepatharrayref, 0);
807 if ($$completefilenameref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find download file $filename!", "put_banner_bmp_into_template"); }
809 if ( $^O
=~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g
; }
811 replace_one_variable
($templatefile, "BANNERBMPPLACEHOLDER", $$completefilenameref);
814 ##################################################################
815 # Windows: Including the path to the welcome.bmp into nsi template
816 ##################################################################
818 sub put_welcome_bmp_into_template
820 my ($templatefile, $includepatharrayref, $allvariables) = @_;
822 # my $filename = "downloadbitmap.bmp";
823 if ( ! $allvariables->{'DOWNLOADBITMAP'} ) { installer
::exiter
::exit_program
("ERROR: DOWNLOADBITMAP not defined in product definition!", "put_welcome_bmp_into_template"); }
824 my $filename = $allvariables->{'DOWNLOADBITMAP'};
826 my $completefilenameref = "";
828 if ( $installer::globals
::include_pathes_read
)
830 $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$filename, $includepatharrayref, 0);
834 $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath_classic
(\
$filename, $includepatharrayref, 0);
837 if ($$completefilenameref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find download file $filename!", "put_welcome_bmp_into_template"); }
839 if ( $^O
=~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g
; }
841 replace_one_variable
($templatefile, "WELCOMEBMPPLACEHOLDER", $$completefilenameref);
844 ##################################################################
845 # Windows: Including the path to the setup.ico into nsi template
846 ##################################################################
848 sub put_setup_ico_into_template
850 my ($templatefile, $includepatharrayref, $allvariables) = @_;
852 # my $filename = "downloadsetup.ico";
853 if ( ! $allvariables->{'DOWNLOADSETUPICO'} ) { installer
::exiter
::exit_program
("ERROR: DOWNLOADSETUPICO not defined in product definition!", "put_setup_ico_into_template"); }
854 my $filename = $allvariables->{'DOWNLOADSETUPICO'};
856 my $completefilenameref = "";
858 if ( $installer::globals
::include_pathes_read
)
860 $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$filename, $includepatharrayref, 0);
864 $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath_classic
(\
$filename, $includepatharrayref, 0);
867 if ($$completefilenameref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find download file $filename!", "put_setup_ico_into_template"); }
869 if ( $^O
=~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g
; }
871 replace_one_variable
($templatefile, "SETUPICOPLACEHOLDER", $$completefilenameref);
874 ##################################################################
875 # Windows: Including the publisher into nsi template
876 ##################################################################
878 sub put_publisher_into_template
880 my ($templatefile) = @_;
882 my $publisher = "Sun Microsystems, Inc.";
884 replace_one_variable
($templatefile, "PUBLISHERPLACEHOLDER", $publisher);
887 ##################################################################
888 # Windows: Including the web site into nsi template
889 ##################################################################
891 sub put_website_into_template
893 my ($templatefile) = @_;
895 my $website = "http\:\/\/www\.sun\.com\/staroffice";
897 replace_one_variable
($templatefile, "WEBSITEPLACEHOLDER", $website);
900 ##################################################################
901 # Windows: Including the Java file name into nsi template
902 ##################################################################
904 sub put_javafilename_into_template
906 my ($templatefile, $variableshashref) = @_;
908 my $javaversion = "";
910 if ( $variableshashref->{'WINDOWSJAVAFILENAME'} ) { $javaversion = $variableshashref->{'WINDOWSJAVAFILENAME'}; }
912 replace_one_variable
($templatefile, "WINDOWSJAVAFILENAMEPLACEHOLDER", $javaversion);
915 ##################################################################
916 # Windows: Including the product version into nsi template
917 ##################################################################
919 sub put_windows_productversion_into_template
921 my ($templatefile, $variableshashref) = @_;
923 my $productversion = $variableshashref->{'PRODUCTVERSION'};
925 replace_one_variable
($templatefile, "PRODUCTVERSIONPLACEHOLDER", $productversion);
928 ##################################################################
929 # Windows: Including the product version into nsi template
930 ##################################################################
932 sub put_windows_productpath_into_template
934 my ($templatefile, $variableshashref, $languagestringref, $localnsisdir) = @_;
936 my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'};
938 my $locallangs = $$languagestringref;
939 $locallangs =~ s/_/ /g;
940 if (length($locallangs) > $installer::globals
::max_lang_length
) { $locallangs = "multi lingual"; }
942 if ( ! $installer::globals
::languagepack
) { $productpath = $productpath . " (" . $locallangs . ")"; }
944 # if (( $installer::globals::languagepack ) && ( $installer::globals::unicodensis )) { $productpath = convert_textstring_to_utf16($productpath, $localnsisdir, "stringhelper.txt"); }
946 replace_one_variable
($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath);
949 ##################################################################
950 # Windows: Including download file name into nsi template
951 ##################################################################
953 sub put_outputfilename_into_template
955 my ($templatefile, $downloadname) = @_;
957 $installer::globals
::downloadfileextension
= ".exe";
958 $downloadname = $downloadname . $installer::globals
::downloadfileextension
;
959 $installer::globals
::downloadfilename
= $downloadname;
961 replace_one_variable
($templatefile, "DOWNLOADNAMEPLACEHOLDER", $downloadname);
964 ##################################################################
965 # Windows: Generating the file list in nsi file format
966 ##################################################################
970 my ( $basedir ) = @_;
974 my $alldirs = installer
::systemactions
::get_all_directories
($basedir);
975 unshift(@
{$alldirs}, $basedir); # $basedir is the first directory in $alldirs
977 for ( my $i = 0; $i <= $#{$alldirs}; $i++ )
979 my $onedir = ${$alldirs}[$i];
982 # SetOutPath "$INSTDIR"
984 my $relativedir = $onedir;
985 $relativedir =~ s/\Q$basedir\E//;
987 my $oneline = " " . "SetOutPath" . " " . "\"\$INSTDIR" . $relativedir . "\"" . "\n";
989 if ( $^O
=~ /cygwin/i ) {
990 $oneline =~ s/\//\\/g
;
992 push(@filelist, $oneline);
994 # Collecting all files in the specific directory
996 my $files = installer
::systemactions
::get_all_files_from_one_directory
($onedir);
998 for ( my $j = 0; $j <= $#{$files}; $j++ )
1000 my $onefile = ${$files}[$j];
1002 my $fileline = " " . "File" . " " . "\"" . $onefile . "\"" . "\n";
1004 if ( $^O
=~ /cygwin/i ) {
1005 $fileline =~ s/\//\\/g
;
1007 push(@filelist, $fileline);
1014 ##################################################################
1015 # Windows: Including list of all files into nsi template
1016 ##################################################################
1018 sub put_filelist_into_template
1020 my ($templatefile, $installationdir) = @_;
1022 my $filelist = get_file_list
($installationdir);
1024 my $filestring = "";
1026 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
1028 $filestring = $filestring . ${$filelist}[$i];
1031 $filestring =~ s/\s*$//;
1033 replace_one_variable
($templatefile, "ALLFILESPLACEHOLDER", $filestring);
1036 ##################################################################
1037 # Windows: NSIS uses specific language names
1038 ##################################################################
1040 sub nsis_language_converter
1042 my ($language) = @_;
1044 my $nsislanguage = "";
1046 if ( $language eq "en-US" ) { $nsislanguage = "English"; }
1047 elsif ( $language eq "sq" ) { $nsislanguage = "Albanian"; }
1048 elsif ( $language eq "ar" ) { $nsislanguage = "Arabic"; }
1049 elsif ( $language eq "bg" ) { $nsislanguage = "Bulgarian"; }
1050 elsif ( $language eq "ca" ) { $nsislanguage = "Catalan"; }
1051 elsif ( $language eq "hr" ) { $nsislanguage = "Croatian"; }
1052 elsif ( $language eq "cs" ) { $nsislanguage = "Czech"; }
1053 elsif ( $language eq "da" ) { $nsislanguage = "Danish"; }
1054 elsif ( $language eq "nl" ) { $nsislanguage = "Dutch"; }
1055 elsif ( $language eq "de" ) { $nsislanguage = "German"; }
1056 elsif ( $language eq "de-LU" ) { $nsislanguage = "Luxembourgish"; }
1057 elsif ( $language eq "et" ) { $nsislanguage = "Estonian"; }
1058 elsif ( $language eq "fa" ) { $nsislanguage = "Farsi"; }
1059 elsif ( $language eq "el" ) { $nsislanguage = "Greek"; }
1060 elsif ( $language eq "fi" ) { $nsislanguage = "Finnish"; }
1061 elsif ( $language eq "fr" ) { $nsislanguage = "French"; }
1062 elsif ( $language eq "hu" ) { $nsislanguage = "Hungarian"; }
1063 elsif ( $language eq "he" ) { $nsislanguage = "Hebrew"; }
1064 elsif ( $language eq "id" ) { $nsislanguage = "Indonesian"; }
1065 elsif ( $language eq "it" ) { $nsislanguage = "Italian"; }
1066 elsif ( $language eq "lv" ) { $nsislanguage = "Latvian"; }
1067 elsif ( $language eq "lt" ) { $nsislanguage = "Lithuanian"; }
1068 elsif ( $language eq "mk" ) { $nsislanguage = "Macedonian"; }
1069 elsif ( $language eq "mn" ) { $nsislanguage = "Mongolian"; }
1070 elsif ( $language eq "no" ) { $nsislanguage = "Norwegian"; }
1071 elsif ( $language eq "no-NO" ) { $nsislanguage = "Norwegian"; }
1072 elsif ( $language eq "es" ) { $nsislanguage = "Spanish"; }
1073 elsif ( $language eq "sl" ) { $nsislanguage = "Slovenian"; }
1074 elsif ( $language eq "sv" ) { $nsislanguage = "Swedish"; }
1075 elsif ( $language eq "sk" ) { $nsislanguage = "Slovak"; }
1076 elsif ( $language eq "pl" ) { $nsislanguage = "Polish"; }
1077 elsif ( $language eq "pt-BR" ) { $nsislanguage = "PortugueseBR"; }
1078 elsif ( $language eq "pt" ) { $nsislanguage = "Portuguese"; }
1079 elsif ( $language eq "ro" ) { $nsislanguage = "Romanian"; }
1080 elsif ( $language eq "ru" ) { $nsislanguage = "Russian"; }
1081 elsif ( $language eq "sh" ) { $nsislanguage = "SerbianLatin"; }
1082 elsif ( $language eq "sr" ) { $nsislanguage = "Serbian"; }
1083 elsif ( $language eq "sr-SP" ) { $nsislanguage = "Serbian"; }
1084 elsif ( $language eq "uk" ) { $nsislanguage = "Ukrainian"; }
1085 elsif ( $language eq "tr" ) { $nsislanguage = "Turkish"; }
1086 elsif ( $language eq "ja" ) { $nsislanguage = "Japanese"; }
1087 elsif ( $language eq "ko" ) { $nsislanguage = "Korean"; }
1088 elsif ( $language eq "th" ) { $nsislanguage = "Thai"; }
1089 elsif ( $language eq "vi" ) { $nsislanguage = "Vietnamese"; }
1090 elsif ( $language eq "zh-CN" ) { $nsislanguage = "SimpChinese"; }
1091 elsif ( $language eq "zh-TW" ) { $nsislanguage = "TradChinese"; }
1093 my $infoline = "NSIS language_converter : Could not find nsis language for $language!\n";
1094 push( @installer::globals
::logfileinfo
, $infoline);
1095 $nsislanguage = "English";
1096 # installer::exiter::exit_program("ERROR: Could not find nsis language for $language!", "nsis_language_converter");
1099 return $nsislanguage;
1102 ##################################################################
1103 # Windows: Including list of all languages into nsi template
1104 ##################################################################
1106 sub put_language_list_into_template
1108 my ($templatefile, $languagesarrayref) = @_;
1110 my $alllangstring = "";
1113 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1115 my $onelanguage = ${$languagesarrayref}[$i];
1116 my $nsislanguage = nsis_language_converter
($onelanguage);
1117 $nsislangs{$nsislanguage}++;
1120 foreach my $nsislanguage ( keys(%nsislangs) )
1122 # Syntax: !insertmacro MUI_LANGUAGE "English"
1123 my $langstring = "\!insertmacro MUI_LANGUAGE_PACK " . $nsislanguage . "\n";
1124 if ( $nsislanguage eq "English" )
1126 $alllangstring = $langstring . $alllangstring;
1130 $alllangstring = $alllangstring . $langstring;
1134 $alllangstring =~ s/\s*$//;
1136 replace_one_variable
($templatefile, "ALLLANGUAGESPLACEHOLDER", $alllangstring);
1139 ##################################################################
1140 # Windows: Collecting all identifier from mlf file
1141 ##################################################################
1145 my ( $mlffile ) = @_;
1147 my @identifier = ();
1149 for ( my $i = 0; $i <= $#{$mlffile}; $i++ )
1151 my $oneline = ${$mlffile}[$i];
1153 if ( $oneline =~ /^\s*\[(.+)\]\s*$/ )
1155 my $identifier = $1;
1156 push(@identifier, $identifier);
1160 return \
@identifier;
1163 ##############################################################
1164 # Returning the complete block in all languages
1165 # for a specified string
1166 ##############################################################
1168 sub get_language_block_from_language_file
1170 my ($searchstring, $languagefile) = @_;
1172 my @language_block = ();
1174 for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
1176 if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
1180 push(@language_block, ${$languagefile}[$counter]);
1183 while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
1185 push(@language_block, ${$languagefile}[$counter]);
1193 return \
@language_block;
1196 ##############################################################
1197 # Returning a specific language string from the block
1198 # of all translations
1199 ##############################################################
1201 sub get_language_string_from_language_block
1203 my ($language_block, $language) = @_;
1207 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1209 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1216 if ( $newstring eq "" )
1218 $language = "en-US"; # defaulting to english
1220 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1222 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1233 ##################################################################
1234 # Windows: Replacing strings in NSIS nsh file
1236 # !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis auswählen"
1237 ##################################################################
1239 sub replace_identifier_in_nshfile
1241 my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_;
1243 if ( $installer::globals
::nsis231
)
1245 $newstring =~ s/\\r/\$\\r/g; # \r -> $\r in modern nsis versions
1246 $newstring =~ s/\\n/\$\\n/g; # \n -> $\n in modern nsis versions
1249 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1251 if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1254 ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1255 my $infoline = "NSIS replacement in $nshfilename ($onelanguage): $oldstring \-\> $newstring\n";
1256 push( @installer::globals
::logfileinfo
, $infoline);
1261 ##################################################################
1262 # Windows: Replacing strings in NSIS nlf file
1263 # nlf file syntax (2 lines):
1266 ##################################################################
1268 sub replace_identifier_in_nlffile
1270 my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_;
1272 for ( my $i = 0; $i <= $#{$nlffile}; $i++ )
1274 if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ )
1277 my $oldstring = ${$nlffile}[$next];
1278 ${$nlffile}[$next] = $newstring . "\n";
1279 $oldstring =~ s/\s*$//;
1280 my $infoline = "NSIS replacement in $nlffilename ($onelanguage): $oldstring \-\> $newstring\n";
1281 push( @installer::globals
::logfileinfo
, $infoline);
1286 ##################################################################
1287 # Windows: Translating the NSIS nsh and nlf file
1288 ##################################################################
1290 sub translate_nsh_nlf_file
1292 my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_;
1294 # Analyzing the mlf file, collecting all Identifier
1295 my $allidentifier = get_identifier
($mlffile);
1297 $onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US");
1298 for ( my $i = 0; $i <= $#{$allidentifier}; $i++ )
1300 my $identifier = ${$allidentifier}[$i];
1301 my $language_block = get_language_block_from_language_file
($identifier, $mlffile);
1302 my $newstring = get_language_string_from_language_block
($language_block, $onelanguage);
1305 $newstring =~ s/\\\'/\'/g;
1307 replace_identifier_in_nshfile
($nshfile, $identifier, $newstring, $nshfilename, $onelanguage);
1308 replace_identifier_in_nlffile
($nlffile, $identifier, $newstring, $nlffilename, $onelanguage);
1312 ##################################################################
1313 # Converting utf 16 file to utf 8
1314 ##################################################################
1316 sub convert_utf16_to_utf8
1318 my ( $filename ) = @_;
1322 my $savfilename = $filename . "_before.utf16";
1323 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1325 # open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1326 # open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1327 open( IN
, "<:encoding(UTF16-LE)", $filename ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1328 while ( $line = <IN
> ) {
1329 push @localfile, $line;
1333 if ( open( OUT
, ">:utf8", $filename ) )
1335 print OUT
@localfile;
1339 $savfilename = $filename . "_before.utf8";
1340 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1343 ##################################################################
1344 # Converting utf 8 file to utf 16
1345 ##################################################################
1347 sub convert_utf8_to_utf16
1349 my ( $filename ) = @_;
1353 my $savfilename = $filename . "_after.utf8";
1354 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1356 open( IN
, "<:utf8", $filename ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16");
1357 while ( $line = <IN
> ) {
1358 push @localfile, $line;
1362 if ( open( OUT
, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) )
1364 print OUT
@localfile;
1368 $savfilename = $filename . "_after.utf16";
1369 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1372 ##################################################################
1373 # Converting text string to utf 16
1374 ##################################################################
1376 sub convert_textstring_to_utf16
1378 my ( $textstring, $localnsisdir, $shortfilename ) = @_;
1380 my $filename = $localnsisdir . $installer::globals
::separator
. $shortfilename;
1381 my @filecontent = ();
1382 push(@filecontent, $textstring);
1383 installer
::files
::save_file
($filename, \
@filecontent);
1384 convert_utf8_to_utf16
($filename);
1385 my $newfile = installer
::files
::read_file
($filename);
1386 my $utf16string = "";
1387 if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; }
1389 return $utf16string;
1392 ##################################################################
1393 # Windows: Copying NSIS language files to local nsis directory
1394 ##################################################################
1396 sub copy_and_translate_nsis_language_files
1398 my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_;
1400 my $nlffilepath = $nsispath . $installer::globals
::separator
. "Contrib" . $installer::globals
::separator
. "Language\ files" . $installer::globals
::separator
;
1401 my $nshfilepath = $nsispath . $installer::globals
::separator
. "Contrib" . $installer::globals
::separator
. "Modern\ UI" . $installer::globals
::separator
. "Language files" . $installer::globals
::separator
;
1405 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1407 my $onelanguage = ${$languagesarrayref}[$i];
1408 my $nsislanguage = nsis_language_converter
($onelanguage);
1410 # Copying the nlf file
1411 my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf";
1412 if ( ! -f
$sourcepath ) { installer
::exiter
::exit_program
("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); }
1413 my $nlffilename = $localnsisdir . $installer::globals
::separator
. $nsislanguage . "_pack.nlf";
1414 if ( $^O
=~ /cygwin/i ) { $nlffilename =~ s/\//\\/g
; }
1415 installer
::systemactions
::copy_one_file
($sourcepath, $nlffilename);
1417 # Copying the nsh file
1418 # In newer nsis versions, the nsh file is located next to the nlf file
1419 $sourcepath = $nshfilepath . $nsislanguage . "\.nsh";
1420 if ( ! -f
$sourcepath )
1422 # trying to find the nsh file next to the nlf file
1423 $sourcepath = $nlffilepath . $nsislanguage . "\.nsh";
1424 if ( ! -f
$sourcepath )
1426 installer
::exiter
::exit_program
("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1429 my $nshfilename = $localnsisdir . $installer::globals
::separator
. $nsislanguage . "_pack.nsh";
1430 if ( $^O
=~ /cygwin/i ) { $nshfilename =~ s/\//\\/g
; }
1431 installer
::systemactions
::copy_one_file
($sourcepath, $nshfilename);
1433 # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1434 my $nshfile = installer
::files
::read_file
($nshfilename);
1435 set_nsis_version
($nshfile);
1437 if ( $installer::globals
::unicodensis
)
1439 $infoline = "This is Unicode NSIS!\n";
1440 push( @installer::globals
::logfileinfo
, $infoline);
1441 convert_utf16_to_utf8
($nshfilename);
1442 convert_utf16_to_utf8
($nlffilename);
1443 $nshfile = installer
::files
::read_file
($nshfilename); # read nsh file again
1446 replace_one_variable
($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1448 # find the ulf file for translation
1449 my $mlffile = get_translation_file
($allvariables);
1451 # Translate the files
1452 my $nlffile = installer
::files
::read_file
($nlffilename);
1453 translate_nsh_nlf_file
($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1455 installer
::files
::save_file
($nshfilename, $nshfile);
1456 installer
::files
::save_file
($nlffilename, $nlffile);
1458 if ( $installer::globals
::unicodensis
)
1460 convert_utf8_to_utf16
($nshfilename);
1461 convert_utf8_to_utf16
($nlffilename);
1467 ##################################################################
1468 # Windows: Including the nsis path into the nsi template
1469 ##################################################################
1471 sub put_nsis_path_into_template
1473 my ($templatefile, $nsisdir) = @_;
1475 replace_one_variable
($templatefile, "NSISPATHPLACEHOLDER", $nsisdir);
1478 ##################################################################
1479 # Windows: Including the output path into the nsi template
1480 ##################################################################
1482 sub put_output_path_into_template
1484 my ($templatefile, $downloaddir) = @_;
1486 if ( $^O
=~ /cygwin/i ) { $downloaddir =~ s/\//\\/g
; }
1488 replace_one_variable
($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1491 ##################################################################
1492 # Windows: Only allow specific code for nsis 2.0.4 or nsis 2.3.1
1493 ##################################################################
1495 sub put_version_specific_code_into_template
1497 my ($templatefile) = @_;
1502 if ( $installer::globals
::nsis204
)
1511 replace_one_variable
($templatefile, "\#204\#", $subst204);
1512 replace_one_variable
($templatefile, "\#231\#", $subst231);
1515 ##################################################################
1516 # Windows: Finding the path to the nsis SDK
1517 ##################################################################
1519 sub get_path_to_nsis_sdk
1526 if ( $ENV{'NSIS_PATH'} ) {
1527 $nsispath = $ENV{'NSIS_PATH'};
1528 } elsif ( $ENV{'SOLARROOT'} ) {
1529 $nsispath = $ENV{'SOLARROOT'} . $installer::globals
::separator
. "NSIS";
1531 # do we have nsis already in path ?
1532 @paths = split(/:/, $ENV{'PATH'});
1533 foreach $paths (@paths) {
1534 $paths =~ s/[\/\\]+$//; # remove trailing slashes;
1535 $nsispath = $paths . "/nsis";
1537 if ( -x
$nsispath ) {
1546 if ( $ENV{'NSISSDK_SOURCE'} ) {
1547 installer
::logger
::print_warning
( "NSISSDK_SOURCE is deprecated. use NSIS_PATH instead.\n" );
1548 $nsispath = $ENV{'NSISSDK_SOURCE'}; # overriding the NSIS SDK with NSISSDK_SOURCE
1551 # if( ($^O =~ /cygwin/i) and $nsispath =~ /\\/ ) {
1552 # # We need a POSIX path for W32-4nt-cygwin-perl
1553 # $nsispath =~ s/\\/\\\\/g;
1554 # chomp( $nsispath = qx{cygpath -u "$nsispath"} );
1557 if ( $nsispath eq "" )
1559 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");
1560 } elsif ( ! -d
$nsispath )
1562 installer
::exiter
::exit_program
("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1568 ##################################################################
1569 # Windows: Executing NSIS to create the installation set
1570 ##################################################################
1574 my ( $nsispath, $nsifile ) = @_;
1576 my $makensisexe = $nsispath . $installer::globals
::separator
. "makensis.exe";
1578 installer
::logger
::print_message
( "... starting $makensisexe ... \n" );
1580 if( $^O
=~ /cygwin/i ) { $nsifile =~ s/\\/\//g
; }
1582 my $systemcall = "$makensisexe $nsifile |";
1584 my $infoline = "Systemcall: $systemcall\n";
1585 push( @installer::globals
::logfileinfo
, $infoline);
1587 my @nsisoutput = ();
1589 open (NSI
, "$systemcall");
1590 while (<NSI
>) {push(@nsisoutput, $_); }
1593 my $returnvalue = $?
; # $? contains the return value of the systemcall
1597 $infoline = "ERROR: $systemcall !\n";
1598 push( @installer::globals
::logfileinfo
, $infoline);
1602 $infoline = "Success: $systemcall\n";
1603 push( @installer::globals
::logfileinfo
, $infoline);
1606 for ( my $i = 0; $i <= $#nsisoutput; $i++ ) { push( @installer::globals
::logfileinfo
, "$nsisoutput[$i]"); }
1610 #################################################################################
1611 # Replacing one variable in one files
1612 #################################################################################
1614 sub replace_one_variable_in_translationfile
1616 my ($translationfile, $variable, $searchstring) = @_;
1618 for ( my $i = 0; $i <= $#{$translationfile}; $i++ )
1620 ${$translationfile}[$i] =~ s/\%$searchstring/$variable/g;
1624 #################################################################################
1625 # Replacing the variables in the translation file
1626 #################################################################################
1628 sub replace_variables
1630 my ($translationfile, $variableshashref) = @_;
1632 foreach $key (keys %{$variableshashref})
1634 my $value = $variableshashref->{$key};
1636 # special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'}
1637 if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; }
1639 replace_one_variable_in_translationfile
($translationfile, $value, $key);
1643 #########################################################
1644 # Getting the translation file for the nsis installer
1645 #########################################################
1647 sub get_translation_file
1649 my ($allvariableshashref) = @_;
1650 my $translationfilename = $installer::globals
::idtlanguagepath
. $installer::globals
::separator
. $installer::globals
::nsisfilename
;
1651 if ( $installer::globals
::unicodensis
) { $translationfilename = $translationfilename . ".uulf"; }
1652 else { $translationfilename = $translationfilename . ".mlf"; }
1653 if ( ! -f
$translationfilename ) { installer
::exiter
::exit_program
("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1654 my $translationfile = installer
::files
::read_file
($translationfilename);
1655 replace_variables
($translationfile, $allvariableshashref);
1657 my $infoline = "Reading translation file: $translationfilename\n";
1658 push( @installer::globals
::logfileinfo
, $infoline);
1660 return $translationfile;
1663 ####################################################
1664 # Removing english, if it was added before
1665 ####################################################
1667 sub remove_english_for_nsis_installer
1669 my ($languagestringref, $languagesarrayref) = @_;
1671 # $$languagestringref =~ s/en-US_//;
1672 # shift(@{$languagesarrayref});
1674 @
{$languagesarrayref} = ("en-US"); # only english for NSIS installer!
1677 ####################################################
1678 # Creating link tree for upload
1679 ####################################################
1681 sub create_link_tree
1683 my ($sourcedownloadfile, $destfilename, $versionstring) = @_;
1685 if ( ! $installer::globals
::ooouploaddir
) { installer
::exiter
::exit_program
("ERROR: Directory for OOo upload not defined!", "create_link_tree"); }
1686 my $versiondir = $installer::globals
::ooouploaddir
. $installer::globals
::separator
. $versionstring;
1687 my $infoline = "Directory for the link: $versiondir\n";
1688 push(@installer::globals
::logfileinfo
, $infoline);
1690 if ( ! -d
$versiondir ) { installer
::systemactions
::create_directory_structure
($versiondir); }
1692 # inside directory $versiondir all links have to be created
1693 my $linkdestination = $versiondir . $installer::globals
::separator
. $destfilename;
1695 # If there is an older version of this file (link), it has to be removed
1696 if ( -f
$linkdestination ) { unlink($linkdestination); }
1698 $infoline = "Creating hard link from $sourcedownloadfile to $linkdestination\n";
1699 push(@installer::globals
::logfileinfo
, $infoline);
1700 installer
::systemactions
::hardlink_one_file
($sourcedownloadfile, $linkdestination);
1703 #######################################################
1704 # Setting supported platform for Sun OpenOffice.org
1706 #######################################################
1708 sub is_supported_platform
1710 my $is_supported = 0;
1712 if (( $installer::globals
::islinuxrpmbuild
) ||
1713 ( $installer::globals
::issolarissparcbuild
) ||
1714 ( $installer::globals
::issolarisx86build
) ||
1715 ( $installer::globals
::iswindowsbuild
))
1720 return $is_supported;
1723 ####################################################
1724 # Creating download installation sets
1725 ####################################################
1727 sub create_download_sets
1729 my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_;
1733 my $force = 1; # print this message even in 'quiet' mode
1734 installer
::logger
::print_message
( "\n******************************************\n" );
1735 installer
::logger
::print_message
( "... creating download installation set ...\n", $force );
1736 installer
::logger
::print_message
( "******************************************\n" );
1738 installer
::logger
::include_header_into_logfile
("Creating download installation sets:");
1740 # special handling for installation sets, to which english was added automatically
1741 if ( $installer::globals
::added_english
) { remove_english_for_nsis_installer
($languagestringref, $languagesarrayref); }
1743 my $firstdir = $installationdir;
1744 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$firstdir);
1746 my $lastdir = $installationdir;
1747 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$lastdir);
1749 if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ }
1750 else { $lastdir = $lastdir . "_download_inprogress"; }
1752 # removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed"
1754 my $downloaddir = $firstdir . $lastdir;
1756 if ( -d
$downloaddir ) { installer
::systemactions
::remove_complete_directory
($downloaddir); }
1758 my $olddir = $downloaddir;
1759 $olddir =~ s/_inprogress/_witherror/;
1760 if ( -d
$olddir ) { installer
::systemactions
::remove_complete_directory
($olddir); }
1762 $olddir = $downloaddir;
1763 $olddir =~ s/_inprogress//;
1764 if ( -d
$olddir ) { installer
::systemactions
::remove_complete_directory
($olddir); }
1766 # creating the new directory
1768 installer
::systemactions
::create_directory
($downloaddir);
1770 $installer::globals
::saveinstalldir
= $downloaddir;
1772 # evaluating the name of the download file
1774 if ( $allvariableshashref->{'OOODOWNLOADNAME'} ) { $downloadname = set_download_filename
($languagestringref, $allvariableshashref); }
1775 else { $downloadname = resolve_variables_in_downloadname
($allvariableshashref, $downloadname, $languagestringref); }
1777 if ( ! $installer::globals
::iswindowsbuild
) # Unix specific part
1780 # getting the path of the getuid.so (only required for Solaris and Linux)
1781 my $getuidlibrary = "";
1782 if (( $installer::globals
::issolarisbuild
) || ( $installer::globals
::islinuxbuild
)) { $getuidlibrary = get_path_for_library
($includepatharrayref); }
1784 if ( $allvariableshashref->{'OOODOWNLOADNAME'} )
1786 my $downloadfile = create_tar_gz_file_from_directory
($installationdir, $getuidlibrary, $downloaddir, $downloadname);
1790 # find and read setup script template
1791 my $scriptfilename = "downloadscript.sh";
1795 if ( $installer::globals
::include_pathes_read
)
1797 $scriptref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$scriptfilename, $includepatharrayref, 0);
1801 $scriptref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath_classic
(\
$scriptfilename, $includepatharrayref, 0);
1804 if ($$scriptref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); }
1805 my $scriptfile = installer
::files
::read_file
($$scriptref);
1807 $infoline = "Found script file $scriptfilename: $$scriptref \n";
1808 push( @installer::globals
::logfileinfo
, $infoline);
1810 # add product name into script template
1811 put_productname_into_script
($scriptfile, $allvariableshashref);
1813 # replace linenumber in script template
1814 put_linenumber_into_script
($scriptfile);
1817 my $temporary_tarfile_name = $downloaddir . $installer::globals
::separator
. 'installset.tar';
1818 my $size = tar_package
($installationdir, $temporary_tarfile_name, $getuidlibrary);
1819 installer
::exiter
::exit_program
("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size;
1821 # calling sum to determine checksum and size of the tar file
1822 my $sumout = call_sum
($temporary_tarfile_name);
1824 # writing checksum and size into scriptfile
1825 put_checksum_and_size_into_script
($scriptfile, $sumout);
1827 # saving the script file
1828 my $newscriptfilename = determine_scriptfile_name
($downloadname);
1829 $newscriptfilename = save_script_file
($downloaddir, $newscriptfilename, $scriptfile);
1831 installer
::logger
::print_message
( "... including installation set into $newscriptfilename ... \n" );
1832 # Append tar file to script
1833 include_tar_into_script
($newscriptfilename, $temporary_tarfile_name);
1836 else # Windows specific part
1838 my $localnsisdir = installer
::systemactions
::create_directories
("nsis", $languagestringref);
1839 # push(@installer::globals::removedirs, $localnsisdir);
1841 # find nsis in the system
1842 my $nsispath = get_path_to_nsis_sdk
();
1844 if ( $nsispath eq "" ) {
1845 # If nsis is not found just skip the rest of this function
1846 # and do not create the NSIS file.
1847 $infoline = "\nNo NSIS SDK found. Skipping the generation of NSIS file.\n";
1848 push(@installer::globals
::logfileinfo
, $infoline);
1849 installer
::logger
::print_message
( "... no NSIS SDK found. Skipping the generation of NSIS file ... \n" );
1850 return $downloaddir;
1853 # copy language files into nsis directory and translate them
1854 copy_and_translate_nsis_language_files
($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref);
1856 # find and read the nsi file template
1857 my $templatefilename = "downloadtemplate.nsi";
1859 my $templateref = "";
1861 if ( $installer::globals
::include_pathes_read
)
1863 $templateref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$templatefilename, $includepatharrayref, 0);
1867 $templateref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath_classic
(\
$templatefilename, $includepatharrayref, 0);
1870 if ($$templateref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); }
1871 my $templatefile = installer
::files
::read_file
($$templateref);
1873 # add product name into script template
1874 put_windows_productname_into_template
($templatefile, $allvariableshashref);
1875 put_banner_bmp_into_template
($templatefile, $includepatharrayref, $allvariableshashref);
1876 put_welcome_bmp_into_template
($templatefile, $includepatharrayref, $allvariableshashref);
1877 put_setup_ico_into_template
($templatefile, $includepatharrayref, $allvariableshashref);
1878 put_publisher_into_template
($templatefile);
1879 put_website_into_template
($templatefile);
1880 put_javafilename_into_template
($templatefile, $allvariableshashref);
1881 put_windows_productversion_into_template
($templatefile, $allvariableshashref);
1882 put_windows_productpath_into_template
($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
1883 put_outputfilename_into_template
($templatefile, $downloadname);
1884 put_filelist_into_template
($templatefile, $installationdir);
1885 put_language_list_into_template
($templatefile, $languagesarrayref);
1886 put_nsis_path_into_template
($templatefile, $localnsisdir);
1887 put_output_path_into_template
($templatefile, $downloaddir);
1888 put_version_specific_code_into_template
($templatefile);
1890 my $nsifilename = save_script_file
($localnsisdir, $templatefilename, $templatefile);
1892 installer
::logger
::print_message
( "... created NSIS file $nsifilename ... \n" );
1894 # starting the NSIS SDK to create the download file
1895 call_nsis
($nsispath, $nsifilename);
1898 return $downloaddir;
1901 ####################################################
1902 # Creating OOo upload tree
1903 ####################################################
1905 sub create_download_link_tree
1907 my ($downloaddir, $languagestringref, $allvariableshashref) = @_;
1911 installer
::logger
::print_message
( "\n******************************************\n" );
1912 installer
::logger
::print_message
( "... creating download hard link ...\n" );
1913 installer
::logger
::print_message
( "******************************************\n" );
1915 installer
::logger
::include_header_into_logfile
("Creating download hard link:");
1916 installer
::logger
::include_timestamp_into_logfile
("\nPerformance Info: Creating hard link, start");
1918 if ( is_supported_platform
() )
1920 my $versionstring = "";
1921 # Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ?
1923 if ( ! $installer::globals
::oooversionstring
) { $versionstring = get_current_version
(); }
1924 else { $versionstring = $installer::globals
::oooversionstring
; }
1926 # Is $versionstring empty? If yes, there is nothing to do now.
1928 $infoline = "Version string is set to: $versionstring\n";
1929 push( @installer::globals
::logfileinfo
, $infoline);
1931 if ( $versionstring )
1933 # Now the downloadfilename has to be set (if not already done)
1934 my $destdownloadfilename = "";
1935 if ( ! $installer::globals
::ooodownloadfilename
) { $destdownloadfilename = set_download_filename
($languagestringref, $versionstring, $allvariableshashref); }
1936 else { $destdownloadfilename = $installer::globals
::ooodownloadfilename
; }
1938 if ( $destdownloadfilename )
1940 $destdownloadfilename = $destdownloadfilename . $installer::globals
::downloadfileextension
;
1942 $infoline = "Setting destination download file name: $destdownloadfilename\n";
1943 push( @installer::globals
::logfileinfo
, $infoline);
1945 my $sourcedownloadfile = $downloaddir . $installer::globals
::separator
. $installer::globals
::downloadfilename
;
1947 $infoline = "Setting source download file name: $sourcedownloadfile\n";
1948 push( @installer::globals
::logfileinfo
, $infoline);
1950 create_link_tree
($sourcedownloadfile, $destdownloadfilename, $versionstring);
1951 # my $md5sumoutput = call_md5sum($downloadfile);
1952 # my $md5sum = get_md5sum($md5sumoutput);
1958 $infoline = "Version string is empty. Nothing to do!\n";
1959 push( @installer::globals
::logfileinfo
, $infoline);
1964 $infoline = "Platform not used for hard linking. Nothing to do!\n";
1965 push( @installer::globals
::logfileinfo
, $infoline);
1968 installer
::logger
::include_timestamp_into_logfile
("Performance Info: Creating hard link, stop");