update dev300-m58
[ooovba.git] / solenv / bin / modules / installer / epmfile.pm
blobda10a604959e52da9e861a8ca302a959a9f2a298
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: epmfile.pm,v $
11 # $Revision: 1.87 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::epmfile;
34 use Cwd;
35 use installer::converter;
36 use installer::existence;
37 use installer::exiter;
38 use installer::files;
39 use installer::globals;
40 use installer::logger;
41 use installer::packagelist;
42 use installer::pathanalyzer;
43 use installer::remover;
44 use installer::scriptitems;
45 use installer::systemactions;
46 use installer::worker;
47 use POSIX;
49 ############################################################################
50 # Reading the package map to find Solaris package names for
51 # the corresponding abbreviations
52 ############################################################################
54 sub read_packagemap
56 my ($allvariables, $includepatharrayref, $languagesarrayref) = @_;
58 my $packagemapname = "";
59 if ( $allvariables->{'PACKAGEMAP'} ) { $packagemapname = $allvariables->{'PACKAGEMAP'}; }
60 if ( $packagemapname eq "" ) { installer::exiter::exit_program("ERROR: Property PACKAGEMAP must be defined!", "read_packagemap"); }
62 my $infoline = "\n\nCollected abbreviations and package names:\n";
63 push(@installer::globals::logfileinfo, $infoline);
65 # Can be a comma separated list. All files have to be found in include pathes
66 my $allpackagemapnames = installer::converter::convert_stringlist_into_hash(\$packagemapname, ",");
67 foreach my $onepackagemapname ( keys %{$allpackagemapnames} )
69 my $packagemapref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onepackagemapname, $includepatharrayref, 0);
71 if ( $$packagemapref eq "" ) { installer::exiter::exit_program("ERROR: Could not find package map file \"$onepackagemapname\" (propery PACKAGEMAP)!", "read_packagemap"); }
73 my $packagemapcontent = installer::files::read_file($$packagemapref);
75 for ( my $i = 0; $i <= $#{$packagemapcontent}; $i++ )
77 my $line = ${$packagemapcontent}[$i];
79 if ( $line =~ /^\s*\#/ ) { next; } # comment line
80 if ( $line =~ /^\s*$/ ) { next; } # empty line
82 if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ )
84 my $abbreviation = $1;
85 my $packagename = $2;
86 installer::packagelist::resolve_packagevariables(\$abbreviation, $allvariables, 0);
87 installer::packagelist::resolve_packagevariables(\$packagename, $allvariables, 0);
89 # Special handling for language strings %LANGUAGESTRING
91 if (( $abbreviation =~ /\%LANGUAGESTRING/ ) || ( $packagename =~ /\%LANGUAGESTRING/ ))
93 foreach my $onelang ( @{$languagesarrayref} )
95 my $local_abbreviation = $abbreviation;
96 my $local_packagename = $packagename;
97 $local_abbreviation =~ s/\%LANGUAGESTRING/$onelang/g;
98 $local_packagename =~ s/\%LANGUAGESTRING/$onelang/g;
100 # Logging all abbreviations and packagenames
101 $infoline = "$onelang : $local_abbreviation : $local_packagename\n";
102 push(@installer::globals::logfileinfo, $infoline);
104 if ( exists($installer::globals::dependfilenames{$local_abbreviation}) )
106 installer::exiter::exit_program("ERROR: Packagename for Solaris package $local_abbreviation already defined ($installer::globals::dependfilenames{$local_abbreviation})!", "read_packagemap");
108 else
110 $installer::globals::dependfilenames{$local_abbreviation} = $local_packagename;
114 else
116 # Logging all abbreviations and packagenames
117 $infoline = "$abbreviation : $packagename\n";
118 push(@installer::globals::logfileinfo, $infoline);
120 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
122 installer::exiter::exit_program("ERROR: Packagename for Solaris package $abbreviation already defined ($installer::globals::dependfilenames{$abbreviation})!", "read_packagemap");
124 else
126 $installer::globals::dependfilenames{$abbreviation} = $packagename;
130 else
132 my $errorline = $i + 1;
133 installer::exiter::exit_program("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap");
138 $infoline = "\n\n";
139 push(@installer::globals::logfileinfo, $infoline);
143 ############################################################################
144 # The header file contains the strings for the epm header in all languages
145 ############################################################################
147 sub get_string_from_headerfile
149 my ($searchstring, $language, $fileref) = @_;
151 my $returnstring = "";
152 my $onestring = "";
153 my $englishstring = "";
154 my $foundblock = 0;
155 my $foundstring = 0;
156 my $foundenglishstring = 0;
157 my $englishidentifier = "01";
159 $searchstring = "[" . $searchstring . "]";
161 for ( my $i = 0; $i <= $#{$fileref}; $i++ )
163 my $line = ${$fileref}[$i];
165 if ( $line =~ /^\s*\Q$searchstring\E\s*$/ )
167 $foundblock = 1;
168 my $counter = $i + 1;
170 $line = ${$fileref}[$counter];
172 # Beginning of the next block oder Dateiende
174 while ((!($line =~ /^\s*\[\s*\w+\s*\]\s*$/ )) && ( $counter <= $#{$fileref} ))
176 if ( $line =~ /^\s*\Q$language\E\s+\=\s*\"(.*)\"\s*$/ )
178 $onestring = $1;
179 $foundstring = 1;
180 last;
183 if ( $line =~ /^\s*\Q$englishidentifier\E\s+\=\s*\"(.*)\"\s*$/ )
185 $englishstring = $1;
186 $foundenglishstring = 1;
189 $counter++;
190 $line = ${$fileref}[$counter];
195 if ( $foundstring )
197 $returnstring = $onestring;
199 else
201 if ( $foundenglishstring )
203 $returnstring = $englishstring;
205 else
207 installer::exiter::exit_program("ERROR: No string found for $searchstring in epm header file (-h)", "get_string_from_headerfile");
211 return \$returnstring;
214 ##########################################################
215 # Filling the epm file with directories, files and links
216 ##########################################################
218 sub put_directories_into_epmfile
220 my ($directoriesarrayref, $epmfileref, $allvariables, $packagerootpath) = @_;
221 my $group = "bin";
223 if ( $installer::globals::islinuxbuild )
225 $group = "root";
228 for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ )
230 my $onedir = ${$directoriesarrayref}[$i];
231 my $dir = "";
233 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
235 # if (!($dir =~ /\bPREDEFINED_/ ))
236 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
238 my $hostname = $onedir->{'HostName'};
240 # not including simple directory "/opt"
241 # if (( $allvariables->{'SETSTATICPATH'} ) && ( $hostname eq $packagerootpath )) { next; }
243 my $line = "d 755 root $group $hostname -\n";
245 push(@{$epmfileref}, $line)
250 sub put_files_into_epmfile
252 my ($filesinproductarrayref, $epmfileref) = @_;
254 for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ )
256 my $onefile = ${$filesinproductarrayref}[$i];
258 my $unixrights = $onefile->{'UnixRights'};
259 my $destination = $onefile->{'destination'};
260 my $sourcepath = $onefile->{'sourcepath'};
262 my $filetype = "f";
263 my $styles = "";
264 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
265 if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; }
267 my $group = "bin";
268 if ( $installer::globals::islinuxbuild ) { $group = "root"; }
269 if (( $installer::globals::issolarisbuild ) && ( $onefile->{'SolarisGroup'} )) { $group = $onefile->{'SolarisGroup'}; }
271 my $line = "$filetype $unixrights root $group $destination $sourcepath\n";
273 push(@{$epmfileref}, $line);
277 sub put_links_into_epmfile
279 my ($linksinproductarrayref, $epmfileref) = @_;
280 my $group = "bin";
282 if ( $installer::globals::islinuxbuild )
284 $group = "root";
288 for ( my $i = 0; $i <= $#{$linksinproductarrayref}; $i++ )
290 my $onelink = ${$linksinproductarrayref}[$i];
291 my $destination = $onelink->{'destination'};
292 my $destinationfile = $onelink->{'destinationfile'};
294 my $line = "l 000 root $group $destination $destinationfile\n";
296 push(@{$epmfileref}, $line)
300 sub put_unixlinks_into_epmfile
302 my ($unixlinksinproductarrayref, $epmfileref) = @_;
303 my $group = "bin";
305 if ( $installer::globals::islinuxbuild ) { $group = "root"; }
307 for ( my $i = 0; $i <= $#{$unixlinksinproductarrayref}; $i++ )
309 my $onelink = ${$unixlinksinproductarrayref}[$i];
310 my $destination = $onelink->{'destination'};
311 my $target = $onelink->{'Target'};
313 my $line = "l 000 root $group $destination $target\n";
315 push(@{$epmfileref}, $line)
319 ###############################################
320 # Creating epm header file
321 ###############################################
323 sub create_epm_header
325 my ($variableshashref, $filesinproduct, $languagesref, $onepackage) = @_;
327 my @epmheader = ();
329 my ($licensefilename, $readmefilename);
331 my $foundlicensefile = 0;
332 my $foundreadmefile = 0;
334 my $line = "";
335 my $infoline = "";
337 # %product OpenOffice.org Software
338 # %version 2.0
339 # %description A really great software
340 # %copyright 1999-2003 by OOo
341 # %vendor OpenOffice.org
342 # %license /test/replace/01/LICENSE01
343 # %readme /test/replace/01/README01
344 # %requires foo
345 # %provides bar
347 # The first language in the languages array determines the language of license and readme file
349 my $searchlanguage = ${$languagesref}[0];
351 # using the description for the %product line in the epm list file
353 my $productnamestring = $onepackage->{'description'};
354 installer::packagelist::resolve_packagevariables(\$productnamestring, $variableshashref, 0);
355 if ( $variableshashref->{'PRODUCTEXTENSION'} ) { $productnamestring = $productnamestring . " " . $variableshashref->{'PRODUCTEXTENSION'}; }
357 $line = "%product" . " " . $productnamestring . "\n";
358 push(@epmheader, $line);
360 # Determining the release version
361 # This release version has to be listed in the line %version : %version versionnumber releasenumber
363 # if ( $variableshashref->{'PACKAGEVERSION'} ) { $installer::globals::packageversion = $variableshashref->{'PACKAGEVERSION'}; }
364 if ( ! $onepackage->{'packageversion'} ) { installer::exiter::exit_program("ERROR: No packageversion defined for package: $onepackage->{'module'}!", "create_epm_header"); }
365 $installer::globals::packageversion = $onepackage->{'packageversion'};
366 installer::packagelist::resolve_packagevariables(\$installer::globals::packageversion, $variableshashref, 0);
367 if ( $variableshashref->{'PACKAGEREVISION'} ) { $installer::globals::packagerevision = $variableshashref->{'PACKAGEREVISION'}; }
369 $line = "%version" . " " . $installer::globals::packageversion . "\n";
370 push(@epmheader, $line);
372 $line = "%release" . " " . $installer::globals::packagerevision . "\n";
373 if ( $installer::globals::islinuxrpmbuild ) { $line = "%release" . " " . $installer::globals::buildid . "\n"; }
374 push(@epmheader, $line);
376 # Description, Copyright and Vendor are multilingual and are defined in
377 # the string file for the header file ($headerfileref)
379 my $descriptionstring = $onepackage->{'description'};
380 installer::packagelist::resolve_packagevariables(\$descriptionstring, $variableshashref, 0);
381 $line = "%description" . " " . $descriptionstring . "\n";
382 push(@epmheader, $line);
384 my $copyrightstring = $onepackage->{'copyright'};
385 installer::packagelist::resolve_packagevariables(\$copyrightstring, $variableshashref, 0);
386 $line = "%copyright" . " " . $copyrightstring . "\n";
387 push(@epmheader, $line);
389 my $vendorstring = $onepackage->{'vendor'};
390 installer::packagelist::resolve_packagevariables(\$vendorstring, $variableshashref, 0);
391 $line = "%vendor" . " " . $vendorstring . "\n";
392 push(@epmheader, $line);
394 # License and Readme file can be included automatically from the file list
396 if ( $installer::globals::iswindowsbuild )
398 $licensefilename = "license.txt";
399 $readmefilename = "readme.txt";
401 else
403 $licensefilename = "LICENSE";
404 $readmefilename = "README";
407 if (( $installer::globals::languagepack ) # in language packs the files LICENSE and README are removed, because they are not language specific
408 || ( $variableshashref->{'NO_README_IN_ROOTDIR'} ))
410 if ( $installer::globals::iswindowsbuild )
412 $licensefilename = "license_$searchlanguage.txt";
413 $readmefilename = "readme_$searchlanguage.txt";
415 else
417 $licensefilename = "LICENSE_$searchlanguage";
418 $readmefilename = "README_$searchlanguage";
422 my $license_in_package_defined = 0;
424 if ( $installer::globals::issolarisbuild )
426 if ( $onepackage->{'solariscopyright'} )
428 $licensefilename = $onepackage->{'solariscopyright'};
429 $license_in_package_defined = 1;
433 # searching for and readme file
435 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
437 my $onefile = ${$filesinproduct}[$i];
438 my $filename = $onefile->{'Name'};
439 if ( $filename eq $readmefilename )
441 $foundreadmefile = 1;
442 $line = "%readme" . " " . $onefile->{'sourcepath'} . "\n";
443 push(@epmheader, $line);
444 last;
448 # searching for and license file
450 if ( $license_in_package_defined )
452 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
454 if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename!", "create_epm_header"); }
456 # Special handling to add the content of the file "license_en-US" to the solaris copyrightfile
457 if ( $installer::globals::issolarispkgbuild )
459 if ( ! $installer::globals::englishlicenseset ) { installer::worker::set_english_license() }
461 # The location for the new file
462 my $languagestring = "";
463 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; }
464 $languagestring =~ s/^\s*_//;
466 my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring);
468 my $copyrightfile = installer::files::read_file($$fileref);
470 # Adding license content to copyright file
471 push(@{$copyrightfile}, "\n");
472 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
474 # New destination for $$fileref
475 $$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'};
476 if ( -f $$fileref ) { unlink $$fileref; }
477 installer::files::save_file($$fileref, $copyrightfile);
480 $infoline = "Using license file: \"$$fileref\"!\n";
481 push(@installer::globals::logfileinfo, $infoline);
483 $foundlicensefile = 1;
484 $line = "%license" . " " . $$fileref . "\n";
485 push(@epmheader, $line);
487 else
489 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
491 my $onefile = ${$filesinproduct}[$i];
492 my $filename = $onefile->{'Name'};
494 if ( $filename eq $licensefilename )
496 $foundlicensefile = 1;
497 $line = "%license" . " " . $onefile->{'sourcepath'} . "\n";
498 push(@epmheader, $line);
499 last;
504 if (!($foundlicensefile))
506 installer::exiter::exit_program("ERROR: Could not find license file $licensefilename", "create_epm_header");
509 if (!($foundreadmefile))
511 installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename", "create_epm_header");
514 # including %replaces
516 my $replaces = "";
518 if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch ))
520 $replaces = "solarisreplaces"; # the name in the packagelist
522 elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch ))
524 $replaces = "linuxreplaces"; # the name in the packagelist
527 if (( $replaces ) && ( ! $installer::globals::patch ))
529 if ( $onepackage->{$replaces} )
531 my $replacesstring = $onepackage->{$replaces};
533 my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ",");
535 for ( my $i = 0; $i <= $#{$allreplaces}; $i++ )
537 my $onereplaces = ${$allreplaces}[$i];
538 $onereplaces =~ s/\s*$//;
539 installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1);
540 if ( $installer::globals::linuxlinkrpmprocess ) { $onereplaces = $onereplaces . "u"; }
541 $line = "%replaces" . " " . $onereplaces . "\n";
542 push(@epmheader, $line);
544 # Force the openofficeorg packages to get removed,
545 # see http://www.debian.org/doc/debian-policy/ch-relationships.html
546 # 7.5.2 Replacing whole packages, forcing their removal
548 if ( $installer::globals::debian )
550 $line = "%incompat" . " " . $onereplaces . "\n";
551 push(@epmheader, $line);
555 if ( $installer::globals::debian && $variableshashref->{'UNIXPRODUCTNAME'} eq 'openoffice.org' )
557 $line = "%provides" . " openoffice.org-unbundled\n";
558 push(@epmheader, $line);
559 $line = "%incompat" . " openoffice.org-bundled\n";
560 push(@epmheader, $line);
565 # including the directives for %requires and %provides
567 my $provides = "";
568 my $requires = "";
570 if ( $installer::globals::issolarispkgbuild )
572 $provides = "solarisprovides"; # the name in the packagelist
573 $requires = "solarisrequires"; # the name in the packagelist
575 elsif ( $installer::globals::isfreebsdpkgbuild )
577 $provides = "freebsdprovides"; # the name in the packagelist
578 $requires = "freebsdrequires"; # the name in the packagelist
580 elsif (( $installer::globals::islinuxrpmbuild ) &&
581 ( $installer::globals::patch ) &&
582 ( exists($onepackage->{'linuxpatchrequires'}) ))
584 $provides = "provides"; # the name in the packagelist
585 $requires = "linuxpatchrequires"; # the name in the packagelist
587 else
589 $provides = "provides"; # the name in the packagelist
590 $requires = "requires"; # the name in the packagelist
593 # if ( $installer::globals::patch )
595 # $onepackage->{$provides} = "";
596 my $isdict = 0;
597 if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; }
599 # $onepackage->{$requires} = "";
602 if ( $onepackage->{$provides} )
604 my $providesstring = $onepackage->{$provides};
606 my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ",");
608 for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
610 my $oneprovides = ${$allprovides}[$i];
611 $oneprovides =~ s/\s*$//;
612 installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1);
613 if ( $installer::globals::linuxlinkrpmprocess ) { $oneprovides = $oneprovides . "u"; }
614 $line = "%provides" . " " . $oneprovides . "\n";
615 push(@epmheader, $line);
619 if ( $onepackage->{$requires} )
621 my $requiresstring = $onepackage->{$requires};
623 if ( $installer::globals::add_required_package ) { $requiresstring = $requiresstring . "," . $installer::globals::add_required_package; }
625 # The requires string can contain the separator "," in the names (descriptions) of the packages
626 # (that are required for Solaris depend files). Therefore "," inside such a description has to
627 # masked with a backslash.
628 # This masked separator need to be found and replaced, before the stringlist is converted into an array.
629 # This replacement has to be turned back after the array is created.
631 my $replacementstring = "COMMAREPLACEMENT";
632 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
634 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
636 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
638 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
640 my $onerequires = ${$allrequires}[$i];
641 $onerequires =~ s/\s*$//;
642 installer::packagelist::resolve_packagevariables2(\$onerequires, $variableshashref, 0, $isdict);
644 # Special handling for Solaris. In depend files, the names of the packages are required, not
645 # only the abbreviation. Therefore there is a special syntax for names in packagelist:
646 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
647 # if ( $installer::globals::issolarispkgbuild )
649 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
651 # $onerequires = $1;
652 # $packagename = $2;
653 # $installer::globals::dependfilenames{$onerequires} = $packagename;
657 $line = "%requires" . " " . $onerequires . "\n";
658 push(@epmheader, $line);
661 else
663 if ( $installer::globals::add_required_package )
665 my $requiresstring = $installer::globals::add_required_package;
667 my $replacementstring = "COMMAREPLACEMENT";
668 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
669 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
670 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
672 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
674 my $onerequires = ${$allrequires}[$i];
675 $onerequires =~ s/\s*$//;
676 installer::packagelist::resolve_packagevariables(\$onerequires, $variableshashref, 0);
678 # Special handling for Solaris. In depend files, the names of the packages are required, not
679 # only the abbreviation. Therefore there is a special syntax for names in packagelist:
680 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
681 # if ( $installer::globals::issolarispkgbuild )
683 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
685 # $onerequires = $1;
686 # $packagename = $2;
687 # $installer::globals::dependfilenames{$onerequires} = $packagename;
691 $line = "%requires" . " " . $onerequires . "\n";
692 push(@epmheader, $line);
697 return \@epmheader;
700 #######################################
701 # Adding header to epm file
702 #######################################
704 sub adding_header_to_epm_file
706 my ($epmfileref, $epmheaderref) = @_;
708 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
710 push( @{$epmfileref}, ${$epmheaderref}[$i] );
713 push( @{$epmfileref}, "\n\n" );
716 #####################################################
717 # Replace one in shell scripts ( ${VARIABLENAME} )
718 #####################################################
720 sub replace_variable_in_shellscripts
722 my ($scriptref, $variable, $searchstring) = @_;
724 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
726 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
730 ###################################################
731 # Replace one in shell scripts ( %VARIABLENAME )
732 ###################################################
734 sub replace_percent_variable_in_shellscripts
736 my ($scriptref, $variable, $searchstring) = @_;
738 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
740 ${$scriptref}[$i] =~ s/\%$searchstring/$variable/g;
744 ################################################
745 # Replacing many variables in shell scripts
746 ################################################
748 sub replace_many_variables_in_shellscripts
750 my ($scriptref, $variableshashref) = @_;
752 my $key;
754 foreach $key (keys %{$variableshashref})
756 my $value = $variableshashref->{$key};
757 if ( ! $value =~ /.oxt/ ) { $value = lc($value); } # lowercase !
758 if ( $installer::globals::issolarisbuild) { $value =~ s/\.org/org/g; } # openofficeorg instead of openoffice.org
759 replace_variable_in_shellscripts($scriptref, $value, $key);
763 #######################################
764 # Setting oxt file name variable
765 #######################################
767 sub set_oxt_filename
769 my ($filesinpackage, $allvariables) = @_;
771 for ( my $i = 0; $i <= $#{$filesinpackage}; $i++ )
773 my $onefile = ${$filesinpackage}[$i];
774 if ( $onefile->{'Name'} =~ /.oxt\s*$/ )
776 $allvariables->{'OXTFILENAME'} = $onefile->{'Name'};
777 # $allvariables->{'FULLOXTFILENAME'} = $onefile->{'destination'};
778 last; # only one oxt file for each rpm!
783 #######################################
784 # Adding shell scripts to epm file
785 #######################################
787 sub adding_shellscripts_to_epm_file
789 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
791 # Setting variable for ${OXTFILENAME} into $allvariableshashref, if this is a RPM with an extension
792 set_oxt_filename($filesinpackage, $allvariableshashref);
794 # $installer::globals::shellscriptsfilename
796 push( @{$epmfileref}, "\n\n" );
798 my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename);
800 replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath");
802 replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref);
804 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
806 push( @{$epmfileref}, ${$shellscriptsfileref}[$i] );
809 push( @{$epmfileref}, "\n" );
812 #################################################
813 # Determining the epm on the system
814 #################################################
816 sub find_epm_on_system
818 my ($includepatharrayref) = @_;
820 installer::logger::include_header_into_logfile("Check epm on system");
822 my $epmname = "epm";
824 # epm should be defined through the configure script but we need to
825 # check for it to be defined because of the Sun environment.
826 # Check the environment variable first and if it is not defined,
827 # or if it is but the location is not executable, search further.
828 # It has to be found in the solver or it has to be in the path
829 # (saved in $installer::globals::epm_in_path) or we get the specified
830 # one through the environment (i.e. when --with-epm=... is specified)
832 if ($ENV{'EPM'})
834 if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}"))
836 $epmname = $ENV{'EPM'};
838 elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") )
840 $epmname = "epm";
841 my $epmref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$epmname, $includepatharrayref, 0);
842 if ($$epmref eq "") { installer::exiter::exit_program("ERROR: Could not find program $epmname (EPM set to \"internal\" or \"no\")!", "find_epm_on_system"); }
843 $epmname = $$epmref;
845 else
847 installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
850 else
852 my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0);
854 if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
855 if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; }
856 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
859 my $infoline = "Using epmfile: $epmname\n";
860 push( @installer::globals::logfileinfo, $infoline);
862 return $epmname;
865 #################################################
866 # Determining the epm patch state
867 # saved in $installer::globals::is_special_epm
868 #################################################
870 sub set_patch_state
872 my ($epmexecutable) = @_;
874 my $infoline = "";
876 my $systemcall = "$epmexecutable |";
877 open (EPMPATCH, "$systemcall");
879 while (<EPMPATCH>)
881 chop;
882 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals::is_special_epm = 1; }
885 close (EPMPATCH);
887 if ( $installer::globals::is_special_epm )
889 $infoline = "\nPatch state: This is a patched version of epm!\n\n";
890 push( @installer::globals::logfileinfo, $infoline);
892 else
894 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
895 push( @installer::globals::logfileinfo, $infoline);
898 if ( ( $installer::globals::is_special_epm ) && (($installer::globals::islinuxrpmbuild) || ($installer::globals::issolarispkgbuild)) )
900 # Special postprocess handling only for Linux RPM and Solaris packages
901 $installer::globals::postprocess_specialepm = 1;
902 $installer::globals::postprocess_standardepm = 0;
904 else
906 $installer::globals::postprocess_specialepm = 0;
907 $installer::globals::postprocess_standardepm = 1;
911 #################################################
912 # LD_PRELOAD string for Debian packages
913 #################################################
915 sub get_ld_preload_string
917 my ($includepatharrayref) = @_;
919 my $getuidlibraryname = "getuid.so";
921 my $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0);
922 if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); }
924 my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
926 return $ldpreloadstring;
929 #################################################
930 # Calling epm to create the installation sets
931 #################################################
933 sub call_epm
935 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
937 installer::logger::include_header_into_logfile("epm call for $packagename");
939 my $packageformat = $installer::globals::packageformat;
941 my $localpackagename = $packagename;
942 # Debian allows only lowercase letters in package name
943 if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); }
945 my $outdirstring = "";
946 if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
948 # Debian package build needs a LD_PRELOAD for correct rights
950 my $ldpreloadstring = "";
952 if ( $installer::globals::debian ) { $ldpreloadstring = get_ld_preload_string($includepatharrayref) . " "; }
954 my $extraflags = "";
955 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
957 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " -v " . " 2\>\&1 |";
959 installer::logger::print_message( "... $systemcall ...\n" );
961 my $maxepmcalls = 3;
963 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
965 my @epmoutput = ();
967 open (EPM, "$systemcall");
968 while (<EPM>) {push(@epmoutput, $_); }
969 close (EPM);
971 my $returnvalue = $?; # $? contains the return value of the systemcall
973 my $infoline = "Systemcall (Try $i): $systemcall\n";
974 push( @installer::globals::logfileinfo, $infoline);
976 for ( my $j = 0; $j <= $#epmoutput; $j++ )
978 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
979 push( @installer::globals::logfileinfo, "$epmoutput[$j]");
982 if ($returnvalue)
984 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
985 push( @installer::globals::logfileinfo, $infoline);
986 if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); }
988 else
990 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
991 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
992 push( @installer::globals::logfileinfo, $infoline);
993 last;
998 #####################################################################
999 # Adding the new line for relocatables into pkginfo file (Solaris)
1000 # or spec file (Linux) created by epm
1001 #####################################################################
1003 sub add_one_line_into_file
1005 my ($file, $insertline, $filename) = @_;
1007 if ( $installer::globals::issolarispkgbuild )
1009 push(@{$file}, $insertline); # simply adding at the end of pkginfo file
1012 if ( $installer::globals::islinuxrpmbuild )
1014 # Adding behind the line beginning with: Group:
1016 my $inserted_line = 0;
1018 for ( my $i = 0; $i <= $#{$file}; $i++ )
1020 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
1022 splice(@{$file},$i+1,0,$insertline);
1023 $inserted_line = 1;
1024 last;
1028 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
1031 $insertline =~ s/\s*$//; # removing line end for correct logging
1032 my $infoline = "Success: Added line $insertline into file $filename!\n";
1033 push( @installer::globals::logfileinfo, $infoline);
1036 #####################################################################
1037 # Setting the revision VERSION=1.9,REV=66 .
1038 # Also adding the new line: "AutoReqProv: no"
1039 #####################################################################
1041 sub set_revision_in_pkginfo
1043 my ($file, $filename, $variables, $packagename) = @_;
1045 my $revisionstring = "\,REV\=" . $installer::globals::packagerevision;
1047 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
1049 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
1051 $mday = $mday;
1052 $mon = $mon + 1;
1053 $year = $year + 1900;
1055 if ( $mday < 10 ) { $mday = "0" . $mday; }
1056 if ( $mon < 10 ) { $mon = "0" . $mon; }
1057 $datestring = $year . "." . $mon . "." . $mday;
1058 $revisionstring = $revisionstring . "." . $datestring;
1060 for ( my $i = 0; $i <= $#{$file}; $i++ )
1062 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
1064 my $oldstring = $1;
1065 my $newstring = $oldstring . $revisionstring; # also adding the date string
1066 ${$file}[$i] =~ s/$oldstring/$newstring/;
1067 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1068 push( @installer::globals::logfileinfo, $infoline);
1069 last;
1073 # For Update and Patch reasons, this string can also be kept constant
1075 my $pkgversion = "SOLSPARCPKGVERSION";
1076 if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; }
1078 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
1080 if ( $variables->{$pkgversion} ne "FINALVERSION" )
1082 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
1083 # In the string: "3.0.0,REV=9.2008.09.30" only the part "REV=9.2008.09.30" can be unique for all packages
1084 # and therefore be set as $pkgversion.
1085 # The first part "3.0.0" has to be derived from the
1087 my $version = $installer::globals::packageversion;
1088 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
1090 my $major = $1;
1091 my $minor = $2;
1092 my $micro = $3;
1094 my $finalmajor = $major;
1095 my $finalminor = $minor;
1096 my $finalmicro = 0;
1098 # if (( $packagename =~ /-ure\s*$/ ) && ( $finalmajor == 1 )) { $finalminor = 4; }
1100 $version = "$finalmajor.$finalminor.$finalmicro";
1103 my $versionstring = "$version,$variables->{$pkgversion}";
1105 for ( my $i = 0; $i <= $#{$file}; $i++ )
1107 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
1109 my $start = $1;
1110 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
1111 my $oldstring = ${$file}[$i];
1112 ${$file}[$i] = $newstring;
1113 $oldstring =~ s/\s*$//;
1114 $newstring =~ s/\s*$//;
1115 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1116 push( @installer::globals::logfileinfo, $infoline);
1117 last;
1124 ########################################################
1125 # Setting Patch information for Respin versions
1126 # into pkginfo file. This prevents Respin versions
1127 # from patching.
1128 ########################################################
1130 sub set_patchlist_in_pkginfo_for_respin
1132 my ($changefile, $filename, $allvariables, $packagename) = @_;
1134 my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN";
1135 if ( $installer::globals::issolarisx86build ) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; }
1137 if ( $allvariables->{$patchlistname} )
1139 # patchlist separator is a blank
1140 my $allpatchesstring = $allvariables->{$patchlistname};
1141 my @usedpatches = ();
1143 # Analyzing the patchlist
1144 # Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01
1145 # Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01
1146 my $allpatches = installer::converter::convert_whitespace_stringlist_into_array(\$allpatchesstring);
1148 for ( my $i = 0; $i <= $#{$allpatches}; $i++ )
1150 my $patchdefinition = ${$allpatches}[$i];
1152 my $patchid = "";
1153 my $symbol = "";
1154 my $constraint = "";
1155 my $isusedpatch = 0;
1157 if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ )
1159 $patchid = $1;
1160 $symbol = $2;
1161 $constraint = $3;
1163 elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ )) # small syntax check
1165 # if there is a bracket in the $patchdefinition, but it does not
1166 # match the if-condition, this is an erroneous definition.
1167 installer::exiter::exit_program("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin");
1169 else
1171 $patchid = $patchdefinition;
1172 $isusedpatch = 1; # patches without constraint are always included
1175 if ( $symbol ne "" )
1177 if ( $symbol eq "+" )
1179 if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; }
1182 if ( $symbol eq "-" )
1184 if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; }
1188 if ( $isusedpatch ) { push(@usedpatches, $patchid); }
1191 if ( $#usedpatches > -1 )
1193 my $patchstring = installer::converter::convert_array_to_space_separated_string(\@usedpatches);
1195 my $newline = "PATCHLIST=" . $patchstring . "\n";
1196 add_one_line_into_file($changefile, $newline, $filename);
1198 # Adding patch info for each used patch in the patchlist
1200 for ( my $i = 0; $i <= $#usedpatches; $i++ )
1202 my $patchid = $usedpatches[$i];
1203 my $key = "PATCH_INFO_" . $patchid;
1204 $key =~ s/\s*$//;
1206 if ( ! $allvariables->{$key} ) { installer::exiter::exit_program("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); }
1207 my $value = set_timestamp_in_patchinfo($allvariables->{$key});
1208 $newline = $key . "=" . $value . "\n";
1210 add_one_line_into_file($changefile, $newline, $filename);
1216 ########################################################
1217 # Solaris requires, that the time of patch installation
1218 # must not be empty.
1219 # Format: Mon Mar 24 11:20:56 PDT 2008
1220 # Log file: Tue Apr 29 23:26:19 2008 (04:31 min.)
1221 # Replace string: ${TIMESTAMP}
1222 ########################################################
1224 sub set_timestamp_in_patchinfo
1226 my ($value) = @_;
1228 my $currenttime = localtime();
1230 if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ )
1232 my $start = $1;
1233 my $year = $2;
1234 $currenttime = $start . "CET " . $year;
1237 $value =~ s/\$\{TIMESTAMP\}/$currenttime/;
1239 return $value;
1242 ########################################################
1243 # Setting MAXINST=1000 into the pkginfo file.
1244 ########################################################
1246 sub set_maxinst_in_pkginfo
1248 my ($changefile, $filename) = @_;
1250 my $newline = "MAXINST\=1000\n";
1252 add_one_line_into_file($changefile, $newline, $filename);
1255 #############################################################
1256 # Setting several Solaris variables into the pkginfo file.
1257 #############################################################
1259 sub set_solaris_parameter_in_pkginfo
1261 my ($changefile, $filename, $allvariables) = @_;
1263 my $newline = "";
1265 # SUNW_PRODNAME
1266 # SUNW_PRODVERS
1267 # SUNW_PKGVERS
1268 # Not: SUNW_PKGTYPE
1269 # HOTLINE
1270 # EMAIL
1272 my $productname = $allvariables->{'PRODUCTNAME'};
1273 $newline = "SUNW_PRODNAME=$productname\n";
1274 add_one_line_into_file($changefile, $newline, $filename);
1276 my $productversion = "";
1277 if ( $allvariables->{'PRODUCTVERSION'} )
1279 $productversion = $allvariables->{'PRODUCTVERSION'};
1280 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1282 $newline = "SUNW_PRODVERS=$productversion\n";
1283 add_one_line_into_file($changefile, $newline, $filename);
1285 $newline = "SUNW_PKGVERS=1\.0\n";
1286 add_one_line_into_file($changefile, $newline, $filename);
1288 if ( $allvariables->{'SUNW_PKGTYPE'} )
1290 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1291 add_one_line_into_file($changefile, $newline, $filename);
1293 else
1295 $newline = "SUNW_PKGTYPE=\n";
1296 add_one_line_into_file($changefile, $newline, $filename);
1299 $newline = "HOTLINE=Please contact your local service provider\n";
1300 add_one_line_into_file($changefile, $newline, $filename);
1302 $newline = "EMAIL=\n";
1303 add_one_line_into_file($changefile, $newline, $filename);
1307 #####################################################################
1308 # epm uses as archtecture for Solaris x86 "i86pc". This has to be
1309 # changed to "i386".
1310 #####################################################################
1312 sub fix_architecture_setting
1314 my ($changefile) = @_;
1316 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1318 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1320 ${$changefile}[$i] =~ s/i86pc/i386/;
1321 last;
1327 #####################################################################
1328 # Adding a new line for topdir into specfile, removing old
1329 # topdir if set.
1330 #####################################################################
1332 sub set_topdir_in_specfile
1334 my ($changefile, $filename, $newepmdir) = @_;
1336 # $newepmdir =~ s/^\s*\.//; # removing leading "."
1337 $newepmdir = cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed
1339 # removing "%define _topdir", if existing
1341 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1343 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1345 my $removeline = ${$changefile}[$i];
1346 $removeline =~ s/\s*$//;
1347 splice(@{$changefile},$i,1);
1348 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1349 push( @installer::globals::logfileinfo, $infoline);
1350 last;
1354 # Adding "topdir" behind the line beginning with: Group:
1356 my $inserted_line = 0;
1358 my $topdirline = "\%define _topdir $newepmdir\n";
1360 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1362 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1364 splice(@{$changefile},$i+1,0,$topdirline);
1365 $inserted_line = 1;
1366 $topdirline =~ s/\s*$//;
1367 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1368 push( @installer::globals::logfileinfo, $infoline);
1372 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1376 #####################################################################
1377 # Setting the packager in the spec file
1378 # Syntax: Packager: abc@def
1379 #####################################################################
1381 sub set_packager_in_specfile
1383 my ($changefile) = @_;
1385 my $packager = $installer::globals::longmanufacturer;
1387 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1389 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1391 my $oldstring = $1;
1392 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1393 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1394 push( @installer::globals::logfileinfo, $infoline);
1395 last;
1400 #####################################################################
1401 # Setting the requirements in the spec file (i81494)
1402 # Syntax: PreReq: "requirements" (only for shared extensions)
1403 #####################################################################
1405 sub set_prereq_in_specfile
1407 my ($changefile) = @_;
1409 my $prereq = "PreReq:";
1411 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1413 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1415 my $oldstring = ${$changefile}[$i];
1416 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1417 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1418 push( @installer::globals::logfileinfo, $infoline);
1423 #####################################################################
1424 # Setting the Auto[Req]Prov line and __find_requires
1425 #####################################################################
1427 sub set_autoprovreq_in_specfile
1429 my ($changefile, $findrequires, $bindir) = @_;
1431 my $autoreqprovline;
1433 if ( $findrequires )
1435 $autoreqprovline = "AutoProv\: no\n%define __find_requires $bindir/$findrequires\n";
1437 else
1439 $autoreqprovline = "AutoReqProv\: no\n";
1442 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1444 # Adding "autoreqprov" behind the line beginning with: Group:
1445 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1447 splice(@{$changefile},$i+1,0,$autoreqprovline);
1448 $autoreqprovline =~ s/\s*$//;
1449 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1450 push( @installer::globals::logfileinfo, $infoline);
1452 last;
1457 #####################################################################
1458 # Replacing Copyright with License in the spec file
1459 # Syntax: License: LGPL, SISSL
1460 #####################################################################
1462 sub set_license_in_specfile
1464 my ($changefile, $variableshashref) = @_;
1466 my $license = $variableshashref->{'LICENSENAME'};
1468 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1470 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1472 ${$changefile}[$i] = "License: $license\n";
1473 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1474 push( @installer::globals::logfileinfo, $infoline);
1475 last;
1480 #########################################################
1481 # Building relocatable Solaris packages means:
1482 # 1. Add "BASEDIR=/opt" into pkginfo
1483 # 2. Remove "/opt/" from all objects in prototype file
1484 # For step2 this function exists
1485 # Sample: d none /opt/openofficeorg20/help 0755 root other
1486 # -> d none openofficeorg20/help 0755 root other
1487 #########################################################
1489 sub make_prototypefile_relocatable
1491 my ($prototypefile, $relocatablepath) = @_;
1493 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1495 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line
1497 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1501 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1502 # This line has to be removed now
1504 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash
1506 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1508 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1510 my $line = ${$prototypefile}[$i];
1511 splice(@{$prototypefile},$i,1); # removing the line
1512 $line =~ s/\s*$//;
1513 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1514 push( @installer::globals::logfileinfo, $infoline);
1515 last;
1519 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1521 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1523 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1525 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1526 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1527 push( @installer::globals::logfileinfo, $infoline2);
1533 #########################################################################
1534 # In scp the flag VOLATEFILE can be used. This shall lead to style "v"
1535 # in Solaris prototype file. This is not supported by epm and has
1536 # therefore to be included in prototypefile, not in epm list file.
1537 #########################################################################
1539 sub set_volatilefile_into_prototypefile
1541 my ($prototypefile, $filesref) = @_;
1543 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1545 my $onefile = ${$filesref}[$i];
1547 my $styles = "";
1548 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1550 if ( $styles =~ /\bVOLATILEFILE\b/ )
1552 my $sourcepath = $onefile->{'sourcepath'};
1554 for ( my $j = 0; $j <= $#{$prototypefile}; $j++ )
1556 if (( ${$prototypefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$prototypefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1558 my $oldline = ${$prototypefile}[$j];
1559 ${$prototypefile}[$j] =~ s/^\s*f/v/;
1560 my $newline = ${$prototypefile}[$j];
1561 $oldline =~ s/\s*$//;
1562 $newline =~ s/\s*$//;
1563 my $infoline = "Volatile file: Changing content from \"$oldline\" to \"$newline\" .\n";
1564 push(@installer::globals::logfileinfo, $infoline);
1565 last;
1572 #########################################################################
1573 # Replacing the variables in the Solaris patch shell scripts.
1574 # Taking care, that multiple slashes are not always removed.
1575 #########################################################################
1577 sub replace_variables_in_shellscripts_for_patch
1579 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1581 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1583 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1585 my $oldline = ${$scriptfile}[$i];
1586 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; }
1587 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1588 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1589 push(@installer::globals::logfileinfo, $infoline);
1594 #########################################################################
1595 # Replacing the variables in the shell scripts or in the epm list file
1596 # Linux: spec file
1597 # Solaris: preinstall, postinstall, preremove, postremove
1598 # If epm is used in the original version (not relocatable)
1599 # the variables have to be exchanged in the list file,
1600 # created for epm.
1601 #########################################################################
1603 sub replace_variables_in_shellscripts
1605 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1607 my $debug = 0;
1608 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1610 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1612 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1614 my $oldline = ${$scriptfile}[$i];
1615 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1616 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1617 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1618 push(@installer::globals::logfileinfo, $infoline);
1619 if ( $debug )
1621 $infoline = "Old Line: $oldline";
1622 push(@installer::globals::logfileinfo, $infoline);
1623 $infoline = "New Line: ${$scriptfile}[$i]";
1624 push(@installer::globals::logfileinfo, $infoline);
1630 ############################################################
1631 # Determinig the directory created by epm, in which the
1632 # RPMS or Solaris packages are created.
1633 ############################################################
1635 sub determine_installdir_ooo
1637 # A simple "ls" command returns the directory name
1639 my $dirname = "";
1641 my $systemcall = "ls |";
1642 open (LS, "$systemcall");
1643 $dirname = <LS>;
1644 close (LS);
1646 $dirname =~ s/\s*$//;
1648 my $infoline = "Info: Directory created by epm: $dirname\n";
1649 push(@installer::globals::logfileinfo, $infoline);
1651 return $dirname;
1654 ############################################################
1655 # Setting the tab content into the file container
1656 ############################################################
1658 sub set_tab_into_datafile
1660 my ($changefile, $filesref) = @_;
1662 my @newclasses = ();
1663 my $newclassesstring = "";
1665 if ( $installer::globals::issolarispkgbuild )
1667 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1669 my $onefile = ${$filesref}[$i];
1671 if ( $onefile->{'SolarisClass'} )
1673 my $sourcepath = $onefile->{'sourcepath'};
1675 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1677 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1679 my $oldline = ${$changefile}[$j];
1680 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1681 my $newline = ${$changefile}[$j];
1682 $oldline =~ s/\s*$//;
1683 $newline =~ s/\s*$//;
1685 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1686 push(@installer::globals::logfileinfo, $infoline);
1688 # collecting all new classes
1689 if (! installer::existence::exists_in_array($onefile->{'SolarisClass'}, \@newclasses))
1691 push(@newclasses, $onefile->{'SolarisClass'});
1694 last;
1700 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1703 if ( $installer::globals::islinuxrpmbuild )
1705 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1707 my $onefile = ${$filesref}[$i];
1709 if ( $onefile->{'SpecFileContent'} )
1711 my $destination = $onefile->{'destination'};
1713 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1715 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1717 my $begin = $1;
1718 my $end = $2;
1720 my $oldline = ${$changefile}[$j];
1721 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1722 my $newline = ${$changefile}[$j];
1724 $oldline =~ s/\s*$//;
1725 $newline =~ s/\s*$//;
1727 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1728 push(@installer::globals::logfileinfo, $infoline);
1730 last;
1737 return $newclassesstring;
1740 ############################################################
1741 # Including additional classes into the pkginfo file
1742 ############################################################
1744 sub include_classes_into_pkginfo
1746 my ($changefile, $classesstring) = @_;
1748 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1750 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1752 ${$changefile}[$i] =~ s/\s*$//;
1753 my $oldline = ${$changefile}[$i];
1754 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1755 my $newline = ${$changefile}[$i];
1756 $newline =~ s/\s*$//;
1758 my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n";
1759 push(@installer::globals::logfileinfo, $infoline);
1764 ##########################################################################################
1765 # Checking, if an extension is included into the package (Linux).
1766 # All extension files have to be installed into directory
1767 # share/extension/install
1768 # %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt"
1769 ##########################################################################################
1771 sub is_extension_package
1773 my ($specfile) = @_;
1775 my $is_extension_package = 0;
1777 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1779 my $line = ${$specfile}[$i];
1780 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1782 $is_extension_package = 1;
1783 last;
1787 return $is_extension_package;
1790 ######################################################################
1791 # Checking, if an extension is included into the package (Solaris).
1792 # All extension files have to be installed into directory
1793 # share/extension/install
1794 ######################################################################
1796 sub get_extension_name
1798 my ($prototypefile) = @_;
1800 my $extensionName = "";
1802 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1804 my $line = ${$prototypefile}[$i];
1805 if ( $line =~ /^\s*f\s+none\s+share\/extension\/install\/(\w+?\.oxt)\s*\=/ )
1807 $extensionName = $1;
1808 last;
1812 return $extensionName;
1816 ############################################################
1817 # A Solaris patch contains 7 specific scripts
1818 ############################################################
1820 sub add_scripts_into_prototypefile
1822 my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_;
1824 # The files are stored in the directory $installer::globals::patchincludepath
1825 # The file names are available via @installer::globals::solarispatchscripts
1827 my $path = $installer::globals::patchincludepath;
1828 $path =~ s/\/\s*$//;
1829 $path = $path . $installer::globals::separator;
1831 my @newlines = ();
1832 my $extensionname = get_extension_name($prototypefile);
1834 if ( $extensionname ne "" )
1836 for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ )
1838 my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i];
1839 my $destfile = $installer::globals::solarispatchscriptsforextensions[$i];
1841 # If the sourcepath has "_extension" in its name, this has to be removed
1842 $destfile =~ s/_extensions\s*$//; # hard coded renaming of script name
1844 # Creating unique directory name with $prototypefilename
1845 my $extensiondir = installer::systemactions::create_directories("extensionscripts", $languagestringref);
1847 if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; }
1848 $prototypefilename =~ s/\./_/g;
1849 my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename;
1850 if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); }
1851 my $destpath = $destdir . $installer::globals::separator . $destfile;
1852 if ( -f $destpath ) { unlink($destpath); }
1854 # Reading file
1855 my $scriptfile = installer::files::read_file($sourcefilename);
1857 # Replacing variables
1858 my $oldstring = "\$\{OXTFILENAME\}";
1859 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $extensionname);
1860 $oldstring = "PRODUCTDIRECTORYNAME";
1861 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath);
1863 # Saving file
1864 installer::files::save_file($destpath, $scriptfile);
1866 # Writing file destination into prototype file
1867 my $line = "i $destfile=" . $destpath . "\n";
1868 push(@newlines, $line);
1871 else
1873 for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ )
1875 my $line = "i $installer::globals::solarispatchscripts[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n";
1876 push(@newlines, $line);
1880 # Including the new lines after the last line starting with "i"
1882 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1884 if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ )
1886 splice(@{$prototypefile}, $i, 1); # ignoring old copyright text, using patch standard
1887 next;
1889 if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; }
1890 splice(@{$prototypefile}, $i, 0, @newlines);
1891 last;
1895 ############################################################
1896 # Adding patch infos in pkginfo file
1897 ############################################################
1899 sub include_patchinfos_into_pkginfo
1901 my ( $changefile, $filename, $variableshashref ) = @_;
1903 # SUNW_PATCHID=101998-10
1904 # SUNW_OBSOLETES=114999-01 113999-01
1905 # SUNW_PKGTYPE=usr
1906 # SUNW_PKGVERS=1.0
1907 # SUNW_REQUIRES=126411-01
1909 my $patchidname = "SOLSPARCPATCHID";
1910 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; }
1912 if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "include_patchinfos_into_pkginfo"); }
1914 my $newline = "SUNW_PATCHID=" . $variableshashref->{$patchidname} . "\n";
1915 add_one_line_into_file($changefile, $newline, $filename);
1917 my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES";
1918 if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES"; }
1920 my $obsoletes = "";
1921 if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; }
1922 $newline = "SUNW_OBSOLETES=" . $obsoletes . "\n";
1923 add_one_line_into_file($changefile, $newline, $filename);
1925 my $patchrequiresname = "SOLSPARCPATCHREQUIRES";
1926 if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES"; }
1928 if ( $variableshashref->{$patchrequiresname} )
1930 my $requires = $variableshashref->{$patchrequiresname};
1931 $newline = "SUNW_REQUIRES=" . $requires . "\n";
1932 add_one_line_into_file($changefile, $newline, $filename);
1934 $newline = "SUNW_PATCH_PROPERTIES=\n";
1935 add_one_line_into_file($changefile, $newline, $filename);
1936 # $newline = "SUNW_PKGTYPE=usr\n";
1937 # add_one_line_into_file($changefile, $newline, $filename);
1939 # $newline = "SUNW_PKGVERS=1.0\n";
1940 # add_one_line_into_file($changefile, $newline, $filename);
1943 ############################################################
1944 # Setting the correct Solaris locales
1945 ############################################################
1947 sub get_solaris_language_for_langpack
1949 my ( $onelanguage ) = @_;
1951 my $sollanguage = $onelanguage;
1952 $sollanguage =~ s/\-/\_/;
1954 if ( $sollanguage eq "de" ) { $sollanguage = "de"; }
1955 elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; }
1956 elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; }
1957 elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; }
1958 elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; }
1959 elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; }
1960 elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; }
1961 elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; }
1962 elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; }
1963 elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; }
1964 elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; }
1965 elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; }
1966 elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; }
1967 elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; }
1968 elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; }
1969 elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; }
1971 return $sollanguage;
1974 ############################################################
1975 # Adding language infos in pkginfo file
1976 ############################################################
1978 sub include_languageinfos_into_pkginfo
1980 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1982 # SUNWPKG_LIST=core01
1983 # SUNW_LOC=de
1985 my $locallang = $onepackage->{'language'};
1986 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1988 my $newline = "SUNW_LOC=" . $solarislanguage . "\n";
1989 add_one_line_into_file($changefile, $newline, $filename);
1991 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1992 if ( $onepackage->{'pkg_list_entry'} )
1994 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1995 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1996 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1997 add_one_line_into_file($changefile, $newline, $filename);
1999 else
2001 # Using default package ooobasis30-core01.
2002 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01";
2003 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
2004 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
2005 add_one_line_into_file($changefile, $newline, $filename);
2009 ############################################################
2010 # Collecting all files included in patch in
2011 # @installer::globals::patchfilecollector
2012 ############################################################
2014 sub collect_patch_files
2016 my ($file, $packagename, $prefix) = @_;
2018 # $file is the spec file or the prototypefile
2020 $prefix = $prefix . "/";
2021 my $packagenamestring = "Package " . $packagename . " \:\n";
2022 push(@installer::globals::patchfilecollector, $packagenamestring);
2024 for ( my $i = 0; $i <= $#{$file}; $i++ )
2026 my $line = ${$file}[$i];
2028 if ( $installer::globals::islinuxrpmbuild )
2030 # %attr(0444,root,root) "/opt/openofficeorg20/program/about.bmp"
2032 if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ )
2034 my $filename = $1 . "\n";
2035 $filename =~ s/^\s*\Q$prefix\E//;
2036 push(@installer::globals::patchfilecollector, $filename);
2040 if ( $installer::globals::issolarispkgbuild )
2042 # f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin
2044 if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ )
2046 my $filename = $1 . "\n";
2047 push(@installer::globals::patchfilecollector, $filename);
2052 push(@installer::globals::patchfilecollector, "\n");
2056 ############################################################
2057 # Including package names into the depend files.
2058 # The package names have to be included into
2059 # packagelist. They are already saved in
2060 # %installer::globals::dependfilenames.
2061 ############################################################
2063 sub put_packagenames_into_dependfile
2065 my ( $file ) = @_;
2067 for ( my $i = 0; $i <= $#{$file}; $i++ )
2069 my $line = ${$file}[$i];
2070 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
2072 my $abbreviation = $1;
2074 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); }
2076 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
2078 my $packagename = $installer::globals::dependfilenames{$abbreviation};
2079 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); }
2081 $line =~ s/\s*$//;
2082 ${$file}[$i] = $line . "\t" . $packagename . "\n";
2084 else
2086 installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile");
2092 ############################################################
2093 # Including the relocatable directory into
2094 # spec file and pkginfo file
2095 # Linux: set topdir in specfile
2096 # Solaris: remove $relocatablepath (/opt/)
2097 # for all objects in prototype file
2098 # and changing "topdir" for Linux
2099 ############################################################
2101 sub prepare_packages
2103 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
2105 my $filename = "";
2106 my $newline = "";
2107 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
2109 my $localrelocatablepath = $relocatablepath;
2110 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; }
2112 if ( $installer::globals::issolarispkgbuild )
2114 $filename = $packagename . ".pkginfo";
2115 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
2118 if ( $installer::globals::islinuxrpmbuild )
2120 # if ( $localrelocatablepath =~ /^\s*$/ ) { $localrelocatablepath = "/"; }; # at least the "/"
2121 $filename = $packagename . ".spec";
2122 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
2125 my $completefilename = $newepmdir . $filename;
2127 if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); }
2128 my $changefile = installer::files::read_file($completefilename);
2129 if ( $newline ne "" )
2131 add_one_line_into_file($changefile, $newline, $filename);
2132 installer::files::save_file($completefilename, $changefile);
2135 # my $newepmdir = $completefilename;
2136 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$newepmdir);
2138 # adding new "topdir" and removing old "topdir" in specfile
2140 if ( $installer::globals::islinuxrpmbuild )
2142 set_topdir_in_specfile($changefile, $filename, $newepmdir);
2143 set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin");
2144 set_packager_in_specfile($changefile);
2145 if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); }
2146 set_license_in_specfile($changefile, $variableshashref);
2147 set_tab_into_datafile($changefile, $filesref);
2148 # check_requirements_in_specfile($changefile);
2149 installer::files::save_file($completefilename, $changefile);
2150 if ( $installer::globals::patch ) { collect_patch_files($changefile, $packagename, $localrelocatablepath); }
2153 # removing the relocatable path in prototype file
2155 if ( $installer::globals::issolarispkgbuild )
2157 set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename);
2158 set_maxinst_in_pkginfo($changefile, $filename);
2159 set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref);
2160 if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); }
2161 if ( ! $installer::globals::patch ) { set_patchlist_in_pkginfo_for_respin($changefile, $filename, $variableshashref, $packagename); }
2162 if ( $installer::globals::patch ) { include_patchinfos_into_pkginfo($changefile, $filename, $variableshashref); }
2163 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
2164 installer::files::save_file($completefilename, $changefile);
2166 my $prototypefilename = $packagename . ".prototype";
2167 $prototypefilename = $newepmdir . $prototypefilename;
2168 if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
2170 my $prototypefile = installer::files::read_file($prototypefilename);
2171 make_prototypefile_relocatable($prototypefile, $relocatablepath);
2172 set_volatilefile_into_prototypefile($prototypefile, $filesref);
2173 my $classesstring = set_tab_into_datafile($prototypefile, $filesref);
2174 if ($classesstring)
2176 include_classes_into_pkginfo($changefile, $classesstring);
2177 installer::files::save_file($completefilename, $changefile);
2180 if ( $installer::globals::patch ) { add_scripts_into_prototypefile($prototypefile, $prototypefilename, $languagestringref, $staticpath); }
2182 installer::files::save_file($prototypefilename, $prototypefile);
2183 if ( $installer::globals::patch ) { collect_patch_files($prototypefile, $packagename, ""); }
2185 # Adding package names into depend files for Solaris (not supported by epm)
2186 my $dependfilename = $packagename . ".depend";
2187 $dependfilename = $newepmdir . $dependfilename;
2188 if ( -f $dependfilename)
2190 my $dependfile = installer::files::read_file($dependfilename);
2191 put_packagenames_into_dependfile($dependfile);
2192 installer::files::save_file($dependfilename, $dependfile);
2196 return $newepmdir;
2199 ############################################################
2200 # Linux requirement for perl is changed by epm from
2201 # /usr/bin/perl to perl .
2202 # Requires: perl
2203 ############################################################
2205 sub check_requirements_in_specfile
2207 my ( $specfile ) = @_;
2209 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
2211 if (( ${$specfile}[$i] =~ /^\s*Requires/ ) && ( ${$specfile}[$i] =~ /\bperl\b/ ) && ( ! ( ${$specfile}[$i] =~ /\/usr\/bin\/perl\b/ )))
2213 my $oldline = ${$specfile}[$i];
2214 ${$specfile}[$i] =~ s/perl/\/usr\/bin\/perl/;
2215 my $newline = ${$specfile}[$i];
2217 $oldline =~ s/\s*$//;
2218 $newline =~ s/\s*$//;
2219 my $infoline = "Spec File: Changing content from \"$oldline\" to \"$newline\".\n";
2220 push(@installer::globals::logfileinfo, $infoline);
2225 ###############################################################################
2226 # Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
2227 # epm list file.
2228 # The complete rootpath is stored in $installer::globals::rootpath
2229 # or for each package in $onepackage->{'destpath'}
2230 # The static rootpath is stored in $staticpath
2231 # The relocatable path is stored in $relocatablepath
2232 # PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
2233 # PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
2234 # In standard epm process:
2235 # No usage of package specific variables like $BASEDIR, because
2236 # 1. These variables would be replaced in epm process
2237 # 2. epm version 3.7 does not support relocatable packages
2238 ###############################################################################
2240 sub resolve_path_in_epm_list_before_packaging
2242 my ($listfile, $listfilename, $variable, $path) = @_;
2244 installer::logger::include_header_into_logfile("Replacing variables in epm list file:");
2246 $path =~ s/\/\s*$//;
2247 replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path);
2251 #################################################################
2252 # Determining the rpm version. Beginning with rpm version 4.0
2253 # the tool to create RPMs is "rpmbuild" and no longer "rpm"
2254 #################################################################
2256 sub determine_rpm_version
2258 my $rpmversion = 0;
2259 my $rpmout = "";
2260 my $systemcall = "";
2262 # my $systemcall = "rpm --version |";
2263 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
2264 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
2265 # is saved in $installer::globals::rpm
2267 if ( $installer::globals::rpm ne "" )
2269 $systemcall = "$installer::globals::rpm --version |";
2271 else
2273 $systemcall = "rpm --version |";
2276 open (RPM, "$systemcall");
2277 $rpmout = <RPM>;
2278 close (RPM);
2280 if ( $rpmout ne "" )
2282 $rpmout =~ s/\s*$//g;
2284 my $infoline = "Systemcall: $systemcall\n";
2285 push( @installer::globals::logfileinfo, $infoline);
2287 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
2288 else { $infoline = "Success: rpm version: $rpmout\n"; }
2290 push( @installer::globals::logfileinfo, $infoline);
2292 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2293 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2294 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
2295 else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
2298 return $rpmversion;
2301 #################################################
2302 # Systemcall to start the packaging process
2303 #################################################
2305 sub create_packages_without_epm
2307 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
2309 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
2310 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
2311 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
2313 if ( $installer::globals::issolarispkgbuild )
2315 my $prototypefile = $epmdir . $packagename . ".prototype";
2316 if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
2318 my $destinationdir = $prototypefile;
2319 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir);
2320 $destinationdir =~ s/\/\s*$//; # removing ending slashes
2322 # my $systemcall = "pkgmk -o -f $prototypefile -d $destinationdir \> /dev/null 2\>\&1";
2323 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
2324 installer::logger::print_message( "... $systemcall ...\n" );
2326 my $maxpkgmkcalls = 3;
2328 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
2330 my @pkgmkoutput = ();
2332 open (PKGMK, "$systemcall");
2333 while (<PKGMK>) {push(@pkgmkoutput, $_); }
2334 close (PKGMK);
2336 my $returnvalue = $?; # $? contains the return value of the systemcall
2338 my $infoline = "Systemcall (Try $i): $systemcall\n";
2339 push( @installer::globals::logfileinfo, $infoline);
2341 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
2343 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2344 push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]");
2347 if ($returnvalue)
2349 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2350 push( @installer::globals::logfileinfo, $infoline);
2351 if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2353 else
2355 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2356 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2357 push( @installer::globals::logfileinfo, $infoline);
2358 last;
2362 # It might be necessary to save uncompressed Solaris packages
2364 if ( $allvariables->{'JDSBUILD'} )
2366 if ( ! $installer::globals::jds_language_controlled )
2368 my $correct_language = installer::worker::check_jds_language($allvariables, $languagestringref);
2369 $installer::globals::correct_jds_language = $correct_language;
2370 $installer::globals::jds_language_controlled = 1;
2373 if ( $installer::globals::correct_jds_language )
2375 if ( $installer::globals::saved_packages_path eq "" )
2377 $packagestempdir = installer::systemactions::create_directories("jds", $languagestringref);
2378 $installer::globals::saved_packages_path = $packagestempdir;
2379 push(@installer::globals::jdsremovedirs, $packagestempdir);
2382 $systemcall = "cd $destinationdir; cp -p -R $packagename $installer::globals::saved_packages_path;";
2383 make_systemcall($systemcall);
2384 installer::logger::print_message( "... $systemcall ...\n" );
2386 # Setting unix rights to "775" for all created directories inside the package,
2387 # that is saved in temp directory
2389 $systemcall = "cd $packagestempdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2390 installer::logger::print_message( "... $systemcall ...\n" );
2392 $returnvalue = system($systemcall);
2394 $infoline = "Systemcall: $systemcall\n";
2395 push( @installer::globals::logfileinfo, $infoline);
2397 if ($returnvalue)
2399 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2400 push( @installer::globals::logfileinfo, $infoline);
2402 else
2404 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2405 push( @installer::globals::logfileinfo, $infoline);
2410 # compressing packages
2412 if ( ! $installer::globals::solarisdontcompress )
2414 my $faspac = "faspac-so.sh";
2416 my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0);
2417 if ($$compressorref ne "")
2419 # Saving original pkginfo, to set time stamp later
2420 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
2421 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
2422 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
2423 make_systemcall($systemcall);
2425 $faspac = $$compressorref;
2426 $infoline = "Found compressor: $faspac\n";
2427 push( @installer::globals::logfileinfo, $infoline);
2429 installer::logger::print_message( "... $faspac ...\n" );
2430 installer::logger::include_timestamp_into_logfile("Starting $faspac");
2432 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
2433 make_systemcall($systemcall);
2435 # Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file,
2436 # updated the size and checksum, but not the time stamp.
2437 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
2438 make_systemcall($systemcall);
2439 if ( -f $pkginfotmp ) { unlink($pkginfotmp); }
2441 installer::logger::include_timestamp_into_logfile("End of $faspac");
2443 else
2445 $infoline = "Not found: $faspac\n";
2446 push( @installer::globals::logfileinfo, $infoline);
2450 # Setting unix rights to "775" for all created directories inside the package
2452 $systemcall = "cd $destinationdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2453 installer::logger::print_message( "... $systemcall ...\n" );
2455 $returnvalue = system($systemcall);
2457 $infoline = "Systemcall: $systemcall\n";
2458 push( @installer::globals::logfileinfo, $infoline);
2460 if ($returnvalue)
2462 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2463 push( @installer::globals::logfileinfo, $infoline);
2465 else
2467 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2468 push( @installer::globals::logfileinfo, $infoline);
2471 ######################
2472 # making pkg files
2473 ######################
2475 # my $streamname = $packagename . ".pkg";
2476 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
2477 # print "... $systemcall ...\n";
2479 # $returnvalue = system($systemcall);
2481 # $infoline = "Systemcall: $systemcall\n";
2482 # push( @installer::globals::logfileinfo, $infoline);
2484 # if ($returnvalue)
2486 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2487 # push( @installer::globals::logfileinfo, $infoline);
2489 # else
2491 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2492 # push( @installer::globals::logfileinfo, $infoline);
2493 # }
2495 #########################
2496 # making tar.gz files
2497 #########################
2499 # my $targzname = $packagename . ".tar.gz";
2500 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
2501 # print "... $systemcall ...\n";
2503 # $returnvalue = system($systemcall);
2505 # $infoline = "Systemcall: $systemcall\n";
2506 # push( @installer::globals::logfileinfo, $infoline);
2508 # if ($returnvalue)
2510 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2511 # push( @installer::globals::logfileinfo, $infoline);
2513 # else
2515 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2516 # push( @installer::globals::logfileinfo, $infoline);
2520 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2522 if ( $installer::globals::islinuxrpmbuild )
2524 my $specfilename = $epmdir . $packagename . ".spec";
2525 if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2527 # my $rpmcommand = "rpm";
2528 my $rpmcommand = $installer::globals::rpm;
2529 my $rpmversion = determine_rpm_version();
2531 # if ( $rpmversion >= 4 ) { $rpmcommand = "rpmbuild"; }
2533 # saving globally for later usage
2534 $installer::globals::rpmcommand = $rpmcommand;
2535 $installer::globals::rpmquerycommand = "rpm";
2537 my $target = "";
2538 if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; }
2539 elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; }
2541 # rpm 4.6 ignores buildroot tag in spec file
2543 my $buildrootstring = "";
2545 if ( $rpmversion >= 4 )
2547 my $dir = getcwd;
2548 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2549 $buildrootstring = "--buildroot=$buildroot";
2552 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2554 installer::logger::print_message( "... $systemcall ...\n" );
2556 my $maxrpmcalls = 3;
2557 my $rpm_failed = 0;
2559 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2561 my @rpmoutput = ();
2563 open (RPM, "$systemcall");
2564 while (<RPM>) {push(@rpmoutput, $_); }
2565 close (RPM);
2567 my $returnvalue = $?; # $? contains the return value of the systemcall
2569 my $infoline = "Systemcall (Try $i): $systemcall\n";
2570 push( @installer::globals::logfileinfo, $infoline);
2572 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2574 # if ( $i < $maxrpmcalls ) { $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2575 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2576 push( @installer::globals::logfileinfo, "$rpmoutput[$j]");
2579 if ($returnvalue)
2581 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2582 push( @installer::globals::logfileinfo, $infoline);
2583 $rpm_failed = 1;
2585 else
2587 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2588 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2589 push( @installer::globals::logfileinfo, $infoline);
2590 $rpm_failed = 0;
2591 last;
2595 if ( $rpm_failed )
2597 # Because of the problems with LD_LIBARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2598 my $rpmprog = "";
2599 if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2600 elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2602 if ( $rpmprog ne "" )
2604 installer::logger::print_message( "... $rpmprog ...\n" );
2606 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2608 my @helperrpmoutput = ();
2610 open (RPM, "$helpersystemcall");
2611 while (<RPM>) {push(@helperrpmoutput, $_); }
2612 close (RPM);
2614 my $helperreturnvalue = $?; # $? contains the return value of the systemcall
2616 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBARY_PATH)\n";
2617 push( @installer::globals::logfileinfo, $infoline);
2619 $infoline = "\nSystemcall: $helpersystemcall\n";
2620 push( @installer::globals::logfileinfo, $infoline);
2622 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); }
2624 if ($helperreturnvalue)
2626 $infoline = "Could not execute \"$helpersystemcall\"!\n";
2627 push( @installer::globals::logfileinfo, $infoline);
2629 else
2631 installer::logger::print_message( "Success: \"$helpersystemcall\"\n" );
2632 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2633 push( @installer::globals::logfileinfo, $infoline);
2634 $rpm_failed = 0;
2638 # Now it is really time to exit this packaging process, if the error still occurs
2639 if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2644 #################################################
2645 # Removing all temporary files created by epm
2646 #################################################
2648 sub remove_temporary_epm_files
2650 my ($epmdir, $loggingdir, $packagename) = @_;
2652 # saving the files into the loggingdir
2654 if ( $installer::globals::issolarispkgbuild )
2656 my @extensions = ();
2657 push(@extensions, ".pkginfo");
2658 push(@extensions, ".prototype");
2659 push(@extensions, ".postinstall");
2660 push(@extensions, ".postremove");
2661 push(@extensions, ".preinstall");
2662 push(@extensions, ".preremove");
2663 push(@extensions, ".depend");
2665 for ( my $i = 0; $i <= $#extensions; $i++ )
2667 my $removefile = $epmdir . $packagename . $extensions[$i];
2668 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2670 if (! -f $removefile) { next; }
2672 my $systemcall = "mv -f $removefile $destfile";
2673 system($systemcall); # ignoring the return value
2674 $infoline = "Systemcall: $systemcall\n";
2675 push( @installer::globals::logfileinfo, $infoline);
2678 # removing the package
2680 # my $removedir = $epmdir . $packagename;
2682 # my $systemcall = "rm -rf $removedir";
2684 # print "... $systemcall ...\n";
2686 # my $returnvalue = system($systemcall);
2688 # my $infoline = "Systemcall: $systemcall\n";
2689 # push( @installer::globals::logfileinfo, $infoline);
2691 # if ($returnvalue)
2693 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2694 # push( @installer::globals::logfileinfo, $infoline);
2696 # else
2698 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2699 # push( @installer::globals::logfileinfo, $infoline);
2703 if ( $installer::globals::islinuxrpmbuild )
2705 my $removefile = $epmdir . $packagename . ".spec";
2706 my $destfile = $loggingdir . $packagename . ".spec.log";
2708 # if (! -f $removefile) { next; }
2710 my $systemcall = "mv -f $removefile $destfile";
2711 system($systemcall); # ignoring the return value
2712 $infoline = "Systemcall: $systemcall\n";
2713 push( @installer::globals::logfileinfo, $infoline);
2715 # removing the directory "buildroot"
2717 my $removedir = $epmdir . "buildroot";
2719 $systemcall = "rm -rf $removedir";
2721 installer::logger::print_message( "... $systemcall ...\n" );
2723 my $returnvalue = system($systemcall);
2725 my $infoline = "Systemcall: $systemcall\n";
2726 push( @installer::globals::logfileinfo, $infoline);
2728 if ($returnvalue)
2730 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2731 push( @installer::globals::logfileinfo, $infoline);
2733 else
2735 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2736 push( @installer::globals::logfileinfo, $infoline);
2741 ######################################################
2742 # Making the systemcall
2743 ######################################################
2745 sub make_systemcall
2747 my ($systemcall) = @_;
2749 my $returnvalue = system($systemcall);
2751 my $infoline = "Systemcall: $systemcall\n";
2752 push( @installer::globals::logfileinfo, $infoline);
2754 if ($returnvalue)
2756 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2757 push( @installer::globals::logfileinfo, $infoline);
2759 else
2761 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2762 push( @installer::globals::logfileinfo, $infoline);
2766 ###########################################################
2767 # Creating a better directory structure in the solver.
2768 ###########################################################
2770 sub create_new_directory_structure
2772 my ($newepmdir) = @_;
2774 my $newdir = $installer::globals::epmoutpath;
2776 if ( $installer::globals::islinuxrpmbuild )
2778 my $rpmdir;
2779 my $machine = "";
2780 if ( $installer::globals::compiler =~ /unxlngi/) {
2781 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2783 elsif ( $installer::globals::compiler =~ /unxlng/) {
2784 $machine = (POSIX::uname())[4];
2785 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2787 else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2789 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2791 my $returnvalue = system($systemcall);
2793 my $infoline = "Systemcall: $systemcall\n";
2794 push( @installer::globals::logfileinfo, $infoline);
2796 if ($returnvalue)
2798 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2799 push( @installer::globals::logfileinfo, $infoline);
2801 else
2803 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2804 push( @installer::globals::logfileinfo, $infoline);
2807 # and removing the empty directory
2809 if ( $machine ne "" )
2811 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/$machine");
2813 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/x86_64");
2814 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i586");
2815 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i386");
2816 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS");
2820 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2822 my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1";
2823 my $callreturnvalue = system($localcall);
2825 my $callinfoline = "Systemcall: $localcall\n";
2826 push( @installer::globals::logfileinfo, $callinfoline);
2828 if ($callreturnvalue)
2830 $callinfoline = "ERROR: Could not execute \"$localcall\"!\n";
2831 push( @installer::globals::logfileinfo, $callinfoline);
2833 else
2835 $callinfoline = "Success: Executed \"$localcall\" successfully!\n";
2836 push( @installer::globals::logfileinfo, $callinfoline);
2840 ######################################################
2841 # Collect modules with product specific styles.
2842 ######################################################
2844 sub collect_modules_with_style
2846 my ($style, $modulesarrayref) = @_;
2848 my @allmodules = ();
2850 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2852 my $onemodule = ${$modulesarrayref}[$i];
2853 my $styles = "";
2854 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2855 if ( $styles =~ /\b\Q$style\E\b/ )
2857 push(@allmodules, $onemodule);
2861 return \@allmodules;
2864 ######################################################
2865 # Remove modules without packagecontent.
2866 ######################################################
2868 sub remove_modules_without_package
2870 my ($allmodules) = @_;
2872 my @allmodules = ();
2874 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2876 my $onemodule = ${$allmodules}[$i];
2877 my $packagename = "";
2878 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2879 if ( $packagename ne "" )
2881 push(@allmodules, $onemodule);
2885 return \@allmodules;
2888 ######################################################
2889 # Unpacking tar.gz file and setting new packagename.
2890 ######################################################
2892 sub unpack_tar_gz_file
2894 my ($packagename, $destdir) = @_;
2896 my $newpackagename = "";
2898 if ( $packagename =~ /\.tar\.gz\s*$/ )
2900 # Collecting all packages in directory "packages"
2901 my $oldcontent = installer::systemactions::read_directory($destdir);
2903 # unpacking gunzip
2904 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -";
2905 make_systemcall($systemcall);
2907 # deleting the tar.gz files
2908 $systemcall = "cd $destdir; rm -f $packagename";
2909 make_systemcall($systemcall);
2911 # Finding new content -> that is the package name
2912 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2913 $newpackagename = ${$newcontent}[0];
2914 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename);
2917 if ( $newpackagename ne "" ) { $packagename = $newpackagename; }
2919 return $packagename;
2922 ######################################################
2923 # Copying files of child projects.
2924 ######################################################
2926 sub copy_childproject_files
2928 my ($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, $subdir, $includepatharrayref, $use_sopackpath) = @_;
2930 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2932 my $localdestdir = $destdir;
2933 my $onemodule = ${$allmodules}[$i];
2934 my $packagename = $onemodule->{'PackageName'};
2935 my $sourcefile = "";
2936 if ( $use_sopackpath )
2938 $sourcefile = $sopackpath . $installer::globals::separator . $installer::globals::compiler . $installer::globals::separator . $subdir . $installer::globals::separator . $packagename;
2940 else
2942 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagename, $includepatharrayref, 1);
2943 $sourcefile = $$sourcepathref;
2946 if ( ! -f $sourcefile ) { installer::exiter::exit_program("ERROR: File not found: $sourcefile ($packagename) !", "copy_childproject_files"); }
2947 if ( $onemodule->{'Subdir'} )
2949 $localdestdir = $localdestdir . $installer::globals::separator . $onemodule->{'Subdir'};
2950 if ( ! -d $localdestdir ) { installer::systemactions::create_directory($localdestdir); }
2952 installer::systemactions::copy_one_file($sourcefile, $localdestdir);
2953 # Solaris: unpacking tar.gz files and setting new packagename
2954 if ( $installer::globals::issolarispkgbuild ) { $packagename = unpack_tar_gz_file($packagename, $localdestdir); }
2956 if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} ))
2958 installer::xpdinstaller::create_xpd_file_for_childproject($onemodule, $localdestdir, $packagename, $allvariableshashref, $modulesarrayref);
2964 ######################################################
2965 # Copying files for system integration.
2966 ######################################################
2968 sub copy_and_unpack_tar_gz_files
2970 my ($sourcefile, $destdir) = @_;
2972 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2973 make_systemcall($systemcall);
2976 ######################################################
2977 # Including child packages into the
2978 # installation set.
2979 ######################################################
2981 sub put_childprojects_into_installset
2983 my ($newdir, $allvariables, $modulesarrayref, $includepatharrayref) = @_;
2985 my $infoline = "";
2987 my $sopackpath = "";
2988 if ( $ENV{'SO_PACK'} ) { $sopackpath = $ENV{'SO_PACK'}; }
2989 else { installer::exiter::exit_program("ERROR: Environment variable SO_PACK not set!", "put_childprojects_into_installset"); }
2991 my $destdir = "$newdir";
2993 # adding Java
2995 my $sourcefile = "";
2997 # Finding the modules defined in scp (with flag JAVAMODULE, ADAMODULE, ...)
2998 # Getting name of package from scp-Module
2999 # Copy file into installation set
3000 # Create xpd file and put it into xpd directory
3001 # xpd file has to be created completely from module and package itself (-> no packagelist!)
3003 if ( $allvariables->{'JAVAPRODUCT'} )
3005 # Collect all modules with flag "JAVAMODULE"
3006 my $allmodules = collect_modules_with_style("JAVAMODULE", $modulesarrayref);
3007 $allmodules = remove_modules_without_package($allmodules);
3008 copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "jre", $includepatharrayref, 1);
3011 # Adding additional required packages (freetype).
3012 # This package names are stored in global array @installer::globals::requiredpackages
3014 if ( $allvariables->{'ADDREQUIREDPACKAGES'} )
3016 # Collect all modules with flag "REQUIREDPACKAGEMODULE"
3017 my $allmodules = collect_modules_with_style("REQUIREDPACKAGEMODULE", $modulesarrayref);
3018 $allmodules = remove_modules_without_package($allmodules);
3019 copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "requiredpackages", $includepatharrayref, 1);
3022 # Collect all modules with flag "USERLANDMODULE"
3023 my $alluserlandmodules = collect_modules_with_style("USERLANDMODULE", $modulesarrayref);
3024 $alluserlandmodules = remove_modules_without_package($alluserlandmodules);
3025 copy_childproject_files($alluserlandmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "", $includepatharrayref, 0);
3029 ######################################################
3030 # Checking whether the new content is a directory and
3031 # not a package. If it is a directory, the complete
3032 # content of the directory has to be added to the
3033 # array newcontent.
3034 ######################################################
3036 sub control_subdirectories
3038 my ($content, $subdir) = @_;
3040 my @newcontent = ();
3042 for ( my $i = 0; $i <= $#{$content}; $i++ )
3044 if ( -d ${$content}[$i] )
3046 $subdir = ${$content}[$i];
3047 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir);
3048 my $allpackages = installer::systemactions::read_directory(${$content}[$i]);
3049 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
3051 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
3052 if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
3053 push(@newcontent, ${$allpackages}[$j]);
3056 else
3058 push(@newcontent, ${$content}[$i]);
3062 return (\@newcontent, $subdir);
3065 ######################################################
3066 # Including the system integration files into the
3067 # installation sets.
3068 ######################################################
3070 sub put_systemintegration_into_installset
3072 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
3074 my $destdir = $newdir;
3076 # adding System integration files
3078 my $sourcefile = "";
3080 # Finding the modules defined in scp (with flag SYSTEMMODULE)
3081 # Getting name of package from scp-Module
3082 # Search package in list off all include files
3083 # Copy file into installation set and unpack it (always tar.gz)
3084 # Create xpd file and put it into xpd directory
3085 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
3086 # xpd file has to be created completely from module and package itself (-> no packagelist!)
3088 # Collect all modules with flag "SYSTEMMODULE"
3089 my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref);
3090 $allmodules = remove_modules_without_package($allmodules);
3092 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
3094 my $onemodule = ${$allmodules}[$i];
3095 my $packagetarfilename = $onemodule->{'PackageName'};
3097 my $infoline = "Including into installation set: $packagetarfilename\n";
3098 push( @installer::globals::logfileinfo, $infoline);
3100 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1);
3101 if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
3103 # Collecting all packages in directory "packages" or "RPMS"
3104 my $oldcontent = installer::systemactions::read_directory($destdir);
3106 copy_and_unpack_tar_gz_files($$sourcepathref, $destdir);
3108 # Finding new content -> that is the package name
3109 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
3111 # special handling, if new content is a directory
3112 my $subdir = "";
3113 if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); }
3115 # Adding license content into Solaris packages
3116 if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset )) { installer::worker::add_license_into_systemintegrationpackages($destdir, $newcontent); }
3118 if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} ))
3120 installer::xpdinstaller::create_xpd_file_for_systemintegration($onemodule, $newcontent, $modulesarrayref, $subdir);
3125 ######################################################
3126 # Analyzing the Unix installation path.
3127 # From the installation path /opt/openofficeorg20
3128 # is the part /opt relocatable and the part
3129 # openofficeorg20 static.
3130 ######################################################
3132 sub analyze_rootpath
3134 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
3136 $rootpath =~ s/\/\s*$//; # removing ending slash
3138 ##############################################################
3139 # Version 1: "/opt" is variable and "openofficeorg20" fixed
3140 ##############################################################
3142 # my $staticpath = $rootpath;
3143 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$staticpath);
3144 # $$staticpathref = $staticpath; # will be "openofficeorg20"
3146 # my $relocatablepath = $rootpath;
3147 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$relocatablepath);
3148 # $$relocatablepathref = $relocatablepath; # will be "/opt/"
3150 ##############################################################
3151 # Version 2: "/opt/openofficeorg20" is variable and "" fixed
3152 ##############################################################
3154 # if ( $$relocatablepathref eq "" ) # relocatablepath is not defined in package list
3156 # $$staticpathref = ""; # will be ""
3157 # $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/openofficeorg20/"
3158 # # setting the static path to the hostname of the directory with style OFFICEDIRECTORY
3159 # if ( $allvariables->{'SETSTATICPATH'} ) { $$staticpathref = $installer::globals::officedirhostname; }
3162 # else # relocatablepath is defined in package list
3163 # {
3164 # $$relocatablepathref =~ s/\/\s*$//; # removing ending slash
3165 # $$relocatablepathref = $$relocatablepathref . "\/"; # relocatable path must end with "/"
3166 # my $staticpath = $rootpath;
3167 # $staticpath =~ s/\Q$$relocatablepathref\E//;
3168 # $staticpath =~ s/\/\s*$//;
3169 # $$staticpathref = $staticpath;
3172 ##############################################################
3173 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
3174 ##############################################################
3176 $$relocatablepathref = "/";
3177 # Static path has to contain the office directory name. This is replaced in shellscripts.
3178 $$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname;
3179 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
3180 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
3181 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
3182 if ( $installer::globals::islinuxrpmbuild )
3184 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
3185 $$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts
3188 if ( $installer::globals::islinuxdebbuild )
3190 $$relocatablepathref = "";
3191 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
3192 # $$staticpathref = $rootpath . $installer::globals::separator . $$staticpathref; # no relocatibility for Debian
3197 ######################################################
3198 # Including license and readme into
3199 # Unix installation sets.
3200 ######################################################
3202 sub put_installsetfiles_into_installset
3204 my ($destdir) = @_;
3206 # All files for the installation set are saved in the global
3207 # array @installer::globals::installsetfiles
3209 for ( my $i = 0; $i <= $#installer::globals::installsetfiles; $i++ )
3211 my $onefile = $installer::globals::installsetfiles[$i];
3212 my $sourcefile = $onefile->{'sourcepath'};
3213 my $destfile = "";
3214 if ( $installer::globals::addjavainstaller ) { $destfile = $onefile->{'Name'}; }
3215 else { $destfile = $destdir . $installer::globals::separator . $onefile->{'Name'}; }
3216 installer::systemactions::copy_one_file($sourcefile, $destfile);
3218 my $infoline = "Adding to installation set \"$destfile\" from source \"$sourcefile\".\n";
3219 push( @installer::globals::logfileinfo, $infoline);
3223 ######################################################
3224 # Replacing one variable in patchinfo file
3225 ######################################################
3227 sub replace_one_variable_in_file
3229 my ( $file, $placeholder, $value ) = @_;
3231 for ( my $i = 0; $i <= $#{$file}; $i++ )
3233 ${$file}[$i] =~ s/$placeholder/$value/g;
3237 ######################################################
3238 # Setting variables in the patchinfo file
3239 ######################################################
3241 sub set_patchinfo
3243 my ( $patchinfofile, $patchid, $allvariables ) = @_;
3245 # Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER
3247 replace_one_variable_in_file($patchinfofile, "PATCHIDPLACEHOLDER", $patchid);
3249 my $architecture = "";
3250 if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; }
3251 if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; }
3253 replace_one_variable_in_file($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture);
3255 if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer::exiter::exit_program("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); }
3256 my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'};
3258 replace_one_variable_in_file($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects);
3260 # Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists
3261 my $requiresstring = "";
3262 if ( $installer::globals::issolarissparcbuild ) { $requiresstring = "SOLSPARCPATCHREQUIRES"; }
3263 if ( $installer::globals::issolarisx86build ) { $requiresstring = "SOLIAPATCHREQUIRES"; }
3265 if ( $allvariables->{$requiresstring} )
3267 my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n";
3268 push(@{$patchinfofile}, $newline);
3272 ######################################################
3273 # Finalizing patch: Renaming directory and
3274 # including additional patch files.
3275 ######################################################
3277 sub finalize_patch
3279 my ( $newepmdir, $allvariables ) = @_;
3281 my $patchidname = "SOLSPARCPATCHID";
3282 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; }
3284 if ( ! $allvariables->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); }
3285 my $patchid = $allvariables->{$patchidname};
3286 installer::systemactions::rename_directory($newepmdir, $patchid);
3288 # Copying all typical patch files into the patch directory
3289 # All patch file names are stored in @installer::globals::solarispatchfiles
3290 # Location of the file is $installer::globals::patchincludepath
3292 my $sourcepath = $installer::globals::patchincludepath;
3293 $sourcepath =~ s/\/\s*$//;
3295 for ( my $i = 0; $i <= $#installer::globals::solarispatchfiles; $i++ )
3297 my $sourcefile = $sourcepath . $installer::globals::separator . $installer::globals::solarispatchfiles[$i];
3298 my $destfile = $patchid . $installer::globals::separator . $installer::globals::solarispatchfiles[$i];
3299 installer::systemactions::copy_one_file($sourcefile, $destfile);
3302 # And editing the patchinfo file
3304 my $patchinfofilename = $patchid . $installer::globals::separator . "patchinfo";
3305 my $patchinfofile = installer::files::read_file($patchinfofilename);
3306 set_patchinfo($patchinfofile, $patchid, $allvariables);
3307 installer::files::save_file($patchinfofilename, $patchinfofile);
3310 ######################################################
3311 # Finalizing Linux patch: Renaming directory and
3312 # including additional patch files.
3313 ######################################################
3315 sub finalize_linux_patch
3317 my ( $newepmdir, $allvariables, $includepatharrayref ) = @_;
3319 # Copying the setup into the patch directory
3320 # and including the list of RPMs into it
3322 print "... creating patch setup ...\n";
3324 installer::logger::include_header_into_logfile("Creating Linux patch setup:");
3326 # find and read setup script template
3328 my $scriptfilename = "linuxpatchscript.sh";
3329 my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0);
3330 if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); }
3331 my $scriptfile = installer::files::read_file($$scriptref);
3333 my $infoline = "Found script file $scriptfilename: $$scriptref \n";
3334 push( @installer::globals::logfileinfo, $infoline);
3336 # Collecting all RPMs in the patch directory
3338 my $fileextension = "rpm";
3339 my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $newepmdir);
3340 if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); }
3341 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); }
3343 # my $installline = "";
3345 # for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3347 # $installline = $installline . " rpm --prefix \$PRODUCTINSTALLLOCATION -U $newepmdir/${$rpmfiles}[$i]\n";
3348 # }
3350 # $installline =~ s/\s*$//;
3352 # for ( my $j = 0; $j <= $#{$scriptfile}; $j++ )
3354 # ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/;
3357 # Searching packagename containing -core01
3358 my $found_package = 0;
3359 my $searchpackagename = "";
3360 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3362 if ( ${$rpmfiles}[$i] =~ /-core01-/ )
3364 $searchpackagename = ${$rpmfiles}[$i];
3365 $found_package = 1;
3366 if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; }
3367 last;
3371 if ( ! $found_package ) { installer::exiter::exit_program("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); }
3373 # Replacing the searchpackagename
3374 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; }
3376 # Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname
3377 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; }
3379 # Replacing the productname
3380 my $productname = $allvariables->{'PRODUCTNAME'};
3381 $productname = lc($productname);
3382 $productname =~ s/ /_/g; # abc office -> abc_office
3383 # $productname =~ s/\.//g; # openoffice.org -> openofficeorg
3385 $infoline = "Adding productname $productname into Linux patch script\n";
3386 push( @installer::globals::logfileinfo, $infoline);
3388 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; }
3390 # Saving the file
3392 my $newscriptfilename = "setup"; # $newepmdir . $installer::globals::separator . "setup";
3393 installer::files::save_file($newscriptfilename, $scriptfile);
3395 $infoline = "Saved Linux patch setup $newscriptfilename \n";
3396 push( @installer::globals::logfileinfo, $infoline);
3398 # Setting unix rights 755
3399 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";
3400 system($localcall);