1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: epmfile.pm,v $
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
;
35 use installer
::converter
;
36 use installer
::existence
;
37 use installer
::exiter
;
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
;
49 ############################################################################
50 # Reading the package map to find Solaris package names for
51 # the corresponding abbreviations
52 ############################################################################
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;
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");
110 $installer::globals
::dependfilenames
{$local_abbreviation} = $local_packagename;
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");
126 $installer::globals
::dependfilenames
{$abbreviation} = $packagename;
132 my $errorline = $i + 1;
133 installer
::exiter
::exit_program
("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap");
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 = "";
153 my $englishstring = "";
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*$/ )
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*$/ )
183 if ( $line =~ /^\s*\Q$englishidentifier\E\s+\=\s*\"(.*)\"\s*$/ )
186 $foundenglishstring = 1;
190 $line = ${$fileref}[$counter];
197 $returnstring = $onestring;
201 if ( $foundenglishstring )
203 $returnstring = $englishstring;
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) = @_;
223 if ( $installer::globals
::islinuxbuild
)
228 for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ )
230 my $onedir = ${$directoriesarrayref}[$i];
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'};
264 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
265 if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; }
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) = @_;
282 if ( $installer::globals
::islinuxbuild
)
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) = @_;
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) = @_;
329 my ($licensefilename, $readmefilename);
331 my $foundlicensefile = 0;
332 my $foundreadmefile = 0;
337 # %product OpenOffice.org Software
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
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";
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";
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);
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);
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);
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
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
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
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 # $onepackage->{$requires} = "";
599 if ( $onepackage->{$provides} )
601 my $providesstring = $onepackage->{$provides};
603 my $allprovides = installer
::converter
::convert_stringlist_into_array
(\
$providesstring, ",");
605 for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
607 my $oneprovides = ${$allprovides}[$i];
608 $oneprovides =~ s/\s*$//;
609 installer
::packagelist
::resolve_packagevariables
(\
$oneprovides, $variableshashref, 1);
610 if ( $installer::globals
::linuxlinkrpmprocess
) { $oneprovides = $oneprovides . "u"; }
611 $line = "%provides" . " " . $oneprovides . "\n";
612 push(@epmheader, $line);
616 if ( $onepackage->{$requires} )
618 my $requiresstring = $onepackage->{$requires};
620 if ( $installer::globals
::add_required_package
) { $requiresstring = $requiresstring . "," . $installer::globals
::add_required_package
; }
622 # The requires string can contain the separator "," in the names (descriptions) of the packages
623 # (that are required for Solaris depend files). Therefore "," inside such a description has to
624 # masked with a backslash.
625 # This masked separator need to be found and replaced, before the stringlist is converted into an array.
626 # This replacement has to be turned back after the array is created.
628 my $replacementstring = "COMMAREPLACEMENT";
629 $requiresstring = installer
::converter
::replace_masked_separator
($requiresstring, ",", "$replacementstring");
631 my $allrequires = installer
::converter
::convert_stringlist_into_array
(\
$requiresstring, ",");
633 installer
::converter
::resolve_masked_separator
($allrequires, ",", $replacementstring);
635 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
637 my $onerequires = ${$allrequires}[$i];
638 $onerequires =~ s/\s*$//;
639 installer
::packagelist
::resolve_packagevariables
(\
$onerequires, $variableshashref, 0);
641 # Special handling for Solaris. In depend files, the names of the packages are required, not
642 # only the abbreviation. Therefore there is a special syntax for names in packagelist:
643 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
644 # if ( $installer::globals::issolarispkgbuild )
646 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
650 # $installer::globals::dependfilenames{$onerequires} = $packagename;
654 $line = "%requires" . " " . $onerequires . "\n";
655 push(@epmheader, $line);
660 if ( $installer::globals
::add_required_package
)
662 my $requiresstring = $installer::globals
::add_required_package
;
664 my $replacementstring = "COMMAREPLACEMENT";
665 $requiresstring = installer
::converter
::replace_masked_separator
($requiresstring, ",", "$replacementstring");
666 my $allrequires = installer
::converter
::convert_stringlist_into_array
(\
$requiresstring, ",");
667 installer
::converter
::resolve_masked_separator
($allrequires, ",", $replacementstring);
669 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
671 my $onerequires = ${$allrequires}[$i];
672 $onerequires =~ s/\s*$//;
673 installer
::packagelist
::resolve_packagevariables
(\
$onerequires, $variableshashref, 0);
675 # Special handling for Solaris. In depend files, the names of the packages are required, not
676 # only the abbreviation. Therefore there is a special syntax for names in packagelist:
677 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
678 # if ( $installer::globals::issolarispkgbuild )
680 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
684 # $installer::globals::dependfilenames{$onerequires} = $packagename;
688 $line = "%requires" . " " . $onerequires . "\n";
689 push(@epmheader, $line);
697 #######################################
698 # Adding header to epm file
699 #######################################
701 sub adding_header_to_epm_file
703 my ($epmfileref, $epmheaderref) = @_;
705 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
707 push( @
{$epmfileref}, ${$epmheaderref}[$i] );
710 push( @
{$epmfileref}, "\n\n" );
713 #####################################################
714 # Replace one in shell scripts ( ${VARIABLENAME} )
715 #####################################################
717 sub replace_variable_in_shellscripts
719 my ($scriptref, $variable, $searchstring) = @_;
721 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
723 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
727 ###################################################
728 # Replace one in shell scripts ( %VARIABLENAME )
729 ###################################################
731 sub replace_percent_variable_in_shellscripts
733 my ($scriptref, $variable, $searchstring) = @_;
735 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
737 ${$scriptref}[$i] =~ s/\%$searchstring/$variable/g;
741 ################################################
742 # Replacing many variables in shell scripts
743 ################################################
745 sub replace_many_variables_in_shellscripts
747 my ($scriptref, $variableshashref) = @_;
751 foreach $key (keys %{$variableshashref})
753 my $value = $variableshashref->{$key};
754 if ( ! $value =~ /.oxt/ ) { $value = lc($value); } # lowercase !
755 if ( $installer::globals
::issolarisbuild
) { $value =~ s/\.org/org/g; } # openofficeorg instead of openoffice.org
756 replace_variable_in_shellscripts
($scriptref, $value, $key);
760 #######################################
761 # Setting oxt file name variable
762 #######################################
766 my ($filesinpackage, $allvariables) = @_;
768 for ( my $i = 0; $i <= $#{$filesinpackage}; $i++ )
770 my $onefile = ${$filesinpackage}[$i];
771 if ( $onefile->{'Name'} =~ /.oxt\s*$/ )
773 $allvariables->{'OXTFILENAME'} = $onefile->{'Name'};
774 # $allvariables->{'FULLOXTFILENAME'} = $onefile->{'destination'};
775 last; # only one oxt file for each rpm!
780 #######################################
781 # Adding shell scripts to epm file
782 #######################################
784 sub adding_shellscripts_to_epm_file
786 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
788 # Setting variable for ${OXTFILENAME} into $allvariableshashref, if this is a RPM with an extension
789 set_oxt_filename
($filesinpackage, $allvariableshashref);
791 # $installer::globals::shellscriptsfilename
793 push( @
{$epmfileref}, "\n\n" );
795 my $shellscriptsfileref = installer
::files
::read_file
($shellscriptsfilename);
797 replace_variable_in_shellscripts
($shellscriptsfileref, $localrootpath, "rootpath");
799 replace_many_variables_in_shellscripts
($shellscriptsfileref, $allvariableshashref);
801 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
803 push( @
{$epmfileref}, ${$shellscriptsfileref}[$i] );
806 push( @
{$epmfileref}, "\n" );
809 #################################################
810 # Determining the epm on the system
811 #################################################
813 sub find_epm_on_system
815 my ($includepatharrayref) = @_;
817 installer
::logger
::include_header_into_logfile
("Check epm on system");
821 # epm should be defined through the configure script but we need to
822 # check for it to be defined because of the Sun environment.
823 # Check the environment variable first and if it is not defined,
824 # or if it is but the location is not executable, search further.
825 # It has to be found in the solver or it has to be in the path
826 # (saved in $installer::globals::epm_in_path) or we get the specified
827 # one through the environment (i.e. when --with-epm=... is specified)
831 if (($ENV{'EPM'} ne "") && (-x
"$ENV{'EPM'}"))
833 $epmname = $ENV{'EPM'};
835 elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") )
841 installer
::exiter
::exit_program
("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
846 my $epmfileref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$epmname, $includepatharrayref, 0);
848 if (($$epmfileref eq "") && (!($installer::globals
::epm_in_path
))) { installer
::exiter
::exit_program
("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
849 if (($$epmfileref eq "") && ($installer::globals
::epm_in_path
)) { $epmname = $installer::globals
::epm_path
; }
850 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
853 my $infoline = "Using epmfile: $epmname\n";
854 push( @installer::globals
::logfileinfo
, $infoline);
859 #################################################
860 # Determining the epm patch state
861 # saved in $installer::globals::is_special_epm
862 #################################################
866 my ($epmexecutable) = @_;
870 my $systemcall = "$epmexecutable |";
871 open (EPMPATCH
, "$systemcall");
876 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals
::is_special_epm
= 1; }
881 if ( $installer::globals
::is_special_epm
)
883 $infoline = "\nPatch state: This is a patched version of epm!\n\n";
884 push( @installer::globals
::logfileinfo
, $infoline);
888 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
889 push( @installer::globals
::logfileinfo
, $infoline);
894 #################################################
895 # LD_PRELOAD string for Debian packages
896 #################################################
898 sub get_ld_preload_string
900 my ($includepatharrayref) = @_;
902 my $getuidlibraryname = "getuid.so";
904 my $getuidlibraryref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$getuidlibraryname, $includepatharrayref, 0);
905 if ($$getuidlibraryref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); }
907 my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
909 return $ldpreloadstring;
912 #################################################
913 # Calling epm to create the installation sets
914 #################################################
918 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
920 installer
::logger
::include_header_into_logfile
("epm call for $packagename");
922 my $packageformat = $installer::globals
::packageformat
;
924 my $localpackagename = $packagename;
925 # Debian allows only lowercase letters in package name
926 if ( $installer::globals
::debian
) { $localpackagename = lc($localpackagename); }
928 my $outdirstring = "";
929 if ( $installer::globals
::epmoutpath
ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
931 # Debian package build needs a LD_PRELOAD for correct rights
933 my $ldpreloadstring = "";
935 if ( $installer::globals
::debian
) { $ldpreloadstring = get_ld_preload_string
($includepatharrayref) . " "; }
938 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
940 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " -v " . " 2\>\&1 |";
942 installer
::logger
::print_message
( "... $systemcall ...\n" );
946 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
950 open (EPM
, "$systemcall");
951 while (<EPM
>) {push(@epmoutput, $_); }
954 my $returnvalue = $?
; # $? contains the return value of the systemcall
956 my $infoline = "Systemcall (Try $i): $systemcall\n";
957 push( @installer::globals
::logfileinfo
, $infoline);
959 for ( my $j = 0; $j <= $#epmoutput; $j++ )
961 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
962 push( @installer::globals
::logfileinfo
, "$epmoutput[$j]");
967 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
968 push( @installer::globals
::logfileinfo
, $infoline);
969 if ( $i == $maxepmcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "call_epm"); }
973 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
974 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
975 push( @installer::globals
::logfileinfo
, $infoline);
981 #####################################################################
982 # Adding the new line for relocatables into pkginfo file (Solaris)
983 # or spec file (Linux) created by epm
984 #####################################################################
986 sub add_one_line_into_file
988 my ($file, $insertline, $filename) = @_;
990 if ( $installer::globals
::issolarispkgbuild
)
992 push(@
{$file}, $insertline); # simply adding at the end of pkginfo file
995 if ( $installer::globals
::islinuxrpmbuild
)
997 # Adding behind the line beginning with: Group:
999 my $inserted_line = 0;
1001 for ( my $i = 0; $i <= $#{$file}; $i++ )
1003 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
1005 splice(@
{$file},$i+1,0,$insertline);
1011 if (! $inserted_line) { installer
::exiter
::exit_program
("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
1014 $insertline =~ s/\s*$//; # removing line end for correct logging
1015 my $infoline = "Success: Added line $insertline into file $filename!\n";
1016 push( @installer::globals
::logfileinfo
, $infoline);
1019 #####################################################################
1020 # Setting the revision VERSION=1.9,REV=66 .
1021 # Also adding the new line: "AutoReqProv: no"
1022 #####################################################################
1024 sub set_revision_in_pkginfo
1026 my ($file, $filename, $variables, $packagename) = @_;
1028 my $revisionstring = "\,REV\=" . $installer::globals
::packagerevision
;
1030 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
1032 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
1036 $year = $year + 1900;
1038 if ( $mday < 10 ) { $mday = "0" . $mday; }
1039 if ( $mon < 10 ) { $mon = "0" . $mon; }
1040 $datestring = $year . "." . $mon . "." . $mday;
1041 $revisionstring = $revisionstring . "." . $datestring;
1043 for ( my $i = 0; $i <= $#{$file}; $i++ )
1045 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
1048 my $newstring = $oldstring . $revisionstring; # also adding the date string
1049 ${$file}[$i] =~ s/$oldstring/$newstring/;
1050 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1051 push( @installer::globals
::logfileinfo
, $infoline);
1056 # For Update and Patch reasons, this string can also be kept constant
1058 my $pkgversion = "SOLSPARCPKGVERSION";
1059 if ( $installer::globals
::issolarisx86build
) { $pkgversion = "SOLIAPKGVERSION"; }
1061 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
1063 if ( $variables->{$pkgversion} ne "FINALVERSION" )
1065 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
1066 # 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
1067 # and therefore be set as $pkgversion.
1068 # The first part "3.0.0" has to be derived from the
1070 my $version = $installer::globals
::packageversion
;
1071 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
1077 my $finalmajor = $major;
1078 my $finalminor = $minor;
1081 # if (( $packagename =~ /-ure\s*$/ ) && ( $finalmajor == 1 )) { $finalminor = 4; }
1083 $version = "$finalmajor.$finalminor.$finalmicro";
1086 my $versionstring = "$version,$variables->{$pkgversion}";
1088 for ( my $i = 0; $i <= $#{$file}; $i++ )
1090 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
1093 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
1094 my $oldstring = ${$file}[$i];
1095 ${$file}[$i] = $newstring;
1096 $oldstring =~ s/\s*$//;
1097 $newstring =~ s/\s*$//;
1098 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1099 push( @installer::globals
::logfileinfo
, $infoline);
1107 ########################################################
1108 # Setting Patch information for Respin versions
1109 # into pkginfo file. This prevents Respin versions
1111 ########################################################
1113 sub set_patchlist_in_pkginfo_for_respin
1115 my ($changefile, $filename, $allvariables, $packagename) = @_;
1117 my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN";
1118 if ( $installer::globals
::issolarisx86build
) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; }
1120 if ( $allvariables->{$patchlistname} )
1122 # patchlist separator is a blank
1123 my $allpatchesstring = $allvariables->{$patchlistname};
1124 my @usedpatches = ();
1126 # Analyzing the patchlist
1127 # Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01
1128 # Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01
1129 my $allpatches = installer
::converter
::convert_whitespace_stringlist_into_array
(\
$allpatchesstring);
1131 for ( my $i = 0; $i <= $#{$allpatches}; $i++ )
1133 my $patchdefinition = ${$allpatches}[$i];
1137 my $constraint = "";
1138 my $isusedpatch = 0;
1140 if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ )
1146 elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ )) # small syntax check
1148 # if there is a bracket in the $patchdefinition, but it does not
1149 # match the if-condition, this is an erroneous definition.
1150 installer
::exiter
::exit_program
("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin");
1154 $patchid = $patchdefinition;
1155 $isusedpatch = 1; # patches without constraint are always included
1158 if ( $symbol ne "" )
1160 if ( $symbol eq "+" )
1162 if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; }
1165 if ( $symbol eq "-" )
1167 if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; }
1171 if ( $isusedpatch ) { push(@usedpatches, $patchid); }
1174 if ( $#usedpatches > -1 )
1176 my $patchstring = installer
::converter
::convert_array_to_space_separated_string
(\
@usedpatches);
1178 my $newline = "PATCHLIST=" . $patchstring . "\n";
1179 add_one_line_into_file
($changefile, $newline, $filename);
1181 # Adding patch info for each used patch in the patchlist
1183 for ( my $i = 0; $i <= $#usedpatches; $i++ )
1185 my $patchid = $usedpatches[$i];
1186 my $key = "PATCH_INFO_" . $patchid;
1189 if ( ! $allvariables->{$key} ) { installer
::exiter
::exit_program
("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); }
1190 my $value = set_timestamp_in_patchinfo
($allvariables->{$key});
1191 $newline = $key . "=" . $value . "\n";
1193 add_one_line_into_file
($changefile, $newline, $filename);
1199 ########################################################
1200 # Solaris requires, that the time of patch installation
1201 # must not be empty.
1202 # Format: Mon Mar 24 11:20:56 PDT 2008
1203 # Log file: Tue Apr 29 23:26:19 2008 (04:31 min.)
1204 # Replace string: ${TIMESTAMP}
1205 ########################################################
1207 sub set_timestamp_in_patchinfo
1211 my $currenttime = localtime();
1213 if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ )
1217 $currenttime = $start . "CET " . $year;
1220 $value =~ s/\$\{TIMESTAMP\}/$currenttime/;
1225 ########################################################
1226 # Setting MAXINST=1000 into the pkginfo file.
1227 ########################################################
1229 sub set_maxinst_in_pkginfo
1231 my ($changefile, $filename) = @_;
1233 my $newline = "MAXINST\=1000\n";
1235 add_one_line_into_file
($changefile, $newline, $filename);
1238 #############################################################
1239 # Setting several Solaris variables into the pkginfo file.
1240 #############################################################
1242 sub set_solaris_parameter_in_pkginfo
1244 my ($changefile, $filename, $allvariables) = @_;
1255 my $productname = $allvariables->{'PRODUCTNAME'};
1256 $newline = "SUNW_PRODNAME=$productname\n";
1257 add_one_line_into_file
($changefile, $newline, $filename);
1259 my $productversion = "";
1260 if ( $allvariables->{'PRODUCTVERSION'} )
1262 $productversion = $allvariables->{'PRODUCTVERSION'};
1263 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1265 $newline = "SUNW_PRODVERS=$productversion\n";
1266 add_one_line_into_file
($changefile, $newline, $filename);
1268 $newline = "SUNW_PKGVERS=1\.0\n";
1269 add_one_line_into_file
($changefile, $newline, $filename);
1271 if ( $allvariables->{'SUNW_PKGTYPE'} )
1273 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1274 add_one_line_into_file
($changefile, $newline, $filename);
1278 $newline = "SUNW_PKGTYPE=\n";
1279 add_one_line_into_file
($changefile, $newline, $filename);
1282 $newline = "HOTLINE=Please contact your local service provider\n";
1283 add_one_line_into_file
($changefile, $newline, $filename);
1285 $newline = "EMAIL=\n";
1286 add_one_line_into_file
($changefile, $newline, $filename);
1290 #####################################################################
1291 # epm uses as archtecture for Solaris x86 "i86pc". This has to be
1292 # changed to "i386".
1293 #####################################################################
1295 sub fix_architecture_setting
1297 my ($changefile) = @_;
1299 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1301 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1303 ${$changefile}[$i] =~ s/i86pc/i386/;
1310 #####################################################################
1311 # Adding a new line for topdir into specfile, removing old
1313 #####################################################################
1315 sub set_topdir_in_specfile
1317 my ($changefile, $filename, $newepmdir) = @_;
1319 # $newepmdir =~ s/^\s*\.//; # removing leading "."
1320 $newepmdir = cwd
() . $installer::globals
::separator
. $newepmdir; # only absolute path allowed
1322 # removing "%define _topdir", if existing
1324 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1326 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1328 my $removeline = ${$changefile}[$i];
1329 $removeline =~ s/\s*$//;
1330 splice(@
{$changefile},$i,1);
1331 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1332 push( @installer::globals
::logfileinfo
, $infoline);
1337 # Adding "topdir" behind the line beginning with: Group:
1339 my $inserted_line = 0;
1341 my $topdirline = "\%define _topdir $newepmdir\n";
1343 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1345 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1347 splice(@
{$changefile},$i+1,0,$topdirline);
1349 $topdirline =~ s/\s*$//;
1350 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1351 push( @installer::globals
::logfileinfo
, $infoline);
1355 if (! $inserted_line) { installer
::exiter
::exit_program
("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1359 #####################################################################
1360 # Setting the packager in the spec file
1361 # Syntax: Packager: abc@def
1362 #####################################################################
1364 sub set_packager_in_specfile
1366 my ($changefile) = @_;
1368 my $packager = $installer::globals
::longmanufacturer
;
1370 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1372 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1375 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1376 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1377 push( @installer::globals
::logfileinfo
, $infoline);
1383 #####################################################################
1384 # Setting the requirements in the spec file (i81494)
1385 # Syntax: PreReq: "requirements" (only for shared extensions)
1386 #####################################################################
1388 sub set_prereq_in_specfile
1390 my ($changefile) = @_;
1392 my $prereq = "PreReq:";
1394 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1396 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1398 my $oldstring = ${$changefile}[$i];
1399 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1400 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1401 push( @installer::globals
::logfileinfo
, $infoline);
1406 #####################################################################
1407 # Setting the Auto[Req]Prov line and __find_requires
1408 #####################################################################
1410 sub set_autoprovreq_in_specfile
1412 my ($changefile, $findrequires, $bindir) = @_;
1414 my $autoreqprovline;
1416 if ( $findrequires )
1418 $autoreqprovline = "AutoProv\: no\n%define __find_requires $bindir/$findrequires\n";
1422 $autoreqprovline = "AutoReqProv\: no\n";
1425 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1427 # Adding "autoreqprov" behind the line beginning with: Group:
1428 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1430 splice(@
{$changefile},$i+1,0,$autoreqprovline);
1431 $autoreqprovline =~ s/\s*$//;
1432 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1433 push( @installer::globals
::logfileinfo
, $infoline);
1440 #####################################################################
1441 # Replacing Copyright with License in the spec file
1442 # Syntax: License: LGPL, SISSL
1443 #####################################################################
1445 sub set_license_in_specfile
1447 my ($changefile, $variableshashref) = @_;
1449 my $license = $variableshashref->{'LICENSENAME'};
1451 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1453 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1455 ${$changefile}[$i] = "License: $license\n";
1456 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1457 push( @installer::globals
::logfileinfo
, $infoline);
1463 #########################################################
1464 # Building relocatable Solaris packages means:
1465 # 1. Add "BASEDIR=/opt" into pkginfo
1466 # 2. Remove "/opt/" from all objects in prototype file
1467 # For step2 this function exists
1468 # Sample: d none /opt/openofficeorg20/help 0755 root other
1469 # -> d none openofficeorg20/help 0755 root other
1470 #########################################################
1472 sub make_prototypefile_relocatable
1474 my ($prototypefile, $relocatablepath) = @_;
1476 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1478 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w
+/ ) # this is an object line
1480 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1484 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1485 # This line has to be removed now
1487 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s
/\
/\s*$//; } # removing the ending slash
1489 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1491 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1493 my $line = ${$prototypefile}[$i];
1494 splice(@
{$prototypefile},$i,1); # removing the line
1496 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1497 push( @installer::globals
::logfileinfo
, $infoline);
1502 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1504 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1506 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1508 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1509 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1510 push( @installer::globals
::logfileinfo
, $infoline2);
1516 #########################################################################
1517 # In scp the flag VOLATEFILE can be used. This shall lead to style "v"
1518 # in Solaris prototype file. This is not supported by epm and has
1519 # therefore to be included in prototypefile, not in epm list file.
1520 #########################################################################
1522 sub set_volatilefile_into_prototypefile
1524 my ($prototypefile, $filesref) = @_;
1526 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1528 my $onefile = ${$filesref}[$i];
1531 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1533 if ( $styles =~ /\bVOLATILEFILE\b/ )
1535 my $sourcepath = $onefile->{'sourcepath'};
1537 for ( my $j = 0; $j <= $#{$prototypefile}; $j++ )
1539 if (( ${$prototypefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$prototypefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1541 my $oldline = ${$prototypefile}[$j];
1542 ${$prototypefile}[$j] =~ s/^\s*f/v/;
1543 my $newline = ${$prototypefile}[$j];
1544 $oldline =~ s/\s*$//;
1545 $newline =~ s/\s*$//;
1546 my $infoline = "Volatile file: Changing content from \"$oldline\" to \"$newline\" .\n";
1547 push(@installer::globals
::logfileinfo
, $infoline);
1555 #########################################################################
1556 # Replacing the variables in the Solaris patch shell scripts.
1557 # Taking care, that multiple slashes are not always removed.
1558 #########################################################################
1560 sub replace_variables_in_shellscripts_for_patch
1562 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1564 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1566 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1568 my $oldline = ${$scriptfile}[$i];
1569 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; }
1570 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1571 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1572 push(@installer::globals
::logfileinfo
, $infoline);
1577 #########################################################################
1578 # Replacing the variables in the shell scripts or in the epm list file
1580 # Solaris: preinstall, postinstall, preremove, postremove
1581 # If epm is used in the original version (not relocatable)
1582 # the variables have to be exchanged in the list file,
1584 #########################################################################
1586 sub replace_variables_in_shellscripts
1588 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1591 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1593 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1595 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1597 my $oldline = ${$scriptfile}[$i];
1598 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1599 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1600 my $infoline = "Info
: Substituting
in $scriptfilename $oldstring by
$newstring\n";
1601 push(@installer::globals::logfileinfo, $infoline);
1604 $infoline = "Old Line
: $oldline";
1605 push(@installer::globals::logfileinfo, $infoline);
1606 $infoline = "New Line
: ${$scriptfile}[$i]";
1607 push(@installer::globals::logfileinfo, $infoline);
1613 ############################################################
1614 # Determinig the directory created by epm, in which the
1615 # RPMS or Solaris packages are created.
1616 ############################################################
1618 sub determine_installdir_ooo
1620 # A simple "ls
" command returns the directory name
1624 my $systemcall = "ls
|";
1625 open (LS, "$systemcall");
1629 $dirname =~ s/\s*$//;
1631 my $infoline = "Info
: Directory created by epm
: $dirname\n";
1632 push(@installer::globals::logfileinfo, $infoline);
1637 ############################################################
1638 # Setting the tab content into the file container
1639 ############################################################
1641 sub set_tab_into_datafile
1643 my ($changefile, $filesref) = @_;
1645 my @newclasses = ();
1646 my $newclassesstring = "";
1648 if ( $installer::globals::issolarispkgbuild )
1650 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1652 my $onefile = ${$filesref}[$i];
1654 if ( $onefile->{'SolarisClass'} )
1656 my $sourcepath = $onefile->{'sourcepath'};
1658 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1660 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1662 my $oldline = ${$changefile}[$j];
1663 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1664 my $newline = ${$changefile}[$j];
1665 $oldline =~ s/\s*$//;
1666 $newline =~ s/\s*$//;
1668 my $infoline = "TAB
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1669 push(@installer::globals::logfileinfo, $infoline);
1671 # collecting all new classes
1672 if (! installer::existence::exists_in_array($onefile->{'SolarisClass'}, \@newclasses))
1674 push(@newclasses, $onefile->{'SolarisClass'});
1683 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1686 if ( $installer::globals::islinuxrpmbuild )
1688 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1690 my $onefile = ${$filesref}[$i];
1692 if ( $onefile->{'SpecFileContent'} )
1694 my $destination = $onefile->{'destination'};
1696 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1698 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1703 my $oldline = ${$changefile}[$j];
1704 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1705 my $newline = ${$changefile}[$j];
1707 $oldline =~ s/\s*$//;
1708 $newline =~ s/\s*$//;
1710 my $infoline = "TAB
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1711 push(@installer::globals::logfileinfo, $infoline);
1720 return $newclassesstring;
1723 ############################################################
1724 # Including additional classes into the pkginfo file
1725 ############################################################
1727 sub include_classes_into_pkginfo
1729 my ($changefile, $classesstring) = @_;
1731 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1733 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1735 ${$changefile}[$i] =~ s/\s*$//;
1736 my $oldline = ${$changefile}[$i];
1737 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1738 my $newline = ${$changefile}[$i];
1739 $newline =~ s/\s*$//;
1741 my $infoline = "pkginfo file
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1742 push(@installer::globals::logfileinfo, $infoline);
1747 ##########################################################################################
1748 # Checking, if an extension is included into the package (Linux).
1749 # All extension files have to be installed into directory
1750 # share/extension/install
1751 # %attr(0444,root,root) "/opt/staroffice
8/share/extension
/install/SunSearchToolbar
.oxt
"
1752 ##########################################################################################
1754 sub is_extension_package
1756 my ($specfile) = @_;
1758 my $is_extension_package = 0;
1760 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1762 my $line = ${$specfile}[$i];
1763 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1765 $is_extension_package = 1;
1770 return $is_extension_package;
1773 ######################################################################
1774 # Checking, if an extension is included into the package (Solaris).
1775 # All extension files have to be installed into directory
1776 # share/extension/install
1777 ######################################################################
1779 sub get_extension_name
1781 my ($prototypefile) = @_;
1783 my $extensionName = "";
1785 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1787 my $line = ${$prototypefile}[$i];
1788 if ( $line =~ /^\s*f\s+none\s+share\/extension\/install\/(\w+?\.oxt)\s*\=/ )
1790 $extensionName = $1;
1795 return $extensionName;
1799 ############################################################
1800 # A Solaris patch contains 7 specific scripts
1801 ############################################################
1803 sub add_scripts_into_prototypefile
1805 my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_;
1807 # The files are stored in the directory $installer::globals::patchincludepath
1808 # The file names are available via @installer::globals::solarispatchscripts
1810 my $path = $installer::globals::patchincludepath;
1811 $path =~ s/\/\s*$//;
1812 $path = $path . $installer::globals::separator;
1815 my $extensionname = get_extension_name($prototypefile);
1817 if ( $extensionname ne "" )
1819 for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ )
1821 my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i];
1822 my $destfile = $installer::globals::solarispatchscriptsforextensions[$i];
1824 # If the sourcepath has "_extension
" in its name, this has to be removed
1825 $destfile =~ s/_extensions\s*$//; # hard coded renaming of script name
1827 # Creating unique directory name with $prototypefilename
1828 my $extensiondir = installer::systemactions::create_directories("extensionscripts
", $languagestringref);
1830 if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; }
1831 $prototypefilename =~ s/\./_/g;
1832 my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename;
1833 if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); }
1834 my $destpath = $destdir . $installer::globals::separator . $destfile;
1835 if ( -f $destpath ) { unlink($destpath); }
1838 my $scriptfile = installer::files::read_file($sourcefilename);
1840 # Replacing variables
1841 my $oldstring = "\
$\
{OXTFILENAME\
}";
1842 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $extensionname);
1843 $oldstring = "PRODUCTDIRECTORYNAME
";
1844 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath);
1847 installer::files::save_file($destpath, $scriptfile);
1849 # Writing file destination into prototype file
1850 my $line = "i
$destfile=" . $destpath . "\n";
1851 push(@newlines, $line);
1856 for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ )
1858 my $line = "i
$installer::globals
::solarispatchscripts
[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n";
1859 push(@newlines, $line);
1863 # Including the new lines after the last line starting with "i
"
1865 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1867 if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ )
1869 splice(@{$prototypefile}, $i, 1); # ignoring old copyright text, using patch standard
1872 if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; }
1873 splice(@{$prototypefile}, $i, 0, @newlines);
1878 ############################################################
1879 # Adding patch infos in pkginfo file
1880 ############################################################
1882 sub include_patchinfos_into_pkginfo
1884 my ( $changefile, $filename, $variableshashref ) = @_;
1886 # SUNW_PATCHID=101998-10
1887 # SUNW_OBSOLETES=114999-01 113999-01
1890 # SUNW_REQUIRES=126411-01
1892 my $patchidname = "SOLSPARCPATCHID
";
1893 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID
"; }
1895 if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR
: Variable
$patchidname not defined in zip list file
!", "include_patchinfos_into_pkginfo
"); }
1897 my $newline = "SUNW_PATCHID
=" . $variableshashref->{$patchidname} . "\n";
1898 add_one_line_into_file($changefile, $newline, $filename);
1900 my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES
";
1901 if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES
"; }
1904 if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; }
1905 $newline = "SUNW_OBSOLETES
=" . $obsoletes . "\n";
1906 add_one_line_into_file($changefile, $newline, $filename);
1908 my $patchrequiresname = "SOLSPARCPATCHREQUIRES
";
1909 if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES
"; }
1911 if ( $variableshashref->{$patchrequiresname} )
1913 my $requires = $variableshashref->{$patchrequiresname};
1914 $newline = "SUNW_REQUIRES
=" . $requires . "\n";
1915 add_one_line_into_file($changefile, $newline, $filename);
1918 $newline = "SUNW_PATCH_PROPERTIES
=\n";
1919 add_one_line_into_file($changefile, $newline, $filename);
1921 # $newline = "SUNW_PKGTYPE
=usr
\n";
1922 # add_one_line_into_file($changefile, $newline, $filename);
1924 # $newline = "SUNW_PKGVERS
=1.0\n";
1925 # add_one_line_into_file($changefile, $newline, $filename);
1928 ############################################################
1929 # Setting the correct Solaris locales
1930 ############################################################
1932 sub get_solaris_language_for_langpack
1934 my ( $onelanguage ) = @_;
1936 my $sollanguage = $onelanguage;
1937 $sollanguage =~ s/\-/\_/;
1939 if ( $sollanguage eq "de
" ) { $sollanguage = "de
"; }
1940 elsif ( $sollanguage eq "es
" ) { $sollanguage = "es
"; }
1941 elsif ( $sollanguage eq "fr
" ) { $sollanguage = "fr
"; }
1942 elsif ( $sollanguage eq "it
" ) { $sollanguage = "it
"; }
1943 elsif ( $sollanguage eq "sv
" ) { $sollanguage = "sv
"; }
1944 elsif ( $sollanguage eq "pt_BR
" ) { $sollanguage = "pt_BR
"; }
1945 elsif ( $sollanguage eq "ja
" ) { $sollanguage = "ja
,ja_JP
,ja_JP
.PCK
,ja_JP
.UTF
-8"; }
1946 elsif ( $sollanguage eq "ko
" ) { $sollanguage = "ko
,ko
.UTF
-8"; }
1947 elsif ( $sollanguage eq "zh_CN
" ) { $sollanguage = "zh
,zh
.GBK
,zh_CN
,zh_CN
.GB18030
,zh
.UTF
-8"; }
1948 elsif ( $sollanguage eq "zh_TW
" ) { $sollanguage = "zh_TW
,zh_TW
.BIG5
,zh_TW
.UTF
-8,zh_HK
.BIG5HK
,zh_HK
.UTF
-8"; }
1950 return $sollanguage;
1953 ############################################################
1954 # Adding language infos in pkginfo file
1955 ############################################################
1957 sub include_languageinfos_into_pkginfo
1959 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1961 # SUNWPKG_LIST=core01
1964 my $locallang = $onepackage->{'language'};
1965 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1967 my $newline = "SUNW_LOC
=" . $solarislanguage . "\n";
1968 add_one_line_into_file($changefile, $newline, $filename);
1970 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1971 if ( $onepackage->{'pkg_list_entry'} )
1973 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1974 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1975 $newline = "SUNW_PKGLIST
=" . $packagelistentry . "\n";
1976 add_one_line_into_file($changefile, $newline, $filename);
1980 # Using default package ooobasis30-core01.
1981 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01
";
1982 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1983 $newline = "SUNW_PKGLIST
=" . $packagelistentry . "\n";
1984 add_one_line_into_file($changefile, $newline, $filename);
1988 ############################################################
1989 # Collecting all files included in patch in
1990 # @installer::globals::patchfilecollector
1991 ############################################################
1993 sub collect_patch_files
1995 my ($file, $packagename, $prefix) = @_;
1997 # $file is the spec file or the prototypefile
1999 $prefix = $prefix . "/";
2000 my $packagenamestring = "Package
" . $packagename . " \
:\n";
2001 push(@installer::globals::patchfilecollector, $packagenamestring);
2003 for ( my $i = 0; $i <= $#{$file}; $i++ )
2005 my $line = ${$file}[$i];
2007 if ( $installer::globals::islinuxrpmbuild )
2009 # %attr(0444,root,root) "/opt/openofficeorg
20/program/about
.bmp
"
2011 if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ )
2013 my $filename = $1 . "\n";
2014 $filename =~ s/^\s*\Q$prefix\E//;
2015 push(@installer::globals::patchfilecollector, $filename);
2019 if ( $installer::globals::issolarispkgbuild )
2021 # f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin
2023 if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ )
2025 my $filename = $1 . "\n";
2026 push(@installer::globals::patchfilecollector, $filename);
2031 push(@installer::globals::patchfilecollector, "\n");
2035 ############################################################
2036 # Including package names into the depend files.
2037 # The package names have to be included into
2038 # packagelist. They are already saved in
2039 # %installer::globals::dependfilenames.
2040 ############################################################
2042 sub put_packagenames_into_dependfile
2046 for ( my $i = 0; $i <= $#{$file}; $i++ )
2048 my $line = ${$file}[$i];
2049 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
2051 my $abbreviation = $1;
2053 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR
: Could
not resolve all properties
in Solaris
package abbreviation
\"$abbreviation\"!", "read_packagemap
"); }
2055 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
2057 my $packagename = $installer::globals::dependfilenames{$abbreviation};
2058 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR
: Could
not resolve all properties
in Solaris
package name
\"$packagename\"!", "read_packagemap
"); }
2061 ${$file}[$i] = $line . "\t" . $packagename . "\n";
2065 installer::exiter::exit_program("ERROR
: Missing packagename
for Solaris
package \"$abbreviation\"!", "put_packagenames_into_dependfile
");
2071 ############################################################
2072 # Including the relocatable directory into
2073 # spec file and pkginfo file
2074 # Linux: set topdir in specfile
2075 # Solaris: remove $relocatablepath (/opt/)
2076 # for all objects in prototype file
2077 # and changing "topdir
" for Linux
2078 ############################################################
2080 sub prepare_packages
2082 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
2086 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
2088 my $localrelocatablepath = $relocatablepath;
2089 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\
/\s*$//; }
2091 if ( $installer::globals
::issolarispkgbuild
)
2093 $filename = $packagename . ".pkginfo";
2094 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
2097 if ( $installer::globals
::islinuxrpmbuild
)
2099 # if ( $localrelocatablepath =~ /^\s*$/ ) { $localrelocatablepath = "/"; }; # at least the "/"
2100 $filename = $packagename . ".spec";
2101 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
2104 my $completefilename = $newepmdir . $filename;
2106 if ( ! -f
$completefilename) { installer
::exiter
::exit_program
("ERROR: Did not find file: $completefilename", "prepare_packages"); }
2107 my $changefile = installer
::files
::read_file
($completefilename);
2108 if ( $newline ne "" )
2110 add_one_line_into_file
($changefile, $newline, $filename);
2111 installer
::files
::save_file
($completefilename, $changefile);
2114 # my $newepmdir = $completefilename;
2115 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$newepmdir);
2117 # adding new "topdir" and removing old "topdir" in specfile
2119 if ( $installer::globals
::islinuxrpmbuild
)
2121 set_topdir_in_specfile
($changefile, $filename, $newepmdir);
2122 set_autoprovreq_in_specfile
($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin");
2123 set_packager_in_specfile
($changefile);
2124 if ( is_extension_package
($changefile) ) { set_prereq_in_specfile
($changefile); }
2125 set_license_in_specfile
($changefile, $variableshashref);
2126 set_tab_into_datafile
($changefile, $filesref);
2127 # check_requirements_in_specfile($changefile);
2128 installer
::files
::save_file
($completefilename, $changefile);
2129 if ( $installer::globals
::patch
) { collect_patch_files
($changefile, $packagename, $localrelocatablepath); }
2132 # removing the relocatable path in prototype file
2134 if ( $installer::globals
::issolarispkgbuild
)
2136 set_revision_in_pkginfo
($changefile, $filename, $variableshashref, $packagename);
2137 set_maxinst_in_pkginfo
($changefile, $filename);
2138 set_solaris_parameter_in_pkginfo
($changefile, $filename, $variableshashref);
2139 if ( $installer::globals
::issolarisx86build
) { fix_architecture_setting
($changefile); }
2140 if ( ! $installer::globals
::patch
) { set_patchlist_in_pkginfo_for_respin
($changefile, $filename, $variableshashref, $packagename); }
2141 if ( $installer::globals
::patch
) { include_patchinfos_into_pkginfo
($changefile, $filename, $variableshashref); }
2142 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" )) { include_languageinfos_into_pkginfo
($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
2143 installer
::files
::save_file
($completefilename, $changefile);
2145 my $prototypefilename = $packagename . ".prototype";
2146 $prototypefilename = $newepmdir . $prototypefilename;
2147 if (! -f
$prototypefilename) { installer
::exiter
::exit_program
("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
2149 my $prototypefile = installer
::files
::read_file
($prototypefilename);
2150 make_prototypefile_relocatable
($prototypefile, $relocatablepath);
2151 set_volatilefile_into_prototypefile
($prototypefile, $filesref);
2152 my $classesstring = set_tab_into_datafile
($prototypefile, $filesref);
2155 include_classes_into_pkginfo
($changefile, $classesstring);
2156 installer
::files
::save_file
($completefilename, $changefile);
2159 if ( $installer::globals
::patch
) { add_scripts_into_prototypefile
($prototypefile, $prototypefilename, $languagestringref, $staticpath); }
2161 installer
::files
::save_file
($prototypefilename, $prototypefile);
2162 if ( $installer::globals
::patch
) { collect_patch_files
($prototypefile, $packagename, ""); }
2164 # Adding package names into depend files for Solaris (not supported by epm)
2165 my $dependfilename = $packagename . ".depend";
2166 $dependfilename = $newepmdir . $dependfilename;
2167 if ( -f
$dependfilename)
2169 my $dependfile = installer
::files
::read_file
($dependfilename);
2170 put_packagenames_into_dependfile
($dependfile);
2171 installer
::files
::save_file
($dependfilename, $dependfile);
2178 ############################################################
2179 # Linux requirement for perl is changed by epm from
2180 # /usr/bin/perl to perl .
2182 ############################################################
2184 sub check_requirements_in_specfile
2186 my ( $specfile ) = @_;
2188 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
2190 if (( ${$specfile}[$i] =~ /^\s*Requires/ ) && ( ${$specfile}[$i] =~ /\bperl\b/ ) && ( ! ( ${$specfile}[$i] =~ /\/usr\
/bin\/perl
\b/ )))
2192 my $oldline = ${$specfile}[$i];
2193 ${$specfile}[$i] =~ s/perl/\/usr\
/bin\/perl
/;
2194 my $newline = ${$specfile}[$i];
2196 $oldline =~ s/\s*$//;
2197 $newline =~ s/\s*$//;
2198 my $infoline = "Spec File: Changing content from \"$oldline\" to \"$newline\".\n";
2199 push(@installer::globals
::logfileinfo
, $infoline);
2204 ###############################################################################
2205 # Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
2207 # The complete rootpath is stored in $installer::globals::rootpath
2208 # or for each package in $onepackage->{'destpath'}
2209 # The static rootpath is stored in $staticpath
2210 # The relocatable path is stored in $relocatablepath
2211 # PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
2212 # PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
2213 # In standard epm process:
2214 # No usage of package specific variables like $BASEDIR, because
2215 # 1. These variables would be replaced in epm process
2216 # 2. epm version 3.7 does not support relocatable packages
2217 ###############################################################################
2219 sub resolve_path_in_epm_list_before_packaging
2221 my ($listfile, $listfilename, $variable, $path) = @_;
2223 installer
::logger
::include_header_into_logfile
("Replacing variables in epm list file:");
2225 $path =~ s/\/\s*$//;
2226 replace_variables_in_shellscripts
($listfile, $listfilename, $variable, $path);
2230 #################################################################
2231 # Determining the rpm version. Beginning with rpm version 4.0
2232 # the tool to create RPMs is "rpmbuild" and no longer "rpm"
2233 #################################################################
2235 sub determine_rpm_version
2240 my $systemcall = "rpm --version |";
2241 open (RPM
, "$systemcall");
2245 $rpmout =~ s/\s*$//g;
2247 my $infoline = "Systemcall: $systemcall\n";
2248 push( @installer::globals
::logfileinfo
, $infoline);
2250 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
2251 else { $infoline = "Success: rpm version: $rpmout\n"; }
2253 push( @installer::globals
::logfileinfo
, $infoline);
2255 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2256 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2257 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
2258 else { installer
::exiter
::exit_program
("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
2263 #################################################
2264 # Systemcall to start the packaging process
2265 #################################################
2267 sub create_packages_without_epm
2269 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
2271 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
2272 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
2273 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
2275 if ( $installer::globals
::issolarispkgbuild
)
2277 my $prototypefile = $epmdir . $packagename . ".prototype";
2278 if (! -f
$prototypefile) { installer
::exiter
::exit_program
("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
2280 my $destinationdir = $prototypefile;
2281 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destinationdir);
2282 $destinationdir =~ s/\/\s*$//; # removing ending slashes
2284 # my $systemcall = "pkgmk -o -f $prototypefile -d $destinationdir \> /dev/null 2\>\&1";
2285 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
2286 installer
::logger
::print_message
( "... $systemcall ...\n" );
2288 my $maxpkgmkcalls = 3;
2290 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
2292 my @pkgmkoutput = ();
2294 open (PKGMK
, "$systemcall");
2295 while (<PKGMK
>) {push(@pkgmkoutput, $_); }
2298 my $returnvalue = $?
; # $? contains the return value of the systemcall
2300 my $infoline = "Systemcall (Try $i): $systemcall\n";
2301 push( @installer::globals
::logfileinfo
, $infoline);
2303 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
2305 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2306 push( @installer::globals
::logfileinfo
, "$pkgmkoutput[$j]");
2311 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2312 push( @installer::globals
::logfileinfo
, $infoline);
2313 if ( $i == $maxpkgmkcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2317 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
2318 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2319 push( @installer::globals
::logfileinfo
, $infoline);
2324 # It might be necessary to save uncompressed Solaris packages
2326 if ( $allvariables->{'JDSBUILD'} )
2328 if ( ! $installer::globals
::jds_language_controlled
)
2330 my $correct_language = installer
::worker
::check_jds_language
($allvariables, $languagestringref);
2331 $installer::globals
::correct_jds_language
= $correct_language;
2332 $installer::globals
::jds_language_controlled
= 1;
2335 if ( $installer::globals
::correct_jds_language
)
2337 if ( $installer::globals
::saved_packages_path
eq "" )
2339 $packagestempdir = installer
::systemactions
::create_directories
("jds", $languagestringref);
2340 $installer::globals
::saved_packages_path
= $packagestempdir;
2341 push(@installer::globals
::jdsremovedirs
, $packagestempdir);
2344 $systemcall = "cd $destinationdir; cp -p -R $packagename $installer::globals::saved_packages_path;";
2345 make_systemcall
($systemcall);
2346 installer
::logger
::print_message
( "... $systemcall ...\n" );
2348 # Setting unix rights to "775" for all created directories inside the package,
2349 # that is saved in temp directory
2351 $systemcall = "cd $packagestempdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2352 installer
::logger
::print_message
( "... $systemcall ...\n" );
2354 $returnvalue = system($systemcall);
2356 $infoline = "Systemcall: $systemcall\n";
2357 push( @installer::globals
::logfileinfo
, $infoline);
2361 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2362 push( @installer::globals
::logfileinfo
, $infoline);
2366 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2367 push( @installer::globals
::logfileinfo
, $infoline);
2372 # compressing packages
2374 if ( ! $installer::globals
::solarisdontcompress
)
2376 my $faspac = "faspac-so.sh";
2378 my $compressorref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$faspac, $includepatharrayref, 0);
2379 if ($$compressorref ne "")
2381 # Saving original pkginfo, to set time stamp later
2382 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
2383 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
2384 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
2385 make_systemcall
($systemcall);
2387 $faspac = $$compressorref;
2388 $infoline = "Found compressor: $faspac\n";
2389 push( @installer::globals
::logfileinfo
, $infoline);
2391 installer
::logger
::print_message
( "... $faspac ...\n" );
2392 installer
::logger
::include_timestamp_into_logfile
("Starting $faspac");
2394 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
2395 make_systemcall
($systemcall);
2397 # Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file,
2398 # updated the size and checksum, but not the time stamp.
2399 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
2400 make_systemcall
($systemcall);
2401 if ( -f
$pkginfotmp ) { unlink($pkginfotmp); }
2403 installer
::logger
::include_timestamp_into_logfile
("End of $faspac");
2407 $infoline = "Not found: $faspac\n";
2408 push( @installer::globals
::logfileinfo
, $infoline);
2412 # Setting unix rights to "775" for all created directories inside the package
2414 $systemcall = "cd $destinationdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2415 installer
::logger
::print_message
( "... $systemcall ...\n" );
2417 $returnvalue = system($systemcall);
2419 $infoline = "Systemcall: $systemcall\n";
2420 push( @installer::globals
::logfileinfo
, $infoline);
2424 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2425 push( @installer::globals
::logfileinfo
, $infoline);
2429 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2430 push( @installer::globals
::logfileinfo
, $infoline);
2433 ######################
2435 ######################
2437 # my $streamname = $packagename . ".pkg";
2438 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
2439 # print "... $systemcall ...\n";
2441 # $returnvalue = system($systemcall);
2443 # $infoline = "Systemcall: $systemcall\n";
2444 # push( @installer::globals::logfileinfo, $infoline);
2448 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2449 # push( @installer::globals::logfileinfo, $infoline);
2453 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2454 # push( @installer::globals::logfileinfo, $infoline);
2457 #########################
2458 # making tar.gz files
2459 #########################
2461 # my $targzname = $packagename . ".tar.gz";
2462 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
2463 # print "... $systemcall ...\n";
2465 # $returnvalue = system($systemcall);
2467 # $infoline = "Systemcall: $systemcall\n";
2468 # push( @installer::globals::logfileinfo, $infoline);
2472 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2473 # push( @installer::globals::logfileinfo, $infoline);
2477 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2478 # push( @installer::globals::logfileinfo, $infoline);
2482 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2484 if ( $installer::globals
::islinuxrpmbuild
)
2486 my $specfilename = $epmdir . $packagename . ".spec";
2487 if (! -f
$specfilename) { installer
::exiter
::exit_program
("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2489 my $rpmcommand = "rpm";
2490 my $rpmversion = determine_rpm_version
();
2492 if ( $rpmversion >= 4 ) { $rpmcommand = "rpmbuild"; }
2494 # saving globally for later usage
2495 $installer::globals
::rpmcommand
= $rpmcommand;
2496 $installer::globals
::rpmquerycommand
= "rpm"; # For queries "rpm" is used, not "rpmbuild"
2499 if ( $installer::globals
::compiler
=~ /unxlngi/) { $target = "i586"; }
2500 elsif ( $installer::globals
::compiler
=~ /unxlng/) {$target = (POSIX
::uname
())[4]; }
2502 # rpm 4.6 ignores buildroot tag in spec file
2504 my $buildrootstring = "";
2506 if ( $rpmversion >= 4 )
2509 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2510 $buildrootstring = "--buildroot=$buildroot";
2513 my $systemcall = "$rpmcommand -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2515 installer
::logger
::print_message
( "... $systemcall ...\n" );
2517 my $maxrpmcalls = 3;
2519 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2523 open (RPM
, "$systemcall");
2524 while (<RPM
>) {push(@rpmoutput, $_); }
2527 my $returnvalue = $?
; # $? contains the return value of the systemcall
2529 my $infoline = "Systemcall (Try $i): $systemcall\n";
2530 push( @installer::globals
::logfileinfo
, $infoline);
2532 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2534 if ( $i < $maxrpmcalls ) { $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2535 push( @installer::globals
::logfileinfo
, "$rpmoutput[$j]");
2540 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2541 push( @installer::globals
::logfileinfo
, $infoline);
2542 if ( $i == $maxrpmcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2546 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
2547 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2548 push( @installer::globals
::logfileinfo
, $infoline);
2555 #################################################
2556 # Removing all temporary files created by epm
2557 #################################################
2559 sub remove_temporary_epm_files
2561 my ($epmdir, $loggingdir, $packagename) = @_;
2563 # saving the files into the loggingdir
2565 if ( $installer::globals
::issolarispkgbuild
)
2567 my @extensions = ();
2568 push(@extensions, ".pkginfo");
2569 push(@extensions, ".prototype");
2570 push(@extensions, ".postinstall");
2571 push(@extensions, ".postremove");
2572 push(@extensions, ".preinstall");
2573 push(@extensions, ".preremove");
2574 push(@extensions, ".depend");
2576 for ( my $i = 0; $i <= $#extensions; $i++ )
2578 my $removefile = $epmdir . $packagename . $extensions[$i];
2579 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2581 if (! -f
$removefile) { next; }
2583 my $systemcall = "mv -f $removefile $destfile";
2584 system($systemcall); # ignoring the return value
2585 $infoline = "Systemcall: $systemcall\n";
2586 push( @installer::globals
::logfileinfo
, $infoline);
2589 # removing the package
2591 # my $removedir = $epmdir . $packagename;
2593 # my $systemcall = "rm -rf $removedir";
2595 # print "... $systemcall ...\n";
2597 # my $returnvalue = system($systemcall);
2599 # my $infoline = "Systemcall: $systemcall\n";
2600 # push( @installer::globals::logfileinfo, $infoline);
2604 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2605 # push( @installer::globals::logfileinfo, $infoline);
2609 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2610 # push( @installer::globals::logfileinfo, $infoline);
2614 if ( $installer::globals
::islinuxrpmbuild
)
2616 my $removefile = $epmdir . $packagename . ".spec";
2617 my $destfile = $loggingdir . $packagename . ".spec.log";
2619 # if (! -f $removefile) { next; }
2621 my $systemcall = "mv -f $removefile $destfile";
2622 system($systemcall); # ignoring the return value
2623 $infoline = "Systemcall: $systemcall\n";
2624 push( @installer::globals
::logfileinfo
, $infoline);
2626 # removing the directory "buildroot"
2628 my $removedir = $epmdir . "buildroot";
2630 $systemcall = "rm -rf $removedir";
2632 installer
::logger
::print_message
( "... $systemcall ...\n" );
2634 my $returnvalue = system($systemcall);
2636 my $infoline = "Systemcall: $systemcall\n";
2637 push( @installer::globals
::logfileinfo
, $infoline);
2641 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2642 push( @installer::globals
::logfileinfo
, $infoline);
2646 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2647 push( @installer::globals
::logfileinfo
, $infoline);
2652 ######################################################
2653 # Making the systemcall
2654 ######################################################
2658 my ($systemcall) = @_;
2660 my $returnvalue = system($systemcall);
2662 my $infoline = "Systemcall: $systemcall\n";
2663 push( @installer::globals
::logfileinfo
, $infoline);
2667 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2668 push( @installer::globals
::logfileinfo
, $infoline);
2672 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2673 push( @installer::globals
::logfileinfo
, $infoline);
2677 ###########################################################
2678 # Creating a better directory structure in the solver.
2679 ###########################################################
2681 sub create_new_directory_structure
2683 my ($newepmdir) = @_;
2685 my $newdir = $installer::globals
::epmoutpath
;
2687 if ( $installer::globals
::islinuxrpmbuild
)
2691 if ( $installer::globals
::compiler
=~ /unxlngi/) {
2692 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2694 elsif ( $installer::globals
::compiler
=~ /unxlng/) {
2695 $machine = (POSIX
::uname
())[4];
2696 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2698 else { installer
::exiter
::exit_program
("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2700 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2702 my $returnvalue = system($systemcall);
2704 my $infoline = "Systemcall: $systemcall\n";
2705 push( @installer::globals
::logfileinfo
, $infoline);
2709 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2710 push( @installer::globals
::logfileinfo
, $infoline);
2714 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2715 push( @installer::globals
::logfileinfo
, $infoline);
2718 # and removing the empty directory
2720 if ( $machine ne "" )
2722 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/$machine");
2724 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/x86_64");
2725 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/i586");
2726 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/i386");
2727 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS");
2731 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2733 my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1";
2734 my $callreturnvalue = system($localcall);
2736 my $callinfoline = "Systemcall: $localcall\n";
2737 push( @installer::globals
::logfileinfo
, $callinfoline);
2739 if ($callreturnvalue)
2741 $callinfoline = "ERROR: Could not execute \"$localcall\"!\n";
2742 push( @installer::globals
::logfileinfo
, $callinfoline);
2746 $callinfoline = "Success: Executed \"$localcall\" successfully!\n";
2747 push( @installer::globals
::logfileinfo
, $callinfoline);
2753 ######################################################
2754 # Collect modules with product specific styles.
2755 ######################################################
2757 sub collect_modules_with_style
2759 my ($style, $modulesarrayref) = @_;
2761 my @allmodules = ();
2763 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2765 my $onemodule = ${$modulesarrayref}[$i];
2767 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2768 if ( $styles =~ /\b\Q$style\E\b/ )
2770 push(@allmodules, $onemodule);
2774 return \
@allmodules;
2777 ######################################################
2778 # Remove modules without packagecontent.
2779 ######################################################
2781 sub remove_modules_without_package
2783 my ($allmodules) = @_;
2785 my @allmodules = ();
2787 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2789 my $onemodule = ${$allmodules}[$i];
2790 my $packagename = "";
2791 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2792 if ( $packagename ne "" )
2794 push(@allmodules, $onemodule);
2798 return \
@allmodules;
2801 ######################################################
2802 # Unpacking tar.gz file and setting new packagename.
2803 ######################################################
2805 sub unpack_tar_gz_file
2807 my ($packagename, $destdir) = @_;
2809 my $newpackagename = "";
2811 if ( $packagename =~ /\.tar\.gz\s*$/ )
2813 # Collecting all packages in directory "packages"
2814 my $oldcontent = installer
::systemactions
::read_directory
($destdir);
2817 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -";
2818 make_systemcall
($systemcall);
2820 # deleting the tar.gz files
2821 $systemcall = "cd $destdir; rm -f $packagename";
2822 make_systemcall
($systemcall);
2824 # Finding new content -> that is the package name
2825 my ($newcontent, $allcontent ) = installer
::systemactions
::find_new_content_in_directory
($destdir, $oldcontent);
2826 $newpackagename = ${$newcontent}[0];
2827 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$newpackagename);
2830 if ( $newpackagename ne "" ) { $packagename = $newpackagename; }
2832 return $packagename;
2835 ######################################################
2836 # Copying files of child projects.
2837 ######################################################
2839 sub copy_childproject_files
2841 my ($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, $subdir, $includepatharrayref, $use_sopackpath) = @_;
2843 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2845 my $localdestdir = $destdir;
2846 my $onemodule = ${$allmodules}[$i];
2847 my $packagename = $onemodule->{'PackageName'};
2848 my $sourcefile = "";
2849 if ( $use_sopackpath )
2851 $sourcefile = $sopackpath . $installer::globals
::separator
. $installer::globals
::compiler
. $installer::globals
::separator
. $subdir . $installer::globals
::separator
. $packagename;
2855 my $sourcepathref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$packagename, $includepatharrayref, 1);
2856 $sourcefile = $$sourcepathref;
2859 if ( ! -f
$sourcefile ) { installer
::exiter
::exit_program
("ERROR: File not found: $sourcefile ($packagename) !", "copy_childproject_files"); }
2860 if ( $onemodule->{'Subdir'} )
2862 $localdestdir = $localdestdir . $installer::globals
::separator
. $onemodule->{'Subdir'};
2863 if ( ! -d
$localdestdir ) { installer
::systemactions
::create_directory
($localdestdir); }
2865 installer
::systemactions
::copy_one_file
($sourcefile, $localdestdir);
2866 # Solaris: unpacking tar.gz files and setting new packagename
2867 if ( $installer::globals
::issolarispkgbuild
) { $packagename = unpack_tar_gz_file
($packagename, $localdestdir); }
2869 if (( $installer::globals
::isxpdplatform
) && ( $allvariables->{'XPDINSTALLER'} ))
2871 installer
::xpdinstaller
::create_xpd_file_for_childproject
($onemodule, $localdestdir, $packagename, $allvariableshashref, $modulesarrayref);
2877 ######################################################
2878 # Copying files for system integration.
2879 ######################################################
2881 sub copy_and_unpack_tar_gz_files
2883 my ($sourcefile, $destdir) = @_;
2885 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2886 make_systemcall
($systemcall);
2889 ######################################################
2890 # Including child packages into the
2892 ######################################################
2894 sub put_childprojects_into_installset
2896 my ($newdir, $allvariables, $modulesarrayref, $includepatharrayref) = @_;
2900 my $sopackpath = "";
2901 if ( $ENV{'SO_PACK'} ) { $sopackpath = $ENV{'SO_PACK'}; }
2902 else { installer
::exiter
::exit_program
("ERROR: Environment variable SO_PACK not set!", "put_childprojects_into_installset"); }
2904 my $destdir = "$newdir";
2908 my $sourcefile = "";
2910 # Finding the modules defined in scp (with flag JAVAMODULE, ADAMODULE, ...)
2911 # Getting name of package from scp-Module
2912 # Copy file into installation set
2913 # Create xpd file and put it into xpd directory
2914 # xpd file has to be created completely from module and package itself (-> no packagelist!)
2916 if ( $allvariables->{'JAVAPRODUCT'} )
2918 # Collect all modules with flag "JAVAMODULE"
2919 my $allmodules = collect_modules_with_style
("JAVAMODULE", $modulesarrayref);
2920 $allmodules = remove_modules_without_package
($allmodules);
2921 copy_childproject_files
($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "jre", $includepatharrayref, 1);
2924 # Adding additional required packages (freetype).
2925 # This package names are stored in global array @installer::globals::requiredpackages
2927 if ( $allvariables->{'ADDREQUIREDPACKAGES'} )
2929 # Collect all modules with flag "REQUIREDPACKAGEMODULE"
2930 my $allmodules = collect_modules_with_style
("REQUIREDPACKAGEMODULE", $modulesarrayref);
2931 $allmodules = remove_modules_without_package
($allmodules);
2932 copy_childproject_files
($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "requiredpackages", $includepatharrayref, 1);
2935 # Collect all modules with flag "USERLANDMODULE"
2936 my $alluserlandmodules = collect_modules_with_style
("USERLANDMODULE", $modulesarrayref);
2937 $alluserlandmodules = remove_modules_without_package
($alluserlandmodules);
2938 copy_childproject_files
($alluserlandmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "", $includepatharrayref, 0);
2942 ######################################################
2943 # Checking whether the new content is a directory and
2944 # not a package. If it is a directory, the complete
2945 # content of the directory has to be added to the
2947 ######################################################
2949 sub control_subdirectories
2951 my ($content, $subdir) = @_;
2953 my @newcontent = ();
2955 for ( my $i = 0; $i <= $#{$content}; $i++ )
2957 if ( -d
${$content}[$i] )
2959 $subdir = ${$content}[$i];
2960 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$subdir);
2961 my $allpackages = installer
::systemactions
::read_directory
(${$content}[$i]);
2962 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
2964 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
2965 if (( $installer::globals
::islinuxbuild
) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
2966 push(@newcontent, ${$allpackages}[$j]);
2971 push(@newcontent, ${$content}[$i]);
2975 return (\
@newcontent, $subdir);
2978 ######################################################
2979 # Including the system integration files into the
2980 # installation sets.
2981 ######################################################
2983 sub put_systemintegration_into_installset
2985 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
2987 my $destdir = $newdir;
2989 # adding System integration files
2991 my $sourcefile = "";
2993 # Finding the modules defined in scp (with flag SYSTEMMODULE)
2994 # Getting name of package from scp-Module
2995 # Search package in list off all include files
2996 # Copy file into installation set and unpack it (always tar.gz)
2997 # Create xpd file and put it into xpd directory
2998 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
2999 # xpd file has to be created completely from module and package itself (-> no packagelist!)
3001 # Collect all modules with flag "SYSTEMMODULE"
3002 my $allmodules = collect_modules_with_style
("SYSTEMMODULE", $modulesarrayref);
3003 $allmodules = remove_modules_without_package
($allmodules);
3005 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
3007 my $onemodule = ${$allmodules}[$i];
3008 my $packagetarfilename = $onemodule->{'PackageName'};
3010 my $infoline = "Including into installation set: $packagetarfilename\n";
3011 push( @installer::globals
::logfileinfo
, $infoline);
3013 my $sourcepathref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$packagetarfilename, $includepatharrayref, 1);
3014 if ( $$sourcepathref eq "" ) { installer
::exiter
::exit_program
("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
3016 # Collecting all packages in directory "packages" or "RPMS"
3017 my $oldcontent = installer
::systemactions
::read_directory
($destdir);
3019 copy_and_unpack_tar_gz_files
($$sourcepathref, $destdir);
3021 # Finding new content -> that is the package name
3022 my ($newcontent, $allcontent ) = installer
::systemactions
::find_new_content_in_directory
($destdir, $oldcontent);
3024 # special handling, if new content is a directory
3026 if ( ! $installer::globals
::issolarispkgbuild
) { ($newcontent, $subdir) = control_subdirectories
($newcontent); }
3028 # Adding license content into Solaris packages
3029 if (( $installer::globals
::issolarispkgbuild
) && ( $installer::globals
::englishlicenseset
)) { installer
::worker
::add_license_into_systemintegrationpackages
($destdir, $newcontent); }
3031 if (( $installer::globals
::isxpdplatform
) && ( $allvariables->{'XPDINSTALLER'} ))
3033 installer
::xpdinstaller
::create_xpd_file_for_systemintegration
($onemodule, $newcontent, $modulesarrayref, $subdir);
3038 ######################################################
3039 # Analyzing the Unix installation path.
3040 # From the installation path /opt/openofficeorg20
3041 # is the part /opt relocatable and the part
3042 # openofficeorg20 static.
3043 ######################################################
3045 sub analyze_rootpath
3047 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
3049 $rootpath =~ s/\/\s*$//; # removing ending slash
3051 ##############################################################
3052 # Version 1: "/opt" is variable and "openofficeorg20" fixed
3053 ##############################################################
3055 # my $staticpath = $rootpath;
3056 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$staticpath);
3057 # $$staticpathref = $staticpath; # will be "openofficeorg20"
3059 # my $relocatablepath = $rootpath;
3060 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$relocatablepath);
3061 # $$relocatablepathref = $relocatablepath; # will be "/opt/"
3063 ##############################################################
3064 # Version 2: "/opt/openofficeorg20" is variable and "" fixed
3065 ##############################################################
3067 # if ( $$relocatablepathref eq "" ) # relocatablepath is not defined in package list
3069 # $$staticpathref = ""; # will be ""
3070 # $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/openofficeorg20/"
3071 # # setting the static path to the hostname of the directory with style OFFICEDIRECTORY
3072 # if ( $allvariables->{'SETSTATICPATH'} ) { $$staticpathref = $installer::globals::officedirhostname; }
3075 # else # relocatablepath is defined in package list
3077 # $$relocatablepathref =~ s/\/\s*$//; # removing ending slash
3078 # $$relocatablepathref = $$relocatablepathref . "\/"; # relocatable path must end with "/"
3079 # my $staticpath = $rootpath;
3080 # $staticpath =~ s/\Q$$relocatablepathref\E//;
3081 # $staticpath =~ s/\/\s*$//;
3082 # $$staticpathref = $staticpath;
3085 ##############################################################
3086 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
3087 ##############################################################
3089 $$relocatablepathref = "/";
3090 # Static path has to contain the office directory name. This is replaced in shellscripts.
3091 $$staticpathref = $rootpath . $installer::globals
::separator
. $installer::globals
::officedirhostname
;
3092 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
3093 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
3094 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
3095 if ( $installer::globals
::islinuxrpmbuild
)
3097 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
3098 $$staticpathref = $installer::globals
::officedirhostname
; # to be used as replacement in shell scripts
3101 if ( $installer::globals
::islinuxdebbuild
)
3103 $$relocatablepathref = "";
3104 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
3105 # $$staticpathref = $rootpath . $installer::globals::separator . $$staticpathref; # no relocatibility for Debian
3110 ######################################################
3111 # Including license and readme into
3112 # Unix installation sets.
3113 ######################################################
3115 sub put_installsetfiles_into_installset
3119 # All files for the installation set are saved in the global
3120 # array @installer::globals::installsetfiles
3122 for ( my $i = 0; $i <= $#installer::globals
::installsetfiles
; $i++ )
3124 my $onefile = $installer::globals
::installsetfiles
[$i];
3125 my $sourcefile = $onefile->{'sourcepath'};
3127 if ( $installer::globals
::addjavainstaller
) { $destfile = $onefile->{'Name'}; }
3128 else { $destfile = $destdir . $installer::globals
::separator
. $onefile->{'Name'}; }
3129 installer
::systemactions
::copy_one_file
($sourcefile, $destfile);
3131 my $infoline = "Adding to installation set \"$destfile\" from source \"$sourcefile\".\n";
3132 push( @installer::globals
::logfileinfo
, $infoline);
3136 ######################################################
3137 # Replacing one variable in patchinfo file
3138 ######################################################
3140 sub replace_one_variable_in_file
3142 my ( $file, $placeholder, $value ) = @_;
3144 for ( my $i = 0; $i <= $#{$file}; $i++ )
3146 ${$file}[$i] =~ s/$placeholder/$value/g;
3150 ######################################################
3151 # Setting variables in the patchinfo file
3152 ######################################################
3156 my ( $patchinfofile, $patchid, $allvariables ) = @_;
3158 # Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER
3160 replace_one_variable_in_file
($patchinfofile, "PATCHIDPLACEHOLDER", $patchid);
3162 my $architecture = "";
3163 if ( $installer::globals
::issolarissparcbuild
) { $architecture = "sparc"; }
3164 if ( $installer::globals
::issolarisx86build
) { $architecture = "i386"; }
3166 replace_one_variable_in_file
($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture);
3168 if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer
::exiter
::exit_program
("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); }
3169 my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'};
3171 replace_one_variable_in_file
($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects);
3173 # Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists
3174 my $requiresstring = "";
3175 if ( $installer::globals
::issolarissparcbuild
) { $requiresstring = "SOLSPARCPATCHREQUIRES"; }
3176 if ( $installer::globals
::issolarisx86build
) { $requiresstring = "SOLIAPATCHREQUIRES"; }
3178 if ( $allvariables->{$requiresstring} )
3180 my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n";
3181 push(@
{$patchinfofile}, $newline);
3185 ######################################################
3186 # Finalizing patch: Renaming directory and
3187 # including additional patch files.
3188 ######################################################
3192 my ( $newepmdir, $allvariables ) = @_;
3194 my $patchidname = "SOLSPARCPATCHID";
3195 if ( $installer::globals
::issolarisx86build
) { $patchidname = "SOLIAPATCHID"; }
3197 if ( ! $allvariables->{$patchidname} ) { installer
::exiter
::exit_program
("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); }
3198 my $patchid = $allvariables->{$patchidname};
3199 installer
::systemactions
::rename_directory
($newepmdir, $patchid);
3201 # Copying all typical patch files into the patch directory
3202 # All patch file names are stored in @installer::globals::solarispatchfiles
3203 # Location of the file is $installer::globals::patchincludepath
3205 my $sourcepath = $installer::globals
::patchincludepath
;
3206 $sourcepath =~ s/\/\s*$//;
3208 for ( my $i = 0; $i <= $#installer::globals
::solarispatchfiles
; $i++ )
3210 my $sourcefile = $sourcepath . $installer::globals
::separator
. $installer::globals
::solarispatchfiles
[$i];
3211 my $destfile = $patchid . $installer::globals
::separator
. $installer::globals
::solarispatchfiles
[$i];
3212 installer
::systemactions
::copy_one_file
($sourcefile, $destfile);
3215 # And editing the patchinfo file
3217 my $patchinfofilename = $patchid . $installer::globals
::separator
. "patchinfo";
3218 my $patchinfofile = installer
::files
::read_file
($patchinfofilename);
3219 set_patchinfo
($patchinfofile, $patchid, $allvariables);
3220 installer
::files
::save_file
($patchinfofilename, $patchinfofile);
3223 ######################################################
3224 # Finalizing Linux patch: Renaming directory and
3225 # including additional patch files.
3226 ######################################################
3228 sub finalize_linux_patch
3230 my ( $newepmdir, $allvariables, $includepatharrayref ) = @_;
3232 # Copying the setup into the patch directory
3233 # and including the list of RPMs into it
3235 print "... creating patch setup ...\n";
3237 installer
::logger
::include_header_into_logfile
("Creating Linux patch setup:");
3239 # find and read setup script template
3241 my $scriptfilename = "linuxpatchscript.sh";
3242 my $scriptref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$scriptfilename, $includepatharrayref, 0);
3243 if ($$scriptref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); }
3244 my $scriptfile = installer
::files
::read_file
($$scriptref);
3246 my $infoline = "Found script file $scriptfilename: $$scriptref \n";
3247 push( @installer::globals
::logfileinfo
, $infoline);
3249 # Collecting all RPMs in the patch directory
3251 my $fileextension = "rpm";
3252 my $rpmfiles = installer
::systemactions
::find_file_with_file_extension
($fileextension, $newepmdir);
3253 if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); }
3254 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); }
3256 # my $installline = "";
3258 # for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3260 # $installline = $installline . " rpm --prefix \$PRODUCTINSTALLLOCATION -U $newepmdir/${$rpmfiles}[$i]\n";
3263 # $installline =~ s/\s*$//;
3265 # for ( my $j = 0; $j <= $#{$scriptfile}; $j++ )
3267 # ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/;
3270 # Searching packagename containing -core01
3271 my $found_package = 0;
3272 my $searchpackagename = "";
3273 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3275 if ( ${$rpmfiles}[$i] =~ /-core01-/ )
3277 $searchpackagename = ${$rpmfiles}[$i];
3279 if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; }
3284 if ( ! $found_package ) { installer
::exiter
::exit_program
("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); }
3286 # Replacing the searchpackagename
3287 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; }
3289 # Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname
3290 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; }
3292 # Replacing the productname
3293 my $productname = $allvariables->{'PRODUCTNAME'};
3294 $productname = lc($productname);
3295 $productname =~ s/ /_/g; # abc office -> abc_office
3296 # $productname =~ s/\.//g; # openoffice.org -> openofficeorg
3298 $infoline = "Adding productname $productname into Linux patch script\n";
3299 push( @installer::globals
::logfileinfo
, $infoline);
3301 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; }
3305 my $newscriptfilename = "setup"; # $newepmdir . $installer::globals::separator . "setup";
3306 installer
::files
::save_file
($newscriptfilename, $scriptfile);
3308 $infoline = "Saved Linux patch setup $newscriptfilename \n";
3309 push( @installer::globals
::logfileinfo
, $infoline);
3311 # Setting unix rights 755
3312 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";