Filename | /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer/simplepackage.pm |
Statements | Executed 21 statements in 7.88ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.81ms | 2.45ms | BEGIN@36 | installer::simplepackage::
1 | 1 | 1 | 348µs | 426µs | BEGIN@30 | installer::simplepackage::
1 | 1 | 1 | 19µs | 69µs | BEGIN@31 | installer::simplepackage::
1 | 1 | 1 | 18µs | 20µs | BEGIN@38 | installer::simplepackage::
1 | 1 | 1 | 16µs | 19µs | BEGIN@32 | installer::simplepackage::
1 | 1 | 1 | 15µs | 18µs | BEGIN@37 | installer::simplepackage::
1 | 1 | 1 | 14µs | 16µs | BEGIN@34 | installer::simplepackage::
1 | 1 | 1 | 14µs | 16µs | BEGIN@33 | installer::simplepackage::
1 | 1 | 1 | 13µs | 40µs | BEGIN@35 | installer::simplepackage::
1 | 1 | 1 | 7µs | 7µs | check_simple_packager_project | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | create_package | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | create_simple_package | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | get_extensions_dir | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | get_identifier | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | get_language_block_from_language_file | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | get_language_string_from_language_block | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | localize_scriptfile | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | replace_one_variable_in_shellscript | installer::simplepackage::
0 | 0 | 0 | 0s | 0s | replace_variables_in_scriptfile | installer::simplepackage::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #************************************************************************* | ||||
2 | # | ||||
3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||||
4 | # | ||||
5 | # Copyright 2000, 2010 Oracle and/or its affiliates. | ||||
6 | # | ||||
7 | # OpenOffice.org - a multi-platform office productivity suite | ||||
8 | # | ||||
9 | # This file is part of OpenOffice.org. | ||||
10 | # | ||||
11 | # OpenOffice.org is free software: you can redistribute it and/or modify | ||||
12 | # it under the terms of the GNU Lesser General Public License version 3 | ||||
13 | # only, as published by the Free Software Foundation. | ||||
14 | # | ||||
15 | # OpenOffice.org is distributed in the hope that it will be useful, | ||||
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
18 | # GNU Lesser General Public License version 3 for more details | ||||
19 | # (a copy is included in the LICENSE file that accompanied this code). | ||||
20 | # | ||||
21 | # You should have received a copy of the GNU Lesser General Public License | ||||
22 | # version 3 along with OpenOffice.org. If not, see | ||||
23 | # <http://www.openoffice.org/license.html> | ||||
24 | # for a copy of the LGPLv3 License. | ||||
25 | # | ||||
26 | #************************************************************************* | ||||
27 | |||||
28 | package installer::simplepackage; | ||||
29 | |||||
30 | 2 | 62µs | 2 | 505µs | # spent 426µs (348+78) within installer::simplepackage::BEGIN@30 which was called:
# once (348µs+78µs) by installer::BEGIN@57 at line 30 # spent 426µs making 1 call to installer::simplepackage::BEGIN@30
# spent 78µs making 1 call to Exporter::import |
31 | 2 | 62µs | 2 | 119µs | # spent 69µs (19+50) within installer::simplepackage::BEGIN@31 which was called:
# once (19µs+50µs) by installer::BEGIN@57 at line 31 # spent 69µs making 1 call to installer::simplepackage::BEGIN@31
# spent 50µs making 1 call to Exporter::import |
32 | 2 | 55µs | 2 | 21µs | # spent 19µs (16+3) within installer::simplepackage::BEGIN@32 which was called:
# once (16µs+3µs) by installer::BEGIN@57 at line 32 # spent 19µs making 1 call to installer::simplepackage::BEGIN@32
# spent 2µs making 1 call to UNIVERSAL::import |
33 | 2 | 53µs | 2 | 18µs | # spent 16µs (14+2) within installer::simplepackage::BEGIN@33 which was called:
# once (14µs+2µs) by installer::BEGIN@57 at line 33 # spent 16µs making 1 call to installer::simplepackage::BEGIN@33
# spent 2µs making 1 call to UNIVERSAL::import |
34 | 2 | 52µs | 2 | 18µs | # spent 16µs (14+2) within installer::simplepackage::BEGIN@34 which was called:
# once (14µs+2µs) by installer::BEGIN@57 at line 34 # spent 16µs making 1 call to installer::simplepackage::BEGIN@34
# spent 2µs making 1 call to UNIVERSAL::import |
35 | 2 | 66µs | 2 | 68µs | # spent 40µs (13+27) within installer::simplepackage::BEGIN@35 which was called:
# once (13µs+27µs) by installer::BEGIN@57 at line 35 # spent 40µs making 1 call to installer::simplepackage::BEGIN@35
# spent 27µs making 1 call to Exporter::import |
36 | 2 | 998µs | 2 | 2.51ms | # spent 2.45ms (1.81+637µs) within installer::simplepackage::BEGIN@36 which was called:
# once (1.81ms+637µs) by installer::BEGIN@57 at line 36 # spent 2.45ms making 1 call to installer::simplepackage::BEGIN@36
# spent 63µs making 1 call to Exporter::import |
37 | 2 | 54µs | 2 | 21µs | # spent 18µs (15+3) within installer::simplepackage::BEGIN@37 which was called:
# once (15µs+3µs) by installer::BEGIN@57 at line 37 # spent 18µs making 1 call to installer::simplepackage::BEGIN@37
# spent 3µs making 1 call to UNIVERSAL::import |
38 | 2 | 6.46ms | 2 | 22µs | # spent 20µs (18+2) within installer::simplepackage::BEGIN@38 which was called:
# once (18µs+2µs) by installer::BEGIN@57 at line 38 # spent 20µs making 1 call to installer::simplepackage::BEGIN@38
# spent 2µs making 1 call to UNIVERSAL::import |
39 | |||||
40 | #################################################### | ||||
41 | # Checking if the simple packager is required. | ||||
42 | # This can be achieved by setting the global | ||||
43 | # variable SIMPLE_PACKAGE in *.lst file or by | ||||
44 | # setting the environment variable SIMPLE_PACKAGE. | ||||
45 | #################################################### | ||||
46 | |||||
47 | sub check_simple_packager_project | ||||
48 | # spent 7µs within installer::simplepackage::check_simple_packager_project which was called:
# once (7µs+0s) by installer::run at line 235 of /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer.pm | ||||
49 | 1 | 2µs | my ( $allvariables ) = @_; | ||
50 | |||||
51 | 1 | 8µs | if (( $installer::globals::packageformat eq "installed" ) || | ||
52 | ( $installer::globals::packageformat eq "archive" )) | ||||
53 | { | ||||
54 | $installer::globals::is_simple_packager_project = 1; | ||||
55 | $installer::globals::patch_user_dir = 1; | ||||
56 | } | ||||
57 | elsif( $installer::globals::packageformat eq "dmg" ) | ||||
58 | { | ||||
59 | $installer::globals::is_simple_packager_project = 1; | ||||
60 | } | ||||
61 | } | ||||
62 | |||||
63 | #################################################### | ||||
64 | # Detecting the directory with extensions | ||||
65 | #################################################### | ||||
66 | |||||
67 | sub get_extensions_dir | ||||
68 | { | ||||
69 | my ( $subfolderdir ) = @_; | ||||
70 | |||||
71 | my $extensiondir = $subfolderdir . $installer::globals::separator; | ||||
72 | if ( $installer::globals::officedirhostname ne "" ) { $extensiondir = $extensiondir . $installer::globals::officedirhostname . $installer::globals::separator; } | ||||
73 | my $extensionsdir = $extensiondir . "share" . $installer::globals::separator . "extensions"; | ||||
74 | |||||
75 | return $extensionsdir; | ||||
76 | } | ||||
77 | |||||
78 | ################################################################## | ||||
79 | # Collecting all identifier from ulf file | ||||
80 | ################################################################## | ||||
81 | |||||
82 | sub get_identifier | ||||
83 | { | ||||
84 | my ( $translationfile ) = @_; | ||||
85 | |||||
86 | my @identifier = (); | ||||
87 | |||||
88 | for ( my $i = 0; $i <= $#{$translationfile}; $i++ ) | ||||
89 | { | ||||
90 | my $oneline = ${$translationfile}[$i]; | ||||
91 | |||||
92 | if ( $oneline =~ /^\s*\[(.+)\]\s*$/ ) | ||||
93 | { | ||||
94 | my $identifier = $1; | ||||
95 | push(@identifier, $identifier); | ||||
96 | } | ||||
97 | } | ||||
98 | |||||
99 | return \@identifier; | ||||
100 | } | ||||
101 | |||||
102 | ############################################################## | ||||
103 | # Returning the complete block in all languages | ||||
104 | # for a specified string | ||||
105 | ############################################################## | ||||
106 | |||||
107 | sub get_language_block_from_language_file | ||||
108 | { | ||||
109 | my ($searchstring, $languagefile) = @_; | ||||
110 | |||||
111 | my @language_block = (); | ||||
112 | |||||
113 | for ( my $i = 0; $i <= $#{$languagefile}; $i++ ) | ||||
114 | { | ||||
115 | if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ ) | ||||
116 | { | ||||
117 | my $counter = $i; | ||||
118 | |||||
119 | push(@language_block, ${$languagefile}[$counter]); | ||||
120 | $counter++; | ||||
121 | |||||
122 | while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ ))) | ||||
123 | { | ||||
124 | push(@language_block, ${$languagefile}[$counter]); | ||||
125 | $counter++; | ||||
126 | } | ||||
127 | |||||
128 | last; | ||||
129 | } | ||||
130 | } | ||||
131 | |||||
132 | return \@language_block; | ||||
133 | } | ||||
134 | |||||
135 | ############################################################## | ||||
136 | # Returning a specific language string from the block | ||||
137 | # of all translations | ||||
138 | ############################################################## | ||||
139 | |||||
140 | sub get_language_string_from_language_block | ||||
141 | { | ||||
142 | my ($language_block, $language) = @_; | ||||
143 | |||||
144 | my $newstring = ""; | ||||
145 | |||||
146 | for ( my $i = 0; $i <= $#{$language_block}; $i++ ) | ||||
147 | { | ||||
148 | if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) | ||||
149 | { | ||||
150 | $newstring = $1; | ||||
151 | last; | ||||
152 | } | ||||
153 | } | ||||
154 | |||||
155 | if ( $newstring eq "" ) | ||||
156 | { | ||||
157 | $language = "en-US"; # defaulting to english | ||||
158 | |||||
159 | for ( my $i = 0; $i <= $#{$language_block}; $i++ ) | ||||
160 | { | ||||
161 | if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) | ||||
162 | { | ||||
163 | $newstring = $1; | ||||
164 | last; | ||||
165 | } | ||||
166 | } | ||||
167 | } | ||||
168 | |||||
169 | return $newstring; | ||||
170 | } | ||||
171 | |||||
172 | ######################################################################## | ||||
173 | # Localizing the script for the Mac Language Pack installer | ||||
174 | ######################################################################## | ||||
175 | |||||
176 | sub localize_scriptfile | ||||
177 | { | ||||
178 | my ($scriptfile, $translationfile, $languagestringref) = @_; | ||||
179 | |||||
180 | my $onelanguage = $$languagestringref; | ||||
181 | if ( $onelanguage =~ /^\s*(.*?)_/ ) { $onelanguage = $1; } | ||||
182 | |||||
183 | # Analyzing the ulf file, collecting all Identifier | ||||
184 | my $allidentifier = get_identifier($translationfile); | ||||
185 | |||||
186 | for ( my $i = 0; $i <= $#{$allidentifier}; $i++ ) | ||||
187 | { | ||||
188 | my $identifier = ${$allidentifier}[$i]; | ||||
189 | my $language_block = get_language_block_from_language_file($identifier, $translationfile); | ||||
190 | my $newstring = get_language_string_from_language_block($language_block, $onelanguage); | ||||
191 | |||||
192 | # removing mask | ||||
193 | $newstring =~ s/\\\'/\'/g; | ||||
194 | |||||
195 | replace_one_variable_in_shellscript($scriptfile, $newstring, $identifier); | ||||
196 | } | ||||
197 | } | ||||
198 | |||||
199 | ################################################################################# | ||||
200 | # Replacing one variable in Mac shell script | ||||
201 | ################################################################################# | ||||
202 | |||||
203 | sub replace_one_variable_in_shellscript | ||||
204 | { | ||||
205 | my ($scriptfile, $variable, $searchstring) = @_; | ||||
206 | |||||
207 | for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) | ||||
208 | { | ||||
209 | ${$scriptfile}[$i] =~ s/\[$searchstring\]/$variable/g; | ||||
210 | } | ||||
211 | } | ||||
212 | |||||
213 | ############################################# | ||||
214 | # Replacing variables in Mac shell script | ||||
215 | ############################################# | ||||
216 | |||||
217 | sub replace_variables_in_scriptfile | ||||
218 | { | ||||
219 | my ($scriptfile, $volume_name, $volume_name_app, $allvariables) = @_; | ||||
220 | |||||
221 | replace_one_variable_in_shellscript($scriptfile, $volume_name, "FULLPRODUCTNAME" ); | ||||
222 | replace_one_variable_in_shellscript($scriptfile, $volume_name_app, "FULLAPPPRODUCTNAME" ); | ||||
223 | replace_one_variable_in_shellscript($scriptfile, $allvariables->{'PRODUCTNAME'}, "PRODUCTNAME" ); | ||||
224 | replace_one_variable_in_shellscript($scriptfile, $allvariables->{'PRODUCTVERSION'}, "PRODUCTVERSION" ); | ||||
225 | |||||
226 | my $scriptname = lc($allvariables->{'PRODUCTNAME'}) . "\.script"; | ||||
227 | if ( $allvariables->{'PRODUCTNAME'} eq "LibreOffice" ) { $scriptname = "org.libreoffice.script"; } | ||||
228 | |||||
229 | replace_one_variable_in_shellscript($scriptfile, $scriptname, "SEARCHSCRIPTNAME" ); | ||||
230 | } | ||||
231 | |||||
232 | ############################################# | ||||
233 | # Creating the "simple" package. | ||||
234 | # "zip" for Windows | ||||
235 | # "tar.gz" for all other platforms | ||||
236 | # additionally "dmg" on Mac OS X | ||||
237 | ############################################# | ||||
238 | |||||
239 | sub create_package | ||||
240 | { | ||||
241 | my ( $installdir, $archivedir, $packagename, $allvariables, $includepatharrayref, $languagestringref, $format ) = @_; | ||||
242 | |||||
243 | installer::logger::print_message( "... creating $installer::globals::packageformat file ...\n" ); | ||||
244 | installer::logger::include_header_into_logfile("Creating $installer::globals::packageformat file:"); | ||||
245 | |||||
246 | # moving dir into temporary directory | ||||
247 | my $pid = $$; # process id | ||||
248 | my $tempdir = $installdir . "_temp" . "." . $pid; | ||||
249 | my $systemcall = ""; | ||||
250 | my $from = ""; | ||||
251 | my $makesystemcall = 1; | ||||
252 | my $return_to_start = 0; | ||||
253 | installer::systemactions::rename_directory($installdir, $tempdir); | ||||
254 | |||||
255 | # creating new directory with original name | ||||
256 | installer::systemactions::create_directory($archivedir); | ||||
257 | |||||
258 | my $archive = $archivedir . $installer::globals::separator . $packagename . $format; | ||||
259 | |||||
260 | if ( $archive =~ /zip$/ ) | ||||
261 | { | ||||
262 | $from = cwd(); | ||||
263 | $return_to_start = 1; | ||||
264 | chdir($tempdir); | ||||
265 | $systemcall = "$installer::globals::zippath -qr $archive ."; | ||||
266 | |||||
267 | # Using Archive::Zip fails because of very long path names below "share/uno_packages/cache" | ||||
268 | # my $packzip = Archive::Zip->new(); | ||||
269 | # $packzip->addTree("."); # after changing into $tempdir | ||||
270 | # $packzip->writeToFileNamed($archive); | ||||
271 | # $makesystemcall = 0; | ||||
272 | } | ||||
273 | elsif ( $archive =~ /dmg$/ ) | ||||
274 | { | ||||
275 | my $folder = (( -l "$tempdir/$packagename/Applications" ) or ( -l "$tempdir/$packagename/opt" )) ? $packagename : "\."; | ||||
276 | |||||
277 | if ( $allvariables->{'PACK_INSTALLED'} ) { | ||||
278 | $folder = $packagename; | ||||
279 | } | ||||
280 | |||||
281 | # my $volume_name = $allvariables->{'PRODUCTNAME'} . ' ' . $allvariables->{'PRODUCTVERSION'}; # Adding PRODUCTVERSION makes this difficult to maintain! | ||||
282 | my $volume_name = $allvariables->{'PRODUCTNAME'}; | ||||
283 | my $volume_name_classic = $allvariables->{'PRODUCTNAME'} . ' ' . $allvariables->{'PRODUCTVERSION'}; | ||||
284 | my $volume_name_classic_app = $volume_name; # "app" should not contain version number | ||||
285 | # $volume_name = $volume_name . ' ' . $allvariables->{'PRODUCTEXTENSION'} if $allvariables->{'PRODUCTEXTENSION'}; # Adding PRODUCTEXTENSION makes this difficult to maintain! | ||||
286 | $volume_name_classic = $volume_name_classic . ' ' . $allvariables->{'PRODUCTEXTENSION'} if $allvariables->{'PRODUCTEXTENSION'}; | ||||
287 | $volume_name_classic_app = $volume_name_classic_app . ' ' . $allvariables->{'PRODUCTEXTENSION'} if $allvariables->{'PRODUCTEXTENSION'}; | ||||
288 | if ( $allvariables->{'DMG_VOLUMEEXTENSION'} ) { | ||||
289 | $volume_name = $volume_name . ' ' . $allvariables->{'DMG_VOLUMEEXTENSION'}; | ||||
290 | $volume_name_classic = $volume_name_classic . ' ' . $allvariables->{'DMG_VOLUMEEXTENSION'}; | ||||
291 | $volume_name_classic_app = $volume_name_classic_app . ' ' . $allvariables->{'DMG_VOLUMEEXTENSION'}; | ||||
292 | } | ||||
293 | |||||
294 | my $sla = 'sla.r'; | ||||
295 | my $ref = ""; | ||||
296 | |||||
297 | if ( ! $allvariables->{'HIDELICENSEDIALOG'} ) | ||||
298 | { | ||||
299 | installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$sla, $includepatharrayref, 0); | ||||
300 | } | ||||
301 | |||||
302 | my $localtempdir = $tempdir; | ||||
303 | |||||
304 | if (( $installer::globals::languagepack ) || ( $installer::globals::helppack ) || ( $installer::globals::patch )) | ||||
305 | { | ||||
306 | $localtempdir = "$tempdir/$packagename"; | ||||
307 | if ( $installer::globals::helppack ) { $volume_name = "$volume_name Help Pack"; } | ||||
308 | if ( $installer::globals::languagepack ) | ||||
309 | { | ||||
310 | $volume_name = "$volume_name Language Pack"; | ||||
311 | $volume_name_classic = "$volume_name_classic Language Pack"; | ||||
312 | $volume_name_classic_app = "$volume_name_classic_app Language Pack"; | ||||
313 | } | ||||
314 | if ( $installer::globals::patch ) | ||||
315 | { | ||||
316 | $volume_name = "$volume_name Patch"; | ||||
317 | $volume_name_classic = "$volume_name_classic Patch"; | ||||
318 | $volume_name_classic_app = "$volume_name_classic_app Patch"; | ||||
319 | } | ||||
320 | |||||
321 | # Create tar ball named tarball.tar.bz2 | ||||
322 | # my $appfolder = $localtempdir . "/" . $volume_name . "\.app"; | ||||
323 | my $appfolder = $localtempdir . "/" . $volume_name_classic_app . "\.app"; | ||||
324 | my $contentsfolder = $appfolder . "/Contents"; | ||||
325 | my $tarballname = "tarball.tar.bz2"; | ||||
326 | |||||
327 | my $localfrom = cwd(); | ||||
328 | chdir $appfolder; | ||||
329 | |||||
330 | $systemcall = "tar -cjf $tarballname Contents/"; | ||||
331 | |||||
332 | print "... $systemcall ...\n"; | ||||
333 | my $localreturnvalue = system($systemcall); | ||||
334 | $infoline = "Systemcall: $systemcall\n"; | ||||
335 | push( @installer::globals::logfileinfo, $infoline); | ||||
336 | |||||
337 | if ($localreturnvalue) | ||||
338 | { | ||||
339 | $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; | ||||
340 | push( @installer::globals::logfileinfo, $infoline); | ||||
341 | } | ||||
342 | else | ||||
343 | { | ||||
344 | $infoline = "Success: Executed \"$systemcall\" successfully!\n"; | ||||
345 | push( @installer::globals::logfileinfo, $infoline); | ||||
346 | } | ||||
347 | |||||
348 | my $sourcefile = $appfolder . "/" . $tarballname; | ||||
349 | my $destfile = $contentsfolder . "/" . $tarballname; | ||||
350 | |||||
351 | installer::systemactions::remove_complete_directory($contentsfolder); | ||||
352 | installer::systemactions::create_directory($contentsfolder); | ||||
353 | |||||
354 | installer::systemactions::copy_one_file($sourcefile, $destfile); | ||||
355 | unlink($sourcefile); | ||||
356 | |||||
357 | # Copy two files into installation set next to the tar ball | ||||
358 | # 1. "osx_install.applescript" | ||||
359 | # 2 "OpenOffice.org Languagepack" | ||||
360 | |||||
361 | my $scriptrealfilename = "osx_install.applescript"; | ||||
362 | my $scriptfilename = ""; | ||||
363 | if ( $installer::globals::languagepack ) { $scriptfilename = "osx_install_languagepack.applescript"; } | ||||
364 | if ( $installer::globals::helppack ) { $scriptfilename = "osx_install_helppack.applescript"; } | ||||
365 | if ( $installer::globals::patch ) { $scriptfilename = "osx_install_patch.applescript"; } | ||||
366 | my $scripthelpersolverfilename = "mac_install.script"; | ||||
367 | # my $scripthelperrealfilename = $volume_name; | ||||
368 | my $scripthelperrealfilename = $volume_name_classic_app; | ||||
369 | my $translationfilename = $installer::globals::macinstallfilename; | ||||
370 | |||||
371 | # Finding both files in solver | ||||
372 | |||||
373 | my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$scriptfilename, $includepatharrayref, 0); | ||||
374 | if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script $scriptfilename!", "create_package"); } | ||||
375 | my $scripthelperref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$scripthelpersolverfilename, $includepatharrayref, 0); | ||||
376 | if ($$scripthelperref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script $scripthelpersolverfilename!", "create_package"); } | ||||
377 | my $translationfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$translationfilename, $includepatharrayref, 0); | ||||
378 | if ($$translationfileref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script translation file $translationfilename!", "create_package"); } | ||||
379 | |||||
380 | $scriptfilename = $contentsfolder . "/" . $scriptrealfilename; | ||||
381 | $scripthelperrealfilename = $contentsfolder . "/" . $scripthelperrealfilename; | ||||
382 | |||||
383 | installer::systemactions::copy_one_file($$scriptref, $scriptfilename); | ||||
384 | installer::systemactions::copy_one_file($$scripthelperref, $scripthelperrealfilename); | ||||
385 | |||||
386 | # Replacing variables in script $scriptfilename | ||||
387 | # Localizing script $scriptfilename | ||||
388 | my $scriptfilecontent = installer::files::read_file($scriptfilename); | ||||
389 | my $translationfilecontent = installer::files::read_file($$translationfileref); | ||||
390 | localize_scriptfile($scriptfilecontent, $translationfilecontent, $languagestringref); | ||||
391 | # replace_variables_in_scriptfile($scriptfilecontent, $volume_name, $allvariables); | ||||
392 | replace_variables_in_scriptfile($scriptfilecontent, $volume_name_classic, $volume_name_classic_app, $allvariables); | ||||
393 | installer::files::save_file($scriptfilename, $scriptfilecontent); | ||||
394 | |||||
395 | chmod 0775, $scriptfilename; | ||||
396 | chmod 0775, $scripthelperrealfilename; | ||||
397 | |||||
398 | # Copy also Info.plist and icon file | ||||
399 | # Finding both files in solver | ||||
400 | my $iconfile = "ooo3_installer.icns"; | ||||
401 | my $iconfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$iconfile, $includepatharrayref, 0); | ||||
402 | if ($$iconfileref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script icon file $iconfile!", "create_package"); } | ||||
403 | my $subdir = $contentsfolder . "/" . "Resources"; | ||||
404 | if ( ! -d $subdir ) { installer::systemactions::create_directory($subdir); } | ||||
405 | $destfile = $subdir . "/" . $iconfile; | ||||
406 | installer::systemactions::copy_one_file($$iconfileref, $destfile); | ||||
407 | |||||
408 | my $infoplistfile = "Info.plist.langpack"; | ||||
409 | my $installname = "Info.plist"; | ||||
410 | my $infoplistfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$infoplistfile, $includepatharrayref, 0); | ||||
411 | if ($$infoplistfileref eq "") { installer::exiter::exit_program("ERROR: Could not find Apple script Info.plist: $infoplistfile!", "create_package"); } | ||||
412 | $destfile = $contentsfolder . "/" . $installname; | ||||
413 | installer::systemactions::copy_one_file($$infoplistfileref, $destfile); | ||||
414 | |||||
415 | # Replacing variables in Info.plist | ||||
416 | $scriptfilecontent = installer::files::read_file($destfile); | ||||
417 | # replace_one_variable_in_shellscript($scriptfilecontent, $volume_name, "FULLPRODUCTNAME" ); | ||||
418 | replace_one_variable_in_shellscript($scriptfilecontent, $volume_name_classic_app, "FULLAPPPRODUCTNAME" ); # OpenOffice.org Language Pack | ||||
419 | installer::files::save_file($destfile, $scriptfilecontent); | ||||
420 | |||||
421 | chdir $localfrom; | ||||
422 | } | ||||
423 | |||||
424 | $systemcall = "cd $localtempdir && hdiutil makehybrid -hfs -hfs-openfolder $folder $folder -hfs-volume-name \"$volume_name\" -ov -o $installdir/tmp && hdiutil convert -ov -format UDBZ $installdir/tmp.dmg -o $archive && "; | ||||
425 | if (( $ref ne "" ) && ( $$ref ne "" )) { | ||||
426 | $systemcall .= "hdiutil unflatten $archive && Rez -a $$ref -o $archive && hdiutil flatten $archive &&"; | ||||
427 | } | ||||
428 | $systemcall .= "rm -f $installdir/tmp.dmg"; | ||||
429 | } | ||||
430 | else | ||||
431 | { | ||||
432 | # getting the path of the getuid.so (only required for Solaris and Linux) | ||||
433 | my $getuidlibrary = ""; | ||||
434 | my $ldpreloadstring = ""; | ||||
435 | if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild )) | ||||
436 | { | ||||
437 | $getuidlibrary = installer::download::get_path_for_library($includepatharrayref); | ||||
438 | if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } | ||||
439 | } | ||||
440 | |||||
441 | $systemcall = "cd $tempdir; $ldpreloadstring tar -cf - . | gzip > $archive"; | ||||
442 | } | ||||
443 | |||||
444 | if ( $makesystemcall ) | ||||
445 | { | ||||
446 | print "... $systemcall ...\n"; | ||||
447 | my $returnvalue = system($systemcall); | ||||
448 | my $infoline = "Systemcall: $systemcall\n"; | ||||
449 | push( @installer::globals::logfileinfo, $infoline); | ||||
450 | |||||
451 | if ($returnvalue) | ||||
452 | { | ||||
453 | $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; | ||||
454 | push( @installer::globals::logfileinfo, $infoline); | ||||
455 | } | ||||
456 | else | ||||
457 | { | ||||
458 | $infoline = "Success: Executed \"$systemcall\" successfully!\n"; | ||||
459 | push( @installer::globals::logfileinfo, $infoline); | ||||
460 | } | ||||
461 | } | ||||
462 | |||||
463 | if ( $return_to_start ) { chdir($from); } | ||||
464 | |||||
465 | print "... removing $tempdir ...\n"; | ||||
466 | installer::systemactions::remove_complete_directory($tempdir); | ||||
467 | } | ||||
468 | |||||
469 | #################################################### | ||||
470 | # Main method for creating the simple package | ||||
471 | # installation sets | ||||
472 | #################################################### | ||||
473 | |||||
474 | sub create_simple_package | ||||
475 | { | ||||
476 | my ( $filesref, $dirsref, $scpactionsref, $linksref, $unixlinksref, $loggingdir, $languagestringref, $shipinstalldir, $allsettingsarrayref, $allvariables, $includepatharrayref ) = @_; | ||||
477 | |||||
478 | # Creating directories | ||||
479 | |||||
480 | my $current_install_number = ""; | ||||
481 | my $infoline = ""; | ||||
482 | |||||
483 | installer::logger::print_message( "... creating installation directory ...\n" ); | ||||
484 | installer::logger::include_header_into_logfile("Creating installation directory"); | ||||
485 | |||||
486 | $installer::globals::csp_installdir = installer::worker::create_installation_directory($shipinstalldir, $languagestringref, \$current_install_number); | ||||
487 | $installer::globals::csp_installlogdir = installer::systemactions::create_directory_next_to_directory($installer::globals::csp_installdir, "log"); | ||||
488 | |||||
489 | my $installdir = $installer::globals::csp_installdir; | ||||
490 | my $installlogdir = $installer::globals::csp_installlogdir; | ||||
491 | |||||
492 | # Setting package name (similar to the download name) | ||||
493 | my $packagename = ""; | ||||
494 | |||||
495 | if ( $installer::globals::packageformat eq "archive" || | ||||
496 | $installer::globals::packageformat eq "dmg" ) | ||||
497 | { | ||||
498 | $installer::globals::csp_languagestring = $$languagestringref; | ||||
499 | |||||
500 | my $locallanguage = $installer::globals::csp_languagestring; | ||||
501 | |||||
502 | if ( $allvariables->{'OOODOWNLOADNAME'} ) | ||||
503 | { | ||||
504 | $packagename = installer::download::set_download_filename(\$locallanguage, $allvariables); | ||||
505 | } | ||||
506 | else | ||||
507 | { | ||||
508 | $downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "downloadname"); | ||||
509 | if ( $installer::globals::languagepack ) { $downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "langpackdownloadname"); } | ||||
510 | if ( $installer::globals::helppack ) { $downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "helppackdownloadname"); } | ||||
511 | if ( $installer::globals::patch ) { $downloadname = installer::ziplist::getinfofromziplist($allsettingsarrayref, "patchdownloadname"); } | ||||
512 | $packagename = installer::download::resolve_variables_in_downloadname($allvariables, $$downloadname, \$locallanguage); | ||||
513 | } | ||||
514 | } | ||||
515 | |||||
516 | # Work around Windows problems with long pathnames (see issue 50885) by | ||||
517 | # putting the to-be-archived installation tree into the temp directory | ||||
518 | # instead of the module output tree (unless LOCALINSTALLDIR dictates | ||||
519 | # otherwise, anyway); can be removed once issue 50885 is fixed: | ||||
520 | my $tempinstalldir = $installdir; | ||||
521 | if ( $installer::globals::iswindowsbuild && | ||||
522 | $installer::globals::packageformat eq "archive" && | ||||
523 | !$installer::globals::localinstalldirset ) | ||||
524 | { | ||||
525 | $tempinstalldir = File::Temp::tempdir; | ||||
526 | } | ||||
527 | |||||
528 | # Creating subfolder in installdir, which shall become the root of package or zip file | ||||
529 | my $subfolderdir = ""; | ||||
530 | if ( $packagename ne "" ) { $subfolderdir = $tempinstalldir . $installer::globals::separator . $packagename; } | ||||
531 | else { $subfolderdir = $tempinstalldir; } | ||||
532 | |||||
533 | if ( ! -d $subfolderdir ) { installer::systemactions::create_directory($subfolderdir); } | ||||
534 | |||||
535 | # Create directories, copy files and ScpActions | ||||
536 | |||||
537 | installer::logger::print_message( "... creating directories ...\n" ); | ||||
538 | installer::logger::include_header_into_logfile("Creating directories:"); | ||||
539 | |||||
540 | for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) | ||||
541 | { | ||||
542 | my $onedir = ${$dirsref}[$i]; | ||||
543 | |||||
544 | if ( $onedir->{'HostName'} ) | ||||
545 | { | ||||
546 | my $destdir = $subfolderdir . $installer::globals::separator . $onedir->{'HostName'}; | ||||
547 | |||||
548 | if ( ! -d $destdir ) | ||||
549 | { | ||||
550 | if ( $^O =~ /cygwin/i ) # Cygwin performance check | ||||
551 | { | ||||
552 | $infoline = "Try to create directory $destdir\n"; | ||||
553 | push(@installer::globals::logfileinfo, $infoline); | ||||
554 | # Directories in $dirsref are sorted and all parents were added -> "mkdir" works without parent creation! | ||||
555 | if ( ! ( -d $destdir )) { mkdir($destdir, 0775); } | ||||
556 | } | ||||
557 | else | ||||
558 | { | ||||
559 | installer::systemactions::create_directory_structure($destdir); | ||||
560 | } | ||||
561 | } | ||||
562 | } | ||||
563 | } | ||||
564 | |||||
565 | # stripping files ?! | ||||
566 | if (( $installer::globals::strip ) && ( ! $installer::globals::iswindowsbuild )) { strip_libraries($filesref, $languagestringref); } | ||||
567 | |||||
568 | # copy Files | ||||
569 | installer::logger::print_message( "... copying files ...\n" ); | ||||
570 | installer::logger::include_header_into_logfile("Copying files:"); | ||||
571 | |||||
572 | for ( my $i = 0; $i <= $#{$filesref}; $i++ ) | ||||
573 | { | ||||
574 | my $onefile = ${$filesref}[$i]; | ||||
575 | |||||
576 | if (( $onefile->{'Styles'} ) && ( $onefile->{'Styles'} =~ /\bBINARYTABLE_ONLY\b/ )) { next; } | ||||
577 | if (( $installer::globals::patch ) && ( $onefile->{'Styles'} ) && ( ! ( $onefile->{'Styles'} =~ /\bPATCH\b/ ))) { next; } | ||||
578 | if (( $installer::globals::patch ) && ( $installer::globals::packageformat eq "dmg" )) { push(@installer::globals::patchfilecollector, "$onefile->{'destination'}\n"); } | ||||
579 | |||||
580 | my $source = $onefile->{'sourcepath'}; | ||||
581 | my $destination = $onefile->{'destination'}; | ||||
582 | $destination = $subfolderdir . $installer::globals::separator . $destination; | ||||
583 | |||||
584 | # Replacing $$ by $ is necessary to install files with $ in its name (back-masquerading) | ||||
585 | # Otherwise, the following shell command does not work and the file list is not correct | ||||
586 | $source =~ s/\$\$/\$/; | ||||
587 | $destination =~ s/\$\$/\$/; | ||||
588 | |||||
589 | if ( $^O =~ /cygwin/i ) # Cygwin performance, do not use copy_one_file. "chmod -R" at the end | ||||
590 | { | ||||
591 | my $copyreturn = copy($source, $destination); | ||||
592 | |||||
593 | if ($copyreturn) | ||||
594 | { | ||||
595 | $infoline = "Copy: $source to $destination\n"; | ||||
596 | $returnvalue = 1; | ||||
597 | } | ||||
598 | else | ||||
599 | { | ||||
600 | $infoline = "ERROR: Could not copy $source to $destination $!\n"; | ||||
601 | $returnvalue = 0; | ||||
602 | } | ||||
603 | |||||
604 | push(@installer::globals::logfileinfo, $infoline); | ||||
605 | } | ||||
606 | else | ||||
607 | { | ||||
608 | installer::systemactions::copy_one_file($source, $destination); | ||||
609 | |||||
610 | if ( ! $installer::globals::iswindowsbuild ) | ||||
611 | { | ||||
612 | # see issue 102274 | ||||
613 | if ( $onefile->{'UnixRights'} ) | ||||
614 | { | ||||
615 | chmod oct($onefile->{'UnixRights'}), $destination; | ||||
616 | } | ||||
617 | } | ||||
618 | } | ||||
619 | } | ||||
620 | |||||
621 | # creating Links | ||||
622 | |||||
623 | installer::logger::print_message( "... creating links ...\n" ); | ||||
624 | installer::logger::include_header_into_logfile("Creating links:"); | ||||
625 | |||||
626 | for ( my $i = 0; $i <= $#{$linksref}; $i++ ) | ||||
627 | { | ||||
628 | my $onelink = ${$linksref}[$i]; | ||||
629 | |||||
630 | if (( $installer::globals::patch ) && ( $onelink->{'Styles'} ) && ( ! ( $onelink->{'Styles'} =~ /\bPATCH\b/ ))) { next; } | ||||
631 | |||||
632 | my $destination = $onelink->{'destination'}; | ||||
633 | $destination = $subfolderdir . $installer::globals::separator . $destination; | ||||
634 | my $destinationfile = $onelink->{'destinationfile'}; | ||||
635 | |||||
636 | my $localcall = "ln -sf \'$destinationfile\' \'$destination\' \>\/dev\/null 2\>\&1"; | ||||
637 | system($localcall); | ||||
638 | |||||
639 | $infoline = "Creating link: \"ln -sf $destinationfile $destination\"\n"; | ||||
640 | push(@installer::globals::logfileinfo, $infoline); | ||||
641 | } | ||||
642 | |||||
643 | for ( my $i = 0; $i <= $#{$unixlinksref}; $i++ ) | ||||
644 | { | ||||
645 | my $onelink = ${$unixlinksref}[$i]; | ||||
646 | |||||
647 | if (( $installer::globals::patch ) && ( $onelink->{'Styles'} ) && ( ! ( $onelink->{'Styles'} =~ /\bPATCH\b/ ))) { next; } | ||||
648 | |||||
649 | my $target = $onelink->{'Target'}; | ||||
650 | my $destination = $subfolderdir . $installer::globals::separator . $onelink->{'destination'}; | ||||
651 | |||||
652 | my $localcall = "ln -sf \'$target\' \'$destination\' \>\/dev\/null 2\>\&1"; | ||||
653 | system($localcall); | ||||
654 | |||||
655 | $infoline = "Creating Unix link: \"ln -sf $target $destination\"\n"; | ||||
656 | push(@installer::globals::logfileinfo, $infoline); | ||||
657 | } | ||||
658 | |||||
659 | # Setting privileges for cygwin globally | ||||
660 | |||||
661 | if ( $^O =~ /cygwin/i ) | ||||
662 | { | ||||
663 | installer::logger::print_message( "... changing privileges in $subfolderdir ...\n" ); | ||||
664 | installer::logger::include_header_into_logfile("Changing privileges in $subfolderdir:"); | ||||
665 | |||||
666 | my $localcall = "chmod -R 755 " . "\"" . $subfolderdir . "\""; | ||||
667 | system($localcall); | ||||
668 | } | ||||
669 | |||||
670 | installer::logger::print_message( "... removing superfluous directories ...\n" ); | ||||
671 | installer::logger::include_header_into_logfile("Removing superfluous directories:"); | ||||
672 | |||||
673 | my $extensionfolder = get_extensions_dir($subfolderdir); | ||||
674 | installer::systemactions::remove_empty_dirs_in_folder($extensionfolder); | ||||
675 | |||||
676 | if ( $installer::globals::compiler =~ /^unxmacx/ ) | ||||
677 | { | ||||
678 | installer::worker::put_scpactions_into_installset("$installdir/$packagename"); | ||||
679 | } | ||||
680 | |||||
681 | # Creating archive file | ||||
682 | if ( $installer::globals::packageformat eq "archive" ) | ||||
683 | { | ||||
684 | create_package($tempinstalldir, $installdir, $packagename, $allvariables, $includepatharrayref, $languagestringref, $installer::globals::archiveformat); | ||||
685 | } | ||||
686 | elsif ( $installer::globals::packageformat eq "dmg" ) | ||||
687 | { | ||||
688 | create_package($installdir, $installdir, $packagename, $allvariables, $includepatharrayref, $languagestringref, ".dmg"); | ||||
689 | } | ||||
690 | |||||
691 | # Analyzing the log file | ||||
692 | |||||
693 | installer::worker::clean_output_tree(); # removing directories created in the output tree | ||||
694 | installer::worker::analyze_and_save_logfile($loggingdir, $installdir, $installlogdir, $allsettingsarrayref, $languagestringref, $current_install_number); | ||||
695 | } | ||||
696 | |||||
697 | 1 | 8µs | 1; |