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"; }
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"; }
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	$newstring =~ s/\\r/\$\\r/g; # \r -> $\r in modern nsis versions
1408	$newstring =~ s/\\n/\$\\n/g; # \n -> $\n in modern nsis versions
1409
1410	for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1411	{
1412		if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1413		{
1414			my $oldstring = $1;
1415			${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1416			$installer::logger::Lang->printf("NSIS replacement in %s (%s): \-\> %s\n",
1417				$nshfilename,
1418				$onelanguage,
1419				$oldstring,
1420				$newstring);
1421		}
1422	}
1423}
1424
1425##################################################################
1426# Windows: Replacing strings in NSIS nlf file
1427# nlf file syntax (2 lines):
1428# # ^DirSubText
1429# Zielverzeichnis
1430##################################################################
1431
1432sub replace_identifier_in_nlffile
1433{
1434	my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_;
1435
1436	for ( my $i = 0; $i <= $#{$nlffile}; $i++ )
1437	{
1438		if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ )
1439		{
1440			my $next = $i+1;
1441			my $oldstring = ${$nlffile}[$next];
1442			${$nlffile}[$next] = $newstring . "\n";
1443			$oldstring =~ s/\s*$//;
1444			$installer::logger::Lang->printf("NSIS replacement in %s (%s): %s \-\> %s\n",
1445				$nlffilename,
1446				$onelanguage,
1447				$oldstring,
1448				$newstring);
1449		}
1450	}
1451}
1452
1453##################################################################
1454# Windows: Translating the NSIS nsh and nlf file
1455##################################################################
1456
1457sub translate_nsh_nlf_file
1458{
1459	my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_;
1460
1461	# Analyzing the mlf file, collecting all Identifier
1462	my $allidentifier = get_identifier($mlffile);
1463
1464	$onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US");
1465	for ( my $i = 0; $i <= $#{$allidentifier}; $i++ )
1466	{
1467		my $identifier = ${$allidentifier}[$i];
1468		my $language_block = get_language_block_from_language_file($identifier, $mlffile);
1469		my $newstring = get_language_string_from_language_block($language_block, $onelanguage);
1470
1471		# removing mask
1472		$newstring =~ s/\\\'/\'/g;
1473
1474		replace_identifier_in_nshfile($nshfile, $identifier, $newstring, $nshfilename, $onelanguage);
1475		replace_identifier_in_nlffile($nlffile, $identifier, $newstring, $nlffilename, $onelanguage);
1476	}
1477}
1478
1479##################################################################
1480# Converting utf 16 file to utf 8
1481##################################################################
1482
1483sub convert_utf16_to_utf8
1484{
1485	my ( $filename ) = @_;
1486
1487	my @localfile = ();
1488
1489	my $savfilename = $filename . "_before.utf16";
1490	installer::systemactions::copy_one_file($filename, $savfilename);
1491
1492#	open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1493#	open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1494	open( IN, "<:encoding(UTF16-LE)", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8");
1495	while ( my $line = <IN> )
1496	{
1497		push @localfile, $line;
1498	}
1499	close( IN );
1500
1501	if ( open( OUT, ">:utf8", $filename ) )
1502	{
1503		print OUT @localfile;
1504		close(OUT);
1505	}
1506
1507	$savfilename = $filename . "_before.utf8";
1508	installer::systemactions::copy_one_file($filename, $savfilename);
1509}
1510
1511##################################################################
1512# Converting utf 8 file to utf 16
1513##################################################################
1514
1515sub convert_utf8_to_utf16
1516{
1517	my ( $filename ) = @_;
1518
1519	my @localfile = ();
1520
1521	my $savfilename = $filename . "_after.utf8";
1522	installer::systemactions::copy_one_file($filename, $savfilename);
1523
1524	open( IN, "<:utf8", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16");
1525	while (my $line = <IN>)
1526	{
1527		push @localfile, $line;
1528	}
1529	close( IN );
1530
1531	if ( open( OUT, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) )
1532	{
1533		print OUT @localfile;
1534		close(OUT);
1535	}
1536
1537	$savfilename = $filename . "_after.utf16";
1538	installer::systemactions::copy_one_file($filename, $savfilename);
1539}
1540
1541##################################################################
1542# Converting text string to utf 16
1543##################################################################
1544
1545sub convert_textstring_to_utf16
1546{
1547	my ( $textstring, $localnsisdir, $shortfilename ) = @_;
1548
1549	my $filename = $localnsisdir . $installer::globals::separator . $shortfilename;
1550	my @filecontent = ();
1551	push(@filecontent, $textstring);
1552	installer::files::save_file($filename, \@filecontent);
1553	convert_utf8_to_utf16($filename);
1554	my $newfile = installer::files::read_file($filename);
1555	my $utf16string = "";
1556	if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; }
1557
1558	return $utf16string;
1559}
1560
1561##################################################################
1562# Windows: Copying NSIS language files to local nsis directory
1563##################################################################
1564
1565sub copy_and_translate_nsis_language_files
1566{
1567	my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_;
1568
1569	my $nlffilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Language\ files" . $installer::globals::separator;
1570	my $nshfilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Modern\ UI" . $installer::globals::separator . "Language files" . $installer::globals::separator;
1571
1572	for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1573	{
1574		my $onelanguage = ${$languagesarrayref}[$i];
1575		my $nsislanguage = nsis_language_converter($onelanguage);
1576
1577		# Copying the nlf file
1578		my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf";
1579		if ( ! -f $sourcepath ) { installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); }
1580		my $nlffilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nlf";
1581		if ( $^O =~ /cygwin/i ) { $nlffilename =~ s/\//\\/g; }
1582		installer::systemactions::copy_one_file($sourcepath, $nlffilename);
1583
1584		# Copying the nsh file
1585		# In newer nsis versions, the nsh file is located next to the nlf file
1586		$sourcepath = $nshfilepath . $nsislanguage . "\.nsh";
1587		if ( ! -f $sourcepath )
1588		{
1589			# trying to find the nsh file next to the nlf file
1590			$sourcepath = $nlffilepath . $nsislanguage . "\.nsh";
1591			if ( ! -f $sourcepath )
1592			{
1593				installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1594			}
1595		}
1596		my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh";
1597		if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; }
1598		installer::systemactions::copy_one_file($sourcepath, $nshfilename);
1599
1600		# Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1601		#convert_utf16_to_utf8($nshfilename);
1602		#convert_utf16_to_utf8($nlffilename);
1603		my $nshfile = installer::files::read_file($nshfilename);
1604		replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1605
1606		# find the ulf file for translation
1607		my $mlffile = get_translation_file($allvariables);
1608
1609		# Translate the files
1610		my $nlffile = installer::files::read_file($nlffilename);
1611		translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1612
1613		installer::files::save_file($nshfilename, $nshfile);
1614		installer::files::save_file($nlffilename, $nlffile);
1615
1616		#convert_utf8_to_utf16($nshfilename);
1617		#convert_utf8_to_utf16($nlffilename);
1618	}
1619
1620}
1621
1622##################################################################
1623# Windows: Including the nsis path into the nsi template
1624##################################################################
1625
1626sub put_nsis_path_into_template
1627{
1628	my ($templatefile, $nsisdir) = @_;
1629
1630	replace_one_variable($templatefile, "NSISPATHPLACEHOLDER", $nsisdir);
1631}
1632
1633##################################################################
1634# Windows: Including the output path into the nsi template
1635##################################################################
1636
1637sub put_output_path_into_template
1638{
1639	my ($templatefile, $downloaddir) = @_;
1640
1641	if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; }
1642
1643	replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1644}
1645
1646##################################################################
1647# Windows: Finding the path to the nsis SDK
1648##################################################################
1649
1650sub get_path_to_nsis_sdk
1651{
1652	my $nsispath = "";
1653
1654	if ( $ENV{'NSIS_PATH'} )
1655	{
1656		$nsispath = $ENV{'NSIS_PATH'};
1657	}
1658	if ( $nsispath eq "" )
1659	{
1660		$installer::logger::Info->print("... no Environment variable \"NSIS_PATH\"!\n");
1661	}
1662	elsif ( ! -d $nsispath )
1663	{
1664		installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1665	}
1666
1667	return $nsispath;
1668}
1669
1670##################################################################
1671# Windows: Executing NSIS to create the installation set
1672##################################################################
1673
1674sub call_nsis
1675{
1676	my ( $nsispath, $nsifile ) = @_;
1677
1678	my $makensisexe = $nsispath . $installer::globals::separator . "makensis.exe";
1679
1680	$installer::logger::Info->printf("... starting %s ... \n", $makensisexe);
1681
1682	if( $^O =~ /cygwin/i ) { $nsifile =~ s/\\/\//g;	}
1683
1684	my $systemcall = "$makensisexe $nsifile |";
1685
1686	$installer::logger::Lang->printf("Systemcall: %s\n", $systemcall);
1687
1688	my @nsisoutput = ();
1689
1690	open (NSI, "$systemcall");
1691	while (<NSI>) {push(@nsisoutput, $_); }
1692	close (NSI);
1693
1694	my $returnvalue = $?;	# $? contains the return value of the systemcall
1695
1696	if ($returnvalue)
1697	{
1698		$installer::logger::Lang->printf("ERROR: %s !\n", $systemcall);
1699	}
1700	else
1701	{
1702		$installer::logger::Lang->printf("Success: %s\n", $systemcall);
1703	}
1704
1705	foreach my $line (@nsisoutput)
1706	{
1707		$installer::logger::Lang->print($line);
1708	}
1709}
1710
1711#################################################################################
1712# Replacing one variable in one files
1713#################################################################################
1714
1715sub replace_one_variable_in_translationfile
1716{
1717	my ($translationfile, $variable, $searchstring) = @_;
1718
1719	for ( my $i = 0; $i <= $#{$translationfile}; $i++ )
1720	{
1721		${$translationfile}[$i] =~ s/\%$searchstring/$variable/g;
1722	}
1723}
1724
1725#################################################################################
1726# Replacing the variables in the translation file
1727#################################################################################
1728
1729sub replace_variables
1730{
1731	my ($translationfile, $variableshashref) = @_;
1732
1733	foreach my $key (keys %{$variableshashref})
1734	{
1735		my $value = $variableshashref->{$key};
1736
1737		# special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'}
1738		if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; }
1739
1740		replace_one_variable_in_translationfile($translationfile, $value, $key);
1741	}
1742}
1743
1744#########################################################
1745# Getting the translation file for the nsis installer
1746#########################################################
1747
1748sub get_translation_file
1749{
1750	my ($allvariableshashref) = @_;
1751	my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename . ".uulf";
1752	if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1753	my $translationfile = installer::files::read_file($translationfilename);
1754	replace_variables($translationfile, $allvariableshashref);
1755
1756	$installer::logger::Lang->printf("Reading translation file: %s\n", $translationfilename);
1757
1758	return $translationfile;
1759}
1760
1761####################################################
1762# Removing English, if it was added before
1763####################################################
1764
1765sub remove_english_for_nsis_installer
1766{
1767	my ($languagestringref, $languagesarrayref) = @_;
1768
1769	# $$languagestringref =~ s/en-US_//;
1770	# shift(@{$languagesarrayref});
1771
1772	@{$languagesarrayref} = ("en-US");	# only English for NSIS installer!
1773}
1774
1775####################################################
1776# Creating link tree for upload
1777####################################################
1778
1779sub create_link_tree
1780{
1781	my ($sourcedownloadfile, $destfilename, $versionstring) = @_;
1782
1783	if ( ! $installer::globals::ooouploaddir ) { installer::exiter::exit_program("ERROR: Directory for AOO upload not defined!", "create_link_tree"); }
1784	my $versiondir = $installer::globals::ooouploaddir . $installer::globals::separator . $versionstring;
1785	$installer::logger::Lang->printf("Directory for the link: %s\n", $versiondir);
1786
1787	if ( ! -d $versiondir ) { installer::systemactions::create_directory_structure($versiondir); }
1788
1789	# inside directory $versiondir all links have to be created
1790	my $linkdestination = $versiondir . $installer::globals::separator . $destfilename;
1791
1792	# If there is an older version of this file (link), it has to be removed
1793	if ( -f $linkdestination ) { unlink($linkdestination); }
1794
1795	$installer::logger::Lang->printf("Creating hard link from %s to %s\n", $sourcedownloadfile, $linkdestination);
1796	installer::systemactions::hardlink_one_file($sourcedownloadfile, $linkdestination);
1797}
1798
1799#######################################################
1800# Setting supported platform for Sun OpenOffice.org
1801# builds
1802#######################################################
1803
1804sub is_supported_platform
1805{
1806	my $is_supported = 0;
1807
1808	if (( $installer::globals::islinuxrpmbuild ) ||
1809		( $installer::globals::issolarissparcbuild ) ||
1810		( $installer::globals::issolarisx86build ) ||
1811		( $installer::globals::iswindowsbuild ))
1812	{
1813		$is_supported = 1;
1814	}
1815
1816	return $is_supported;
1817}
1818
1819####################################################
1820# Creating download installation sets
1821####################################################
1822
1823sub create_download_sets
1824{
1825	my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_;
1826
1827	$installer::logger::Info->print("\n");
1828	$installer::logger::Info->print("******************************************\n");
1829	$installer::logger::Info->print("... creating download installation set ...\n", 1);
1830	$installer::logger::Info->print("******************************************\n");
1831
1832	installer::logger::include_header_into_logfile("Creating download installation sets:");
1833
1834	# special handling for installation sets, to which English was added automatically
1835	if ( $installer::globals::added_english ) { remove_english_for_nsis_installer($languagestringref, $languagesarrayref); }
1836
1837	my $firstdir = $installationdir;
1838	installer::pathanalyzer::get_path_from_fullqualifiedname(\$firstdir);
1839
1840	my $lastdir = $installationdir;
1841	installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$lastdir);
1842
1843	if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ }
1844	else { $lastdir = $lastdir . "_download_inprogress"; }
1845
1846	# removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed"
1847
1848	my $downloaddir = $firstdir . $lastdir;
1849
1850	if ( -d $downloaddir ) { installer::systemactions::remove_complete_directory($downloaddir); }
1851
1852	my $olddir = $downloaddir;
1853	$olddir =~ s/_inprogress/_witherror/;
1854	if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); }
1855
1856	$olddir = $downloaddir;
1857	$olddir =~ s/_inprogress//;
1858	if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); }
1859
1860	# creating the new directory
1861
1862	installer::systemactions::create_directory($downloaddir);
1863
1864	$installer::globals::saveinstalldir = $downloaddir;
1865
1866	# evaluating the name of the download file
1867
1868	if ( $allvariableshashref->{'AOODOWNLOADNAME'} )
1869	{
1870		$downloadname = set_download_filename($languagestringref, $allvariableshashref);
1871	}
1872	else
1873	{
1874		$downloadname = resolve_variables_in_downloadname($allvariableshashref, $downloadname, $languagestringref);
1875	}
1876
1877	if ( ! $installer::globals::iswindowsbuild )	# Unix specific part
1878	{
1879
1880		# getting the path of the getuid.so (only required for Solaris and Linux)
1881		my $getuidlibrary = "";
1882		if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild )) {	$getuidlibrary = get_path_for_library($includepatharrayref); }
1883
1884		if ( $allvariableshashref->{'AOODOWNLOADNAME'} )
1885		{
1886			my $downloadfile = create_tar_gz_file_from_directory($installationdir, $getuidlibrary, $downloaddir, $downloadname);
1887		}
1888		else
1889		{
1890			# find and read setup script template
1891			my $scriptfilename = "downloadscript.sh";
1892
1893			my $scriptref = "";
1894
1895			if ( $installer::globals::include_pathes_read )
1896			{
1897				$scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0);
1898			}
1899			else
1900			{
1901				$scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$scriptfilename, $includepatharrayref, 0);
1902			}
1903
1904			if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); }
1905			my $scriptfile = installer::files::read_file($$scriptref);
1906
1907			$installer::logger::Lang->printf("Found script file %s: %s \n", $scriptfilename, $$scriptref);
1908
1909			# add product name into script template
1910			put_productname_into_script($scriptfile, $allvariableshashref);
1911
1912			# replace linenumber in script template
1913			put_linenumber_into_script($scriptfile);
1914
1915			# create tar file
1916			my $temporary_tarfile_name = $downloaddir . $installer::globals::separator . 'installset.tar';
1917			my $size = tar_package($installationdir, $temporary_tarfile_name, $getuidlibrary);
1918			installer::exiter::exit_program("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size;
1919
1920			# calling sum to determine checksum and size of the tar file
1921			my $sumout = call_sum($temporary_tarfile_name);
1922
1923			# writing checksum and size into scriptfile
1924			put_checksum_and_size_into_script($scriptfile, $sumout);
1925
1926			# saving the script file
1927			my $newscriptfilename = determine_scriptfile_name($downloadname);
1928			$newscriptfilename = save_script_file($downloaddir, $newscriptfilename, $scriptfile);
1929
1930			$installer::logger::Info->printf("... including installation set into %s ... \n", $newscriptfilename);
1931			# Append tar file to script
1932			include_tar_into_script($newscriptfilename, $temporary_tarfile_name);
1933		}
1934	}
1935	else	# Windows specific part
1936	{
1937		my $localnsisdir = installer::systemactions::create_directories("nsis", $languagestringref);
1938		# push(@installer::globals::removedirs, $localnsisdir);
1939
1940		# find nsis in the system
1941		my $nsispath = get_path_to_nsis_sdk();
1942
1943		if ( $nsispath eq "" ) {
1944			# If nsis is not found just skip the rest of this function
1945			# and do not create the NSIS file.
1946			$installer::logger::Lang->print("\n");
1947			$installer::logger::Lang->printf("No NSIS SDK found. Skipping the generation of NSIS file.\n");
1948			$installer::logger::Info->print("... no NSIS SDK found. Skipping the generation of NSIS file ... \n");
1949			return $downloaddir;
1950		}
1951
1952		# copy language files into nsis directory and translate them
1953		copy_and_translate_nsis_language_files($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref);
1954
1955		# find and read the nsi file template
1956		my $templatefilename = "downloadtemplate.nsi";
1957
1958		my $templateref = "";
1959
1960		if ( $installer::globals::include_pathes_read )
1961		{
1962			$templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$templatefilename, $includepatharrayref, 0);
1963		}
1964		else
1965		{
1966			$templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$templatefilename, $includepatharrayref, 0);
1967		}
1968
1969		if ($$templateref eq "") { installer::exiter::exit_program("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); }
1970		my $templatefile = installer::files::read_file($$templateref);
1971
1972		# add product name into script template
1973		put_windows_productname_into_template($templatefile, $allvariableshashref);
1974		put_banner_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1975		put_welcome_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1976		put_setup_ico_into_template($templatefile, $includepatharrayref, $allvariableshashref);
1977		put_publisher_into_template($templatefile, $allvariableshashref);
1978		put_website_into_template($templatefile, $allvariableshashref);
1979		put_javafilename_into_template($templatefile, $allvariableshashref);
1980		put_windows_productversion_into_template($templatefile, $allvariableshashref);
1981		put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
1982		put_outputfilename_into_template($templatefile, $downloadname);
1983		put_filelist_into_template($templatefile, $installationdir);
1984		put_language_list_into_template($templatefile, $languagesarrayref);
1985		put_nsis_path_into_template($templatefile, $localnsisdir);
1986		put_output_path_into_template($templatefile, $downloaddir);
1987
1988		my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile);
1989
1990		$installer::logger::Info->printf("... created NSIS file %s ... \n", $nsifilename);
1991
1992		# starting the NSIS SDK to create the download file
1993		call_nsis($nsispath, $nsifilename);
1994	}
1995
1996	return $downloaddir;
1997}
1998
1999####################################################
2000# Creating AOO upload tree
2001####################################################
2002
2003sub create_download_link_tree
2004{
2005	my ($downloaddir, $languagestringref, $allvariableshashref) = @_;
2006
2007	$installer::logger::Info->print("\n");
2008	$installer::logger::Info->print("******************************************\n"); #
2009	$installer::logger::Info->print("... creating download hard link ...\n");
2010	$installer::logger::Info->print("******************************************\n");
2011
2012	installer::logger::include_header_into_logfile("Creating download hard link:");
2013	$installer::logger::Lang->print("\n");
2014	$installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, start");
2015
2016	if ( is_supported_platform() )
2017	{
2018		my $versionstring = "";
2019		# Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ?
2020
2021		if ( ! $installer::globals::oooversionstring ) { $versionstring = get_current_version(); }
2022		else { $versionstring = $installer::globals::oooversionstring; }
2023
2024		# Is $versionstring empty? If yes, there is nothing to do now.
2025
2026		$installer::logger::Lang->printf("Version string is set to: %s\n", $versionstring);
2027
2028		if ( $versionstring )
2029		{
2030			# Now the downloadfilename has to be set (if not already done)
2031			my $destdownloadfilename = "";
2032			if ( ! $installer::globals::ooodownloadfilename ) { $destdownloadfilename = set_download_filename($languagestringref, $versionstring, $allvariableshashref); }
2033			else { $destdownloadfilename = $installer::globals::ooodownloadfilename; }
2034
2035			if ( $destdownloadfilename )
2036			{
2037				$destdownloadfilename = $destdownloadfilename . $installer::globals::downloadfileextension;
2038
2039				$installer::logger::Lang->printf("Setting destination download file name: %s\n", $destdownloadfilename);
2040
2041				my $sourcedownloadfile = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename;
2042
2043				$installer::logger::Lang->printf("Setting source download file name: %s\n", $sourcedownloadfile);
2044
2045				create_link_tree($sourcedownloadfile, $destdownloadfilename, $versionstring);
2046				# my $md5sumoutput = call_md5sum($downloadfile);
2047				# my $md5sum = get_md5sum($md5sumoutput);
2048
2049			}
2050		}
2051		else
2052		{
2053			$installer::logger::Lang->printf("Version string is empty. Nothing to do!\n");
2054		}
2055	}
2056	else
2057	{
2058		$installer::logger::Lang->printf("Platform not used for hard linking. Nothing to do!\n");
2059	}
2060
2061	$installer::logger::Lang->add_timestamp("Performance Info: Creating hard link, stop");
2062}
2063
20641;
2065