xref: /AOO41X/main/solenv/bin/modules/installer/simplepackage.pm (revision 14ebc950dd6c8574371cc2a3501fbfcd18389854)
19780544fSAndrew Rist#**************************************************************
2cdf0e10cSrcweir#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
19cdf0e10cSrcweir#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::simplepackage;
25cdf0e10cSrcweir
26cdf0e10cSrcweir# use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
27cdf0e10cSrcweiruse Cwd;
28cdf0e10cSrcweiruse File::Copy;
29cdf0e10cSrcweiruse installer::download;
30cdf0e10cSrcweiruse installer::exiter;
31cdf0e10cSrcweiruse installer::globals;
32cdf0e10cSrcweiruse installer::logger;
33cdf0e10cSrcweiruse installer::strip;
34cdf0e10cSrcweiruse installer::systemactions;
35cdf0e10cSrcweiruse installer::worker;
36cdf0e10cSrcweir
37cdf0e10cSrcweir####################################################
38cdf0e10cSrcweir# Checking if the simple packager is required.
39cdf0e10cSrcweir# This can be achieved by setting the global
40cdf0e10cSrcweir# variable SIMPLE_PACKAGE in *.lst file or by
41cdf0e10cSrcweir# setting the environment variable SIMPLE_PACKAGE.
42cdf0e10cSrcweir####################################################
43cdf0e10cSrcweir
44cdf0e10cSrcweirsub check_simple_packager_project
45cdf0e10cSrcweir{
46cdf0e10cSrcweir	my ( $allvariables ) = @_;
47cdf0e10cSrcweir
48cdf0e10cSrcweir	if (( $installer::globals::packageformat eq "installed" ) ||
49cdf0e10cSrcweir		( $installer::globals::packageformat eq "archive" ))
50cdf0e10cSrcweir	{
51cdf0e10cSrcweir		$installer::globals::is_simple_packager_project = 1;
52cdf0e10cSrcweir		$installer::globals::patch_user_dir = 1;
53cdf0e10cSrcweir	}
54cdf0e10cSrcweir	elsif( $installer::globals::packageformat eq "dmg" )
55cdf0e10cSrcweir	{
56cdf0e10cSrcweir		$installer::globals::is_simple_packager_project = 1;
57cdf0e10cSrcweir	}
58cdf0e10cSrcweir}
59cdf0e10cSrcweir
60cdf0e10cSrcweir####################################################
61cdf0e10cSrcweir# Detecting the directory with extensions
62cdf0e10cSrcweir####################################################
63cdf0e10cSrcweir
64cdf0e10cSrcweirsub get_extensions_dir
65cdf0e10cSrcweir{
66cdf0e10cSrcweir	my ( $subfolderdir ) = @_;
67cdf0e10cSrcweir
68cdf0e10cSrcweir	my $extensiondir = $subfolderdir . $installer::globals::separator;
69cdf0e10cSrcweir	if ( $installer::globals::officedirhostname ne "" ) { $extensiondir = $extensiondir . $installer::globals::officedirhostname . $installer::globals::separator; }
70cdf0e10cSrcweir	my $extensionsdir = $extensiondir . "share" . $installer::globals::separator . "extensions";
71cdf0e10cSrcweir	my $preregdir = $extensiondir . "share" . $installer::globals::separator . "prereg" . $installer::globals::separator . "bundled";
72cdf0e10cSrcweir
73cdf0e10cSrcweir	return ( $extensionsdir, $preregdir );
74cdf0e10cSrcweir}
75cdf0e10cSrcweir
76cdf0e10cSrcweir####################################################
77cdf0e10cSrcweir# Registering extensions
78cdf0e10cSrcweir####################################################
79cdf0e10cSrcweir
80cdf0e10cSrcweirsub register_extensions
81cdf0e10cSrcweir{
82cdf0e10cSrcweir	my ($officedir, $languagestringref, $preregdir) = @_;
83cdf0e10cSrcweir
84cdf0e10cSrcweir	my $infoline = "";
85cdf0e10cSrcweir
86cdf0e10cSrcweir	if ( $preregdir eq "" )
87cdf0e10cSrcweir	{
88cdf0e10cSrcweir		$infoline = "ERROR: Failed to determine directory \"prereg\" for extension registration! Please check your installation set.\n";
89b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
90cdf0e10cSrcweir		installer::exiter::exit_program($infoline, "register_extensions");
91cdf0e10cSrcweir	}
92cdf0e10cSrcweir
93cdf0e10cSrcweir	my $programdir = $officedir . $installer::globals::separator;
94cdf0e10cSrcweir	if ( $installer::globals::officedirhostname ne "" ) { $programdir = $programdir . $installer::globals::officedirhostname . $installer::globals::separator; }
95cdf0e10cSrcweir	$programdir = $programdir . "program";
96cdf0e10cSrcweir
97cdf0e10cSrcweir	my $from = cwd();
98cdf0e10cSrcweir	chdir($programdir);
99cdf0e10cSrcweir
100cdf0e10cSrcweir	my $unopkgfile = $installer::globals::unopkgfile;
101cdf0e10cSrcweir
102cdf0e10cSrcweir	my $unopkgexists = 1;
103cdf0e10cSrcweir	if (( $installer::globals::languagepack ) && ( ! -f $unopkgfile ))
104cdf0e10cSrcweir	{
105cdf0e10cSrcweir		$unopkgexists = 0;
106cdf0e10cSrcweir		$infoline = "Language packs do not contain unopkg!\n";
107b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
108cdf0e10cSrcweir	}
109cdf0e10cSrcweir
110cdf0e10cSrcweir	if ( ! -f $unopkgfile )
111cdf0e10cSrcweir	{
112cdf0e10cSrcweir		$unopkgexists = 0;
113cdf0e10cSrcweir		$infoline = "Info: File $unopkgfile does not exist! Extensions cannot be registered.\n";
114b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
115cdf0e10cSrcweir	}
116cdf0e10cSrcweir
117cdf0e10cSrcweir	if ( $unopkgexists )
118cdf0e10cSrcweir	{
119cdf0e10cSrcweir		my $currentdir = cwd();
120b274bc22SAndre Fischer		$installer::logger::Info->printf("... current dir: %s ...\n", $currentdir);
121cdf0e10cSrcweir		$infoline = "Current dir: $currentdir\n";
122b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
123cdf0e10cSrcweir
124cdf0e10cSrcweir		if ( ! -f $unopkgfile ) { installer::exiter::exit_program("ERROR: $unopkgfile not found!", "register_extensions"); }
125cdf0e10cSrcweir
126cdf0e10cSrcweir		my $systemcall = $unopkgfile . " sync --verbose" . " -env:UNO_JAVA_JFW_ENV_JREHOME=true 2\>\&1 |";
127cdf0e10cSrcweir
128b274bc22SAndre Fischer		$installer::logger::Info->printf("... %s ...\n", $systemcall);
129cdf0e10cSrcweir
130cdf0e10cSrcweir		$infoline = "Systemcall: $systemcall\n";
131b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
132cdf0e10cSrcweir
133cdf0e10cSrcweir		my @unopkgoutput = ();
134cdf0e10cSrcweir
135cdf0e10cSrcweir		open (UNOPKG, $systemcall);
136cdf0e10cSrcweir		while (<UNOPKG>)
137cdf0e10cSrcweir		{
138cdf0e10cSrcweir			my $lastline = $_;
139cdf0e10cSrcweir			push(@unopkgoutput, $lastline);
140cdf0e10cSrcweir		}
141cdf0e10cSrcweir		close (UNOPKG);
142cdf0e10cSrcweir
143cdf0e10cSrcweir		my $returnvalue = $?;	# $? contains the return value of the systemcall
144cdf0e10cSrcweir
145cdf0e10cSrcweir		if ($returnvalue)
146cdf0e10cSrcweir		{
147cdf0e10cSrcweir			# Writing content of @unopkgoutput only in the error case into the log file. Sometimes it
148cdf0e10cSrcweir			# contains strings like "Error" even in the case of success. This causes a packaging error
149cdf0e10cSrcweir			# when the log file is analyzed at the end, even if there is no real error.
150b274bc22SAndre Fischer			foreach my $line (@unopkgoutput)
151b274bc22SAndre Fischer            {
152b274bc22SAndre Fischer                $installer::logger::Lang->printf($line);
153b274bc22SAndre Fischer            }
154cdf0e10cSrcweir
155cdf0e10cSrcweir			$infoline = "ERROR: Could not execute \"$systemcall\"!\nExitcode: '$returnvalue'\n";
156b274bc22SAndre Fischer			$installer::logger::Lang->print($infoline);
157cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: $systemcall failed!", "register_extensions");
158cdf0e10cSrcweir		}
159cdf0e10cSrcweir		else
160cdf0e10cSrcweir		{
161cdf0e10cSrcweir			$infoline = "Success: Executed \"$systemcall\" successfully!\n";
162b274bc22SAndre Fischer			$installer::logger::Lang->print($infoline);
163cdf0e10cSrcweir		}
164cdf0e10cSrcweir	}
165cdf0e10cSrcweir
166cdf0e10cSrcweir	chdir($from);
167cdf0e10cSrcweir}
168cdf0e10cSrcweir
169cdf0e10cSrcweir########################################################################
170cdf0e10cSrcweir# Getting the translation file for the Mac Language Pack installer
171cdf0e10cSrcweir########################################################################
172cdf0e10cSrcweir
173cdf0e10cSrcweirsub get_mac_translation_file
174cdf0e10cSrcweir{
175cdf0e10cSrcweir	my $translationfilename = $installer::globals::maclangpackfilename;
176cdf0e10cSrcweir	if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_mac_translation_file"); }
177cdf0e10cSrcweir	my $translationfile = installer::files::read_file($translationfilename);
178cdf0e10cSrcweir
179cdf0e10cSrcweir	my $infoline = "Reading translation file: $translationfilename\n";
180b274bc22SAndre Fischer	$installer::logger::Lang->print($infoline);
181cdf0e10cSrcweir
182cdf0e10cSrcweir	return $translationfile;
183cdf0e10cSrcweir}
184cdf0e10cSrcweir
185cdf0e10cSrcweir##################################################################
186cdf0e10cSrcweir# Collecting all identifier from ulf file
187cdf0e10cSrcweir##################################################################
188cdf0e10cSrcweir
189cdf0e10cSrcweirsub get_identifier
190cdf0e10cSrcweir{
191cdf0e10cSrcweir	my ( $translationfile ) = @_;
192cdf0e10cSrcweir
193cdf0e10cSrcweir	my @identifier = ();
194cdf0e10cSrcweir
195cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$translationfile}; $i++ )
196cdf0e10cSrcweir	{
197cdf0e10cSrcweir		my $oneline = ${$translationfile}[$i];
198cdf0e10cSrcweir
199cdf0e10cSrcweir		if ( $oneline =~ /^\s*\[(.+)\]\s*$/ )
200cdf0e10cSrcweir		{
201cdf0e10cSrcweir			my $identifier = $1;
202cdf0e10cSrcweir			push(@identifier, $identifier);
203cdf0e10cSrcweir		}
204cdf0e10cSrcweir	}
205cdf0e10cSrcweir
206cdf0e10cSrcweir	return \@identifier;
207cdf0e10cSrcweir}
208cdf0e10cSrcweir
209cdf0e10cSrcweir##############################################################
210cdf0e10cSrcweir# Returning the complete block in all languages
211cdf0e10cSrcweir# for a specified string
212cdf0e10cSrcweir##############################################################
213cdf0e10cSrcweir
214cdf0e10cSrcweirsub get_language_block_from_language_file
215cdf0e10cSrcweir{
216cdf0e10cSrcweir	my ($searchstring, $languagefile) = @_;
217cdf0e10cSrcweir
218cdf0e10cSrcweir	my @language_block = ();
219cdf0e10cSrcweir
220cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
221cdf0e10cSrcweir	{
222cdf0e10cSrcweir		if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
223cdf0e10cSrcweir		{
224cdf0e10cSrcweir			my $counter = $i;
225cdf0e10cSrcweir
226cdf0e10cSrcweir			push(@language_block, ${$languagefile}[$counter]);
227cdf0e10cSrcweir			$counter++;
228cdf0e10cSrcweir
229cdf0e10cSrcweir			while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
230cdf0e10cSrcweir			{
231cdf0e10cSrcweir				push(@language_block, ${$languagefile}[$counter]);
232cdf0e10cSrcweir				$counter++;
233cdf0e10cSrcweir			}
234cdf0e10cSrcweir
235cdf0e10cSrcweir			last;
236cdf0e10cSrcweir		}
237cdf0e10cSrcweir	}
238cdf0e10cSrcweir
239cdf0e10cSrcweir	return \@language_block;
240cdf0e10cSrcweir}
241cdf0e10cSrcweir
242cdf0e10cSrcweir##############################################################
243cdf0e10cSrcweir# Returning a specific language string from the block
244cdf0e10cSrcweir# of all translations
245cdf0e10cSrcweir##############################################################
246cdf0e10cSrcweir
247cdf0e10cSrcweirsub get_language_string_from_language_block
248cdf0e10cSrcweir{
249cdf0e10cSrcweir	my ($language_block, $language) = @_;
250cdf0e10cSrcweir
251cdf0e10cSrcweir	my $newstring = "";
252cdf0e10cSrcweir
253cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$language_block}; $i++ )
254cdf0e10cSrcweir	{
255cdf0e10cSrcweir		if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
256cdf0e10cSrcweir		{
257cdf0e10cSrcweir			$newstring = $1;
258cdf0e10cSrcweir			last;
259cdf0e10cSrcweir		}
260cdf0e10cSrcweir	}
261cdf0e10cSrcweir
262cdf0e10cSrcweir	if ( $newstring eq "" )
263cdf0e10cSrcweir	{
264cdf0e10cSrcweir		$language = "en-US"; 	# defaulting to english
265cdf0e10cSrcweir
266cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$language_block}; $i++ )
267cdf0e10cSrcweir		{
268cdf0e10cSrcweir			if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
269cdf0e10cSrcweir			{
270cdf0e10cSrcweir				$newstring = $1;
271cdf0e10cSrcweir				last;
272cdf0e10cSrcweir			}
273cdf0e10cSrcweir		}
274cdf0e10cSrcweir	}
275cdf0e10cSrcweir
276cdf0e10cSrcweir	return $newstring;
277cdf0e10cSrcweir}
278cdf0e10cSrcweir
279cdf0e10cSrcweir########################################################################
280cdf0e10cSrcweir# Localizing the script for the Mac Language Pack installer
281cdf0e10cSrcweir########################################################################
282cdf0e10cSrcweir
283cdf0e10cSrcweirsub localize_scriptfile
284cdf0e10cSrcweir{
285cdf0e10cSrcweir	my ($scriptfile, $translationfile, $languagestringref) = @_;
286cdf0e10cSrcweir
287cdf0e10cSrcweir	# my $translationfile = get_mac_translation_file();
288cdf0e10cSrcweir
289cdf0e10cSrcweir	my $onelanguage = $$languagestringref;
290cdf0e10cSrcweir	if ( $onelanguage =~ /^\s*(.*?)_/ ) { $onelanguage = $1; }
291cdf0e10cSrcweir
292cdf0e10cSrcweir	# Analyzing the ulf file, collecting all Identifier
293cdf0e10cSrcweir	my $allidentifier = get_identifier($translationfile);
294cdf0e10cSrcweir
295cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allidentifier}; $i++ )
296cdf0e10cSrcweir	{
297cdf0e10cSrcweir		my $identifier = ${$allidentifier}[$i];
298cdf0e10cSrcweir		my $language_block = get_language_block_from_language_file($identifier, $translationfile);
299cdf0e10cSrcweir		my $newstring = get_language_string_from_language_block($language_block, $onelanguage);
300cdf0e10cSrcweir
301cdf0e10cSrcweir		# removing mask
302cdf0e10cSrcweir		$newstring =~ s/\\\'/\'/g;
303cdf0e10cSrcweir
304cdf0e10cSrcweir		replace_one_variable_in_shellscript($scriptfile, $newstring, $identifier);
305cdf0e10cSrcweir	}
306cdf0e10cSrcweir}
307cdf0e10cSrcweir
308cdf0e10cSrcweir#################################################################################
309cdf0e10cSrcweir# Replacing one variable in Mac shell script
310cdf0e10cSrcweir#################################################################################
311cdf0e10cSrcweir
312cdf0e10cSrcweirsub replace_one_variable_in_shellscript
313cdf0e10cSrcweir{
314cdf0e10cSrcweir	my ($scriptfile, $variable, $searchstring) = @_;
315cdf0e10cSrcweir
316cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
317cdf0e10cSrcweir	{
318cdf0e10cSrcweir		${$scriptfile}[$i] =~ s/\[$searchstring\]/$variable/g;
319cdf0e10cSrcweir	}
320cdf0e10cSrcweir}
321cdf0e10cSrcweir
322cdf0e10cSrcweir#############################################
323cdf0e10cSrcweir# Replacing variables in Mac shell script
324cdf0e10cSrcweir#############################################
325cdf0e10cSrcweir
326cdf0e10cSrcweirsub replace_variables_in_scriptfile
327cdf0e10cSrcweir{
328cdf0e10cSrcweir	my ($scriptfile, $volume_name, $volume_name_app, $allvariables) = @_;
329cdf0e10cSrcweir
330cdf0e10cSrcweir	replace_one_variable_in_shellscript($scriptfile, $volume_name, "FULLPRODUCTNAME" );
331cdf0e10cSrcweir	replace_one_variable_in_shellscript($scriptfile, $volume_name_app, "FULLAPPPRODUCTNAME" );
332cdf0e10cSrcweir	replace_one_variable_in_shellscript($scriptfile, $allvariables->{'PRODUCTNAME'}, "PRODUCTNAME" );
333cdf0e10cSrcweir	replace_one_variable_in_shellscript($scriptfile, $allvariables->{'PRODUCTVERSION'}, "PRODUCTVERSION" );
334cdf0e10cSrcweir
335cdf0e10cSrcweir	my $scriptname = lc($allvariables->{'PRODUCTNAME'}) . "\.script";
336599cc5b4SOliver-Rainer Wittmann	if ( $allvariables->{'PRODUCTNAME'} eq "OpenOffice" )
337ff3f4ebcSOliver-Rainer Wittmann    {
338ff3f4ebcSOliver-Rainer Wittmann        $scriptname = "org.openoffice.script";
339ff3f4ebcSOliver-Rainer Wittmann    }
340cdf0e10cSrcweir
341cdf0e10cSrcweir	replace_one_variable_in_shellscript($scriptfile, $scriptname, "SEARCHSCRIPTNAME" );
342cdf0e10cSrcweir}
343cdf0e10cSrcweir
344cdf0e10cSrcweir#############################################
345cdf0e10cSrcweir# Creating the "simple" package.
346cdf0e10cSrcweir# "zip" for Windows
347cdf0e10cSrcweir# "tar.gz" for all other platforms
348cdf0e10cSrcweir# additionally "dmg" on Mac OS X
349cdf0e10cSrcweir#############################################
350cdf0e10cSrcweir
351cdf0e10cSrcweirsub create_package
352cdf0e10cSrcweir{
353cdf0e10cSrcweir	my ( $installdir, $archivedir, $packagename, $allvariables, $includepatharrayref, $languagestringref, $format ) = @_;
354cdf0e10cSrcweir
355b274bc22SAndre Fischer    $installer::logger::Info->printf("... creating %s file ...\n", $installer::globals::packageformat);
356cdf0e10cSrcweir    installer::logger::include_header_into_logfile("Creating $installer::globals::packageformat file:");
357cdf0e10cSrcweir
358cdf0e10cSrcweir	# moving dir into temporary directory
359cdf0e10cSrcweir	my $pid = $$; # process id
360cdf0e10cSrcweir	my $tempdir = $installdir . "_temp" . "." . $pid;
361cdf0e10cSrcweir	my $systemcall = "";
362cdf0e10cSrcweir	my $from = "";
363cdf0e10cSrcweir	my $makesystemcall = 1;
364cdf0e10cSrcweir	my $return_to_start = 0;
365cdf0e10cSrcweir	installer::systemactions::rename_directory($installdir, $tempdir);
366cdf0e10cSrcweir
367cdf0e10cSrcweir	# creating new directory with original name
368cdf0e10cSrcweir	installer::systemactions::create_directory($archivedir);
369cdf0e10cSrcweir
370cdf0e10cSrcweir	my $archive = $archivedir . $installer::globals::separator . $packagename . $format;
371cdf0e10cSrcweir
372cdf0e10cSrcweir	if ( $archive =~ /zip$/ )
373cdf0e10cSrcweir	{
374cdf0e10cSrcweir		$from = cwd();
375cdf0e10cSrcweir		$return_to_start = 1;
376cdf0e10cSrcweir		chdir($tempdir);
377dfa12748SYuri Dario		if ( $^O =~ /os2/i )
378dfa12748SYuri Dario		{
379dfa12748SYuri Dario			my $zip = Cwd::realpath($archive);
380dfa12748SYuri Dario			$systemcall = "$installer::globals::zippath -qr $zip .";
381dfa12748SYuri Dario		}
382dfa12748SYuri Dario	 	else
383dfa12748SYuri Dario		{
384cdf0e10cSrcweir			$systemcall = "$installer::globals::zippath -qr $archive .";
385dfa12748SYuri Dario		}
386cdf0e10cSrcweir
387cdf0e10cSrcweir		# Using Archive::Zip fails because of very long path names below "share/uno_packages/cache"
388cdf0e10cSrcweir		# my $packzip = Archive::Zip->new();
389cdf0e10cSrcweir		# $packzip->addTree(".");	# after changing into $tempdir
390cdf0e10cSrcweir		# $packzip->writeToFileNamed($archive);
391cdf0e10cSrcweir		# $makesystemcall = 0;
392cdf0e10cSrcweir	}
393cdf0e10cSrcweir 	elsif ( $archive =~ /dmg$/ )
394cdf0e10cSrcweir	{
395cdf0e10cSrcweir		my $folder = (( -l "$tempdir/$packagename/Applications" ) or ( -l "$tempdir/$packagename/opt" )) ? $packagename : "\.";
396cdf0e10cSrcweir
397cdf0e10cSrcweir		if ( $allvariables->{'PACK_INSTALLED'} ) {
398cdf0e10cSrcweir		    $folder = $packagename;
399cdf0e10cSrcweir		}
400cdf0e10cSrcweir
401cdf0e10cSrcweir		# my $volume_name = $allvariables->{'PRODUCTNAME'} . ' ' . $allvariables->{'PRODUCTVERSION'}; # Adding PRODUCTVERSION makes this difficult to maintain!
402cdf0e10cSrcweir		my $volume_name = $allvariables->{'PRODUCTNAME'};
403cdf0e10cSrcweir		my $volume_name_classic = $allvariables->{'PRODUCTNAME'} . ' ' . $allvariables->{'PRODUCTVERSION'};
404cdf0e10cSrcweir		my $volume_name_classic_app = $volume_name;  # "app" should not contain version number
405cdf0e10cSrcweir		# $volume_name = $volume_name . ' ' . $allvariables->{'PRODUCTEXTENSION'} if $allvariables->{'PRODUCTEXTENSION'}; # Adding PRODUCTEXTENSION makes this difficult to maintain!
406cdf0e10cSrcweir		$volume_name_classic = $volume_name_classic . ' ' . $allvariables->{'PRODUCTEXTENSION'} if $allvariables->{'PRODUCTEXTENSION'};
407cdf0e10cSrcweir		$volume_name_classic_app = $volume_name_classic_app . ' ' . $allvariables->{'PRODUCTEXTENSION'} if $allvariables->{'PRODUCTEXTENSION'};
408cdf0e10cSrcweir		if ( $allvariables->{'DMG_VOLUMEEXTENSION'} ) {
409cdf0e10cSrcweir		    $volume_name = $volume_name . ' ' . $allvariables->{'DMG_VOLUMEEXTENSION'};
410cdf0e10cSrcweir		    $volume_name_classic = $volume_name_classic . ' ' . $allvariables->{'DMG_VOLUMEEXTENSION'};
411cdf0e10cSrcweir		    $volume_name_classic_app = $volume_name_classic_app . ' ' . $allvariables->{'DMG_VOLUMEEXTENSION'};
412cdf0e10cSrcweir		}
413cdf0e10cSrcweir
414cdf0e10cSrcweir		my $sla = 'sla.r';
415cdf0e10cSrcweir		my $ref = "";
416cdf0e10cSrcweir
417cdf0e10cSrcweir		if ( ! $allvariables->{'HIDELICENSEDIALOG'} )
418cdf0e10cSrcweir		{
419cdf0e10cSrcweir			installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$sla, $includepatharrayref, 0);
420cdf0e10cSrcweir		}
421cdf0e10cSrcweir
422cdf0e10cSrcweir		my $localtempdir = $tempdir;
423cdf0e10cSrcweir
424cdf0e10cSrcweir		if (( $installer::globals::languagepack ) || ( $installer::globals::patch ))
425cdf0e10cSrcweir		{
426cdf0e10cSrcweir			$localtempdir = "$tempdir/$packagename";
427cdf0e10cSrcweir			if ( $installer::globals::languagepack )
428cdf0e10cSrcweir			{
429cdf0e10cSrcweir				$volume_name = "$volume_name Language Pack";
430cdf0e10cSrcweir				$volume_name_classic = "$volume_name_classic Language Pack";
431cdf0e10cSrcweir				$volume_name_classic_app = "$volume_name_classic_app Language Pack";
432cdf0e10cSrcweir			}
433cdf0e10cSrcweir			if ( $installer::globals::patch )
434cdf0e10cSrcweir			{
435cdf0e10cSrcweir				$volume_name = "$volume_name Patch";
436cdf0e10cSrcweir				$volume_name_classic = "$volume_name_classic Patch";
437cdf0e10cSrcweir				$volume_name_classic_app = "$volume_name_classic_app Patch";
438cdf0e10cSrcweir			}
439cdf0e10cSrcweir
440cdf0e10cSrcweir			# Create tar ball named tarball.tar.bz2
441cdf0e10cSrcweir			# my $appfolder = $localtempdir . "/" . $volume_name . "\.app";
442cdf0e10cSrcweir			my $appfolder = $localtempdir . "/" . $volume_name_classic_app . "\.app";
443cdf0e10cSrcweir			my $contentsfolder = $appfolder . "/Contents";
444cdf0e10cSrcweir			my $tarballname = "tarball.tar.bz2";
445cdf0e10cSrcweir
446cdf0e10cSrcweir			my $localfrom = cwd();
447cdf0e10cSrcweir			chdir $appfolder;
448cdf0e10cSrcweir
449cdf0e10cSrcweir			$systemcall = "tar -cjf $tarballname Contents/";
450cdf0e10cSrcweir
451b274bc22SAndre Fischer			$installer::logger::Info->printf("... %s ...\n", $systemcall);
452cdf0e10cSrcweir			my $localreturnvalue = system($systemcall);
453cdf0e10cSrcweir			$infoline = "Systemcall: $systemcall\n";
454b274bc22SAndre Fischer			$installer::logger::Lang->print($infoline);
455cdf0e10cSrcweir
456cdf0e10cSrcweir			if ($localreturnvalue)
457cdf0e10cSrcweir			{
458cdf0e10cSrcweir				$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
459b274bc22SAndre Fischer				$installer::logger::Lang->print($infoline);
460cdf0e10cSrcweir			}
461cdf0e10cSrcweir			else
462cdf0e10cSrcweir			{
463cdf0e10cSrcweir				$infoline = "Success: Executed \"$systemcall\" successfully!\n";
464b274bc22SAndre Fischer				$installer::logger::Lang->print($infoline);
465cdf0e10cSrcweir			}
466cdf0e10cSrcweir
467cdf0e10cSrcweir			my $sourcefile = $appfolder . "/" . $tarballname;
468cdf0e10cSrcweir			my $destfile = $contentsfolder . "/" . $tarballname;
469cdf0e10cSrcweir
470cdf0e10cSrcweir			installer::systemactions::remove_complete_directory($contentsfolder);
471cdf0e10cSrcweir			installer::systemactions::create_directory($contentsfolder);
472cdf0e10cSrcweir
473cdf0e10cSrcweir			installer::systemactions::copy_one_file($sourcefile, $destfile);
474cdf0e10cSrcweir			unlink($sourcefile);
475cdf0e10cSrcweir
476cdf0e10cSrcweir			# Copy two files into installation set next to the tar ball
477cdf0e10cSrcweir			# 1. "osx_install.applescript"
478cdf0e10cSrcweir			# 2 "OpenOffice.org Languagepack"
479cdf0e10cSrcweir
480cdf0e10cSrcweir			my $scriptrealfilename = "osx_install.applescript";
481cdf0e10cSrcweir			my $scriptfilename = "";
482cdf0e10cSrcweir			if ( $installer::globals::languagepack ) { $scriptfilename = "osx_install_languagepack.applescript"; }
483cdf0e10cSrcweir			if ( $installer::globals::patch ) { $scriptfilename = "osx_install_patch.applescript"; }
484cdf0e10cSrcweir			my $scripthelpersolverfilename = "mac_install.script";
485cdf0e10cSrcweir			# my $scripthelperrealfilename = $volume_name;
486cdf0e10cSrcweir			my $scripthelperrealfilename = $volume_name_classic_app;
487cdf0e10cSrcweir			my $translationfilename = $installer::globals::macinstallfilename;
488cdf0e10cSrcweir
489cdf0e10cSrcweir			# Finding both files in solver
490cdf0e10cSrcweir
491cdf0e10cSrcweir			my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$scriptfilename, $includepatharrayref, 0);
492cdf0e10cSrcweir			if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script $scriptfilename!", "create_package"); }
493cdf0e10cSrcweir			my $scripthelperref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$scripthelpersolverfilename, $includepatharrayref, 0);
494cdf0e10cSrcweir			if ($$scripthelperref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script $scripthelpersolverfilename!", "create_package"); }
495cdf0e10cSrcweir			my $translationfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$translationfilename, $includepatharrayref, 0);
496cdf0e10cSrcweir			if ($$translationfileref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script translation file $translationfilename!", "create_package"); }
497cdf0e10cSrcweir
498cdf0e10cSrcweir			$scriptfilename = $contentsfolder . "/" . $scriptrealfilename;
499cdf0e10cSrcweir			$scripthelperrealfilename = $contentsfolder . "/" . $scripthelperrealfilename;
500cdf0e10cSrcweir
501cdf0e10cSrcweir			installer::systemactions::copy_one_file($$scriptref, $scriptfilename);
502cdf0e10cSrcweir			installer::systemactions::copy_one_file($$scripthelperref, $scripthelperrealfilename);
503cdf0e10cSrcweir
504cdf0e10cSrcweir			# Replacing variables in script $scriptfilename
505cdf0e10cSrcweir			# Localizing script $scriptfilename
506cdf0e10cSrcweir			my $scriptfilecontent = installer::files::read_file($scriptfilename);
507cdf0e10cSrcweir			my $translationfilecontent = installer::files::read_file($$translationfileref);
508cdf0e10cSrcweir			localize_scriptfile($scriptfilecontent, $translationfilecontent, $languagestringref);
509cdf0e10cSrcweir			# replace_variables_in_scriptfile($scriptfilecontent, $volume_name, $allvariables);
510cdf0e10cSrcweir			replace_variables_in_scriptfile($scriptfilecontent, $volume_name_classic, $volume_name_classic_app, $allvariables);
511cdf0e10cSrcweir			installer::files::save_file($scriptfilename, $scriptfilecontent);
512cdf0e10cSrcweir
513cdf0e10cSrcweir			$systemcall = "chmod 775 " . "\"" . $scriptfilename . "\"";
514cdf0e10cSrcweir			system($systemcall);
515cdf0e10cSrcweir			$systemcall = "chmod 775 " . "\"" . $scripthelperrealfilename . "\"";
516cdf0e10cSrcweir			system($systemcall);
517cdf0e10cSrcweir
518cdf0e10cSrcweir			# Copy also Info.plist and icon file
519cdf0e10cSrcweir			# Finding both files in solver
520cdf0e10cSrcweir			my $iconfile = "ooo3_installer.icns";
521cdf0e10cSrcweir			my $iconfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$iconfile, $includepatharrayref, 0);
522cdf0e10cSrcweir			if ($$iconfileref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script icon file $iconfile!", "create_package"); }
523cdf0e10cSrcweir			my $subdir = $contentsfolder . "/" . "Resources";
524cdf0e10cSrcweir			if ( ! -d $subdir ) { installer::systemactions::create_directory($subdir); }
525cdf0e10cSrcweir			$destfile = $subdir . "/" . $iconfile;
526cdf0e10cSrcweir			installer::systemactions::copy_one_file($$iconfileref, $destfile);
527cdf0e10cSrcweir
528cdf0e10cSrcweir			my $infoplistfile = "Info.plist.langpack";
529cdf0e10cSrcweir			my $installname = "Info.plist";
530cdf0e10cSrcweir			my $infoplistfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$infoplistfile, $includepatharrayref, 0);
531cdf0e10cSrcweir			if ($$infoplistfileref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script Info.plist: $infoplistfile!", "create_package"); }
532cdf0e10cSrcweir			$destfile = $contentsfolder . "/" . $installname;
533cdf0e10cSrcweir			installer::systemactions::copy_one_file($$infoplistfileref, $destfile);
534cdf0e10cSrcweir
535cdf0e10cSrcweir			# Replacing variables in Info.plist
536cdf0e10cSrcweir			$scriptfilecontent = installer::files::read_file($destfile);
537cdf0e10cSrcweir			# replace_one_variable_in_shellscript($scriptfilecontent, $volume_name, "FULLPRODUCTNAME" );
538cdf0e10cSrcweir			replace_one_variable_in_shellscript($scriptfilecontent, $volume_name_classic_app, "FULLAPPPRODUCTNAME" ); # OpenOffice.org Language Pack
539cdf0e10cSrcweir			installer::files::save_file($destfile, $scriptfilecontent);
540cdf0e10cSrcweir
541cdf0e10cSrcweir			chdir $localfrom;
542cdf0e10cSrcweir		}
543cdf0e10cSrcweir
544cdf0e10cSrcweir		$systemcall = "cd $localtempdir && hdiutil makehybrid -hfs -hfs-openfolder $folder $folder -hfs-volume-name \"$volume_name\" -ov -o $installdir/tmp && hdiutil convert -ov -format UDZO $installdir/tmp.dmg -o $archive && ";
545cdf0e10cSrcweir        if (( $ref ne "" ) && ( $$ref ne "" )) {
546cdf0e10cSrcweir			$systemcall .= "hdiutil unflatten $archive && Rez -a $$ref -o $archive && hdiutil flatten $archive &&";
547cdf0e10cSrcweir		}
548cdf0e10cSrcweir		$systemcall .= "rm -f $installdir/tmp.dmg";
549cdf0e10cSrcweir	}
550cdf0e10cSrcweir	else
551cdf0e10cSrcweir	{
552cdf0e10cSrcweir		# getting the path of the getuid.so (only required for Solaris and Linux)
553cdf0e10cSrcweir		my $getuidlibrary = "";
554cdf0e10cSrcweir		my $ldpreloadstring = "";
555cdf0e10cSrcweir		if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild ))
556cdf0e10cSrcweir		{
557cdf0e10cSrcweir			$getuidlibrary = installer::download::get_path_for_library($includepatharrayref);
558cdf0e10cSrcweir			if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; }
559cdf0e10cSrcweir		}
560cdf0e10cSrcweir
561cdf0e10cSrcweir		$systemcall = "cd $tempdir; $ldpreloadstring tar -cf - . | gzip > $archive";
562cdf0e10cSrcweir	}
563cdf0e10cSrcweir
564cdf0e10cSrcweir	if ( $makesystemcall )
565cdf0e10cSrcweir	{
566b274bc22SAndre Fischer		$installer::logger::Info->printf("... %s ...\n", $systemcall);
567cdf0e10cSrcweir		my $returnvalue = system($systemcall);
568cdf0e10cSrcweir		my $infoline = "Systemcall: $systemcall\n";
569b274bc22SAndre Fischer		$installer::logger::Lang->print($infoline);
570cdf0e10cSrcweir
571cdf0e10cSrcweir		if ($returnvalue)
572cdf0e10cSrcweir		{
573cdf0e10cSrcweir			$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
574b274bc22SAndre Fischer			$installer::logger::Lang->print($infoline);
575cdf0e10cSrcweir		}
576cdf0e10cSrcweir		else
577cdf0e10cSrcweir		{
578cdf0e10cSrcweir			$infoline = "Success: Executed \"$systemcall\" successfully!\n";
579b274bc22SAndre Fischer			$installer::logger::Lang->print($infoline);
580cdf0e10cSrcweir		}
581cdf0e10cSrcweir	}
582cdf0e10cSrcweir
583cdf0e10cSrcweir	if ( $return_to_start ) { chdir($from); }
584cdf0e10cSrcweir
585b274bc22SAndre Fischer	$installer::logger::Info->printf("... removing %s ...\n", $tempdir);
586cdf0e10cSrcweir	installer::systemactions::remove_complete_directory($tempdir);
587cdf0e10cSrcweir}
588cdf0e10cSrcweir
589cdf0e10cSrcweir####################################################
590cdf0e10cSrcweir# Main method for creating the simple package
591cdf0e10cSrcweir# installation sets
592cdf0e10cSrcweir####################################################
593cdf0e10cSrcweir
594cdf0e10cSrcweirsub create_simple_package
595cdf0e10cSrcweir{
596cdf0e10cSrcweir	my ( $filesref, $dirsref, $scpactionsref, $linksref, $unixlinksref, $loggingdir, $languagestringref, $shipinstalldir, $allsettingsarrayref, $allvariables, $includepatharrayref ) = @_;
597cdf0e10cSrcweir
598cdf0e10cSrcweir	# Creating directories
599cdf0e10cSrcweir
600cdf0e10cSrcweir	my $current_install_number = "";
601cdf0e10cSrcweir	my $infoline = "";
602cdf0e10cSrcweir
603b274bc22SAndre Fischer	$installer::logger::Info->print( "... creating installation directory ...\n" );
604cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Creating installation directory");
605cdf0e10cSrcweir
606cdf0e10cSrcweir	$installer::globals::csp_installdir = installer::worker::create_installation_directory($shipinstalldir, $languagestringref, \$current_install_number);
607cdf0e10cSrcweir	$installer::globals::csp_installlogdir = installer::systemactions::create_directory_next_to_directory($installer::globals::csp_installdir, "log");
608cdf0e10cSrcweir
609cdf0e10cSrcweir	my $installdir = $installer::globals::csp_installdir;
610cdf0e10cSrcweir	my $installlogdir = $installer::globals::csp_installlogdir;
611cdf0e10cSrcweir
612cdf0e10cSrcweir	# Setting package name (similar to the download name)
613cdf0e10cSrcweir	my $packagename = "";
614cdf0e10cSrcweir
615cdf0e10cSrcweir	if ( $installer::globals::packageformat eq "archive"  ||
616cdf0e10cSrcweir		$installer::globals::packageformat eq "dmg" )
617cdf0e10cSrcweir	{
618cdf0e10cSrcweir		$installer::globals::csp_languagestring = $$languagestringref;
619cdf0e10cSrcweir
620cdf0e10cSrcweir		my $locallanguage = $installer::globals::csp_languagestring;
621cdf0e10cSrcweir
622ff3f4ebcSOliver-Rainer Wittmann		if ( $allvariables->{'AOODOWNLOADNAME'} )
623cdf0e10cSrcweir		{
624cdf0e10cSrcweir			$packagename = installer::download::set_download_filename(\$locallanguage, $allvariables);
625cdf0e10cSrcweir		}
626cdf0e10cSrcweir		else
627cdf0e10cSrcweir		{
628cdf0e10cSrcweir			$downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "downloadname");
629cdf0e10cSrcweir			if ( $installer::globals::languagepack ) { $downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "langpackdownloadname"); }
630cdf0e10cSrcweir			if ( $installer::globals::patch ) { $downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "patchdownloadname"); }
631cdf0e10cSrcweir			$packagename = installer::download::resolve_variables_in_downloadname($allvariables, $$downloadname, \$locallanguage);
632cdf0e10cSrcweir		}
633cdf0e10cSrcweir	}
634cdf0e10cSrcweir
635cdf0e10cSrcweir    # Work around Windows problems with long pathnames (see issue 50885) by
636cdf0e10cSrcweir    # putting the to-be-archived installation tree into the temp directory
637cdf0e10cSrcweir    # instead of the module output tree (unless LOCALINSTALLDIR dictates
638cdf0e10cSrcweir    # otherwise, anyway); can be removed once issue 50885 is fixed:
639cdf0e10cSrcweir    my $tempinstalldir = $installdir;
640cdf0e10cSrcweir    if ( $installer::globals::iswindowsbuild &&
641cdf0e10cSrcweir         $installer::globals::packageformat eq "archive" &&
642cdf0e10cSrcweir         !$installer::globals::localinstalldirset )
643cdf0e10cSrcweir    {
644cdf0e10cSrcweir        $tempinstalldir = File::Temp::tempdir;
645cdf0e10cSrcweir    }
646cdf0e10cSrcweir
647cdf0e10cSrcweir	# Creating subfolder in installdir, which shall become the root of package or zip file
648cdf0e10cSrcweir	my $subfolderdir = "";
649cdf0e10cSrcweir	if ( $packagename ne "" ) { $subfolderdir = $tempinstalldir . $installer::globals::separator . $packagename; }
650cdf0e10cSrcweir	else { $subfolderdir = $tempinstalldir; }
651cdf0e10cSrcweir
652cdf0e10cSrcweir	if ( ! -d $subfolderdir ) { installer::systemactions::create_directory($subfolderdir); }
653cdf0e10cSrcweir
654cdf0e10cSrcweir	# Create directories, copy files and ScpActions
655cdf0e10cSrcweir
656b274bc22SAndre Fischer	$installer::logger::Info->print("... creating directories ...\n");
657cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Creating directories:");
658cdf0e10cSrcweir
659cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
660cdf0e10cSrcweir	{
661cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
662cdf0e10cSrcweir
663cdf0e10cSrcweir		if ( $onedir->{'HostName'} )
664cdf0e10cSrcweir		{
665cdf0e10cSrcweir			my $destdir = $subfolderdir . $installer::globals::separator . $onedir->{'HostName'};
666cdf0e10cSrcweir
667cdf0e10cSrcweir			if ( ! -d $destdir )
668cdf0e10cSrcweir			{
669dfa12748SYuri Dario				if ( $^O =~ /cygwin/i || $^O =~ /os2/i ) # Cygwin performance check
670cdf0e10cSrcweir				{
671b274bc22SAndre Fischer                    $installer::logger::Lang->printf("Try to create directory %s\n", $destdir);
672cdf0e10cSrcweir					# Directories in $dirsref are sorted and all parents were added -> "mkdir" works without parent creation!
673cdf0e10cSrcweir					if ( ! ( -d $destdir )) { mkdir($destdir, 0775); }
674cdf0e10cSrcweir				}
675cdf0e10cSrcweir				else
676cdf0e10cSrcweir				{
677cdf0e10cSrcweir					installer::systemactions::create_directory_structure($destdir);
678cdf0e10cSrcweir				}
679cdf0e10cSrcweir			}
680cdf0e10cSrcweir		}
681cdf0e10cSrcweir	}
682cdf0e10cSrcweir
683cdf0e10cSrcweir	# stripping files ?!
684dfa12748SYuri Dario	if (( $installer::globals::strip ) && ( ! $installer::globals::iswindowsbuild ) && ( ! $installer::globals::isos2 )) { installer::strip::strip_libraries($filesref, $languagestringref); }
685cdf0e10cSrcweir
686cdf0e10cSrcweir	# copy Files
687b274bc22SAndre Fischer	$installer::logger::Info->print("... copying files ...\n");
688cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Copying files:");
689cdf0e10cSrcweir
690cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
691cdf0e10cSrcweir	{
692cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
693cdf0e10cSrcweir
694cdf0e10cSrcweir		if (( $onefile->{'Styles'} ) && ( $onefile->{'Styles'} =~ /\bBINARYTABLE_ONLY\b/ )) { next; }
695cdf0e10cSrcweir		if (( $installer::globals::patch ) && ( $onefile->{'Styles'} ) && ( ! ( $onefile->{'Styles'} =~ /\bPATCH\b/ ))) { next; }
696cdf0e10cSrcweir		if (( $installer::globals::patch ) && ( $installer::globals::packageformat eq "dmg" )) { push(@installer::globals::patchfilecollector, "$onefile->{'destination'}\n"); }
697cdf0e10cSrcweir
698cdf0e10cSrcweir		my $source = $onefile->{'sourcepath'};
699cdf0e10cSrcweir		my $destination = $onefile->{'destination'};
700cdf0e10cSrcweir		$destination = $subfolderdir . $installer::globals::separator . $destination;
701cdf0e10cSrcweir
702cdf0e10cSrcweir		# Replacing $$ by $ is necessary to install files with $ in its name (back-masquerading)
703cdf0e10cSrcweir		# Otherwise, the following shell command does not work and the file list is not correct
704cdf0e10cSrcweir		$source =~ s/\$\$/\$/;
705cdf0e10cSrcweir		$destination =~ s/\$\$/\$/;
706cdf0e10cSrcweir
707dfa12748SYuri Dario		if ( $^O =~ /cygwin/i || $^O =~ /os2/i )	# Cygwin performance, do not use copy_one_file. "chmod -R" at the end
708cdf0e10cSrcweir		{
709cdf0e10cSrcweir			my $copyreturn = copy($source, $destination);
710cdf0e10cSrcweir
711cdf0e10cSrcweir			if ($copyreturn)
712cdf0e10cSrcweir			{
713b274bc22SAndre Fischer                $installer::logger::Lang->printf("Copy: $source to %s\n", $destination);
714cdf0e10cSrcweir				$returnvalue = 1;
715cdf0e10cSrcweir			}
716cdf0e10cSrcweir			else
717cdf0e10cSrcweir			{
718b274bc22SAndre Fischer                $installer::logger::Lang->printf("ERROR: Could not copy %s to %s\n", $source, $destination);
719cdf0e10cSrcweir				$returnvalue = 0;
720cdf0e10cSrcweir			}
721cdf0e10cSrcweir		}
722cdf0e10cSrcweir		else
723cdf0e10cSrcweir		{
724cdf0e10cSrcweir			installer::systemactions::copy_one_file($source, $destination);
725cdf0e10cSrcweir
726cdf0e10cSrcweir			if ( ! $installer::globals::iswindowsbuild )
727cdf0e10cSrcweir			{
728cdf0e10cSrcweir				# see issue 102274
729cdf0e10cSrcweir				my $unixrights = "";
730cdf0e10cSrcweir				if ( $onefile->{'UnixRights'} )
731cdf0e10cSrcweir				{
732cdf0e10cSrcweir					$unixrights = $onefile->{'UnixRights'};
733cdf0e10cSrcweir
734cdf0e10cSrcweir					my $localcall = "$installer::globals::wrapcmd chmod $unixrights \'$destination\' \>\/dev\/null 2\>\&1";
735cdf0e10cSrcweir					system($localcall);
736cdf0e10cSrcweir				}
737cdf0e10cSrcweir			}
738cdf0e10cSrcweir		}
739cdf0e10cSrcweir	}
740cdf0e10cSrcweir
741cdf0e10cSrcweir	# creating Links
742cdf0e10cSrcweir
743b274bc22SAndre Fischer	$installer::logger::Info->print("... creating links ...\n");
744cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Creating links:");
745cdf0e10cSrcweir
746cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linksref}; $i++ )
747cdf0e10cSrcweir	{
748cdf0e10cSrcweir		my $onelink = ${$linksref}[$i];
749cdf0e10cSrcweir
750cdf0e10cSrcweir		if (( $installer::globals::patch ) && ( $onelink->{'Styles'} ) && ( ! ( $onelink->{'Styles'} =~ /\bPATCH\b/ ))) { next; }
751cdf0e10cSrcweir
752cdf0e10cSrcweir		my $destination = $onelink->{'destination'};
753cdf0e10cSrcweir		$destination = $subfolderdir . $installer::globals::separator . $destination;
754cdf0e10cSrcweir		my $destinationfile = $onelink->{'destinationfile'};
755cdf0e10cSrcweir
756cdf0e10cSrcweir		my $localcall = "ln -sf \'$destinationfile\' \'$destination\' \>\/dev\/null 2\>\&1";
757cdf0e10cSrcweir		system($localcall);
758cdf0e10cSrcweir
759b274bc22SAndre Fischer        $installer::logger::Lang->printf("Creating link: \"ln -sf %s %s\"\n",
760b274bc22SAndre Fischer            $destinationfile,
761b274bc22SAndre Fischer            $destination);
762cdf0e10cSrcweir	}
763cdf0e10cSrcweir
764cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$unixlinksref}; $i++ )
765cdf0e10cSrcweir	{
766cdf0e10cSrcweir		my $onelink = ${$unixlinksref}[$i];
767cdf0e10cSrcweir
768cdf0e10cSrcweir		if (( $installer::globals::patch ) && ( $onelink->{'Styles'} ) && ( ! ( $onelink->{'Styles'} =~ /\bPATCH\b/ ))) { next; }
769cdf0e10cSrcweir
770cdf0e10cSrcweir		my $target = $onelink->{'Target'};
771cdf0e10cSrcweir		my $destination = $subfolderdir . $installer::globals::separator . $onelink->{'destination'};
772cdf0e10cSrcweir
773cdf0e10cSrcweir		my $localcall = "ln -sf \'$target\' \'$destination\' \>\/dev\/null 2\>\&1";
774cdf0e10cSrcweir		system($localcall);
775cdf0e10cSrcweir
776b274bc22SAndre Fischer        $installer::logger::Lang->printf("Creating Unix link: \"ln -sf %s %s\"\n",
777b274bc22SAndre Fischer            $target,
778b274bc22SAndre Fischer            $destination);
779cdf0e10cSrcweir	}
780cdf0e10cSrcweir
781cdf0e10cSrcweir	# Setting privileges for cygwin globally
782cdf0e10cSrcweir
783cdf0e10cSrcweir	if ( $^O =~ /cygwin/i )
784cdf0e10cSrcweir	{
785b274bc22SAndre Fischer		$installer::logger::Lang->print( "... changing privileges in $subfolderdir ...\n" );
786cdf0e10cSrcweir		installer::logger::include_header_into_logfile("Changing privileges in $subfolderdir:");
787cdf0e10cSrcweir
788cdf0e10cSrcweir		my $localcall = "chmod -R 755 " . "\"" . $subfolderdir . "\"";
789cdf0e10cSrcweir		system($localcall);
790cdf0e10cSrcweir	}
791cdf0e10cSrcweir
792b274bc22SAndre Fischer	$installer::logger::Lang->print( "... removing superfluous directories ...\n" );
793cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Removing superfluous directories:");
794cdf0e10cSrcweir
795cdf0e10cSrcweir	my ( $extensionfolder, $preregdir ) = get_extensions_dir($subfolderdir);
796cdf0e10cSrcweir	installer::systemactions::remove_empty_dirs_in_folder($extensionfolder);
797cdf0e10cSrcweir
798cdf0e10cSrcweir	# Registering the extensions
799cdf0e10cSrcweir
800b274bc22SAndre Fischer	$installer::logger::Lang->print( "... registering extensions ...\n" );
801cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Registering extensions:");
802cdf0e10cSrcweir	register_extensions($subfolderdir, $languagestringref, $preregdir);
803cdf0e10cSrcweir
804*4101619dSHerbert Dürr	if ( $installer::globals::compiler =~ /^unxmac/ )
805cdf0e10cSrcweir	{
806cdf0e10cSrcweir		installer::worker::put_scpactions_into_installset("$installdir/$packagename");
807cdf0e10cSrcweir	}
808cdf0e10cSrcweir
809cdf0e10cSrcweir	# Creating archive file
810cdf0e10cSrcweir    if ( $installer::globals::packageformat eq "archive" )
811cdf0e10cSrcweir    {
812cdf0e10cSrcweir        create_package($tempinstalldir, $installdir, $packagename, $allvariables, $includepatharrayref, $languagestringref, $installer::globals::archiveformat);
813cdf0e10cSrcweir    }
814cdf0e10cSrcweir    elsif ( $installer::globals::packageformat eq "dmg" )
815cdf0e10cSrcweir    {
816cdf0e10cSrcweir        create_package($installdir, $installdir, $packagename, $allvariables, $includepatharrayref, $languagestringref, ".dmg");
817cdf0e10cSrcweir    }
818cdf0e10cSrcweir
819cdf0e10cSrcweir	# Analyzing the log file
820cdf0e10cSrcweir
821cdf0e10cSrcweir	installer::worker::clean_output_tree();	# removing directories created in the output tree
822cdf0e10cSrcweir	installer::worker::analyze_and_save_logfile($loggingdir, $installdir, $installlogdir, $allsettingsarrayref, $languagestringref, $current_install_number);
823cdf0e10cSrcweir}
824cdf0e10cSrcweir
825cdf0e10cSrcweir1;
826