xref: /trunk/main/solenv/bin/modules/installer/download.pm (revision 8e44b893f976561605ef2d78f346a63374d4be89)
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") {
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") {
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    }
684
685    return $type;
686}
687
688#########################################################
689# Setting installation addons
690#########################################################
691
692sub get_downloadname_addon
693{
694    my $addon = "";
695
696    if ( $installer::globals::islinuxdebbuild ) { $addon = $addon . "_deb"; }
697
698    return $addon;
699}
700
701#########################################################
702# Looking for versionstring in version.info
703# This has to be the only content of this file.
704#########################################################
705
706sub get_versionstring
707{
708    my ( $versionfile ) = @_;
709
710    my $versionstring = "";
711
712    for ( my $i = 0; $i <= $#{$versionfile}; $i++ )
713    {
714        my $oneline = ${$versionfile}[$i];
715
716        if ( $oneline =~ /^\s*\#/ ) { next; } # comment line
717        if ( $oneline =~ /^\s*\"\s*(.*?)\s*\"\s*$/ )
718        {
719            $versionstring = $1;
720            last;
721        }
722    }
723
724    return $versionstring;
725}
726
727#########################################################
728# Returning the current product version
729# This has to be defined in file "version.info"
730# in directory $installer::globals::ooouploaddir
731#########################################################
732
733sub get_current_version
734{
735    my $versionstring = "";
736    my $filename = "version.info";
737    # $filename = $installer::globals::ooouploaddir . $installer::globals::separator . $filename;
738
739    if ( -f $filename )
740    {
741        $installer::logger::Lang->printf("File %s exists. Trying to find current version.\n", $filename);
742        my $versionfile = installer::files::read_file($filename);
743        $versionstring = get_versionstring($versionfile);
744        $installer::logger::Lang->printf("Setting version string: %s\n", $versionstring);
745    }
746    else
747    {
748        $installer::logger::Lang->printf("File %s does not exist. No version setting in download file name.\n", $filename);
749    }
750
751    $installer::globals::oooversionstring = $versionstring;
752
753    return $versionstring;
754}
755
756###############################################################################################
757# Setting the download file name
758# Syntax:
759# (PRODUCTNAME)_(VERSION)_(TIMESTAMP)_(OS)_(ARCH)_(INSTALLTYPE)_(LANGUAGE).(FILEEXTENSION)
760# Rules:
761# Timestamp only for Beta and Release Candidate
762###############################################################################################
763
764sub set_download_filename
765{
766    my ($languagestringref, $allvariables) = @_;
767
768    my $start = get_downloadname_productname($allvariables);
769    my $versionstring = get_download_version($allvariables);
770    my $date = set_date_string($allvariables);
771    my $platform = get_download_platformname();
772    my $architecture = get_download_architecture();
773    my $type = get_install_type($allvariables);
774    my $language = get_downloadname_language($languagestringref);
775
776    # Setting the extension happens automatically
777
778    my $filename = $start . "_" . $versionstring . "_" . $date . "_" . $platform . "_" . $architecture . "_" . $type . "_" . $language;
779
780    $filename =~ s/\_\_/\_/g;   # necessary, if $versionstring or $platform or $language are empty
781    $filename =~ s/\_\s*$//;    # necessary, if $language and $addon are empty
782
783    $installer::globals::ooodownloadfilename = $filename;
784
785    return $filename;
786}
787
788#########################################################
789# Creating a tar.gz file
790#########################################################
791
792sub create_tar_gz_file_from_directory
793{
794    my ($installdir, $getuidlibrary, $downloaddir, $downloadfilename) = @_;
795
796    my $packdir = $installdir;
797    installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packdir);
798    my $changedir = $installdir;
799    installer::pathanalyzer::get_path_from_fullqualifiedname(\$changedir);
800
801    my $ldpreloadstring = "";
802
803    if ($ENV{'FAKEROOT'} ne "no") {
804        $ldpreloadstring = $ENV{'FAKEROOT'};
805    } else {
806        if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
807    }
808
809    $installer::globals::downloadfileextension = ".tar.gz";
810    $installer::globals::downloadfilename = $downloadfilename . $installer::globals::downloadfileextension;
811    my $targzname = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename;
812
813    my $systemcall = "cd $changedir; $ldpreloadstring tar -cf - $packdir | gzip > $targzname";
814
815    my $returnvalue = system($systemcall);
816
817    $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall);
818
819    if ($returnvalue)
820    {
821        $installer::logger::Lang->printf("ERROR: Could not execute \"%s\"!\n", $systemcall);
822    }
823    else
824    {
825        $installer::logger::Lang->printf("Success: Executed \"%s\" successfully!\n", $systemcall);
826    }
827
828    return $targzname;
829}
830
831#########################################################
832# Setting the variables in the download name
833#########################################################
834
835sub resolve_variables_in_downloadname
836{
837    my ($allvariables, $downloadname, $languagestringref) = @_;
838
839    # Typical name: soa-{productversion}-{extension}-bin-{os}-{languages}
840
841    my $productversion = $allvariables->{'PRODUCTVERSION'};
842    $productversion = "" unless defined $productversion;
843    $downloadname =~ s/\{productversion\}/$productversion/;
844
845    my $packageversion = $allvariables->{'PACKAGEVERSION'};
846    $packageversion = "" unless defined $packageversion;
847    $downloadname =~ s/\{packageversion\}/$packageversion/;
848
849    my $extension = $allvariables->{'SHORT_PRODUCTEXTENSION'};
850    $extension = "" unless defined $extension;
851    $extension = lc($extension);
852    $downloadname =~ s/\{extension\}/$extension/;
853
854    my $os = "";
855    if ( $installer::globals::iswindowsbuild ) { $os = "windows"; }
856    elsif ( $installer::globals::issolarissparcbuild ) { $os = "solsparc"; }
857    elsif ( $installer::globals::issolarisx86build ) { $os = "solia"; }
858    elsif ( $installer::globals::islinuxbuild ) { $os = "linux"; }
859    elsif ( $installer::globals::compiler =~ /unxmac.i/ ) { $os = "macosi"; }
860    elsif ( $installer::globals::compiler =~ /unxmac.x/ ) { $os = "macosx"; }
861    elsif ( $installer::globals::compiler =~ /unxmacxp/ ) { $os = "macosp"; }
862    else { $os = ""; }
863    $downloadname =~ s/\{os\}/$os/;
864
865    my $languages = $$languagestringref;
866    $downloadname =~ s/\{languages\}/$languages/;
867
868    $downloadname =~ s/\-\-\-/\-/g;
869    $downloadname =~ s/\-\-/\-/g;
870    $downloadname =~ s/\-\s*$//;
871
872    return $downloadname;
873}
874
875##################################################################
876# Windows: Replacing one placeholder with the specified value
877##################################################################
878
879sub replace_one_variable
880{
881    my ($templatefile, $placeholder, $value) = @_;
882
883    $installer::logger::Lang->printf("Replacing %s by %s in nsi file\n", $placeholder, $value);
884
885    for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
886    {
887        ${$templatefile}[$i] =~ s/$placeholder/$value/g;
888    }
889
890}
891
892########################################################################################
893# Converting a string to a unicode string
894########################################################################################
895
896sub convert_to_unicode
897{
898    my ($string) = @_;
899
900    my $unicodestring = "";
901
902    my $stringlength = length($string);
903
904    for ( my $i = 0; $i < $stringlength; $i++ )
905    {
906        $unicodestring = $unicodestring . substr($string, $i, 1);
907        $unicodestring = $unicodestring . chr(0);
908    }
909
910    return $unicodestring;
911}
912
913##################################################################
914# Windows: Including the product name into nsi template
915##################################################################
916
917sub put_windows_productname_into_template
918{
919    my ($templatefile, $variableshashref) = @_;
920
921    my $productname = $variableshashref->{'PRODUCTNAME'};
922    $productname =~ s/\.//g;    # OpenOffice.org -> OpenOfficeorg
923
924    replace_one_variable($templatefile, "PRODUCTNAMEPLACEHOLDER", $productname);
925}
926
927##################################################################
928# Windows: Including the path to the banner.bmp into nsi template
929##################################################################
930
931sub put_banner_bmp_into_template
932{
933    my ($templatefile, $includepatharrayref, $allvariables) = @_;
934
935    # my $filename = "downloadbanner.bmp";
936    if ( ! $allvariables->{'DOWNLOADBANNER'} ) { installer::exiter::exit_program("ERROR: DOWNLOADBANNER not defined in product definition!", "put_banner_bmp_into_template"); }
937    my $filename = $allvariables->{'DOWNLOADBANNER'};
938
939    my $completefilenameref = "";
940
941    if ( $installer::globals::include_pathes_read )
942    {
943        $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0);
944    }
945    else
946    {
947        $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0);
948    }
949
950    if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_banner_bmp_into_template"); }
951
952    if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; }
953
954    replace_one_variable($templatefile, "BANNERBMPPLACEHOLDER", $$completefilenameref);
955}
956
957##################################################################
958# Windows: Including the path to the welcome.bmp into nsi template
959##################################################################
960
961sub put_welcome_bmp_into_template
962{
963    my ($templatefile, $includepatharrayref, $allvariables) = @_;
964
965    # my $filename = "downloadbitmap.bmp";
966    if ( ! $allvariables->{'DOWNLOADBITMAP'} ) { installer::exiter::exit_program("ERROR: DOWNLOADBITMAP not defined in product definition!", "put_welcome_bmp_into_template"); }
967    my $filename = $allvariables->{'DOWNLOADBITMAP'};
968
969    my $completefilenameref = "";
970
971    if ( $installer::globals::include_pathes_read )
972    {
973        $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0);
974    }
975    else
976    {
977        $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0);
978    }
979
980    if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_welcome_bmp_into_template"); }
981
982    if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; }
983
984    replace_one_variable($templatefile, "WELCOMEBMPPLACEHOLDER", $$completefilenameref);
985}
986
987##################################################################
988# Windows: Including the path to the setup.ico into nsi template
989##################################################################
990
991sub put_setup_ico_into_template
992{
993    my ($templatefile, $includepatharrayref, $allvariables) = @_;
994
995    # my $filename = "downloadsetup.ico";
996    if ( ! $allvariables->{'DOWNLOADSETUPICO'} ) { installer::exiter::exit_program("ERROR: DOWNLOADSETUPICO not defined in product definition!", "put_setup_ico_into_template"); }
997    my $filename = $allvariables->{'DOWNLOADSETUPICO'};
998
999    my $completefilenameref = "";
1000
1001    if ( $installer::globals::include_pathes_read )
1002    {
1003        $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0);
1004    }
1005    else
1006    {
1007        $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0);
1008    }
1009
1010    if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_setup_ico_into_template"); }
1011
1012    if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; }
1013
1014    replace_one_variable($templatefile, "SETUPICOPLACEHOLDER", $$completefilenameref);
1015}
1016
1017##################################################################
1018# Windows: Including the publisher into nsi template
1019##################################################################
1020
1021sub put_publisher_into_template ($$)
1022{
1023    my ($templatefile, $variables) = @_;
1024
1025    my $publisher = $variables->{'OOOVENDOR'};
1026    $publisher = "" unless defined $publisher;
1027
1028    replace_one_variable($templatefile, "PUBLISHERPLACEHOLDER", $publisher);
1029}
1030
1031##################################################################
1032# Windows: Including the web site into nsi template
1033##################################################################
1034
1035sub put_website_into_template ($$)
1036{
1037    my ($templatefile, $variables) = @_;
1038
1039    my $website = $variables->{'STARTCENTER_INFO_URL'};
1040    $website = "" unless defined $website;
1041
1042    replace_one_variable($templatefile, "WEBSITEPLACEHOLDER", $website);
1043}
1044
1045##################################################################
1046# Windows: Including the Java file name into nsi template
1047##################################################################
1048
1049sub put_javafilename_into_template
1050{
1051    my ($templatefile, $variableshashref) = @_;
1052
1053    my $javaversion = "";
1054
1055    if ( $variableshashref->{'WINDOWSJAVAFILENAME'} ) { $javaversion = $variableshashref->{'WINDOWSJAVAFILENAME'}; }
1056
1057    replace_one_variable($templatefile, "WINDOWSJAVAFILENAMEPLACEHOLDER", $javaversion);
1058}
1059
1060##################################################################
1061# Windows: Including the product version into nsi template
1062##################################################################
1063
1064sub put_windows_productversion_into_template
1065{
1066    my ($templatefile, $variableshashref) = @_;
1067
1068    my $productversion = $variableshashref->{'PRODUCTVERSION'};
1069
1070    replace_one_variable($templatefile, "PRODUCTVERSIONPLACEHOLDER", $productversion);
1071}
1072
1073##################################################################
1074# Windows: Including the product version into nsi template
1075##################################################################
1076
1077sub put_windows_productpath_into_template
1078{
1079    my ($templatefile, $variableshashref, $languagestringref, $localnsisdir) = @_;
1080
1081    my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'};
1082
1083    my $locallangs = $$languagestringref;
1084    $locallangs =~ s/_/ /g;
1085    if (length($locallangs) > $installer::globals::max_lang_length) { $locallangs = "multi lingual"; }
1086
1087    if ( ! $installer::globals::languagepack ) { $productpath = $productpath . " (" . $locallangs . ")"; }
1088
1089    replace_one_variable($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath);
1090}
1091
1092##################################################################
1093# Windows: Including download file name into nsi template
1094##################################################################
1095
1096sub put_outputfilename_into_template
1097{
1098    my ($templatefile, $downloadname) = @_;
1099
1100    $installer::globals::downloadfileextension = ".exe";
1101    $downloadname = $downloadname . $installer::globals::downloadfileextension;
1102    $installer::globals::downloadfilename = $downloadname;
1103
1104    replace_one_variable($templatefile, "DOWNLOADNAMEPLACEHOLDER", $downloadname);
1105}
1106
1107##################################################################
1108# Windows: Generating the file list in nsi file format
1109##################################################################
1110
1111sub get_file_list
1112{
1113    my ( $basedir ) = @_;
1114
1115    my @filelist = ();
1116
1117    my $alldirs = installer::systemactions::get_all_directories($basedir);
1118    unshift(@{$alldirs}, $basedir); # $basedir is the first directory in $alldirs
1119
1120    for ( my $i = 0; $i <= $#{$alldirs}; $i++ )
1121    {
1122        my $onedir = ${$alldirs}[$i];
1123
1124        # Syntax:
1125        # SetOutPath "$INSTDIR"
1126
1127        my $relativedir = $onedir;
1128        $relativedir =~ s/\Q$basedir\E//;
1129
1130        my $oneline = " " . "SetOutPath" . " " . "\"\$INSTDIR" . $relativedir . "\"" . "\n";
1131
1132        if ( $^O =~ /cygwin/i ) {
1133            $oneline =~ s/\//\\/g;
1134        }
1135        push(@filelist, $oneline);
1136
1137        # Collecting all files in the specific directory
1138
1139        my $files = installer::systemactions::get_all_files_from_one_directory($onedir);
1140
1141        for ( my $j = 0; $j <= $#{$files}; $j++ )
1142        {
1143            my $onefile = ${$files}[$j];
1144
1145            my $fileline = "  " . "File" . " " . "\"" . $onefile . "\"" . "\n";
1146
1147            if ( $^O =~ /cygwin/i ) {
1148                $fileline =~ s/\//\\/g;
1149            }
1150            push(@filelist, $fileline);
1151        }
1152    }
1153
1154    return \@filelist;
1155}
1156
1157##################################################################
1158# Windows: Including list of all files into nsi template
1159##################################################################
1160
1161sub put_filelist_into_template
1162{
1163    my ($templatefile, $installationdir) = @_;
1164
1165    my $filelist = get_file_list($installationdir);
1166
1167    my $filestring = "";
1168
1169    for ( my $i = 0; $i <= $#{$filelist}; $i++ )
1170    {
1171        $filestring = $filestring . ${$filelist}[$i];
1172    }
1173
1174    $filestring =~ s/\s*$//;
1175
1176    replace_one_variable($templatefile, "ALLFILESPLACEHOLDER", $filestring);
1177}
1178
1179##################################################################
1180# Windows: NSIS uses specific language names
1181##################################################################
1182
1183sub nsis_language_converter
1184{
1185    my ($language) = @_;
1186
1187    my $nsislanguage = "";
1188
1189    # Assign language used by NSIS.
1190    # The files "$nsislanguage.nsh" and "$nsislanguage.nlf"
1191    # are needed in the NSIS environment.
1192    # Directory: <NSIS-Dir>/Contrib/Language files
1193    if ( $language eq "en-US" ) { $nsislanguage = "English"; }
1194    elsif ( $language eq "af" ) { $nsislanguage = "Afrikaans"; }
1195    elsif ( $language eq "sq" ) { $nsislanguage = "Albanian"; }
1196    #elsif ( $language eq "ar" ) { $nsislanguage = "Arabic"; } # Temporarily disabled (Malformed LO surrogate)
1197    elsif ( $language eq "hy" ) { $nsislanguage = "Armenian"; }
1198    elsif ( $language eq "ast" ) { $nsislanguage = "Asturian"; }
1199    elsif ( $language eq "eu" ) { $nsislanguage = "Basque"; }
1200    elsif ( $language eq "bg" ) { $nsislanguage = "Bulgarian"; }
1201    elsif ( $language eq "ca" ) { $nsislanguage = "Catalan"; }
1202    elsif ( $language eq "hr" ) { $nsislanguage = "Croatian"; }
1203    elsif ( $language eq "cs" ) { $nsislanguage = "Czech"; }
1204    elsif ( $language eq "da" ) { $nsislanguage = "Danish"; }
1205    elsif ( $language eq "nl" ) { $nsislanguage = "Dutch"; }
1206    elsif ( $language eq "en-GB" ) { $nsislanguage = "English"; }
1207    elsif ( $language eq "et" ) { $nsislanguage = "Estonian"; }
1208    elsif ( $language eq "fa" ) { $nsislanguage = "Farsi"; }
1209    elsif ( $language eq "fi" ) { $nsislanguage = "Finnish"; }
1210    elsif ( $language eq "fr" ) { $nsislanguage = "French"; }
1211    elsif ( $language eq "gl" ) { $nsislanguage = "Galician"; }
1212    elsif ( $language eq "de" ) { $nsislanguage = "German"; }
1213    elsif ( $language eq "el" ) { $nsislanguage = "Greek"; }
1214    elsif ( $language eq "he" ) { $nsislanguage = "Hebrew"; }
1215    elsif ( $language eq "hu" ) { $nsislanguage = "Hungarian"; }
1216    elsif ( $language eq "is" ) { $nsislanguage = "Icelandic"; }
1217    elsif ( $language eq "id" ) { $nsislanguage = "Indonesian"; }
1218    elsif ( $language eq "it" ) { $nsislanguage = "Italian"; }
1219    elsif ( $language eq "ja" ) { $nsislanguage = "Japanese"; }
1220    elsif ( $language eq "ko" ) { $nsislanguage = "Korean"; }
1221    elsif ( $language eq "lv" ) { $nsislanguage = "Latvian"; }
1222    elsif ( $language eq "lt" ) { $nsislanguage = "Lithuanian"; }
1223    elsif ( $language eq "de-LU" ) { $nsislanguage = "Luxembourgish"; }
1224    elsif ( $language eq "mk" ) { $nsislanguage = "Macedonian"; }
1225    elsif ( $language eq "mn" ) { $nsislanguage = "Mongolian"; }
1226    elsif ( $language eq "nb" ) { $nsislanguage = "Norwegian"; }
1227    elsif ( $language eq "no" ) { $nsislanguage = "Norwegian"; }
1228    elsif ( $language eq "no-NO" ) { $nsislanguage = "Norwegian"; }
1229    elsif ( $language eq "nn" ) { $nsislanguage = "NorwegianNynorsk"; }
1230    elsif ( $language eq "pl" ) { $nsislanguage = "Polish"; }
1231    elsif ( $language eq "pt" ) { $nsislanguage = "Portuguese"; }
1232    elsif ( $language eq "pt-BR" ) { $nsislanguage = "PortugueseBR"; }
1233    elsif ( $language eq "ro" ) { $nsislanguage = "Romanian"; }
1234    elsif ( $language eq "ru" ) { $nsislanguage = "Russian"; }
1235    elsif ( $language eq "gd" ) { $nsislanguage = "ScotsGaelic"; }
1236    elsif ( $language eq "sr" ) { $nsislanguage = "Serbian"; }
1237    elsif ( $language eq "sr-SP" ) { $nsislanguage = "Serbian"; }
1238    elsif ( $language eq "sh" ) { $nsislanguage = "SerbianLatin"; }
1239    elsif ( $language eq "zh-CN" ) { $nsislanguage = "SimpChinese"; }
1240    elsif ( $language eq "sl" ) { $nsislanguage = "Slovenian"; }
1241    elsif ( $language eq "sk" ) { $nsislanguage = "Slovak"; }
1242    elsif ( $language eq "es" ) { $nsislanguage = "Spanish"; }
1243    elsif ( $language eq "sv" ) { $nsislanguage = "Swedish"; }
1244    elsif ( $language eq "th" ) { $nsislanguage = "Thai"; }
1245    elsif ( $language eq "zh-TW" ) { $nsislanguage = "TradChinese"; }
1246    elsif ( $language eq "tr" ) { $nsislanguage = "Turkish"; }
1247    #elsif ( $language eq "uk" ) { $nsislanguage = "Ukrainian"; } # Temporarily disabled (Problem in Ukrainian.nsh)
1248    elsif ( $language eq "vi" ) { $nsislanguage = "Vietnamese"; }
1249    elsif ( $language eq "cy" ) { $nsislanguage = "Welsh"; }
1250    else
1251    {
1252        $installer::logger::Lang->printf("NSIS language_converter : Could not find nsis language for %s!\n", $language);
1253        $nsislanguage = "English";
1254    }
1255
1256    return $nsislanguage;
1257}
1258
1259##################################################################
1260# Windows: Including list of all languages into nsi template
1261##################################################################
1262
1263sub put_language_list_into_template
1264{
1265    my ($templatefile, $languagesarrayref) = @_;
1266
1267    my $alllangstring = "";
1268    my %nsislangs;
1269
1270    for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1271    {
1272        my $onelanguage = ${$languagesarrayref}[$i];
1273        my $nsislanguage = nsis_language_converter($onelanguage);
1274        $nsislangs{$nsislanguage}++;
1275    }
1276
1277    foreach my $nsislanguage ( keys(%nsislangs) )
1278    {
1279        # Syntax: !insertmacro MUI_LANGUAGE "English"
1280        my $langstring = "\!insertmacro MUI_LANGUAGE_PACK " . $nsislanguage . "\n";
1281        if ( $nsislanguage eq "English" )
1282        {
1283            $alllangstring = $langstring . $alllangstring;
1284        }
1285        else
1286        {
1287            $alllangstring = $alllangstring . $langstring;
1288        }
1289    }
1290
1291    $alllangstring =~ s/\s*$//;
1292
1293    replace_one_variable($templatefile, "ALLLANGUAGESPLACEHOLDER", $alllangstring);
1294}
1295
1296##################################################################
1297# Windows: Collecting all identifier from mlf file
1298##################################################################
1299
1300sub get_identifier
1301{
1302    my ( $mlffile ) = @_;
1303
1304    my @identifier = ();
1305
1306    for ( my $i = 0; $i <= $#{$mlffile}; $i++ )
1307    {
1308        my $oneline = ${$mlffile}[$i];
1309
1310        if ( $oneline =~ /^\s*\[(.+)\]\s*$/ )
1311        {
1312            my $identifier = $1;
1313            push(@identifier, $identifier);
1314        }
1315    }
1316
1317    return \@identifier;
1318}
1319
1320##############################################################
1321# Returning the complete block in all languages
1322# for a specified string
1323##############################################################
1324
1325sub get_language_block_from_language_file
1326{
1327    my ($searchstring, $languagefile) = @_;
1328
1329    my @language_block = ();
1330
1331    for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
1332    {
1333        if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
1334        {
1335            my $counter = $i;
1336
1337            push(@language_block, ${$languagefile}[$counter]);
1338            $counter++;
1339
1340            while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
1341            {
1342                push(@language_block, ${$languagefile}[$counter]);
1343                $counter++;
1344            }
1345
1346            last;
1347        }
1348    }
1349
1350    return \@language_block;
1351}
1352
1353##############################################################
1354# Returning a specific language string from the block
1355# of all translations
1356##############################################################
1357
1358sub get_language_string_from_language_block
1359{
1360    my ($language_block, $language) = @_;
1361
1362    my $newstring = "";
1363
1364    for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1365    {
1366        if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1367        {
1368            $newstring = $1;
1369            last;
1370        }
1371    }
1372
1373    if ( $newstring eq "" )
1374    {
1375        $language = "en-US";    # defaulting to english
1376
1377        for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1378        {
1379            if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1380            {
1381                $newstring = $1;
1382                last;
1383            }
1384        }
1385    }
1386
1387    return $newstring;
1388}
1389
1390##################################################################
1391# Windows: Replacing strings in NSIS nsh file
1392# nsh file syntax:
1393# !define MUI_TEXT_DIRECTORY_TITLE "Choose Install Location"
1394##################################################################
1395
1396sub replace_identifier_in_nshfile
1397{
1398    my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_;
1399
1400    for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1401    {
1402        if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1403        {
1404            my $oldstring = $1;
1405            ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1406            $installer::logger::Lang->printf("NSIS replacement in %s (%s):  \-\> %s\n",
1407                $nshfilename,
1408                $onelanguage,
1409                $oldstring,
1410                $newstring);
1411        }
1412    }
1413}
1414
1415##################################################################
1416# Windows: Replacing strings in NSIS nlf file
1417# nlf file syntax (2 lines):
1418# # ^DirSubText
1419# Destination Folder
1420##################################################################
1421
1422sub replace_identifier_in_nlffile
1423{
1424    my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_;
1425
1426    for ( my $i = 0; $i <= $#{$nlffile}; $i++ )
1427    {
1428        if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ )
1429        {
1430            my $next = $i+1;
1431            my $oldstring = ${$nlffile}[$next];
1432            ${$nlffile}[$next] = $newstring . "\n";
1433            $oldstring =~ s/\s*$//;
1434            $installer::logger::Lang->printf("NSIS replacement in %s (%s): %s \-\> %s\n",
1435                $nlffilename,
1436                $onelanguage,
1437                $oldstring,
1438                $newstring);
1439        }
1440    }
1441}
1442
1443##################################################################
1444# Windows: Translating the NSIS nsh and nlf file
1445##################################################################
1446
1447sub translate_nsh_nlf_file
1448{
1449    my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_;
1450
1451    # Analyzing the mlf file, collecting all Identifier
1452    my $allidentifier = get_identifier($mlffile);
1453
1454    $onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US");
1455    for ( my $i = 0; $i <= $#{$allidentifier}; $i++ )
1456    {
1457        my $identifier = ${$allidentifier}[$i];
1458        my $language_block = get_language_block_from_language_file($identifier, $mlffile);
1459        my $newstring = get_language_string_from_language_block($language_block, $onelanguage);
1460
1461        # removing mask
1462        $newstring =~ s/\\\'/\'/g;
1463
1464        replace_identifier_in_nshfile($nshfile, $identifier, $newstring, $nshfilename, $onelanguage);
1465        replace_identifier_in_nlffile($nlffile, $identifier, $newstring, $nlffilename, $onelanguage);
1466    }
1467}
1468
1469##################################################################
1470# Converting utf 16 file to utf 8
1471##################################################################
1472
1473sub convert_utf16_to_utf8
1474{
1475    my ( $filename ) = @_;
1476
1477    my @localfile = ();
1478
1479    my $savfilename = $filename . "_before.utf16";
1480    installer::systemactions::copy_one_file($filename, $savfilename);
1481
1482#   open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1483#   open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1484    open( IN, "<:encoding(UTF16-LE)", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1485    while ( my $line = <IN> )
1486    {
1487        push @localfile, $line;
1488    }
1489    close( IN );
1490
1491    if ( open( OUT, ">:utf8", $filename ) )
1492    {
1493        print OUT @localfile;
1494        close(OUT);
1495    }
1496
1497    $savfilename = $filename . "_before.utf8";
1498    installer::systemactions::copy_one_file($filename, $savfilename);
1499}
1500
1501##################################################################
1502# Converting utf 8 file to utf 16
1503##################################################################
1504
1505sub convert_utf8_to_utf16
1506{
1507    my ( $filename ) = @_;
1508
1509    my @localfile = ();
1510
1511    my $savfilename = $filename . "_after.utf8";
1512    installer::systemactions::copy_one_file($filename, $savfilename);
1513
1514    open( IN, "<:utf8", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16");
1515    while (my  $line = <IN>)
1516    {
1517        push @localfile, $line;
1518    }
1519    close( IN );
1520
1521    if ( open( OUT, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) )
1522    {
1523        print OUT @localfile;
1524        close(OUT);
1525    }
1526
1527    $savfilename = $filename . "_after.utf16";
1528    installer::systemactions::copy_one_file($filename, $savfilename);
1529}
1530
1531##################################################################
1532# Converting text string to utf 16
1533##################################################################
1534
1535sub convert_textstring_to_utf16
1536{
1537    my ( $textstring, $localnsisdir, $shortfilename ) = @_;
1538
1539    my $filename = $localnsisdir . $installer::globals::separator . $shortfilename;
1540    my @filecontent = ();
1541    push(@filecontent, $textstring);
1542    installer::files::save_file($filename, \@filecontent);
1543    convert_utf8_to_utf16($filename);
1544    my $newfile = installer::files::read_file($filename);
1545    my $utf16string = "";
1546    if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; }
1547
1548    return $utf16string;
1549}
1550
1551##################################################################
1552# Windows: Copying NSIS language files to local nsis directory
1553##################################################################
1554
1555sub copy_and_translate_nsis_language_files
1556{
1557    my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_;
1558
1559    my $nlffilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Language\ files" . $installer::globals::separator;
1560    my $nshfilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Modern\ UI" . $installer::globals::separator . "Language files" . $installer::globals::separator;
1561
1562    for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1563    {
1564        my $onelanguage = ${$languagesarrayref}[$i];
1565        my $nsislanguage = nsis_language_converter($onelanguage);
1566
1567        # Copying the nlf file
1568        my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf";
1569        if ( ! -f $sourcepath ) { installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); }
1570        my $nlffilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nlf";
1571        if ( $^O =~ /cygwin/i ) { $nlffilename =~ s/\//\\/g; }
1572        installer::systemactions::copy_one_file($sourcepath, $nlffilename);
1573
1574        # Copying the nsh file
1575        # In newer nsis versions, the nsh file is located next to the nlf file
1576        $sourcepath = $nshfilepath . $nsislanguage . "\.nsh";
1577        if ( ! -f $sourcepath )
1578        {
1579            # trying to find the nsh file next to the nlf file
1580            $sourcepath = $nlffilepath . $nsislanguage . "\.nsh";
1581            if ( ! -f $sourcepath )
1582            {
1583                installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1584            }
1585        }
1586        my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh";
1587        if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; }
1588        installer::systemactions::copy_one_file($sourcepath, $nshfilename);
1589
1590        # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1591        convert_utf16_to_utf8($nshfilename);
1592        convert_utf16_to_utf8($nlffilename);
1593        my $nshfile = installer::files::read_file($nshfilename);
1594        replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1595
1596        # find the ulf file for translation
1597        my $mlffile = get_translation_file($allvariables);
1598
1599        # Translate the files
1600        my $nlffile = installer::files::read_file($nlffilename);
1601        translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1602
1603        installer::files::save_file($nshfilename, $nshfile);
1604        installer::files::save_file($nlffilename, $nlffile);
1605
1606        convert_utf8_to_utf16($nshfilename);
1607        convert_utf8_to_utf16($nlffilename);
1608    }
1609
1610}
1611
1612##################################################################
1613# Windows: Including the nsis path into the nsi template
1614##################################################################
1615
1616sub put_nsis_path_into_template
1617{
1618    my ($templatefile, $nsisdir) = @_;
1619
1620    replace_one_variable($templatefile, "NSISPATHPLACEHOLDER", $nsisdir);
1621}
1622
1623##################################################################
1624# Windows: Including the output path into the nsi template
1625##################################################################
1626
1627sub put_output_path_into_template
1628{
1629    my ($templatefile, $downloaddir) = @_;
1630
1631    if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; }
1632
1633    replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1634}
1635
1636##################################################################
1637# Windows: Finding the path to the nsis SDK
1638##################################################################
1639
1640sub get_path_to_nsis_sdk
1641{
1642    my $nsispath = "";
1643
1644    if ( $ENV{'NSIS_PATH'} )
1645    {
1646        $nsispath = $ENV{'NSIS_PATH'};
1647    }
1648    if ( $nsispath eq "" )
1649    {
1650        $installer::logger::Info->print("... no Environment variable \"NSIS_PATH\"!\n");
1651    }
1652    elsif ( ! -d $nsispath )
1653    {
1654        installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1655    }
1656
1657    return $nsispath;
1658}
1659
1660##################################################################
1661# Windows: Executing NSIS to create the installation set
1662##################################################################
1663
1664sub call_nsis
1665{
1666    my ( $nsispath, $nsifile ) = @_;
1667
1668    my $makensisexe = $nsispath . $installer::globals::separator . "makensis.exe";
1669
1670    $installer::logger::Info->printf("... starting %s ... \n", $makensisexe);
1671
1672    if( $^O =~ /cygwin/i ) { $nsifile =~ s/\\/\//g; }
1673
1674    my $systemcall = "$makensisexe $nsifile |";
1675
1676    $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall);
1677
1678    my @nsisoutput = ();
1679
1680    open (NSI, "$systemcall");
1681    while (<NSI>) {push(@nsisoutput, $_); }
1682    close (NSI);
1683
1684    my $returnvalue = $?;   # $? contains the return value of the systemcall
1685
1686    if ($returnvalue)
1687    {
1688        $installer::logger::Lang->printf("ERROR: %s !\n", $systemcall);
1689    }
1690    else
1691    {
1692        $installer::logger::Lang->printf("Success: %s\n", $systemcall);
1693    }
1694
1695    foreach my $line (@nsisoutput)
1696    {
1697        $installer::logger::Lang->print($line);
1698    }
1699}
1700
1701#################################################################################
1702# Replacing one variable in one files
1703#################################################################################
1704
1705sub replace_one_variable_in_translationfile
1706{
1707    my ($translationfile, $variable, $searchstring) = @_;
1708
1709    for ( my $i = 0; $i <= $#{$translationfile}; $i++ )
1710    {
1711        ${$translationfile}[$i] =~ s/\%$searchstring/$variable/g;
1712    }
1713}
1714
1715#################################################################################
1716# Replacing the variables in the translation file
1717#################################################################################
1718
1719sub replace_variables
1720{
1721    my ($translationfile, $variableshashref) = @_;
1722
1723    foreach my $key (keys %{$variableshashref})
1724    {
1725        my $value = $variableshashref->{$key};
1726
1727        # special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'}
1728        if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; }
1729
1730        replace_one_variable_in_translationfile($translationfile, $value, $key);
1731    }
1732}
1733
1734#########################################################
1735# Getting the translation file for the nsis installer
1736#########################################################
1737
1738sub get_translation_file
1739{
1740    my ($allvariableshashref) = @_;
1741    my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename . ".uulf";
1742    if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1743    my $translationfile = installer::files::read_file($translationfilename);
1744    replace_variables($translationfile, $allvariableshashref);
1745
1746    $installer::logger::Lang->printf("Reading translation file: %s\n", $translationfilename);
1747
1748    return $translationfile;
1749}
1750
1751####################################################
1752# Removing english, if it was added before
1753####################################################
1754
1755sub remove_english_for_nsis_installer
1756{
1757    my ($languagestringref, $languagesarrayref) = @_;
1758
1759    # $$languagestringref =~ s/en-US_//;
1760    # shift(@{$languagesarrayref});
1761
1762    @{$languagesarrayref} = ("en-US");  # only english for NSIS installer!
1763}
1764
1765####################################################
1766# Creating link tree for upload
1767####################################################
1768
1769sub create_link_tree
1770{
1771    my ($sourcedownloadfile, $destfilename, $versionstring) = @_;
1772
1773    if ( ! $installer::globals::ooouploaddir ) { installer::exiter::exit_program("ERROR: Directory for AOO upload not defined!", "create_link_tree"); }
1774    my $versiondir = $installer::globals::ooouploaddir . $installer::globals::separator . $versionstring;
1775    $installer::logger::Lang->printf("Directory for the link: %s\n", $versiondir);
1776
1777    if ( ! -d $versiondir ) { installer::systemactions::create_directory_structure($versiondir); }
1778
1779    # inside directory $versiondir all links have to be created
1780    my $linkdestination = $versiondir . $installer::globals::separator . $destfilename;
1781
1782    # If there is an older version of this file (link), it has to be removed
1783    if ( -f $linkdestination ) { unlink($linkdestination); }
1784
1785    $installer::logger::Lang->printf("Creating hard link from %s to %s\n", $sourcedownloadfile, $linkdestination);
1786    installer::systemactions::hardlink_one_file($sourcedownloadfile, $linkdestination);
1787}
1788
1789#######################################################
1790# Setting supported platform for OpenOffice builds
1791#######################################################
1792
1793sub is_supported_platform
1794{
1795    my $is_supported = 0;
1796
1797    if (( $installer::globals::islinuxrpmbuild ) ||
1798        ( $installer::globals::issolarissparcbuild ) ||
1799        ( $installer::globals::issolarisx86build ) ||
1800        ( $installer::globals::iswindowsbuild ))
1801    {
1802        $is_supported = 1;
1803    }
1804
1805    return $is_supported;
1806}
1807
1808####################################################
1809# Creating download installation sets
1810####################################################
1811
1812sub create_download_sets
1813{
1814    my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_;
1815
1816    $installer::logger::Info->print("\n");
1817    $installer::logger::Info->print("******************************************\n");
1818    $installer::logger::Info->print("... creating download installation set ...\n", 1);
1819    $installer::logger::Info->print("******************************************\n");
1820
1821    installer::logger::include_header_into_logfile("Creating download installation sets:");
1822
1823    # special handling for installation sets, to which english was added automatically
1824    if ( $installer::globals::added_english ) { remove_english_for_nsis_installer($languagestringref, $languagesarrayref); }
1825
1826    my $firstdir = $installationdir;
1827    installer::pathanalyzer::get_path_from_fullqualifiedname(\$firstdir);
1828
1829    my $lastdir = $installationdir;
1830    installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$lastdir);
1831
1832    if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ }
1833    else { $lastdir = $lastdir . "_download_inprogress"; }
1834
1835    # removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed"
1836
1837    my $downloaddir = $firstdir . $lastdir;
1838
1839    if ( -d $downloaddir ) { installer::systemactions::remove_complete_directory($downloaddir); }
1840
1841    my $olddir = $downloaddir;
1842    $olddir =~ s/_inprogress/_witherror/;
1843    if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); }
1844
1845    $olddir = $downloaddir;
1846    $olddir =~ s/_inprogress//;
1847    if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); }
1848
1849    # creating the new directory
1850
1851    installer::systemactions::create_directory($downloaddir);
1852
1853    $installer::globals::saveinstalldir = $downloaddir;
1854
1855    # evaluating the name of the download file
1856
1857    if ( $allvariableshashref->{'AOODOWNLOADNAME'} )
1858    {
1859        $downloadname = set_download_filename($languagestringref, $allvariableshashref);
1860    }
1861    else
1862    {
1863        $downloadname = resolve_variables_in_downloadname($allvariableshashref, $downloadname, $languagestringref);
1864    }
1865
1866    if ( ! $installer::globals::iswindowsbuild )    # Unix specific part
1867    {
1868
1869        # getting the path of the getuid.so (only required for Solaris and Linux)
1870        my $getuidlibrary = "";
1871        if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild )) { $getuidlibrary = get_path_for_library($includepatharrayref); }
1872
1873        if ( $allvariableshashref->{'AOODOWNLOADNAME'} )
1874        {
1875            my $downloadfile = create_tar_gz_file_from_directory($installationdir, $getuidlibrary, $downloaddir, $downloadname);
1876        }
1877        else
1878        {
1879            # find and read setup script template
1880            my $scriptfilename = "downloadscript.sh";
1881
1882            my $scriptref = "";
1883
1884            if ( $installer::globals::include_pathes_read )
1885            {
1886                $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0);
1887            }
1888            else
1889            {
1890                $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$scriptfilename, $includepatharrayref, 0);
1891            }
1892
1893            if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); }
1894            my $scriptfile = installer::files::read_file($$scriptref);
1895
1896            $installer::logger::Lang->printf("Found  script file %s: %s \n", $scriptfilename, $$scriptref);
1897
1898            # add product name into script template
1899            put_productname_into_script($scriptfile, $allvariableshashref);
1900
1901            # replace linenumber in script template
1902            put_linenumber_into_script($scriptfile);
1903
1904            # create tar file
1905            my $temporary_tarfile_name = $downloaddir . $installer::globals::separator . 'installset.tar';
1906            my $size = tar_package($installationdir, $temporary_tarfile_name, $getuidlibrary);
1907            installer::exiter::exit_program("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size;
1908
1909            # calling sum to determine checksum and size of the tar file
1910            my $sumout = call_sum($temporary_tarfile_name);
1911
1912            # writing checksum and size into scriptfile
1913            put_checksum_and_size_into_script($scriptfile, $sumout);
1914
1915            # saving the script file
1916            my $newscriptfilename = determine_scriptfile_name($downloadname);
1917            $newscriptfilename = save_script_file($downloaddir, $newscriptfilename, $scriptfile);
1918
1919            $installer::logger::Info->printf("... including installation set into %s ... \n", $newscriptfilename);
1920            # Append tar file to script
1921            include_tar_into_script($newscriptfilename, $temporary_tarfile_name);
1922        }
1923    }
1924    else    # Windows specific part
1925    {
1926        my $localnsisdir = installer::systemactions::create_directories("nsis", $languagestringref);
1927        # push(@installer::globals::removedirs, $localnsisdir);
1928
1929        # find nsis in the system
1930        my $nsispath = get_path_to_nsis_sdk();
1931
1932        if ( $nsispath eq "" ) {
1933            # If nsis is not found just skip the rest of this function
1934            # and do not create the NSIS file.
1935            $installer::logger::Lang->print("\n");
1936            $installer::logger::Lang->printf("No NSIS SDK found. Skipping the generation of NSIS file.\n");
1937            $installer::logger::Info->print("... no NSIS SDK found. Skipping the generation of NSIS file ... \n");
1938            return $downloaddir;
1939        }
1940
1941        # copy language files into nsis directory and translate them
1942        copy_and_translate_nsis_language_files($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref);
1943
1944        # find and read the nsi file template
1945        my $templatefilename = "downloadtemplate.nsi";
1946
1947        my $templateref = "";
1948
1949        if ( $installer::globals::include_pathes_read )
1950        {
1951            $templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$templatefilename, $includepatharrayref, 0);
1952        }
1953        else
1954        {
1955            $templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$templatefilename, $includepatharrayref, 0);
1956        }
1957
1958        if ($$templateref eq "") { installer::exiter::exit_program("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); }
1959        my $templatefile = installer::files::read_file($$templateref);
1960
1961        # add product name into script template
1962        put_windows_productname_into_template($templatefile, $allvariableshashref);
1963        put_banner_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1964        put_welcome_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1965        put_setup_ico_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1966        put_publisher_into_template($templatefile, $allvariableshashref);
1967        put_website_into_template($templatefile, $allvariableshashref);
1968        put_javafilename_into_template($templatefile, $allvariableshashref);
1969        put_windows_productversion_into_template($templatefile, $allvariableshashref);
1970        put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
1971        put_outputfilename_into_template($templatefile, $downloadname);
1972        put_filelist_into_template($templatefile, $installationdir);
1973        put_language_list_into_template($templatefile, $languagesarrayref);
1974        put_nsis_path_into_template($templatefile, $localnsisdir);
1975        put_output_path_into_template($templatefile, $downloaddir);
1976
1977        my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile);
1978
1979        $installer::logger::Info->printf("... created NSIS file %s ... \n", $nsifilename);
1980
1981        # starting the NSIS SDK to create the download file
1982        call_nsis($nsispath, $nsifilename);
1983    }
1984
1985    return $downloaddir;
1986}
1987
1988####################################################
1989# Creating AOO upload tree
1990####################################################
1991
1992sub create_download_link_tree
1993{
1994    my ($downloaddir, $languagestringref, $allvariableshashref) = @_;
1995
1996    $installer::logger::Info->print("\n");
1997    $installer::logger::Info->print("******************************************\n");
1998    $installer::logger::Info->print("... creating download hard link ...\n");
1999    $installer::logger::Info->print("******************************************\n");
2000
2001    installer::logger::include_header_into_logfile("Creating download hard link:");
2002    $installer::logger::Lang->print("\n");
2003    $installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, start");
2004
2005    if ( is_supported_platform() )
2006    {
2007        my $versionstring = "";
2008        # Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ?
2009
2010        if ( ! $installer::globals::oooversionstring ) { $versionstring = get_current_version(); }
2011        else { $versionstring = $installer::globals::oooversionstring; }
2012
2013        # Is $versionstring empty? If yes, there is nothing to do now.
2014
2015        $installer::logger::Lang->printf("Version string is set to: %s\n", $versionstring);
2016
2017        if ( $versionstring )
2018        {
2019            # Now the downloadfilename has to be set (if not already done)
2020            my $destdownloadfilename = "";
2021            if ( ! $installer::globals::ooodownloadfilename ) { $destdownloadfilename = set_download_filename($languagestringref, $versionstring, $allvariableshashref); }
2022            else { $destdownloadfilename = $installer::globals::ooodownloadfilename; }
2023
2024            if ( $destdownloadfilename )
2025            {
2026                $destdownloadfilename = $destdownloadfilename . $installer::globals::downloadfileextension;
2027
2028                $installer::logger::Lang->printf("Setting destination download file name: %s\n", $destdownloadfilename);
2029
2030                my $sourcedownloadfile = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename;
2031
2032                $installer::logger::Lang->printf("Setting source download file name: %s\n", $sourcedownloadfile);
2033
2034                create_link_tree($sourcedownloadfile, $destdownloadfilename, $versionstring);
2035                # my $md5sumoutput = call_md5sum($downloadfile);
2036                # my $md5sum = get_md5sum($md5sumoutput);
2037
2038            }
2039        }
2040        else
2041        {
2042            $installer::logger::Lang->printf("Version string is empty. Nothing to do!\n");
2043        }
2044    }
2045    else
2046    {
2047        $installer::logger::Lang->printf("Platform not used for hard linking. Nothing to do!\n");
2048    }
2049
2050    $installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, stop");
2051}
2052
20531;
2054