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";
273 my $getuidlibraryref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$getuidlibraryname, $includepatharrayref, 0);
274 if ($$getuidlibraryref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find $getuidlibraryname!", "get_path_for_library"); }
276 return $$getuidlibraryref;
279 #########################################################
280 # Include the tar file into the script
281 #########################################################
283 sub include_tar_into_script
285 my ($scriptfile, $temporary_tarfile) = @_;
287 my $systemcall = "cat $temporary_tarfile >> $scriptfile && rm $temporary_tarfile";
288 my $returnvalue = system($systemcall);
290 my $infoline = "Systemcall: $systemcall\n";
291 push( @installer::globals
::logfileinfo
, $infoline);
295 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
296 push( @installer::globals
::logfileinfo
, $infoline);
300 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
301 push( @installer::globals
::logfileinfo
, $infoline);
306 #########################################################
307 # Create a tar file from the binary package
308 #########################################################
312 my ( $installdir, $tarfilename, $getuidlibrary) = @_;
314 my $ldpreloadstring = "";
315 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
317 my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - * > $tarfilename";
319 my $returnvalue = system($systemcall);
321 my $infoline = "Systemcall: $systemcall\n";
322 push( @installer::globals
::logfileinfo
, $infoline);
326 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
327 push( @installer::globals
::logfileinfo
, $infoline);
331 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
332 push( @installer::globals
::logfileinfo
, $infoline);
335 my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1";
336 $returnvalue = system($localcall);
338 return ( -s
$tarfilename );
341 #########################################################
342 # Creating a tar.gz file
343 #########################################################
345 sub create_tar_gz_file_from_package
347 my ($installdir, $getuidlibrary) = @_;
350 my $alldirs = installer
::systemactions
::get_all_directories
($installdir);
351 my $onedir = ${$alldirs}[0];
352 $installdir = $onedir;
354 my $allfiles = installer
::systemactions
::get_all_files_from_one_directory
($installdir);
356 for ( my $i = 0; $i <= $#{$allfiles}; $i++ )
358 my $onefile = ${$allfiles}[$i];
359 my $systemcall = "cd $installdir; rm $onefile";
360 my $returnvalue = system($systemcall);
362 $infoline = "Systemcall: $systemcall\n";
363 push( @installer::globals
::logfileinfo
, $infoline);
367 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
368 push( @installer::globals
::logfileinfo
, $infoline);
372 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
373 push( @installer::globals
::logfileinfo
, $infoline);
377 $alldirs = installer
::systemactions
::get_all_directories
($installdir);
378 $packagename = ${$alldirs}[0]; # only taking the first Solaris package
379 if ( $packagename eq "" ) { installer
::exiter
::exit_program
("ERROR: Could not find package in directory $installdir!", "determine_packagename"); }
381 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$packagename);
383 $installer::globals
::downloadfileextension
= ".tar.gz";
384 my $targzname = $packagename . $installer::globals
::downloadfileextension
;
385 $installer::globals
::downloadfilename
= $targzname;
386 my $ldpreloadstring = "";
387 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
389 $systemcall = "cd $installdir; $ldpreloadstring tar -cf - $packagename | gzip > $targzname";
390 print "... $systemcall ...\n";
392 my $returnvalue = system($systemcall);
394 $infoline = "Systemcall: $systemcall\n";
395 push( @installer::globals
::logfileinfo
, $infoline);
399 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
400 push( @installer::globals
::logfileinfo
, $infoline);
404 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
405 push( @installer::globals
::logfileinfo
, $infoline);
409 #########################################################
410 # Setting type of installation
411 #########################################################
413 sub get_installation_type
417 if ( $installer::globals
::languagepack
) { $type = "langpack"; }
418 else { $type = "install"; }
423 #########################################################
424 # Setting installation languages
425 #########################################################
427 sub get_downloadname_language
429 my ($languagestringref) = @_;
431 my $languages = $$languagestringref;
433 if ( $installer::globals
::added_english
)
435 $languages =~ s/en-US_//;
436 $languages =~ s/_en-US//;
439 # en-US is default language and can be removed therefore
440 # for one-language installation sets
442 if ( $languages =~ /^\s*en-US\s*$/ )
448 if ( length ($languages) > $installer::globals
::max_lang_length
)
450 $languages = 'multi';
456 #########################################################
457 # Setting download name, first part
458 #########################################################
460 sub get_downloadname_start
462 my ($allvariables) = @_;
465 if ( $allvariables->{'PRODUCTNAME'} eq "BrOffice.org" ) { $start = "BrOo"; }
470 #########################################################
471 # Setting installation addons
472 #########################################################
474 sub get_downloadname_addon
478 if ( $installer::globals
::islinuxdebbuild
) { $addon = $addon . "_deb"; }
480 if ( $installer::globals
::product
=~ /_wJRE\s*$/ ) { $addon = "_wJRE"; }
485 #########################################################
486 # Looking for versionstring in version.info
487 # This has to be the only content of this file.
488 #########################################################
490 sub get_versionstring
492 my ( $versionfile ) = @_;
494 my $versionstring = "";
496 for ( my $i = 0; $i <= $#{$versionfile}; $i++ )
498 my $oneline = ${$versionfile}[$i];
500 if ( $oneline =~ /^\s*\#/ ) { next; } # comment line
501 if ( $oneline =~ /^\s*\"\s*(.*?)\s*\"\s*$/ )
508 return $versionstring;
511 #########################################################
512 # Returning the current product version
513 # This has to be defined in file "version.info"
514 # in directory $installer::globals::ooouploaddir
515 #########################################################
517 sub get_current_version
520 my $versionstring = "";
521 my $filename = "version.info";
522 # $filename = $installer::globals::ooouploaddir . $installer::globals::separator . $filename;
526 $infoline = "File $filename exists. Trying to find current version.\n";
527 push( @installer::globals
::logfileinfo
, $infoline);
528 my $versionfile = installer
::files
::read_file
($filename);
529 $versionstring = get_versionstring
($versionfile);
530 $infoline = "Setting version string: $versionstring\n";
531 push( @installer::globals
::logfileinfo
, $infoline);
535 $infoline = "File $filename does not exist. No version setting in download file name.\n";
536 push( @installer::globals
::logfileinfo
, $infoline);
539 $installer::globals
::oooversionstring
= $versionstring;
541 return $versionstring;
544 #########################################################
545 # Determining the download file name
547 # OOo_2.0.2rc1_060213_Solarisx86_install_de
548 # OOo_2.0.2rc1_060213_LinuxIntel_langpack_zh-TW
549 # OOo_2.0.2rc1_060213_SolarisSparc_install_zh-TW_wJRE
550 # OOo_2.0.2rc1_060213_Win32Intel_install_zh-TW_wJRE
551 # OOo_2.0.157_LinuxIntel_install_de
553 #########################################################
555 sub set_download_filename
557 my ($languagestringref, $allvariables) = @_;
559 my $start = get_downloadname_start
($allvariables);
560 # my $versionstring = get_current_version();
561 my $versionstring = "";
562 my $date = installer
::logger
::set_installation_date
();
563 if ( $installer::globals
::product
=~ /_Dev\s*$/ ) { $date = ""; }
564 my $platform = installer
::worker
::get_platform_name
();
565 my $type = get_installation_type
();
566 my $language = get_downloadname_language
($languagestringref);
567 my $addon = get_downloadname_addon
();
569 if ( $installer::globals
::product
=~ /_Dev\s*$/ )
572 if ( $installer::globals
::minor
ne "" ) { $localminor = $installer::globals
::minor
; }
573 else { $localminor = $installer::globals
::lastminor
; }
574 if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; }
575 $versionstring = $allvariables->{'PRODUCTVERSION'} . "." . $localminor;
579 if ( $allvariables->{'PACKAGEVERSION'} )
581 $versionstring = $allvariables->{'PACKAGEVERSION'};
585 my $filename = $start . "_" . $versionstring . "_" . $date . "_" . $platform . "_" . $type . "_" . $language . $addon;
587 $filename =~ s/\_\_/\_/g; # necessary, if $versionstring or $platform or $language are empty
588 $filename =~ s/\_\s*$//; # necessary, if $language and $addon are empty
590 $installer::globals
::ooodownloadfilename
= $filename;
595 #########################################################
596 # Creating a tar.gz file
597 #########################################################
599 sub create_tar_gz_file_from_directory
601 my ($installdir, $getuidlibrary, $downloaddir, $downloadfilename) = @_;
605 my $packdir = $installdir;
606 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$packdir);
607 my $changedir = $installdir;
608 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$changedir);
610 my $ldpreloadstring = "";
611 if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
613 $installer::globals
::downloadfileextension
= ".tar.gz";
614 $installer::globals
::downloadfilename
= $downloadfilename . $installer::globals
::downloadfileextension
;
615 my $targzname = $downloaddir . $installer::globals
::separator
. $installer::globals
::downloadfilename
;
617 $systemcall = "cd $changedir; $ldpreloadstring tar -cf - $packdir | gzip > $targzname";
619 my $returnvalue = system($systemcall);
621 $infoline = "Systemcall: $systemcall\n";
622 push( @installer::globals
::logfileinfo
, $infoline);
626 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
627 push( @installer::globals
::logfileinfo
, $infoline);
631 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
632 push( @installer::globals
::logfileinfo
, $infoline);
638 #########################################################
639 # Setting the variables in the download name
640 #########################################################
642 sub resolve_variables_in_downloadname
644 my ($allvariables, $downloadname, $languagestringref) = @_;
646 # Typical name: soa-{productversion}-{extension}-bin-{os}-{languages}
648 my $productversion = "";
649 if ( $allvariables->{'PRODUCTVERSION'} ) { $productversion = $allvariables->{'PRODUCTVERSION'}; }
650 $downloadname =~ s/\{productversion\}/$productversion/;
652 my $ppackageversion = "";
653 if ( $allvariables->{'PACKAGEVERSION'} ) { $packageversion = $allvariables->{'PACKAGEVERSION'}; }
654 $downloadname =~ s/\{packageversion\}/$packageversion/;
657 if ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) { $extension = $allvariables->{'SHORT_PRODUCTEXTENSION'}; }
658 $extension = lc($extension);
659 $downloadname =~ s/\{extension\}/$extension/;
662 if ( $installer::globals
::iswindowsbuild
) { $os = "windows"; }
663 elsif ( $installer::globals
::issolarissparcbuild
) { $os = "solsparc"; }
664 elsif ( $installer::globals
::issolarisx86build
) { $os = "solia"; }
665 elsif ( $installer::globals
::islinuxbuild
) { $os = "linux"; }
666 elsif ( $installer::globals
::compiler
=~ /unxmacxi/ ) { $os = "macosxi"; }
667 elsif ( $installer::globals
::compiler
=~ /unxmacxp/ ) { $os = "macosxp"; }
669 $downloadname =~ s/\{os\}/$os/;
671 my $languages = $$languagestringref;
672 $downloadname =~ s/\{languages\}/$languages/;
674 $downloadname =~ s/\-\-\-/\-/g;
675 $downloadname =~ s/\-\-/\-/g;
676 $downloadname =~ s/\-\s*$//;
678 return $downloadname;
681 ##################################################################
682 # Windows: Replacing one placeholder with the specified value
683 ##################################################################
685 sub replace_one_variable
687 my ($templatefile, $placeholder, $value) = @_;
689 my $infoline = "Replacing $placeholder by $value in nsi file\n";
690 push( @installer::globals
::logfileinfo
, $infoline);
692 for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
694 ${$templatefile}[$i] =~ s/$placeholder/$value/g;
699 ########################################################################################
700 # Converting a string to a unicode string
701 ########################################################################################
703 sub convert_to_unicode
707 my $unicodestring = "";
709 my $stringlength = length($string);
711 for ( my $i = 0; $i < $stringlength; $i++ )
713 $unicodestring = $unicodestring . substr($string, $i, 1);
714 $unicodestring = $unicodestring . chr(0);
717 return $unicodestring;
720 ##################################################################
721 # Windows: Setting nsis version is necessary because of small
722 # changes in nsis from version 2.0.4 to 2.3.1
723 ##################################################################
729 my $searchstring = "\$\{LangFileString\}"; # occurs only in nsis 2.3.1 or similar
731 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
733 if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ )
735 # this is nsis 2.3.1 or similar
736 $installer::globals
::nsis231
= 1;
737 $installer::globals
::unicodensis
= 0;
742 # checking unicode version
743 $searchstring = convert_to_unicode
($searchstring);
745 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
747 if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ )
749 # this is nsis 2.3.1 or similar
750 $installer::globals
::nsis231
= 1;
751 $installer::globals
::unicodensis
= 1;
756 if ( ! $installer::globals
::nsis231
) { $installer::globals
::nsis204
= 1; }
759 ##################################################################
760 # Windows: Including the product name into nsi template
761 ##################################################################
763 sub put_windows_productname_into_template
765 my ($templatefile, $variableshashref) = @_;
767 my $productname = $variableshashref->{'PRODUCTNAME'};
768 $productname =~ s/\.//g; # OpenOffice.org -> OpenOfficeorg
770 replace_one_variable
($templatefile, "PRODUCTNAMEPLACEHOLDER", $productname);
773 ##################################################################
774 # Windows: Including the path to the banner.bmp into nsi template
775 ##################################################################
777 sub put_banner_bmp_into_template
779 my ($templatefile, $includepatharrayref, $allvariables) = @_;
781 # my $filename = "downloadbanner.bmp";
782 if ( ! $allvariables->{'DOWNLOADBANNER'} ) { installer
::exiter
::exit_program
("ERROR: DOWNLOADBANNER not defined in product definition!", "put_banner_bmp_into_template"); }
783 my $filename = $allvariables->{'DOWNLOADBANNER'};
785 my $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$filename, $includepatharrayref, 0);
787 if ( $^O
=~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g
; }
789 if ($$completefilenameref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find download file $filename!", "put_banner_bmp_into_template"); }
791 replace_one_variable
($templatefile, "BANNERBMPPLACEHOLDER", $$completefilenameref);
794 ##################################################################
795 # Windows: Including the path to the welcome.bmp into nsi template
796 ##################################################################
798 sub put_welcome_bmp_into_template
800 my ($templatefile, $includepatharrayref, $allvariables) = @_;
802 # my $filename = "downloadbitmap.bmp";
803 if ( ! $allvariables->{'DOWNLOADBITMAP'} ) { installer
::exiter
::exit_program
("ERROR: DOWNLOADBITMAP not defined in product definition!", "put_welcome_bmp_into_template"); }
804 my $filename = $allvariables->{'DOWNLOADBITMAP'};
806 my $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$filename, $includepatharrayref, 0);
808 if ( $^O
=~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g
; }
810 if ($$completefilenameref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find download file $filename!", "put_welcome_bmp_into_template"); }
812 replace_one_variable
($templatefile, "WELCOMEBMPPLACEHOLDER", $$completefilenameref);
815 ##################################################################
816 # Windows: Including the path to the setup.ico into nsi template
817 ##################################################################
819 sub put_setup_ico_into_template
821 my ($templatefile, $includepatharrayref, $allvariables) = @_;
823 # my $filename = "downloadsetup.ico";
824 if ( ! $allvariables->{'DOWNLOADSETUPICO'} ) { installer
::exiter
::exit_program
("ERROR: DOWNLOADSETUPICO not defined in product definition!", "put_setup_ico_into_template"); }
825 my $filename = $allvariables->{'DOWNLOADSETUPICO'};
827 my $completefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$filename, $includepatharrayref, 0);
829 if ( $^O
=~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g
; }
831 if ($$completefilenameref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find download file $filename!", "put_setup_ico_into_template"); }
833 replace_one_variable
($templatefile, "SETUPICOPLACEHOLDER", $$completefilenameref);
836 ##################################################################
837 # Windows: Including the publisher into nsi template
838 ##################################################################
840 sub put_publisher_into_template
842 my ($templatefile) = @_;
844 my $publisher = "Sun Microsystems, Inc.";
846 replace_one_variable
($templatefile, "PUBLISHERPLACEHOLDER", $publisher);
849 ##################################################################
850 # Windows: Including the web site into nsi template
851 ##################################################################
853 sub put_website_into_template
855 my ($templatefile) = @_;
857 my $website = "http\:\/\/www\.sun\.com\/staroffice";
859 replace_one_variable
($templatefile, "WEBSITEPLACEHOLDER", $website);
862 ##################################################################
863 # Windows: Including the Java file name into nsi template
864 ##################################################################
866 sub put_javafilename_into_template
868 my ($templatefile, $variableshashref) = @_;
870 my $javaversion = "";
872 if ( $variableshashref->{'WINDOWSJAVAFILENAME'} ) { $javaversion = $variableshashref->{'WINDOWSJAVAFILENAME'}; }
874 replace_one_variable
($templatefile, "WINDOWSJAVAFILENAMEPLACEHOLDER", $javaversion);
877 ##################################################################
878 # Windows: Including the product version into nsi template
879 ##################################################################
881 sub put_windows_productversion_into_template
883 my ($templatefile, $variableshashref) = @_;
885 my $productversion = $variableshashref->{'PRODUCTVERSION'};
887 replace_one_variable
($templatefile, "PRODUCTVERSIONPLACEHOLDER", $productversion);
890 ##################################################################
891 # Windows: Including the product version into nsi template
892 ##################################################################
894 sub put_windows_productpath_into_template
896 my ($templatefile, $variableshashref, $languagestringref, $localnsisdir) = @_;
898 my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'};
900 my $locallangs = $$languagestringref;
901 $locallangs =~ s/_/ /g;
902 if (length($locallangs) > $installer::globals
::max_lang_length
) { $locallangs = "multi lingual"; }
904 if ( ! $installer::globals
::languagepack
) { $productpath = $productpath . " (" . $locallangs . ")"; }
906 # if (( $installer::globals::languagepack ) && ( $installer::globals::unicodensis )) { $productpath = convert_textstring_to_utf16($productpath, $localnsisdir, "stringhelper.txt"); }
908 replace_one_variable
($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath);
911 ##################################################################
912 # Windows: Including download file name into nsi template
913 ##################################################################
915 sub put_outputfilename_into_template
917 my ($templatefile, $downloadname) = @_;
919 $installer::globals
::downloadfileextension
= ".exe";
920 $downloadname = $downloadname . $installer::globals
::downloadfileextension
;
921 $installer::globals
::downloadfilename
= $downloadname;
923 replace_one_variable
($templatefile, "DOWNLOADNAMEPLACEHOLDER", $downloadname);
926 ##################################################################
927 # Windows: Generating the file list in nsi file format
928 ##################################################################
932 my ( $basedir ) = @_;
936 my $alldirs = installer
::systemactions
::get_all_directories
($basedir);
937 unshift(@
{$alldirs}, $basedir); # $basedir is the first directory in $alldirs
939 for ( my $i = 0; $i <= $#{$alldirs}; $i++ )
941 my $onedir = ${$alldirs}[$i];
944 # SetOutPath "$INSTDIR"
946 my $relativedir = $onedir;
947 $relativedir =~ s/\Q$basedir\E//;
949 my $oneline = " " . "SetOutPath" . " " . "\"\$INSTDIR" . $relativedir . "\"" . "\n";
951 if ( $^O
=~ /cygwin/i ) {
952 $oneline =~ s/\//\\/g
;
954 push(@filelist, $oneline);
956 # Collecting all files in the specific directory
958 my $files = installer
::systemactions
::get_all_files_from_one_directory
($onedir);
960 for ( my $j = 0; $j <= $#{$files}; $j++ )
962 my $onefile = ${$files}[$j];
964 my $fileline = " " . "File" . " " . "\"" . $onefile . "\"" . "\n";
965 if ( $^O
=~ /cygwin/i ) {
966 $fileline =~ s/\//\\/g
;
968 push(@filelist, $fileline);
975 ##################################################################
976 # Windows: Including list of all files into nsi template
977 ##################################################################
979 sub put_filelist_into_template
981 my ($templatefile, $installationdir) = @_;
983 my $filelist = get_file_list
($installationdir);
987 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
989 $filestring = $filestring . ${$filelist}[$i];
992 $filestring =~ s/\s*$//;
994 replace_one_variable
($templatefile, "ALLFILESPLACEHOLDER", $filestring);
997 ##################################################################
998 # Windows: NSIS uses specific language names
999 ##################################################################
1001 sub nsis_language_converter
1003 my ($language) = @_;
1005 my $nsislanguage = "";
1007 if ( $language eq "en-US" ) { $nsislanguage = "English"; }
1008 elsif ( $language eq "sq" ) { $nsislanguage = "Albanian"; }
1009 elsif ( $language eq "ar" ) { $nsislanguage = "Arabic"; }
1010 elsif ( $language eq "bg" ) { $nsislanguage = "Bulgarian"; }
1011 elsif ( $language eq "ca" ) { $nsislanguage = "Catalan"; }
1012 elsif ( $language eq "hr" ) { $nsislanguage = "Croatian"; }
1013 elsif ( $language eq "cs" ) { $nsislanguage = "Czech"; }
1014 elsif ( $language eq "da" ) { $nsislanguage = "Danish"; }
1015 elsif ( $language eq "nl" ) { $nsislanguage = "Dutch"; }
1016 elsif ( $language eq "de" ) { $nsislanguage = "German"; }
1017 elsif ( $language eq "de-LU" ) { $nsislanguage = "Luxembourgish"; }
1018 elsif ( $language eq "et" ) { $nsislanguage = "Estonian"; }
1019 elsif ( $language eq "fa" ) { $nsislanguage = "Farsi"; }
1020 elsif ( $language eq "el" ) { $nsislanguage = "Greek"; }
1021 elsif ( $language eq "fi" ) { $nsislanguage = "Finnish"; }
1022 elsif ( $language eq "fr" ) { $nsislanguage = "French"; }
1023 elsif ( $language eq "hu" ) { $nsislanguage = "Hungarian"; }
1024 elsif ( $language eq "he" ) { $nsislanguage = "Hebrew"; }
1025 elsif ( $language eq "id" ) { $nsislanguage = "Indonesian"; }
1026 elsif ( $language eq "it" ) { $nsislanguage = "Italian"; }
1027 elsif ( $language eq "lv" ) { $nsislanguage = "Latvian"; }
1028 elsif ( $language eq "lt" ) { $nsislanguage = "Lithuanian"; }
1029 elsif ( $language eq "mk" ) { $nsislanguage = "Macedonian"; }
1030 elsif ( $language eq "mn" ) { $nsislanguage = "Mongolian"; }
1031 elsif ( $language eq "no" ) { $nsislanguage = "Norwegian"; }
1032 elsif ( $language eq "no-NO" ) { $nsislanguage = "Norwegian"; }
1033 elsif ( $language eq "es" ) { $nsislanguage = "Spanish"; }
1034 elsif ( $language eq "sl" ) { $nsislanguage = "Slovenian"; }
1035 elsif ( $language eq "sv" ) { $nsislanguage = "Swedish"; }
1036 elsif ( $language eq "sk" ) { $nsislanguage = "Slovak"; }
1037 elsif ( $language eq "pl" ) { $nsislanguage = "Polish"; }
1038 elsif ( $language eq "pt-BR" ) { $nsislanguage = "PortugueseBR"; }
1039 elsif ( $language eq "pt" ) { $nsislanguage = "Portuguese"; }
1040 elsif ( $language eq "ro" ) { $nsislanguage = "Romanian"; }
1041 elsif ( $language eq "ru" ) { $nsislanguage = "Russian"; }
1042 elsif ( $language eq "sh" ) { $nsislanguage = "SerbianLatin"; }
1043 elsif ( $language eq "sr" ) { $nsislanguage = "Serbian"; }
1044 elsif ( $language eq "sr-SP" ) { $nsislanguage = "Serbian"; }
1045 elsif ( $language eq "uk" ) { $nsislanguage = "Ukrainian"; }
1046 elsif ( $language eq "tr" ) { $nsislanguage = "Turkish"; }
1047 elsif ( $language eq "ja" ) { $nsislanguage = "Japanese"; }
1048 elsif ( $language eq "ko" ) { $nsislanguage = "Korean"; }
1049 elsif ( $language eq "th" ) { $nsislanguage = "Thai"; }
1050 elsif ( $language eq "vi" ) { $nsislanguage = "Vietnamese"; }
1051 elsif ( $language eq "zh-CN" ) { $nsislanguage = "SimpChinese"; }
1052 elsif ( $language eq "zh-TW" ) { $nsislanguage = "TradChinese"; }
1055 my $infoline = "NSIS language_converter : Could not find nsis language for $language!\n";
1056 push( @installer::globals
::logfileinfo
, $infoline);
1057 $nsislanguage = "English";
1058 # installer::exiter::exit_program("ERROR: Could not find nsis language for $language!", "nsis_language_converter");
1061 return $nsislanguage;
1064 ##################################################################
1065 # Windows: Including list of all languages into nsi template
1066 ##################################################################
1068 sub put_language_list_into_template
1070 my ($templatefile, $languagesarrayref) = @_;
1072 my $alllangstring = "";
1075 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1077 my $onelanguage = ${$languagesarrayref}[$i];
1078 my $nsislanguage = nsis_language_converter
($onelanguage);
1079 $nsislangs{$nsislanguage}++;
1082 foreach my $nsislanguage ( keys(%nsislangs) )
1084 # Syntax: !insertmacro MUI_LANGUAGE "English"
1085 my $langstring = "\!insertmacro MUI_LANGUAGE_PACK " . $nsislanguage . "\n";
1086 if ( $nsislanguage eq "English" )
1088 $alllangstring = $langstring . $alllangstring;
1092 $alllangstring = $alllangstring . $langstring;
1096 $alllangstring =~ s/\s*$//;
1098 replace_one_variable
($templatefile, "ALLLANGUAGESPLACEHOLDER", $alllangstring);
1101 ##################################################################
1102 # Windows: Collecting all identifier from mlf file
1103 ##################################################################
1107 my ( $mlffile ) = @_;
1109 my @identifier = ();
1111 for ( my $i = 0; $i <= $#{$mlffile}; $i++ )
1113 my $oneline = ${$mlffile}[$i];
1115 if ( $oneline =~ /^\s*\[(.+)\]\s*$/ )
1117 my $identifier = $1;
1118 push(@identifier, $identifier);
1122 return \
@identifier;
1125 ##############################################################
1126 # Returning the complete block in all languages
1127 # for a specified string
1128 ##############################################################
1130 sub get_language_block_from_language_file
1132 my ($searchstring, $languagefile) = @_;
1134 my @language_block = ();
1136 for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
1138 if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
1142 push(@language_block, ${$languagefile}[$counter]);
1145 while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
1147 push(@language_block, ${$languagefile}[$counter]);
1155 return \
@language_block;
1158 ##############################################################
1159 # Returning a specific language string from the block
1160 # of all translations
1161 ##############################################################
1163 sub get_language_string_from_language_block
1165 my ($language_block, $language) = @_;
1169 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1171 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1178 if ( $newstring eq "" )
1180 $language = "en-US"; # defaulting to english
1182 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1184 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1195 ##################################################################
1196 # Windows: Replacing strings in NSIS nsh file
1198 # !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis auswählen"
1199 ##################################################################
1201 sub replace_identifier_in_nshfile
1203 my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_;
1205 if ( $installer::globals
::nsis231
)
1207 $newstring =~ s/\\r/\$\\r/g; # \r -> $\r in modern nsis versions
1208 $newstring =~ s/\\n/\$\\n/g; # \n -> $\n in modern nsis versions
1211 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1213 if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1216 ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1217 my $infoline = "NSIS replacement in $nshfilename ($onelanguage): $oldstring \-\> $newstring\n";
1218 push( @installer::globals
::logfileinfo
, $infoline);
1223 ##################################################################
1224 # Windows: Replacing strings in NSIS nlf file
1225 # nlf file syntax (2 lines):
1228 ##################################################################
1230 sub replace_identifier_in_nlffile
1232 my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_;
1234 for ( my $i = 0; $i <= $#{$nlffile}; $i++ )
1236 if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ )
1239 my $oldstring = ${$nlffile}[$next];
1240 ${$nlffile}[$next] = $newstring . "\n";
1241 $oldstring =~ s/\s*$//;
1242 my $infoline = "NSIS replacement in $nlffilename ($onelanguage): $oldstring \-\> $newstring\n";
1243 push( @installer::globals
::logfileinfo
, $infoline);
1248 ##################################################################
1249 # Windows: Translating the NSIS nsh and nlf file
1250 ##################################################################
1252 sub translate_nsh_nlf_file
1254 my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_;
1256 # Analyzing the mlf file, collecting all Identifier
1257 my $allidentifier = get_identifier
($mlffile);
1259 $onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US");
1260 for ( my $i = 0; $i <= $#{$allidentifier}; $i++ )
1262 my $identifier = ${$allidentifier}[$i];
1263 my $language_block = get_language_block_from_language_file
($identifier, $mlffile);
1264 my $newstring = get_language_string_from_language_block
($language_block, $onelanguage);
1267 $newstring =~ s/\\\'/\'/g;
1269 replace_identifier_in_nshfile
($nshfile, $identifier, $newstring, $nshfilename, $onelanguage);
1270 replace_identifier_in_nlffile
($nlffile, $identifier, $newstring, $nlffilename, $onelanguage);
1274 ##################################################################
1275 # Converting utf 16 file to utf 8
1276 ##################################################################
1278 sub convert_utf16_to_utf8
1280 my ( $filename ) = @_;
1284 my $savfilename = $filename . "_before.utf16";
1285 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1287 # open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1288 # open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1289 open( IN
, "<:encoding(UTF16-LE)", $filename ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1290 while ( $line = <IN
> ) {
1291 push @localfile, $line;
1295 if ( open( OUT
, ">:utf8", $filename ) )
1297 print OUT
@localfile;
1301 $savfilename = $filename . "_before.utf8";
1302 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1305 ##################################################################
1306 # Converting utf 8 file to utf 16
1307 ##################################################################
1309 sub convert_utf8_to_utf16
1311 my ( $filename ) = @_;
1315 my $savfilename = $filename . "_after.utf8";
1316 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1318 open( IN
, "<:utf8", $filename ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16");
1319 while ( $line = <IN
> ) {
1320 push @localfile, $line;
1324 if ( open( OUT
, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) )
1326 print OUT
@localfile;
1330 $savfilename = $filename . "_after.utf16";
1331 installer
::systemactions
::copy_one_file
($filename, $savfilename);
1334 ##################################################################
1335 # Converting text string to utf 16
1336 ##################################################################
1338 sub convert_textstring_to_utf16
1340 my ( $textstring, $localnsisdir, $shortfilename ) = @_;
1342 my $filename = $localnsisdir . $installer::globals
::separator
. $shortfilename;
1343 my @filecontent = ();
1344 push(@filecontent, $textstring);
1345 installer
::files
::save_file
($filename, \
@filecontent);
1346 convert_utf8_to_utf16
($filename);
1347 my $newfile = installer
::files
::read_file
($filename);
1348 my $utf16string = "";
1349 if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; }
1351 return $utf16string;
1354 ##################################################################
1355 # Windows: Copying NSIS language files to local nsis directory
1356 ##################################################################
1358 sub copy_and_translate_nsis_language_files
1360 my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_;
1362 my $nlffilepath = $nsispath . $installer::globals
::separator
. "Contrib" . $installer::globals
::separator
. "Language\ files" . $installer::globals
::separator
;
1363 my $nshfilepath = $nsispath . $installer::globals
::separator
. "Contrib" . $installer::globals
::separator
. "Modern\ UI" . $installer::globals
::separator
. "Language files" . $installer::globals
::separator
;
1365 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1367 my $onelanguage = ${$languagesarrayref}[$i];
1368 my $nsislanguage = nsis_language_converter
($onelanguage);
1370 # Copying the nlf file
1371 my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf";
1372 if ( ! -f
$sourcepath ) { installer
::exiter
::exit_program
("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); }
1373 my $nlffilename = $localnsisdir . $installer::globals
::separator
. $nsislanguage . "_pack.nlf";
1374 if ( $^O
=~ /cygwin/i ) { $nlffilename =~ s/\//\\/g
; }
1375 installer
::systemactions
::copy_one_file
($sourcepath, $nlffilename);
1377 # Copying the nsh file
1378 # In newer nsis versions, the nsh file is located next to the nlf file
1379 $sourcepath = $nshfilepath . $nsislanguage . "\.nsh";
1380 if ( ! -f
$sourcepath )
1382 # trying to find the nsh file next to the nlf file
1383 $sourcepath = $nlffilepath . $nsislanguage . "\.nsh";
1384 if ( ! -f
$sourcepath )
1386 installer
::exiter
::exit_program
("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1389 my $nshfilename = $localnsisdir . $installer::globals
::separator
. $nsislanguage . "_pack.nsh";
1390 if ( $^O
=~ /cygwin/i ) { $nshfilename =~ s/\//\\/g
; }
1391 installer
::systemactions
::copy_one_file
($sourcepath, $nshfilename);
1393 # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1394 my $nshfile = installer
::files
::read_file
($nshfilename);
1395 set_nsis_version
($nshfile);
1397 if ( $installer::globals
::unicodensis
)
1399 convert_utf16_to_utf8
($nshfilename);
1400 convert_utf16_to_utf8
($nlffilename);
1401 $nshfile = installer
::files
::read_file
($nshfilename); # read nsh file again
1404 replace_one_variable
($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1406 # find the ulf file for translation
1407 my $mlffile = get_translation_file
($allvariables);
1409 # Translate the files
1410 my $nlffile = installer
::files
::read_file
($nlffilename);
1411 translate_nsh_nlf_file
($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1413 installer
::files
::save_file
($nshfilename, $nshfile);
1414 installer
::files
::save_file
($nlffilename, $nlffile);
1416 if ( $installer::globals
::unicodensis
)
1418 convert_utf8_to_utf16
($nshfilename);
1419 convert_utf8_to_utf16
($nlffilename);
1425 ##################################################################
1426 # Windows: Including the nsis path into the nsi template
1427 ##################################################################
1429 sub put_nsis_path_into_template
1431 my ($templatefile, $nsisdir) = @_;
1433 replace_one_variable
($templatefile, "NSISPATHPLACEHOLDER", $nsisdir);
1436 ##################################################################
1437 # Windows: Including the output path into the nsi template
1438 ##################################################################
1440 sub put_output_path_into_template
1442 my ($templatefile, $downloaddir) = @_;
1444 if ( $^O
=~ /cygwin/i ) { $downloaddir =~ s/\//\\/g
; }
1446 replace_one_variable
($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1449 ##################################################################
1450 # Windows: Only allow specific code for nsis 2.0.4 or nsis 2.3.1
1451 ##################################################################
1453 sub put_version_specific_code_into_template
1455 my ($templatefile) = @_;
1460 if ( $installer::globals
::nsis204
)
1469 replace_one_variable
($templatefile, "\#204\#", $subst204);
1470 replace_one_variable
($templatefile, "\#231\#", $subst231);
1473 ##################################################################
1474 # Windows: Finding the path to the nsis SDK
1475 ##################################################################
1477 sub get_path_to_nsis_sdk
1484 if ( $ENV{'NSIS_PATH'} ) {
1485 $nsispath = $ENV{'NSIS_PATH'};
1486 } elsif ( $ENV{'SOLARROOT'} ) {
1487 $nsispath = $ENV{'SOLARROOT'} . $installer::globals
::separator
. "NSIS";
1489 # do we have nsis already in path ?
1490 @paths = split(/:/, $ENV{'PATH'});
1491 foreach $paths (@paths) {
1492 $path =~ s/[\/\\]+$//; # remove trailing slashes;
1493 $nsispath = $paths . "/nsis";
1495 if ( -x
$nsispath ) {
1504 if ( $ENV{'NSISSDK_SOURCE'} ) {
1505 installer
::logger
::print_warning
( "NSISSDK_SOURCE is deprecated. use NSIS_PATH instead.\n" );
1506 $nsispath = $ENV{'NSISSDK_SOURCE'}; # overriding the NSIS SDK with NSISSDK_SOURCE
1509 if( ($^O
=~ /cygwin/i) and $nsispath =~ /\\/ ) {
1510 # We need a POSIX path for W32-4nt-cygwin-perl
1511 $nsispath =~ s/\\/\\\\/g;
1512 chomp( $nsispath = qx{cygpath
-u
"$nsispath"} );
1515 if ( $nsispath eq "" )
1517 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");
1518 } elsif ( ! -d
$nsispath )
1520 installer
::exiter
::exit_program
("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1526 ##################################################################
1527 # Windows: Executing NSIS to create the installation set
1528 ##################################################################
1532 my ( $nsispath, $nsifile ) = @_;
1534 my $makensisexe = $nsispath . $installer::globals
::separator
. "makensis.exe";
1536 installer
::logger
::print_message
( "... starting $makensisexe ... \n" );
1538 my $systemcall = "$makensisexe $nsifile |";
1540 my $infoline = "Systemcall: $systemcall\n";
1541 push( @installer::globals
::logfileinfo
, $infoline);
1543 my @nsisoutput = ();
1545 open (NSI
, "$systemcall");
1546 while (<NSI
>) {push(@nsisoutput, $_); }
1549 my $returnvalue = $?
; # $? contains the return value of the systemcall
1553 $infoline = "ERROR: $systemcall !\n";
1554 push( @installer::globals
::logfileinfo
, $infoline);
1558 $infoline = "Success: $systemcall\n";
1559 push( @installer::globals
::logfileinfo
, $infoline);
1562 for ( my $i = 0; $i <= $#nsisoutput; $i++ ) { push( @installer::globals
::logfileinfo
, "$nsisoutput[$i]"); }
1566 #################################################################################
1567 # Replacing one variable in one files
1568 #################################################################################
1570 sub replace_one_variable_in_translationfile
1572 my ($translationfile, $variable, $searchstring) = @_;
1574 for ( my $i = 0; $i <= $#{$translationfile}; $i++ )
1576 ${$translationfile}[$i] =~ s/\%$searchstring/$variable/g;
1580 #################################################################################
1581 # Replacing the variables in the translation file
1582 #################################################################################
1584 sub replace_variables
1586 my ($translationfile, $variableshashref) = @_;
1588 foreach $key (keys %{$variableshashref})
1590 my $value = $variableshashref->{$key};
1592 # special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'}
1593 if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; }
1595 replace_one_variable_in_translationfile
($translationfile, $value, $key);
1599 #########################################################
1600 # Getting the translation file for the nsis installer
1601 #########################################################
1603 sub get_translation_file
1605 my ($allvariableshashref) = @_;
1606 my $translationfilename = $installer::globals
::idtlanguagepath
. $installer::globals
::separator
. $installer::globals
::nsisfilename
;
1607 if ( $installer::globals
::unicodensis
) { $translationfilename = $translationfilename . ".uulf"; }
1608 else { $translationfilename = $translationfilename . ".mlf"; }
1609 if ( ! -f
$translationfilename ) { installer
::exiter
::exit_program
("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1610 my $translationfile = installer
::files
::read_file
($translationfilename);
1611 replace_variables
($translationfile, $allvariableshashref);
1613 return $translationfile;
1616 ####################################################
1617 # Removing english, if it was added before
1618 ####################################################
1620 sub remove_english_for_nsis_installer
1622 my ($languagestringref, $languagesarrayref) = @_;
1624 # $$languagestringref =~ s/en-US_//;
1625 # shift(@{$languagesarrayref});
1627 @
{$languagesarrayref} = ("en-US"); # only english for NSIS installer!
1630 ####################################################
1631 # Creating link tree for upload
1632 ####################################################
1634 sub create_link_tree
1636 my ($sourcedownloadfile, $destfilename, $versionstring) = @_;
1638 if ( ! $installer::globals
::ooouploaddir
) { installer
::exiter
::exit_program
("ERROR: Directory for OOo upload not defined!", "create_link_tree"); }
1639 my $versiondir = $installer::globals
::ooouploaddir
. $installer::globals
::separator
. $versionstring;
1640 my $infoline = "Directory for the link: $versiondir\n";
1641 push(@installer::globals
::logfileinfo
, $infoline);
1643 if ( ! -d
$versiondir ) { installer
::systemactions
::create_directory_structure
($versiondir); }
1645 # inside directory $versiondir all links have to be created
1646 my $linkdestination = $versiondir . $installer::globals
::separator
. $destfilename;
1648 # If there is an older version of this file (link), it has to be removed
1649 if ( -f
$linkdestination ) { unlink($linkdestination); }
1651 $infoline = "Creating hard link from $sourcedownloadfile to $linkdestination\n";
1652 push(@installer::globals
::logfileinfo
, $infoline);
1653 installer
::systemactions
::hardlink_one_file
($sourcedownloadfile, $linkdestination);
1656 #######################################################
1657 # Setting supported platform for Sun OpenOffice.org
1659 #######################################################
1661 sub is_supported_platform
1663 my $is_supported = 0;
1665 if (( $installer::globals
::islinuxrpmbuild
) ||
1666 ( $installer::globals
::issolarissparcbuild
) ||
1667 ( $installer::globals
::issolarisx86build
) ||
1668 ( $installer::globals
::iswindowsbuild
))
1673 return $is_supported;
1676 ####################################################
1677 # Creating download installation sets
1678 ####################################################
1680 sub create_download_sets
1682 my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_;
1686 my $force = 1; # print this message even in 'quiet' mode
1687 installer
::logger
::print_message
( "\n******************************************\n" );
1688 installer
::logger
::print_message
( "... creating download installation set ...\n", $force );
1689 installer
::logger
::print_message
( "******************************************\n" );
1691 installer
::logger
::include_header_into_logfile
("Creating download installation sets:");
1693 # special handling for installation sets, to which english was added automatically
1694 if ( $installer::globals
::added_english
) { remove_english_for_nsis_installer
($languagestringref, $languagesarrayref); }
1696 my $firstdir = $installationdir;
1697 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$firstdir);
1699 my $lastdir = $installationdir;
1700 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$lastdir);
1702 if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ }
1703 else { $lastdir = $lastdir . "_download_inprogress"; }
1705 # removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed"
1707 my $downloaddir = $firstdir . $lastdir;
1708 if ( -d
$downloaddir ) { installer
::systemactions
::remove_complete_directory
($downloaddir); }
1710 my $olddir = $downloaddir;
1711 $olddir =~ s/_inprogress/_witherror/;
1712 if ( -d
$olddir ) { installer
::systemactions
::remove_complete_directory
($olddir); }
1714 $olddir = $downloaddir;
1715 $olddir =~ s/_inprogress//;
1716 if ( -d
$olddir ) { installer
::systemactions
::remove_complete_directory
($olddir); }
1718 # creating the new directory
1720 installer
::systemactions
::create_directory
($downloaddir);
1722 $installer::globals
::saveinstalldir
= $downloaddir;
1724 # evaluating the name of the download file
1726 if ( $allvariableshashref->{'OOODOWNLOADNAME'} ) { $downloadname = set_download_filename
($languagestringref, $allvariableshashref); }
1727 else { $downloadname = resolve_variables_in_downloadname
($allvariableshashref, $downloadname, $languagestringref); }
1729 if ( ! $installer::globals
::iswindowsbuild
) # Unix specific part
1732 # getting the path of the getuid.so (only required for Solaris and Linux)
1733 my $getuidlibrary = "";
1734 if (( $installer::globals
::issolarisbuild
) || ( $installer::globals
::islinuxbuild
)) { $getuidlibrary = get_path_for_library
($includepatharrayref); }
1736 if ( $allvariableshashref->{'OOODOWNLOADNAME'} )
1738 my $downloadfile = create_tar_gz_file_from_directory
($installationdir, $getuidlibrary, $downloaddir, $downloadname);
1742 # find and read setup script template
1743 my $scriptfilename = "downloadscript.sh";
1744 my $scriptref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$scriptfilename, $includepatharrayref, 0);
1745 if ($$scriptref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); }
1746 my $scriptfile = installer
::files
::read_file
($$scriptref);
1748 $infoline = "Found script file $scriptfilename: $$scriptref \n";
1749 push( @installer::globals
::logfileinfo
, $infoline);
1751 # add product name into script template
1752 put_productname_into_script
($scriptfile, $allvariableshashref);
1754 # replace linenumber in script template
1755 put_linenumber_into_script
($scriptfile);
1758 my $temporary_tarfile_name = $downloaddir . $installer::globals
::separator
. 'installset.tar';
1759 my $size = tar_package
($installationdir, $temporary_tarfile_name, $getuidlibrary);
1760 installer
::exiter
::exit_program
("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size;
1762 # calling sum to determine checksum and size of the tar file
1763 my $sumout = call_sum
($temporary_tarfile_name);
1765 # writing checksum and size into scriptfile
1766 put_checksum_and_size_into_script
($scriptfile, $sumout);
1768 # saving the script file
1769 my $newscriptfilename = determine_scriptfile_name
($downloadname);
1770 $newscriptfilename = save_script_file
($downloaddir, $newscriptfilename, $scriptfile);
1772 installer
::logger
::print_message
( "... including installation set into $newscriptfilename ... \n" );
1773 # Append tar file to script
1774 include_tar_into_script
($newscriptfilename, $temporary_tarfile_name);
1777 else # Windows specific part
1779 my $localnsisdir = installer
::systemactions
::create_directories
("nsis", $languagestringref);
1780 # push(@installer::globals::removedirs, $localnsisdir);
1782 # find nsis in the system
1783 my $nsispath = get_path_to_nsis_sdk
();
1785 if ( $nsispath eq "" ) {
1786 # If nsis is not found just skip the rest of this function
1787 # and do not create the NSIS file.
1788 $infoline = "\nNo NSIS SDK found. Skipping the generation of NSIS file.\n";
1789 push(@installer::globals
::logfileinfo
, $infoline);
1790 installer
::logger
::print_message
( "... no NSIS SDK found. Skipping the generation of NSIS file ... \n" );
1791 return $downloaddir;
1794 # copy language files into nsis directory and translate them
1795 copy_and_translate_nsis_language_files
($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref);
1797 # find and read the nsi file template
1798 my $templatefilename = "downloadtemplate.nsi";
1799 my $templateref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$templatefilename, $includepatharrayref, 0);
1800 if ($$templateref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); }
1801 my $templatefile = installer
::files
::read_file
($$templateref);
1803 # add product name into script template
1804 put_windows_productname_into_template
($templatefile, $allvariableshashref);
1805 put_banner_bmp_into_template
($templatefile, $includepatharrayref, $allvariableshashref);
1806 put_welcome_bmp_into_template
($templatefile, $includepatharrayref, $allvariableshashref);
1807 put_setup_ico_into_template
($templatefile, $includepatharrayref, $allvariableshashref);
1808 put_publisher_into_template
($templatefile);
1809 put_website_into_template
($templatefile);
1810 put_javafilename_into_template
($templatefile, $allvariableshashref);
1811 put_windows_productversion_into_template
($templatefile, $allvariableshashref);
1812 put_windows_productpath_into_template
($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
1813 put_outputfilename_into_template
($templatefile, $downloadname);
1814 put_filelist_into_template
($templatefile, $installationdir);
1815 put_language_list_into_template
($templatefile, $languagesarrayref);
1816 put_nsis_path_into_template
($templatefile, $localnsisdir);
1817 put_output_path_into_template
($templatefile, $downloaddir);
1818 put_version_specific_code_into_template
($templatefile);
1820 my $nsifilename = save_script_file
($localnsisdir, $templatefilename, $templatefile);
1822 installer
::logger
::print_message
( "... created NSIS file $nsifilename ... \n" );
1824 # starting the NSIS SDK to create the download file
1825 call_nsis
($nsispath, $nsifilename);
1828 return $downloaddir;
1831 ####################################################
1832 # Creating OOo upload tree
1833 ####################################################
1835 sub create_download_link_tree
1837 my ($downloaddir, $languagestringref, $allvariableshashref) = @_;
1841 installer
::logger
::print_message
( "\n******************************************\n" );
1842 installer
::logger
::print_message
( "... creating download hard link ...\n" );
1843 installer
::logger
::print_message
( "******************************************\n" );
1845 installer
::logger
::include_header_into_logfile
("Creating download hard link:");
1846 installer
::logger
::include_timestamp_into_logfile
("\nPerformance Info: Creating hard link, start");
1848 if ( is_supported_platform
() )
1850 my $versionstring = "";
1851 # Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ?
1853 if ( ! $installer::globals
::oooversionstring
) { $versionstring = get_current_version
(); }
1854 else { $versionstring = $installer::globals
::oooversionstring
; }
1856 # Is $versionstring empty? If yes, there is nothing to do now.
1858 $infoline = "Version string is set to: $versionstring\n";
1859 push( @installer::globals
::logfileinfo
, $infoline);
1861 if ( $versionstring )
1863 # Now the downloadfilename has to be set (if not already done)
1864 my $destdownloadfilename = "";
1865 if ( ! $installer::globals
::ooodownloadfilename
) { $destdownloadfilename = set_download_filename
($languagestringref, $versionstring, $allvariableshashref); }
1866 else { $destdownloadfilename = $installer::globals
::ooodownloadfilename
; }
1868 if ( $destdownloadfilename )
1870 $destdownloadfilename = $destdownloadfilename . $installer::globals
::downloadfileextension
;
1872 $infoline = "Setting destination download file name: $destdownloadfilename\n";
1873 push( @installer::globals
::logfileinfo
, $infoline);
1875 my $sourcedownloadfile = $downloaddir . $installer::globals
::separator
. $installer::globals
::downloadfilename
;
1877 $infoline = "Setting source download file name: $sourcedownloadfile\n";
1878 push( @installer::globals
::logfileinfo
, $infoline);
1880 create_link_tree
($sourcedownloadfile, $destdownloadfilename, $versionstring);
1881 # my $md5sumoutput = call_md5sum($downloadfile);
1882 # my $md5sum = get_md5sum($md5sumoutput);
1888 $infoline = "Version string is empty. Nothing to do!\n";
1889 push( @installer::globals
::logfileinfo
, $infoline);
1894 $infoline = "Platform not used for hard linking. Nothing to do!\n";
1895 push( @installer::globals
::logfileinfo
, $infoline);
1898 installer
::logger
::include_timestamp_into_logfile
("Performance Info: Creating hard link, stop");