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