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