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 version 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"; } # Temporarily disabled (Malformed LO surrogate)
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 "et" ) { $nsislanguage = "Estonian"; }
1215	elsif ( $language eq "fa" ) { $nsislanguage = "Farsi"; }
1216	elsif ( $language eq "fi" ) { $nsislanguage = "Finnish"; }
1217	elsif ( $language eq "fr" ) { $nsislanguage = "French"; }
1218	elsif ( $language eq "gl" ) { $nsislanguage = "Galician"; }
1219	elsif ( $language eq "de" ) { $nsislanguage = "German"; }
1220	elsif ( $language eq "el" ) { $nsislanguage = "Greek"; }
1221	elsif ( $language eq "he" ) { $nsislanguage = "Hebrew"; }
1222	elsif ( $language eq "hu" ) { $nsislanguage = "Hungarian"; }
1223	elsif ( $language eq "is" ) { $nsislanguage = "Icelandic"; }
1224	elsif ( $language eq "id" ) { $nsislanguage = "Indonesian"; }
1225	elsif ( $language eq "it" ) { $nsislanguage = "Italian"; }
1226	elsif ( $language eq "ja" ) { $nsislanguage = "Japanese"; }
1227	elsif ( $language eq "ko" ) { $nsislanguage = "Korean"; }
1228	elsif ( $language eq "lv" ) { $nsislanguage = "Latvian"; }
1229	elsif ( $language eq "lt" ) { $nsislanguage = "Lithuanian"; }
1230	elsif ( $language eq "de-LU" ) { $nsislanguage = "Luxembourgish"; }
1231	elsif ( $language eq "mk" ) { $nsislanguage = "Macedonian"; }
1232	elsif ( $language eq "mn" ) { $nsislanguage = "Mongolian"; }
1233	elsif ( $language eq "nb" ) { $nsislanguage = "Norwegian"; }
1234	elsif ( $language eq "no" ) { $nsislanguage = "Norwegian"; }
1235	elsif ( $language eq "no-NO" ) { $nsislanguage = "Norwegian"; }
1236	elsif ( $language eq "nn" ) { $nsislanguage = "NorwegianNynorsk"; }
1237	elsif ( $language eq "pl" ) { $nsislanguage = "Polish"; }
1238	elsif ( $language eq "pt" ) { $nsislanguage = "Portuguese"; }
1239	elsif ( $language eq "pt-BR" ) { $nsislanguage = "PortugueseBR"; }
1240	elsif ( $language eq "ro" ) { $nsislanguage = "Romanian"; }
1241	elsif ( $language eq "ru" ) { $nsislanguage = "Russian"; }
1242	elsif ( $language eq "gd" ) { $nsislanguage = "ScotsGaelic"; }
1243	elsif ( $language eq "sr" ) { $nsislanguage = "Serbian"; }
1244	elsif ( $language eq "sr-SP" ) { $nsislanguage = "Serbian"; }
1245	elsif ( $language eq "sh" ) { $nsislanguage = "SerbianLatin"; }
1246	elsif ( $language eq "zh-CN" ) { $nsislanguage = "SimpChinese"; }
1247	elsif ( $language eq "sl" ) { $nsislanguage = "Slovenian"; }
1248	elsif ( $language eq "sk" ) { $nsislanguage = "Slovak"; }
1249	elsif ( $language eq "es" ) { $nsislanguage = "Spanish"; }
1250	elsif ( $language eq "sv" ) { $nsislanguage = "Swedish"; }
1251	elsif ( $language eq "th" ) { $nsislanguage = "Thai"; }
1252	elsif ( $language eq "zh-TW" ) { $nsislanguage = "TradChinese"; }
1253	elsif ( $language eq "tr" ) { $nsislanguage = "Turkish"; }
1254	#elsif ( $language eq "uk" ) { $nsislanguage = "Ukrainian"; } # Temporarily disabled (Problem in Ukrainian.nsh)
1255	elsif ( $language eq "vi" ) { $nsislanguage = "Vietnamese"; }
1256	elsif ( $language eq "cy" ) { $nsislanguage = "Welsh"; }
1257	else
1258    {
1259        $installer::logger::Lang->printf("NSIS language_converter : Could not find nsis language for %s!\n", $language);
1260		$nsislanguage = "English";
1261	}
1262
1263	return $nsislanguage;
1264}
1265
1266##################################################################
1267# Windows: Including list of all languages into nsi template
1268##################################################################
1269
1270sub put_language_list_into_template
1271{
1272	my ($templatefile, $languagesarrayref) = @_;
1273
1274	my $alllangstring = "";
1275	my %nsislangs;
1276
1277	for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1278	{
1279		my $onelanguage = ${$languagesarrayref}[$i];
1280		my $nsislanguage = nsis_language_converter($onelanguage);
1281		$nsislangs{$nsislanguage}++;
1282	}
1283
1284	foreach my $nsislanguage ( keys(%nsislangs) )
1285	{
1286		# Syntax: !insertmacro MUI_LANGUAGE "English"
1287		my $langstring = "\!insertmacro MUI_LANGUAGE_PACK " . $nsislanguage . "\n";
1288		if ( $nsislanguage eq "English" )
1289		{
1290			$alllangstring = $langstring . $alllangstring;
1291		}
1292		else
1293		{
1294			$alllangstring = $alllangstring . $langstring;
1295		}
1296	}
1297
1298	$alllangstring =~ s/\s*$//;
1299
1300	replace_one_variable($templatefile, "ALLLANGUAGESPLACEHOLDER", $alllangstring);
1301}
1302
1303##################################################################
1304# Windows: Collecting all identifier from mlf file
1305##################################################################
1306
1307sub get_identifier
1308{
1309	my ( $mlffile ) = @_;
1310
1311	my @identifier = ();
1312
1313	for ( my $i = 0; $i <= $#{$mlffile}; $i++ )
1314	{
1315		my $oneline = ${$mlffile}[$i];
1316
1317		if ( $oneline =~ /^\s*\[(.+)\]\s*$/ )
1318		{
1319			my $identifier = $1;
1320			push(@identifier, $identifier);
1321		}
1322	}
1323
1324	return \@identifier;
1325}
1326
1327##############################################################
1328# Returning the complete block in all languages
1329# for a specified string
1330##############################################################
1331
1332sub get_language_block_from_language_file
1333{
1334	my ($searchstring, $languagefile) = @_;
1335
1336	my @language_block = ();
1337
1338	for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
1339	{
1340		if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
1341		{
1342			my $counter = $i;
1343
1344			push(@language_block, ${$languagefile}[$counter]);
1345			$counter++;
1346
1347			while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
1348			{
1349				push(@language_block, ${$languagefile}[$counter]);
1350				$counter++;
1351			}
1352
1353			last;
1354		}
1355	}
1356
1357	return \@language_block;
1358}
1359
1360##############################################################
1361# Returning a specific language string from the block
1362# of all translations
1363##############################################################
1364
1365sub get_language_string_from_language_block
1366{
1367	my ($language_block, $language) = @_;
1368
1369	my $newstring = "";
1370
1371	for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1372	{
1373		if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1374		{
1375			$newstring = $1;
1376			last;
1377		}
1378	}
1379
1380	if ( $newstring eq "" )
1381	{
1382		$language = "en-US"; 	# defaulting to english
1383
1384		for ( my $i = 0; $i <= $#{$language_block}; $i++ )
1385		{
1386			if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
1387			{
1388				$newstring = $1;
1389				last;
1390			}
1391		}
1392	}
1393
1394	return $newstring;
1395}
1396
1397##################################################################
1398# Windows: Replacing strings in NSIS nsh file
1399# nsh file syntax:
1400# !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis auswählen"
1401##################################################################
1402
1403sub replace_identifier_in_nshfile
1404{
1405	my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_;
1406
1407	for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1408	{
1409		if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1410		{
1411			my $oldstring = $1;
1412			${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1413            $installer::logger::Lang->printf("NSIS replacement in %s (%s):  \-\> %s\n",
1414                $nshfilename,
1415                $onelanguage,
1416                $oldstring,
1417                $newstring);
1418		}
1419	}
1420}
1421
1422##################################################################
1423# Windows: Replacing strings in NSIS nlf file
1424# nlf file syntax (2 lines):
1425# # ^DirSubText
1426# Zielverzeichnis
1427##################################################################
1428
1429sub replace_identifier_in_nlffile
1430{
1431	my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_;
1432
1433	for ( my $i = 0; $i <= $#{$nlffile}; $i++ )
1434	{
1435		if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ )
1436		{
1437			my $next = $i+1;
1438			my $oldstring = ${$nlffile}[$next];
1439			${$nlffile}[$next] = $newstring . "\n";
1440			$oldstring =~ s/\s*$//;
1441            $installer::logger::Lang->printf("NSIS replacement in %s (%s): %s \-\> %s\n",
1442                $nlffilename,
1443                $onelanguage,
1444                $oldstring,
1445                $newstring);
1446		}
1447	}
1448}
1449
1450##################################################################
1451# Windows: Translating the NSIS nsh and nlf file
1452##################################################################
1453
1454sub translate_nsh_nlf_file
1455{
1456	my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_;
1457
1458	# Analyzing the mlf file, collecting all Identifier
1459	my $allidentifier = get_identifier($mlffile);
1460
1461	$onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US");
1462	for ( my $i = 0; $i <= $#{$allidentifier}; $i++ )
1463	{
1464		my $identifier = ${$allidentifier}[$i];
1465		my $language_block = get_language_block_from_language_file($identifier, $mlffile);
1466		my $newstring = get_language_string_from_language_block($language_block, $onelanguage);
1467
1468		# removing mask
1469		$newstring =~ s/\\\'/\'/g;
1470
1471		replace_identifier_in_nshfile($nshfile, $identifier, $newstring, $nshfilename, $onelanguage);
1472		replace_identifier_in_nlffile($nlffile, $identifier, $newstring, $nlffilename, $onelanguage);
1473	}
1474}
1475
1476##################################################################
1477# Converting utf 16 file to utf 8
1478##################################################################
1479
1480sub convert_utf16_to_utf8
1481{
1482	my ( $filename ) = @_;
1483
1484	my @localfile = ();
1485
1486	my $savfilename = $filename . "_before.utf16";
1487	installer::systemactions::copy_one_file($filename, $savfilename);
1488
1489#	open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1490#	open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1491	open( IN, "<:encoding(UTF16-LE)", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1492	while ( my $line = <IN> )
1493    {
1494		push @localfile, $line;
1495	}
1496	close( IN );
1497
1498	if ( open( OUT, ">:utf8", $filename ) )
1499	{
1500		print OUT @localfile;
1501		close(OUT);
1502	}
1503
1504	$savfilename = $filename . "_before.utf8";
1505	installer::systemactions::copy_one_file($filename, $savfilename);
1506}
1507
1508##################################################################
1509# Converting utf 8 file to utf 16
1510##################################################################
1511
1512sub convert_utf8_to_utf16
1513{
1514	my ( $filename ) = @_;
1515
1516	my @localfile = ();
1517
1518	my $savfilename = $filename . "_after.utf8";
1519	installer::systemactions::copy_one_file($filename, $savfilename);
1520
1521	open( IN, "<:utf8", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16");
1522	while (my  $line = <IN>)
1523    {
1524		push @localfile, $line;
1525	}
1526	close( IN );
1527
1528	if ( open( OUT, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) )
1529	{
1530		print OUT @localfile;
1531		close(OUT);
1532	}
1533
1534	$savfilename = $filename . "_after.utf16";
1535	installer::systemactions::copy_one_file($filename, $savfilename);
1536}
1537
1538##################################################################
1539# Converting text string to utf 16
1540##################################################################
1541
1542sub convert_textstring_to_utf16
1543{
1544	my ( $textstring, $localnsisdir, $shortfilename ) = @_;
1545
1546	my $filename = $localnsisdir . $installer::globals::separator . $shortfilename;
1547	my @filecontent = ();
1548	push(@filecontent, $textstring);
1549	installer::files::save_file($filename, \@filecontent);
1550	convert_utf8_to_utf16($filename);
1551	my $newfile = installer::files::read_file($filename);
1552	my $utf16string = "";
1553	if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; }
1554
1555	return $utf16string;
1556}
1557
1558##################################################################
1559# Windows: Copying NSIS language files to local nsis directory
1560##################################################################
1561
1562sub copy_and_translate_nsis_language_files
1563{
1564	my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_;
1565
1566	my $nlffilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Language\ files" . $installer::globals::separator;
1567	my $nshfilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Modern\ UI" . $installer::globals::separator . "Language files" . $installer::globals::separator;
1568
1569	for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1570	{
1571		my $onelanguage = ${$languagesarrayref}[$i];
1572		my $nsislanguage = nsis_language_converter($onelanguage);
1573
1574		# Copying the nlf file
1575		my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf";
1576		if ( ! -f $sourcepath ) { installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); }
1577		my $nlffilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nlf";
1578		if ( $^O =~ /cygwin/i ) { $nlffilename =~ s/\//\\/g; }
1579		installer::systemactions::copy_one_file($sourcepath, $nlffilename);
1580
1581		# Copying the nsh file
1582		# In newer nsis versions, the nsh file is located next to the nlf file
1583		$sourcepath = $nshfilepath . $nsislanguage . "\.nsh";
1584		if ( ! -f $sourcepath )
1585		{
1586			# trying to find the nsh file next to the nlf file
1587			$sourcepath = $nlffilepath . $nsislanguage . "\.nsh";
1588			if ( ! -f $sourcepath )
1589			{
1590				installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1591			}
1592		}
1593		my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh";
1594		if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; }
1595		installer::systemactions::copy_one_file($sourcepath, $nshfilename);
1596
1597		# Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1598        convert_utf16_to_utf8($nshfilename);
1599        convert_utf16_to_utf8($nlffilename);
1600        my $nshfile = installer::files::read_file($nshfilename);
1601		replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1602
1603		# find the ulf file for translation
1604		my $mlffile = get_translation_file($allvariables);
1605
1606		# Translate the files
1607		my $nlffile = installer::files::read_file($nlffilename);
1608		translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1609
1610		installer::files::save_file($nshfilename, $nshfile);
1611		installer::files::save_file($nlffilename, $nlffile);
1612
1613        convert_utf8_to_utf16($nshfilename);
1614        convert_utf8_to_utf16($nlffilename);
1615	}
1616
1617}
1618
1619##################################################################
1620# Windows: Including the nsis path into the nsi template
1621##################################################################
1622
1623sub put_nsis_path_into_template
1624{
1625	my ($templatefile, $nsisdir) = @_;
1626
1627	replace_one_variable($templatefile, "NSISPATHPLACEHOLDER", $nsisdir);
1628}
1629
1630##################################################################
1631# Windows: Including the output path into the nsi template
1632##################################################################
1633
1634sub put_output_path_into_template
1635{
1636	my ($templatefile, $downloaddir) = @_;
1637
1638	if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; }
1639
1640	replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1641}
1642
1643##################################################################
1644# Windows: Finding the path to the nsis SDK
1645##################################################################
1646
1647sub get_path_to_nsis_sdk
1648{
1649	my $nsispath = "";
1650
1651	if ( $ENV{'NSIS_PATH'} )
1652    {
1653		$nsispath = $ENV{'NSIS_PATH'};
1654	}
1655	if ( $nsispath eq "" )
1656	{
1657        $installer::logger::Info->print("... no Environment variable \"NSIS_PATH\"!\n");
1658	}
1659    elsif ( ! -d $nsispath )
1660	{
1661		installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1662	}
1663
1664	return $nsispath;
1665}
1666
1667##################################################################
1668# Windows: Executing NSIS to create the installation set
1669##################################################################
1670
1671sub call_nsis
1672{
1673	my ( $nsispath, $nsifile ) = @_;
1674
1675	my $makensisexe = $nsispath . $installer::globals::separator . "makensis.exe";
1676
1677    $installer::logger::Info->printf("... starting %s ... \n", $makensisexe);
1678
1679	if( $^O =~ /cygwin/i ) { $nsifile =~ s/\\/\//g;	}
1680
1681	my $systemcall = "$makensisexe $nsifile |";
1682
1683    $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall);
1684
1685	my @nsisoutput = ();
1686
1687	open (NSI, "$systemcall");
1688	while (<NSI>) {push(@nsisoutput, $_); }
1689	close (NSI);
1690
1691	my $returnvalue = $?;	# $? contains the return value of the systemcall
1692
1693	if ($returnvalue)
1694	{
1695        $installer::logger::Lang->printf("ERROR: %s !\n", $systemcall);
1696	}
1697	else
1698	{
1699        $installer::logger::Lang->printf("Success: %s\n", $systemcall);
1700	}
1701
1702	foreach my $line (@nsisoutput)
1703    {
1704        $installer::logger::Lang->print($line);
1705    }
1706}
1707
1708#################################################################################
1709# Replacing one variable in one files
1710#################################################################################
1711
1712sub replace_one_variable_in_translationfile
1713{
1714	my ($translationfile, $variable, $searchstring) = @_;
1715
1716	for ( my $i = 0; $i <= $#{$translationfile}; $i++ )
1717	{
1718		${$translationfile}[$i] =~ s/\%$searchstring/$variable/g;
1719	}
1720}
1721
1722#################################################################################
1723# Replacing the variables in the translation file
1724#################################################################################
1725
1726sub replace_variables
1727{
1728	my ($translationfile, $variableshashref) = @_;
1729
1730	foreach my $key (keys %{$variableshashref})
1731	{
1732		my $value = $variableshashref->{$key};
1733
1734		# special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'}
1735		if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; }
1736
1737		replace_one_variable_in_translationfile($translationfile, $value, $key);
1738	}
1739}
1740
1741#########################################################
1742# Getting the translation file for the nsis installer
1743#########################################################
1744
1745sub get_translation_file
1746{
1747	my ($allvariableshashref) = @_;
1748	my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename . ".uulf";
1749	if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1750	my $translationfile = installer::files::read_file($translationfilename);
1751	replace_variables($translationfile, $allvariableshashref);
1752
1753    $installer::logger::Lang->printf("Reading translation file: %s\n", $translationfilename);
1754
1755	return $translationfile;
1756}
1757
1758####################################################
1759# Removing english, if it was added before
1760####################################################
1761
1762sub remove_english_for_nsis_installer
1763{
1764	my ($languagestringref, $languagesarrayref) = @_;
1765
1766	# $$languagestringref =~ s/en-US_//;
1767	# shift(@{$languagesarrayref});
1768
1769	@{$languagesarrayref} = ("en-US");	# only english for NSIS installer!
1770}
1771
1772####################################################
1773# Creating link tree for upload
1774####################################################
1775
1776sub create_link_tree
1777{
1778	my ($sourcedownloadfile, $destfilename, $versionstring) = @_;
1779
1780	if ( ! $installer::globals::ooouploaddir ) { installer::exiter::exit_program("ERROR: Directory for AOO upload not defined!", "create_link_tree"); }
1781	my $versiondir = $installer::globals::ooouploaddir . $installer::globals::separator . $versionstring;
1782    $installer::logger::Lang->printf("Directory for the link: %s\n", $versiondir);
1783
1784	if ( ! -d $versiondir ) { installer::systemactions::create_directory_structure($versiondir); }
1785
1786	# inside directory $versiondir all links have to be created
1787	my $linkdestination = $versiondir . $installer::globals::separator . $destfilename;
1788
1789	# If there is an older version of this file (link), it has to be removed
1790	if ( -f $linkdestination ) { unlink($linkdestination); }
1791
1792    $installer::logger::Lang->printf("Creating hard link from %s to %s\n", $sourcedownloadfile, $linkdestination);
1793	installer::systemactions::hardlink_one_file($sourcedownloadfile, $linkdestination);
1794}
1795
1796#######################################################
1797# Setting supported platform for Sun OpenOffice.org
1798# builds
1799#######################################################
1800
1801sub is_supported_platform
1802{
1803	my $is_supported = 0;
1804
1805	if (( $installer::globals::islinuxrpmbuild ) ||
1806		( $installer::globals::issolarissparcbuild ) ||
1807		( $installer::globals::issolarisx86build ) ||
1808		( $installer::globals::iswindowsbuild ))
1809	{
1810		$is_supported = 1;
1811	}
1812
1813	return $is_supported;
1814}
1815
1816####################################################
1817# Creating download installation sets
1818####################################################
1819
1820sub create_download_sets
1821{
1822	my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_;
1823
1824    $installer::logger::Info->print("\n");
1825    $installer::logger::Info->print("******************************************\n");
1826    $installer::logger::Info->print("... creating download installation set ...\n", 1);
1827    $installer::logger::Info->print("******************************************\n");
1828
1829	installer::logger::include_header_into_logfile("Creating download installation sets:");
1830
1831	# special handling for installation sets, to which english was added automatically
1832	if ( $installer::globals::added_english ) { remove_english_for_nsis_installer($languagestringref, $languagesarrayref); }
1833
1834	my $firstdir = $installationdir;
1835	installer::pathanalyzer::get_path_from_fullqualifiedname(\$firstdir);
1836
1837	my $lastdir = $installationdir;
1838	installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$lastdir);
1839
1840	if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ }
1841	else { $lastdir = $lastdir . "_download_inprogress"; }
1842
1843	# removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed"
1844
1845	my $downloaddir = $firstdir . $lastdir;
1846
1847	if ( -d $downloaddir ) { installer::systemactions::remove_complete_directory($downloaddir); }
1848
1849	my $olddir = $downloaddir;
1850	$olddir =~ s/_inprogress/_witherror/;
1851	if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); }
1852
1853	$olddir = $downloaddir;
1854	$olddir =~ s/_inprogress//;
1855	if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); }
1856
1857	# creating the new directory
1858
1859	installer::systemactions::create_directory($downloaddir);
1860
1861	$installer::globals::saveinstalldir = $downloaddir;
1862
1863	# evaluating the name of the download file
1864
1865	if ( $allvariableshashref->{'AOODOWNLOADNAME'} )
1866    {
1867        $downloadname = set_download_filename($languagestringref, $allvariableshashref);
1868    }
1869	else
1870    {
1871        $downloadname = resolve_variables_in_downloadname($allvariableshashref, $downloadname, $languagestringref);
1872    }
1873
1874	if ( ! $installer::globals::iswindowsbuild )	# Unix specific part
1875	{
1876
1877		# getting the path of the getuid.so (only required for Solaris and Linux)
1878		my $getuidlibrary = "";
1879		if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild )) {	$getuidlibrary = get_path_for_library($includepatharrayref); }
1880
1881		if ( $allvariableshashref->{'AOODOWNLOADNAME'} )
1882		{
1883			my $downloadfile = create_tar_gz_file_from_directory($installationdir, $getuidlibrary, $downloaddir, $downloadname);
1884		}
1885		else
1886		{
1887			# find and read setup script template
1888			my $scriptfilename = "downloadscript.sh";
1889
1890			my $scriptref = "";
1891
1892			if ( $installer::globals::include_pathes_read )
1893			{
1894				$scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0);
1895			}
1896			else
1897			{
1898				$scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$scriptfilename, $includepatharrayref, 0);
1899			}
1900
1901			if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); }
1902			my $scriptfile = installer::files::read_file($$scriptref);
1903
1904            $installer::logger::Lang->printf("Found  script file %s: %s \n", $scriptfilename, $$scriptref);
1905
1906			# add product name into script template
1907			put_productname_into_script($scriptfile, $allvariableshashref);
1908
1909			# replace linenumber in script template
1910			put_linenumber_into_script($scriptfile);
1911
1912			# create tar file
1913			my $temporary_tarfile_name = $downloaddir . $installer::globals::separator . 'installset.tar';
1914			my $size = tar_package($installationdir, $temporary_tarfile_name, $getuidlibrary);
1915			installer::exiter::exit_program("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size;
1916
1917			# calling sum to determine checksum and size of the tar file
1918			my $sumout = call_sum($temporary_tarfile_name);
1919
1920			# writing checksum and size into scriptfile
1921			put_checksum_and_size_into_script($scriptfile, $sumout);
1922
1923			# saving the script file
1924			my $newscriptfilename = determine_scriptfile_name($downloadname);
1925			$newscriptfilename = save_script_file($downloaddir, $newscriptfilename, $scriptfile);
1926
1927            $installer::logger::Info->printf("... including installation set into %s ... \n", $newscriptfilename);
1928            # Append tar file to script
1929			include_tar_into_script($newscriptfilename, $temporary_tarfile_name);
1930		}
1931	}
1932	else	# Windows specific part
1933	{
1934		my $localnsisdir = installer::systemactions::create_directories("nsis", $languagestringref);
1935		# push(@installer::globals::removedirs, $localnsisdir);
1936
1937		# find nsis in the system
1938		my $nsispath = get_path_to_nsis_sdk();
1939
1940		if ( $nsispath eq "" ) {
1941			# If nsis is not found just skip the rest of this function
1942			# and do not create the NSIS file.
1943            $installer::logger::Lang->print("\n");
1944            $installer::logger::Lang->printf("No NSIS SDK found. Skipping the generation of NSIS file.\n");
1945            $installer::logger::Info->print("... no NSIS SDK found. Skipping the generation of NSIS file ... \n");
1946			return $downloaddir;
1947		}
1948
1949		# copy language files into nsis directory and translate them
1950		copy_and_translate_nsis_language_files($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref);
1951
1952		# find and read the nsi file template
1953		my $templatefilename = "downloadtemplate.nsi";
1954
1955		my $templateref = "";
1956
1957		if ( $installer::globals::include_pathes_read )
1958		{
1959			$templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$templatefilename, $includepatharrayref, 0);
1960		}
1961		else
1962		{
1963			$templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$templatefilename, $includepatharrayref, 0);
1964		}
1965
1966		if ($$templateref eq "") { installer::exiter::exit_program("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); }
1967		my $templatefile = installer::files::read_file($$templateref);
1968
1969		# add product name into script template
1970		put_windows_productname_into_template($templatefile, $allvariableshashref);
1971		put_banner_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1972		put_welcome_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1973		put_setup_ico_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1974		put_publisher_into_template($templatefile, $allvariableshashref);
1975		put_website_into_template($templatefile, $allvariableshashref);
1976		put_javafilename_into_template($templatefile, $allvariableshashref);
1977		put_windows_productversion_into_template($templatefile, $allvariableshashref);
1978		put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
1979		put_outputfilename_into_template($templatefile, $downloadname);
1980		put_filelist_into_template($templatefile, $installationdir);
1981		put_language_list_into_template($templatefile, $languagesarrayref);
1982		put_nsis_path_into_template($templatefile, $localnsisdir);
1983		put_output_path_into_template($templatefile, $downloaddir);
1984
1985		my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile);
1986
1987        $installer::logger::Info->printf("... created NSIS file %s ... \n", $nsifilename);
1988
1989		# starting the NSIS SDK to create the download file
1990		call_nsis($nsispath, $nsifilename);
1991	}
1992
1993	return $downloaddir;
1994}
1995
1996####################################################
1997# Creating AOO upload tree
1998####################################################
1999
2000sub create_download_link_tree
2001{
2002	my ($downloaddir, $languagestringref, $allvariableshashref) = @_;
2003
2004    $installer::logger::Info->print("\n");
2005    $installer::logger::Info->print("******************************************\n"); #
2006    $installer::logger::Info->print("... creating download hard link ...\n");
2007    $installer::logger::Info->print("******************************************\n");
2008
2009	installer::logger::include_header_into_logfile("Creating download hard link:");
2010	$installer::logger::Lang->print("\n");
2011	$installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, start");
2012
2013	if ( is_supported_platform() )
2014	{
2015		my $versionstring = "";
2016		# Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ?
2017
2018		if ( ! $installer::globals::oooversionstring ) { $versionstring = get_current_version(); }
2019		else { $versionstring = $installer::globals::oooversionstring; }
2020
2021		# Is $versionstring empty? If yes, there is nothing to do now.
2022
2023        $installer::logger::Lang->printf("Version string is set to: %s\n", $versionstring);
2024
2025		if ( $versionstring )
2026		{
2027			# Now the downloadfilename has to be set (if not already done)
2028			my $destdownloadfilename = "";
2029			if ( ! $installer::globals::ooodownloadfilename ) { $destdownloadfilename = set_download_filename($languagestringref, $versionstring, $allvariableshashref); }
2030			else { $destdownloadfilename = $installer::globals::ooodownloadfilename; }
2031
2032			if ( $destdownloadfilename )
2033			{
2034				$destdownloadfilename = $destdownloadfilename . $installer::globals::downloadfileextension;
2035
2036                $installer::logger::Lang->printf("Setting destination download file name: %s\n", $destdownloadfilename);
2037
2038				my $sourcedownloadfile = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename;
2039
2040                $installer::logger::Lang->printf("Setting source download file name: %s\n", $sourcedownloadfile);
2041
2042				create_link_tree($sourcedownloadfile, $destdownloadfilename, $versionstring);
2043				# my $md5sumoutput = call_md5sum($downloadfile);
2044				# my $md5sum = get_md5sum($md5sumoutput);
2045
2046			}
2047		}
2048		else
2049		{
2050            $installer::logger::Lang->printf("Version string is empty. Nothing to do!\n");
2051        }
2052	}
2053	else
2054	{
2055        $installer::logger::Lang->printf("Platform not used for hard linking. Nothing to do!\n");
2056	}
2057
2058	$installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, stop");
2059}
2060
20611;
2062