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. But not for all products
458 if (( $installer::globals
::issolarispkgbuild
) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} ))
460 if ( ! $installer::globals
::englishlicenseset
) { installer
::worker
::set_english_license
() }
462 # The location for the new file
463 my $languagestring = "";
464 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; }
465 $languagestring =~ s/^\s*_//;
467 my $copyrightdir = installer
::systemactions
::create_directories
("copyright", \
$languagestring);
469 my $copyrightfile = installer
::files
::read_file
($$fileref);
471 # Adding license content to copyright file
472 push(@
{$copyrightfile}, "\n");
473 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
475 # New destination for $$fileref
476 $$fileref = $copyrightdir . $installer::globals
::separator
. "solariscopyrightfile_" . $onepackage->{'module'};
477 if ( -f
$$fileref ) { unlink $$fileref; }
478 installer
::files
::save_file
($$fileref, $copyrightfile);
481 $infoline = "Using license file: \"$$fileref\"!\n";
482 push(@installer::globals
::logfileinfo
, $infoline);
484 $foundlicensefile = 1;
485 $line = "%license" . " " . $$fileref . "\n";
486 push(@epmheader, $line);
490 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
492 my $onefile = ${$filesinproduct}[$i];
493 my $filename = $onefile->{'Name'};
495 if ( $filename eq $licensefilename )
497 $foundlicensefile = 1;
498 $line = "%license" . " " . $onefile->{'sourcepath'} . "\n";
499 push(@epmheader, $line);
505 if (!($foundlicensefile))
507 installer
::exiter
::exit_program
("ERROR: Could not find license file $licensefilename", "create_epm_header");
510 if (!($foundreadmefile))
512 installer
::exiter
::exit_program
("ERROR: Could not find readme file $readmefilename", "create_epm_header");
515 # including %replaces
519 if (( $installer::globals
::issolarispkgbuild
) && ( ! $installer::globals
::patch
))
521 $replaces = "solarisreplaces"; # the name in the packagelist
523 elsif (( $installer::globals
::islinuxbuild
) && ( ! $installer::globals
::patch
))
525 $replaces = "linuxreplaces"; # the name in the packagelist
528 if (( $replaces ) && ( ! $installer::globals
::patch
))
530 if ( $onepackage->{$replaces} )
532 my $replacesstring = $onepackage->{$replaces};
534 my $allreplaces = installer
::converter
::convert_stringlist_into_array
(\
$replacesstring, ",");
536 for ( my $i = 0; $i <= $#{$allreplaces}; $i++ )
538 my $onereplaces = ${$allreplaces}[$i];
539 $onereplaces =~ s/\s*$//;
540 installer
::packagelist
::resolve_packagevariables
(\
$onereplaces, $variableshashref, 1);
541 if ( $installer::globals
::linuxlinkrpmprocess
) { $onereplaces = $onereplaces . "u"; }
542 $line = "%replaces" . " " . $onereplaces . "\n";
543 push(@epmheader, $line);
545 # Force the openofficeorg packages to get removed,
546 # see http://www.debian.org/doc/debian-policy/ch-relationships.html
547 # 7.5.2 Replacing whole packages, forcing their removal
549 if ( $installer::globals
::debian
)
551 $line = "%incompat" . " " . $onereplaces . "\n";
552 push(@epmheader, $line);
556 if ( $installer::globals
::debian
&& $variableshashref->{'UNIXPRODUCTNAME'} eq 'openoffice.org' )
558 $line = "%provides" . " openoffice.org-unbundled\n";
559 push(@epmheader, $line);
560 $line = "%incompat" . " openoffice.org-bundled\n";
561 push(@epmheader, $line);
566 # including the directives for %requires and %provides
571 if ( $installer::globals
::issolarispkgbuild
)
573 $provides = "solarisprovides"; # the name in the packagelist
574 $requires = "solarisrequires"; # the name in the packagelist
576 elsif ( $installer::globals
::isfreebsdpkgbuild
)
578 $provides = "freebsdprovides"; # the name in the packagelist
579 $requires = "freebsdrequires"; # the name in the packagelist
581 elsif (( $installer::globals
::islinuxrpmbuild
) &&
582 ( $installer::globals
::patch
) &&
583 ( exists($onepackage->{'linuxpatchrequires'}) ))
585 $provides = "provides"; # the name in the packagelist
586 $requires = "linuxpatchrequires"; # the name in the packagelist
590 $provides = "provides"; # the name in the packagelist
591 $requires = "requires"; # the name in the packagelist
594 # if ( $installer::globals::patch )
596 # $onepackage->{$provides} = "";
598 if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; }
600 # $onepackage->{$requires} = "";
603 if ( $onepackage->{$provides} )
605 my $providesstring = $onepackage->{$provides};
607 my $allprovides = installer
::converter
::convert_stringlist_into_array
(\
$providesstring, ",");
609 for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
611 my $oneprovides = ${$allprovides}[$i];
612 $oneprovides =~ s/\s*$//;
613 installer
::packagelist
::resolve_packagevariables
(\
$oneprovides, $variableshashref, 1);
614 if ( $installer::globals
::linuxlinkrpmprocess
) { $oneprovides = $oneprovides . "u"; }
615 $line = "%provides" . " " . $oneprovides . "\n";
616 push(@epmheader, $line);
620 if ( $onepackage->{$requires} )
622 my $requiresstring = $onepackage->{$requires};
624 if ( $installer::globals
::add_required_package
) { $requiresstring = $requiresstring . "," . $installer::globals
::add_required_package
; }
626 # The requires string can contain the separator "," in the names (descriptions) of the packages
627 # (that are required for Solaris depend files). Therefore "," inside such a description has to
628 # masked with a backslash.
629 # This masked separator need to be found and replaced, before the stringlist is converted into an array.
630 # This replacement has to be turned back after the array is created.
632 my $replacementstring = "COMMAREPLACEMENT";
633 $requiresstring = installer
::converter
::replace_masked_separator
($requiresstring, ",", "$replacementstring");
635 my $allrequires = installer
::converter
::convert_stringlist_into_array
(\
$requiresstring, ",");
637 installer
::converter
::resolve_masked_separator
($allrequires, ",", $replacementstring);
639 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
641 my $onerequires = ${$allrequires}[$i];
642 $onerequires =~ s/\s*$//;
643 installer
::packagelist
::resolve_packagevariables2
(\
$onerequires, $variableshashref, 0, $isdict);
645 # Special handling for Solaris. In depend files, the names of the packages are required, not
646 # only the abbreviation. Therefore there is a special syntax for names in packagelist:
647 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
648 # if ( $installer::globals::issolarispkgbuild )
650 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
654 # $installer::globals::dependfilenames{$onerequires} = $packagename;
658 $line = "%requires" . " " . $onerequires . "\n";
659 push(@epmheader, $line);
664 if ( $installer::globals
::add_required_package
)
666 my $requiresstring = $installer::globals
::add_required_package
;
668 my $replacementstring = "COMMAREPLACEMENT";
669 $requiresstring = installer
::converter
::replace_masked_separator
($requiresstring, ",", "$replacementstring");
670 my $allrequires = installer
::converter
::convert_stringlist_into_array
(\
$requiresstring, ",");
671 installer
::converter
::resolve_masked_separator
($allrequires, ",", $replacementstring);
673 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
675 my $onerequires = ${$allrequires}[$i];
676 $onerequires =~ s/\s*$//;
677 installer
::packagelist
::resolve_packagevariables
(\
$onerequires, $variableshashref, 0);
679 # Special handling for Solaris. In depend files, the names of the packages are required, not
680 # only the abbreviation. Therefore there is a special syntax for names in packagelist:
681 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
682 # if ( $installer::globals::issolarispkgbuild )
684 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
688 # $installer::globals::dependfilenames{$onerequires} = $packagename;
692 $line = "%requires" . " " . $onerequires . "\n";
693 push(@epmheader, $line);
701 #######################################
702 # Adding header to epm file
703 #######################################
705 sub adding_header_to_epm_file
707 my ($epmfileref, $epmheaderref) = @_;
709 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
711 push( @
{$epmfileref}, ${$epmheaderref}[$i] );
714 push( @
{$epmfileref}, "\n\n" );
717 #####################################################
718 # Replace one in shell scripts ( ${VARIABLENAME} )
719 #####################################################
721 sub replace_variable_in_shellscripts
723 my ($scriptref, $variable, $searchstring) = @_;
725 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
727 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
731 ###################################################
732 # Replace one in shell scripts ( %VARIABLENAME )
733 ###################################################
735 sub replace_percent_variable_in_shellscripts
737 my ($scriptref, $variable, $searchstring) = @_;
739 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
741 ${$scriptref}[$i] =~ s/\%$searchstring/$variable/g;
745 ################################################
746 # Replacing many variables in shell scripts
747 ################################################
749 sub replace_many_variables_in_shellscripts
751 my ($scriptref, $variableshashref) = @_;
755 foreach $key (keys %{$variableshashref})
757 my $value = $variableshashref->{$key};
758 if ( ! $value =~ /.oxt/ ) { $value = lc($value); } # lowercase !
759 if ( $installer::globals
::issolarisbuild
) { $value =~ s/\.org/org/g; } # openofficeorg instead of openoffice.org
760 replace_variable_in_shellscripts
($scriptref, $value, $key);
764 #######################################
765 # Setting oxt file name variable
766 #######################################
770 my ($filesinpackage, $allvariables) = @_;
772 for ( my $i = 0; $i <= $#{$filesinpackage}; $i++ )
774 my $onefile = ${$filesinpackage}[$i];
775 if ( $onefile->{'Name'} =~ /.oxt\s*$/ )
777 $allvariables->{'OXTFILENAME'} = $onefile->{'Name'};
778 # $allvariables->{'FULLOXTFILENAME'} = $onefile->{'destination'};
779 last; # only one oxt file for each rpm!
784 #######################################
785 # Adding shell scripts to epm file
786 #######################################
788 sub adding_shellscripts_to_epm_file
790 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
792 # Setting variable for ${OXTFILENAME} into $allvariableshashref, if this is a RPM with an extension
793 set_oxt_filename
($filesinpackage, $allvariableshashref);
795 # $installer::globals::shellscriptsfilename
797 push( @
{$epmfileref}, "\n\n" );
799 my $shellscriptsfileref = installer
::files
::read_file
($shellscriptsfilename);
801 replace_variable_in_shellscripts
($shellscriptsfileref, $localrootpath, "rootpath");
803 replace_many_variables_in_shellscripts
($shellscriptsfileref, $allvariableshashref);
805 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
807 push( @
{$epmfileref}, ${$shellscriptsfileref}[$i] );
810 push( @
{$epmfileref}, "\n" );
813 #################################################
814 # Determining the epm on the system
815 #################################################
817 sub find_epm_on_system
819 my ($includepatharrayref) = @_;
821 installer
::logger
::include_header_into_logfile
("Check epm on system");
825 # epm should be defined through the configure script but we need to
826 # check for it to be defined because of the Sun environment.
827 # Check the environment variable first and if it is not defined,
828 # or if it is but the location is not executable, search further.
829 # It has to be found in the solver or it has to be in the path
830 # (saved in $installer::globals::epm_in_path) or we get the specified
831 # one through the environment (i.e. when --with-epm=... is specified)
835 if (($ENV{'EPM'} ne "") && (-x
"$ENV{'EPM'}"))
837 $epmname = $ENV{'EPM'};
839 elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") )
842 my $epmref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
( \
$epmname, $includepatharrayref, 0);
843 if ($$epmref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find program $epmname (EPM set to \"internal\" or \"no\")!", "find_epm_on_system"); }
848 installer
::exiter
::exit_program
("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
853 my $epmfileref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$epmname, $includepatharrayref, 0);
855 if (($$epmfileref eq "") && (!($installer::globals
::epm_in_path
))) { installer
::exiter
::exit_program
("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
856 if (($$epmfileref eq "") && ($installer::globals
::epm_in_path
)) { $epmname = $installer::globals
::epm_path
; }
857 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
860 my $infoline = "Using epmfile: $epmname\n";
861 push( @installer::globals
::logfileinfo
, $infoline);
866 #################################################
867 # Determining the epm patch state
868 # saved in $installer::globals::is_special_epm
869 #################################################
873 my ($epmexecutable) = @_;
877 my $systemcall = "$epmexecutable |";
878 open (EPMPATCH
, "$systemcall");
883 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals
::is_special_epm
= 1; }
888 if ( $installer::globals
::is_special_epm
)
890 $infoline = "\nPatch state: This is a patched version of epm!\n\n";
891 push( @installer::globals
::logfileinfo
, $infoline);
895 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
896 push( @installer::globals
::logfileinfo
, $infoline);
899 if ( ( $installer::globals
::is_special_epm
) && (($installer::globals
::islinuxrpmbuild
) || ($installer::globals
::issolarispkgbuild
)) )
901 # Special postprocess handling only for Linux RPM and Solaris packages
902 $installer::globals
::postprocess_specialepm
= 1;
903 $installer::globals
::postprocess_standardepm
= 0;
907 $installer::globals
::postprocess_specialepm
= 0;
908 $installer::globals
::postprocess_standardepm
= 1;
912 #################################################
913 # LD_PRELOAD string for Debian packages
914 #################################################
916 sub get_ld_preload_string
918 my ($includepatharrayref) = @_;
920 my $getuidlibraryname = "getuid.so";
922 my $getuidlibraryref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$getuidlibraryname, $includepatharrayref, 0);
923 if ($$getuidlibraryref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); }
925 my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
927 return $ldpreloadstring;
930 #################################################
931 # Calling epm to create the installation sets
932 #################################################
936 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
938 installer
::logger
::include_header_into_logfile
("epm call for $packagename");
940 my $packageformat = $installer::globals
::packageformat
;
942 my $localpackagename = $packagename;
943 # Debian allows only lowercase letters in package name
944 if ( $installer::globals
::debian
) { $localpackagename = lc($localpackagename); }
946 my $outdirstring = "";
947 if ( $installer::globals
::epmoutpath
ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
949 # Debian package build needs a LD_PRELOAD for correct rights
951 my $ldpreloadstring = "";
953 if ( $installer::globals
::debian
) { $ldpreloadstring = get_ld_preload_string
($includepatharrayref) . " "; }
956 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
958 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " -v " . " 2\>\&1 |";
960 installer
::logger
::print_message
( "... $systemcall ...\n" );
964 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
968 open (EPM
, "$systemcall");
969 while (<EPM
>) {push(@epmoutput, $_); }
972 my $returnvalue = $?
; # $? contains the return value of the systemcall
974 my $infoline = "Systemcall (Try $i): $systemcall\n";
975 push( @installer::globals
::logfileinfo
, $infoline);
977 for ( my $j = 0; $j <= $#epmoutput; $j++ )
979 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
980 push( @installer::globals
::logfileinfo
, "$epmoutput[$j]");
985 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
986 push( @installer::globals
::logfileinfo
, $infoline);
987 if ( $i == $maxepmcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "call_epm"); }
991 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
992 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
993 push( @installer::globals
::logfileinfo
, $infoline);
999 #####################################################################
1000 # Adding the new line for relocatables into pkginfo file (Solaris)
1001 # or spec file (Linux) created by epm
1002 #####################################################################
1004 sub add_one_line_into_file
1006 my ($file, $insertline, $filename) = @_;
1008 if ( $installer::globals
::issolarispkgbuild
)
1010 push(@
{$file}, $insertline); # simply adding at the end of pkginfo file
1013 if ( $installer::globals
::islinuxrpmbuild
)
1015 # Adding behind the line beginning with: Group:
1017 my $inserted_line = 0;
1019 for ( my $i = 0; $i <= $#{$file}; $i++ )
1021 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
1023 splice(@
{$file},$i+1,0,$insertline);
1029 if (! $inserted_line) { installer
::exiter
::exit_program
("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
1032 $insertline =~ s/\s*$//; # removing line end for correct logging
1033 my $infoline = "Success: Added line $insertline into file $filename!\n";
1034 push( @installer::globals
::logfileinfo
, $infoline);
1037 #####################################################################
1038 # Setting the revision VERSION=1.9,REV=66 .
1039 # Also adding the new line: "AutoReqProv: no"
1040 #####################################################################
1042 sub set_revision_in_pkginfo
1044 my ($file, $filename, $variables, $packagename) = @_;
1046 my $revisionstring = "\,REV\=" . $installer::globals
::packagerevision
;
1048 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
1050 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
1054 $year = $year + 1900;
1056 if ( $mday < 10 ) { $mday = "0" . $mday; }
1057 if ( $mon < 10 ) { $mon = "0" . $mon; }
1058 $datestring = $year . "." . $mon . "." . $mday;
1059 $revisionstring = $revisionstring . "." . $datestring;
1061 for ( my $i = 0; $i <= $#{$file}; $i++ )
1063 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
1066 my $newstring = $oldstring . $revisionstring; # also adding the date string
1067 ${$file}[$i] =~ s/$oldstring/$newstring/;
1068 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1069 push( @installer::globals
::logfileinfo
, $infoline);
1074 # For Update and Patch reasons, this string can also be kept constant
1076 my $pkgversion = "SOLSPARCPKGVERSION";
1077 if ( $installer::globals
::issolarisx86build
) { $pkgversion = "SOLIAPKGVERSION"; }
1079 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
1081 if ( $variables->{$pkgversion} ne "FINALVERSION" )
1083 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
1084 # 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
1085 # and therefore be set as $pkgversion.
1086 # The first part "3.0.0" has to be derived from the
1088 my $version = $installer::globals
::packageversion
;
1089 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
1095 my $finalmajor = $major;
1096 my $finalminor = $minor;
1099 # if (( $packagename =~ /-ure\s*$/ ) && ( $finalmajor == 1 )) { $finalminor = 4; }
1101 $version = "$finalmajor.$finalminor.$finalmicro";
1104 my $versionstring = "$version,$variables->{$pkgversion}";
1106 for ( my $i = 0; $i <= $#{$file}; $i++ )
1108 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
1111 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
1112 my $oldstring = ${$file}[$i];
1113 ${$file}[$i] = $newstring;
1114 $oldstring =~ s/\s*$//;
1115 $newstring =~ s/\s*$//;
1116 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1117 push( @installer::globals
::logfileinfo
, $infoline);
1125 ########################################################
1126 # Setting Patch information for Respin versions
1127 # into pkginfo file. This prevents Respin versions
1129 ########################################################
1131 sub set_patchlist_in_pkginfo_for_respin
1133 my ($changefile, $filename, $allvariables, $packagename) = @_;
1135 my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN";
1136 if ( $installer::globals
::issolarisx86build
) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; }
1138 if ( $allvariables->{$patchlistname} )
1140 # patchlist separator is a blank
1141 my $allpatchesstring = $allvariables->{$patchlistname};
1142 my @usedpatches = ();
1144 # Analyzing the patchlist
1145 # Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01
1146 # Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01
1147 my $allpatches = installer
::converter
::convert_whitespace_stringlist_into_array
(\
$allpatchesstring);
1149 for ( my $i = 0; $i <= $#{$allpatches}; $i++ )
1151 my $patchdefinition = ${$allpatches}[$i];
1155 my $constraint = "";
1156 my $isusedpatch = 0;
1158 if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ )
1164 elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ )) # small syntax check
1166 # if there is a bracket in the $patchdefinition, but it does not
1167 # match the if-condition, this is an erroneous definition.
1168 installer
::exiter
::exit_program
("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin");
1172 $patchid = $patchdefinition;
1173 $isusedpatch = 1; # patches without constraint are always included
1176 if ( $symbol ne "" )
1178 if ( $symbol eq "+" )
1180 if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; }
1183 if ( $symbol eq "-" )
1185 if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; }
1189 if ( $isusedpatch ) { push(@usedpatches, $patchid); }
1192 if ( $#usedpatches > -1 )
1194 my $patchstring = installer
::converter
::convert_array_to_space_separated_string
(\
@usedpatches);
1196 my $newline = "PATCHLIST=" . $patchstring . "\n";
1197 add_one_line_into_file
($changefile, $newline, $filename);
1199 # Adding patch info for each used patch in the patchlist
1201 for ( my $i = 0; $i <= $#usedpatches; $i++ )
1203 my $patchid = $usedpatches[$i];
1204 my $key = "PATCH_INFO_" . $patchid;
1207 if ( ! $allvariables->{$key} ) { installer
::exiter
::exit_program
("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); }
1208 my $value = set_timestamp_in_patchinfo
($allvariables->{$key});
1209 $newline = $key . "=" . $value . "\n";
1211 add_one_line_into_file
($changefile, $newline, $filename);
1217 ########################################################
1218 # Solaris requires, that the time of patch installation
1219 # must not be empty.
1220 # Format: Mon Mar 24 11:20:56 PDT 2008
1221 # Log file: Tue Apr 29 23:26:19 2008 (04:31 min.)
1222 # Replace string: ${TIMESTAMP}
1223 ########################################################
1225 sub set_timestamp_in_patchinfo
1229 my $currenttime = localtime();
1231 if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ )
1235 $currenttime = $start . "CET " . $year;
1238 $value =~ s/\$\{TIMESTAMP\}/$currenttime/;
1243 ########################################################
1244 # Setting MAXINST=1000 into the pkginfo file.
1245 ########################################################
1247 sub set_maxinst_in_pkginfo
1249 my ($changefile, $filename) = @_;
1251 my $newline = "MAXINST\=1000\n";
1253 add_one_line_into_file
($changefile, $newline, $filename);
1256 #############################################################
1257 # Setting several Solaris variables into the pkginfo file.
1258 #############################################################
1260 sub set_solaris_parameter_in_pkginfo
1262 my ($changefile, $filename, $allvariables) = @_;
1273 my $productname = $allvariables->{'PRODUCTNAME'};
1274 $newline = "SUNW_PRODNAME=$productname\n";
1275 add_one_line_into_file
($changefile, $newline, $filename);
1277 my $productversion = "";
1278 if ( $allvariables->{'PRODUCTVERSION'} )
1280 $productversion = $allvariables->{'PRODUCTVERSION'};
1281 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1283 $newline = "SUNW_PRODVERS=$productversion\n";
1284 add_one_line_into_file
($changefile, $newline, $filename);
1286 $newline = "SUNW_PKGVERS=1\.0\n";
1287 add_one_line_into_file
($changefile, $newline, $filename);
1289 if ( $allvariables->{'SUNW_PKGTYPE'} )
1291 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1292 add_one_line_into_file
($changefile, $newline, $filename);
1296 $newline = "SUNW_PKGTYPE=\n";
1297 add_one_line_into_file
($changefile, $newline, $filename);
1300 $newline = "HOTLINE=Please contact your local service provider\n";
1301 add_one_line_into_file
($changefile, $newline, $filename);
1303 $newline = "EMAIL=\n";
1304 add_one_line_into_file
($changefile, $newline, $filename);
1308 #####################################################################
1309 # epm uses as archtecture for Solaris x86 "i86pc". This has to be
1310 # changed to "i386".
1311 #####################################################################
1313 sub fix_architecture_setting
1315 my ($changefile) = @_;
1317 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1319 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1321 ${$changefile}[$i] =~ s/i86pc/i386/;
1328 #####################################################################
1329 # Adding a new line for topdir into specfile, removing old
1331 #####################################################################
1333 sub set_topdir_in_specfile
1335 my ($changefile, $filename, $newepmdir) = @_;
1337 # $newepmdir =~ s/^\s*\.//; # removing leading "."
1338 $newepmdir = cwd
() . $installer::globals
::separator
. $newepmdir; # only absolute path allowed
1340 # removing "%define _topdir", if existing
1342 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1344 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1346 my $removeline = ${$changefile}[$i];
1347 $removeline =~ s/\s*$//;
1348 splice(@
{$changefile},$i,1);
1349 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1350 push( @installer::globals
::logfileinfo
, $infoline);
1355 # Adding "topdir" behind the line beginning with: Group:
1357 my $inserted_line = 0;
1359 my $topdirline = "\%define _topdir $newepmdir\n";
1361 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1363 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1365 splice(@
{$changefile},$i+1,0,$topdirline);
1367 $topdirline =~ s/\s*$//;
1368 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1369 push( @installer::globals
::logfileinfo
, $infoline);
1373 if (! $inserted_line) { installer
::exiter
::exit_program
("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1377 #####################################################################
1378 # Setting the packager in the spec file
1379 # Syntax: Packager: abc@def
1380 #####################################################################
1382 sub set_packager_in_specfile
1384 my ($changefile) = @_;
1386 my $packager = $installer::globals
::longmanufacturer
;
1388 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1390 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1393 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1394 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1395 push( @installer::globals
::logfileinfo
, $infoline);
1401 #####################################################################
1402 # Setting the requirements in the spec file (i81494)
1403 # Syntax: PreReq: "requirements" (only for shared extensions)
1404 #####################################################################
1406 sub set_prereq_in_specfile
1408 my ($changefile) = @_;
1410 my $prereq = "PreReq:";
1412 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1414 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1416 my $oldstring = ${$changefile}[$i];
1417 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1418 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1419 push( @installer::globals
::logfileinfo
, $infoline);
1424 #####################################################################
1425 # Setting the Auto[Req]Prov line and __find_requires
1426 #####################################################################
1428 sub set_autoprovreq_in_specfile
1430 my ($changefile, $findrequires, $bindir) = @_;
1432 my $autoreqprovline;
1434 if ( $findrequires )
1436 $autoreqprovline = "AutoProv\: no\n%define __find_requires $bindir/$findrequires\n";
1440 $autoreqprovline = "AutoReqProv\: no\n";
1443 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1445 # Adding "autoreqprov" behind the line beginning with: Group:
1446 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1448 splice(@
{$changefile},$i+1,0,$autoreqprovline);
1449 $autoreqprovline =~ s/\s*$//;
1450 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1451 push( @installer::globals
::logfileinfo
, $infoline);
1458 #####################################################################
1459 # Replacing Copyright with License in the spec file
1460 # Syntax: License: LGPL, SISSL
1461 #####################################################################
1463 sub set_license_in_specfile
1465 my ($changefile, $variableshashref) = @_;
1467 my $license = $variableshashref->{'LICENSENAME'};
1469 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1471 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1473 ${$changefile}[$i] = "License: $license\n";
1474 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1475 push( @installer::globals
::logfileinfo
, $infoline);
1481 #########################################################
1482 # Building relocatable Solaris packages means:
1483 # 1. Add "BASEDIR=/opt" into pkginfo
1484 # 2. Remove "/opt/" from all objects in prototype file
1485 # For step2 this function exists
1486 # Sample: d none /opt/openofficeorg20/help 0755 root other
1487 # -> d none openofficeorg20/help 0755 root other
1488 #########################################################
1490 sub make_prototypefile_relocatable
1492 my ($prototypefile, $relocatablepath) = @_;
1494 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1496 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w
+/ ) # this is an object line
1498 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1502 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1503 # This line has to be removed now
1505 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s
/\
/\s*$//; } # removing the ending slash
1507 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1509 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1511 my $line = ${$prototypefile}[$i];
1512 splice(@
{$prototypefile},$i,1); # removing the line
1514 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1515 push( @installer::globals
::logfileinfo
, $infoline);
1520 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1522 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1524 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1526 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1527 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1528 push( @installer::globals
::logfileinfo
, $infoline2);
1534 #########################################################################
1535 # In scp the flag VOLATEFILE can be used. This shall lead to style "v"
1536 # in Solaris prototype file. This is not supported by epm and has
1537 # therefore to be included in prototypefile, not in epm list file.
1538 #########################################################################
1540 sub set_volatilefile_into_prototypefile
1542 my ($prototypefile, $filesref) = @_;
1544 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1546 my $onefile = ${$filesref}[$i];
1549 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1551 if ( $styles =~ /\bVOLATILEFILE\b/ )
1553 my $sourcepath = $onefile->{'sourcepath'};
1555 for ( my $j = 0; $j <= $#{$prototypefile}; $j++ )
1557 if (( ${$prototypefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$prototypefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1559 my $oldline = ${$prototypefile}[$j];
1560 ${$prototypefile}[$j] =~ s/^\s*f/v/;
1561 my $newline = ${$prototypefile}[$j];
1562 $oldline =~ s/\s*$//;
1563 $newline =~ s/\s*$//;
1564 my $infoline = "Volatile file: Changing content from \"$oldline\" to \"$newline\" .\n";
1565 push(@installer::globals
::logfileinfo
, $infoline);
1573 #########################################################################
1574 # Replacing the variables in the Solaris patch shell scripts.
1575 # Taking care, that multiple slashes are not always removed.
1576 #########################################################################
1578 sub replace_variables_in_shellscripts_for_patch
1580 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1582 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1584 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1586 my $oldline = ${$scriptfile}[$i];
1587 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; }
1588 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1589 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1590 push(@installer::globals
::logfileinfo
, $infoline);
1595 #########################################################################
1596 # Replacing the variables in the shell scripts or in the epm list file
1598 # Solaris: preinstall, postinstall, preremove, postremove
1599 # If epm is used in the original version (not relocatable)
1600 # the variables have to be exchanged in the list file,
1602 #########################################################################
1604 sub replace_variables_in_shellscripts
1606 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1609 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1611 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1613 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1615 my $oldline = ${$scriptfile}[$i];
1616 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1617 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1618 my $infoline = "Info
: Substituting
in $scriptfilename $oldstring by
$newstring\n";
1619 push(@installer::globals::logfileinfo, $infoline);
1622 $infoline = "Old Line
: $oldline";
1623 push(@installer::globals::logfileinfo, $infoline);
1624 $infoline = "New Line
: ${$scriptfile}[$i]";
1625 push(@installer::globals::logfileinfo, $infoline);
1631 ############################################################
1632 # Determinig the directory created by epm, in which the
1633 # RPMS or Solaris packages are created.
1634 ############################################################
1636 sub determine_installdir_ooo
1638 # A simple "ls
" command returns the directory name
1642 my $systemcall = "ls
|";
1643 open (LS, "$systemcall");
1647 $dirname =~ s/\s*$//;
1649 my $infoline = "Info
: Directory created by epm
: $dirname\n";
1650 push(@installer::globals::logfileinfo, $infoline);
1655 ############################################################
1656 # Setting the tab content into the file container
1657 ############################################################
1659 sub set_tab_into_datafile
1661 my ($changefile, $filesref) = @_;
1663 my @newclasses = ();
1664 my $newclassesstring = "";
1666 if ( $installer::globals::issolarispkgbuild )
1668 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1670 my $onefile = ${$filesref}[$i];
1672 if ( $onefile->{'SolarisClass'} )
1674 my $sourcepath = $onefile->{'sourcepath'};
1676 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1678 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1680 my $oldline = ${$changefile}[$j];
1681 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1682 my $newline = ${$changefile}[$j];
1683 $oldline =~ s/\s*$//;
1684 $newline =~ s/\s*$//;
1686 my $infoline = "TAB
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1687 push(@installer::globals::logfileinfo, $infoline);
1689 # collecting all new classes
1690 if (! installer::existence::exists_in_array($onefile->{'SolarisClass'}, \@newclasses))
1692 push(@newclasses, $onefile->{'SolarisClass'});
1701 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1704 if ( $installer::globals::islinuxrpmbuild )
1706 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1708 my $onefile = ${$filesref}[$i];
1710 if ( $onefile->{'SpecFileContent'} )
1712 my $destination = $onefile->{'destination'};
1714 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1716 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1721 my $oldline = ${$changefile}[$j];
1722 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1723 my $newline = ${$changefile}[$j];
1725 $oldline =~ s/\s*$//;
1726 $newline =~ s/\s*$//;
1728 my $infoline = "TAB
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1729 push(@installer::globals::logfileinfo, $infoline);
1738 return $newclassesstring;
1741 ############################################################
1742 # Including additional classes into the pkginfo file
1743 ############################################################
1745 sub include_classes_into_pkginfo
1747 my ($changefile, $classesstring) = @_;
1749 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1751 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1753 ${$changefile}[$i] =~ s/\s*$//;
1754 my $oldline = ${$changefile}[$i];
1755 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1756 my $newline = ${$changefile}[$i];
1757 $newline =~ s/\s*$//;
1759 my $infoline = "pkginfo file
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1760 push(@installer::globals::logfileinfo, $infoline);
1765 ##########################################################################################
1766 # Checking, if an extension is included into the package (Linux).
1767 # All extension files have to be installed into directory
1768 # share/extension/install
1769 # %attr(0444,root,root) "/opt/staroffice
8/share/extension
/install/SunSearchToolbar
.oxt
"
1770 ##########################################################################################
1772 sub is_extension_package
1774 my ($specfile) = @_;
1776 my $is_extension_package = 0;
1778 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1780 my $line = ${$specfile}[$i];
1781 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1783 $is_extension_package = 1;
1788 return $is_extension_package;
1791 ######################################################################
1792 # Checking, if an extension is included into the package (Solaris).
1793 # All extension files have to be installed into directory
1794 # share/extension/install
1795 ######################################################################
1797 sub get_extension_name
1799 my ($prototypefile) = @_;
1801 my $extensionName = "";
1803 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1805 my $line = ${$prototypefile}[$i];
1806 if ( $line =~ /^\s*f\s+none\s+share\/extension\/install\/(\w+?\.oxt)\s*\=/ )
1808 $extensionName = $1;
1813 return $extensionName;
1817 ############################################################
1818 # A Solaris patch contains 7 specific scripts
1819 ############################################################
1821 sub add_scripts_into_prototypefile
1823 my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_;
1825 # The files are stored in the directory $installer::globals::patchincludepath
1826 # The file names are available via @installer::globals::solarispatchscripts
1828 my $path = $installer::globals::patchincludepath;
1829 $path =~ s/\/\s*$//;
1830 $path = $path . $installer::globals::separator;
1833 my $extensionname = get_extension_name($prototypefile);
1835 if ( $extensionname ne "" )
1837 for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ )
1839 my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i];
1840 my $destfile = $installer::globals::solarispatchscriptsforextensions[$i];
1842 # If the sourcepath has "_extension
" in its name, this has to be removed
1843 $destfile =~ s/_extensions\s*$//; # hard coded renaming of script name
1845 # Creating unique directory name with $prototypefilename
1846 my $extensiondir = installer::systemactions::create_directories("extensionscripts
", $languagestringref);
1848 if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; }
1849 $prototypefilename =~ s/\./_/g;
1850 my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename;
1851 if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); }
1852 my $destpath = $destdir . $installer::globals::separator . $destfile;
1853 if ( -f $destpath ) { unlink($destpath); }
1856 my $scriptfile = installer::files::read_file($sourcefilename);
1858 # Replacing variables
1859 my $oldstring = "\
$\
{OXTFILENAME\
}";
1860 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $extensionname);
1861 $oldstring = "PRODUCTDIRECTORYNAME
";
1862 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath);
1865 installer::files::save_file($destpath, $scriptfile);
1867 # Writing file destination into prototype file
1868 my $line = "i
$destfile=" . $destpath . "\n";
1869 push(@newlines, $line);
1874 for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ )
1876 my $line = "i
$installer::globals
::solarispatchscripts
[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n";
1877 push(@newlines, $line);
1881 # Including the new lines after the last line starting with "i
"
1883 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1885 if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ )
1887 splice(@{$prototypefile}, $i, 1); # ignoring old copyright text, using patch standard
1890 if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; }
1891 splice(@{$prototypefile}, $i, 0, @newlines);
1896 ############################################################
1897 # Adding patch infos in pkginfo file
1898 ############################################################
1900 sub include_patchinfos_into_pkginfo
1902 my ( $changefile, $filename, $variableshashref ) = @_;
1904 # SUNW_PATCHID=101998-10
1905 # SUNW_OBSOLETES=114999-01 113999-01
1908 # SUNW_REQUIRES=126411-01
1910 my $patchidname = "SOLSPARCPATCHID
";
1911 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID
"; }
1913 if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR
: Variable
$patchidname not defined in zip list file
!", "include_patchinfos_into_pkginfo
"); }
1915 my $newline = "SUNW_PATCHID
=" . $variableshashref->{$patchidname} . "\n";
1916 add_one_line_into_file($changefile, $newline, $filename);
1918 my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES
";
1919 if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES
"; }
1922 if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; }
1923 $newline = "SUNW_OBSOLETES
=" . $obsoletes . "\n";
1924 add_one_line_into_file($changefile, $newline, $filename);
1926 my $patchrequiresname = "SOLSPARCPATCHREQUIRES
";
1927 if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES
"; }
1929 if ( $variableshashref->{$patchrequiresname} )
1931 my $requires = $variableshashref->{$patchrequiresname};
1932 $newline = "SUNW_REQUIRES
=" . $requires . "\n";
1933 add_one_line_into_file($changefile, $newline, $filename);
1935 $newline = "SUNW_PATCH_PROPERTIES
=\n";
1936 add_one_line_into_file($changefile, $newline, $filename);
1937 # $newline = "SUNW_PKGTYPE
=usr
\n";
1938 # add_one_line_into_file($changefile, $newline, $filename);
1940 # $newline = "SUNW_PKGVERS
=1.0\n";
1941 # add_one_line_into_file($changefile, $newline, $filename);
1944 ############################################################
1945 # Setting the correct Solaris locales
1946 ############################################################
1948 sub get_solaris_language_for_langpack
1950 my ( $onelanguage ) = @_;
1952 my $sollanguage = $onelanguage;
1953 $sollanguage =~ s/\-/\_/;
1955 if ( $sollanguage eq "de
" ) { $sollanguage = "de
"; }
1956 elsif ( $sollanguage eq "en_US
" ) { $sollanguage = "en_AU
,en_CA
,en_GB
,en_IE
,en_MT
,en_NZ
,en_US
,en_US
.UTF
-8"; }
1957 elsif ( $sollanguage eq "es
" ) { $sollanguage = "es
"; }
1958 elsif ( $sollanguage eq "fr
" ) { $sollanguage = "fr
"; }
1959 elsif ( $sollanguage eq "hu
" ) { $sollanguage = "hu_HU
"; }
1960 elsif ( $sollanguage eq "it
" ) { $sollanguage = "it
"; }
1961 elsif ( $sollanguage eq "nl
" ) { $sollanguage = "nl_BE
,nl_NL
"; }
1962 elsif ( $sollanguage eq "pl
" ) { $sollanguage = "pl_PL
"; }
1963 elsif ( $sollanguage eq "sv
" ) { $sollanguage = "sv
"; }
1964 elsif ( $sollanguage eq "pt
" ) { $sollanguage = "pt_PT
"; }
1965 elsif ( $sollanguage eq "pt_BR
" ) { $sollanguage = "pt_BR
"; }
1966 elsif ( $sollanguage eq "ru
" ) { $sollanguage = "ru_RU
"; }
1967 elsif ( $sollanguage eq "ja
" ) { $sollanguage = "ja
,ja_JP
,ja_JP
.PCK
,ja_JP
.UTF
-8"; }
1968 elsif ( $sollanguage eq "ko
" ) { $sollanguage = "ko
,ko
.UTF
-8"; }
1969 elsif ( $sollanguage eq "zh_CN
" ) { $sollanguage = "zh
,zh
.GBK
,zh_CN
.GB18030
,zh
.UTF
-8"; }
1970 elsif ( $sollanguage eq "zh_TW
" ) { $sollanguage = "zh_TW
,zh_TW
.BIG5
,zh_TW
.UTF
-8,zh_HK
.BIG5HK
,zh_HK
.UTF
-8"; }
1972 return $sollanguage;
1975 ############################################################
1976 # Adding language infos in pkginfo file
1977 ############################################################
1979 sub include_languageinfos_into_pkginfo
1981 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1983 # SUNWPKG_LIST=core01
1986 my $locallang = $onepackage->{'language'};
1987 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1989 my $newline = "SUNW_LOC
=" . $solarislanguage . "\n";
1990 add_one_line_into_file($changefile, $newline, $filename);
1992 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1993 if ( $onepackage->{'pkg_list_entry'} )
1995 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1996 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1997 $newline = "SUNW_PKGLIST
=" . $packagelistentry . "\n";
1998 add_one_line_into_file($changefile, $newline, $filename);
2002 # Using default package ooobasis30-core01.
2003 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01
";
2004 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
2005 $newline = "SUNW_PKGLIST
=" . $packagelistentry . "\n";
2006 add_one_line_into_file($changefile, $newline, $filename);
2010 ############################################################
2011 # Collecting all files included in patch in
2012 # @installer::globals::patchfilecollector
2013 ############################################################
2015 sub collect_patch_files
2017 my ($file, $packagename, $prefix) = @_;
2019 # $file is the spec file or the prototypefile
2021 $prefix = $prefix . "/";
2022 my $packagenamestring = "Package
" . $packagename . " \
:\n";
2023 push(@installer::globals::patchfilecollector, $packagenamestring);
2025 for ( my $i = 0; $i <= $#{$file}; $i++ )
2027 my $line = ${$file}[$i];
2029 if ( $installer::globals::islinuxrpmbuild )
2031 # %attr(0444,root,root) "/opt/openofficeorg
20/program/about
.bmp
"
2033 if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ )
2035 my $filename = $1 . "\n";
2036 $filename =~ s/^\s*\Q$prefix\E//;
2037 push(@installer::globals::patchfilecollector, $filename);
2041 if ( $installer::globals::issolarispkgbuild )
2043 # f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin
2045 if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ )
2047 my $filename = $1 . "\n";
2048 push(@installer::globals::patchfilecollector, $filename);
2053 push(@installer::globals::patchfilecollector, "\n");
2057 ############################################################
2058 # Including package names into the depend files.
2059 # The package names have to be included into
2060 # packagelist. They are already saved in
2061 # %installer::globals::dependfilenames.
2062 ############################################################
2064 sub put_packagenames_into_dependfile
2068 for ( my $i = 0; $i <= $#{$file}; $i++ )
2070 my $line = ${$file}[$i];
2071 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
2073 my $abbreviation = $1;
2075 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR
: Could
not resolve all properties
in Solaris
package abbreviation
\"$abbreviation\"!", "read_packagemap
"); }
2077 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
2079 my $packagename = $installer::globals::dependfilenames{$abbreviation};
2080 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR
: Could
not resolve all properties
in Solaris
package name
\"$packagename\"!", "read_packagemap
"); }
2083 ${$file}[$i] = $line . "\t" . $packagename . "\n";
2087 installer::exiter::exit_program("ERROR
: Missing packagename
for Solaris
package \"$abbreviation\"!", "put_packagenames_into_dependfile
");
2093 ############################################################
2094 # Including the relocatable directory into
2095 # spec file and pkginfo file
2096 # Linux: set topdir in specfile
2097 # Solaris: remove $relocatablepath (/opt/)
2098 # for all objects in prototype file
2099 # and changing "topdir
" for Linux
2100 ############################################################
2102 sub prepare_packages
2104 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
2108 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
2110 my $localrelocatablepath = $relocatablepath;
2111 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\
/\s*$//; }
2113 if ( $installer::globals
::issolarispkgbuild
)
2115 $filename = $packagename . ".pkginfo";
2116 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
2119 if ( $installer::globals
::islinuxrpmbuild
)
2121 # if ( $localrelocatablepath =~ /^\s*$/ ) { $localrelocatablepath = "/"; }; # at least the "/"
2122 $filename = $packagename . ".spec";
2123 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
2126 my $completefilename = $newepmdir . $filename;
2128 if ( ! -f
$completefilename) { installer
::exiter
::exit_program
("ERROR: Did not find file: $completefilename", "prepare_packages"); }
2129 my $changefile = installer
::files
::read_file
($completefilename);
2130 if ( $newline ne "" )
2132 add_one_line_into_file
($changefile, $newline, $filename);
2133 installer
::files
::save_file
($completefilename, $changefile);
2136 # my $newepmdir = $completefilename;
2137 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$newepmdir);
2139 # adding new "topdir" and removing old "topdir" in specfile
2141 if ( $installer::globals
::islinuxrpmbuild
)
2143 set_topdir_in_specfile
($changefile, $filename, $newepmdir);
2144 set_autoprovreq_in_specfile
($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin");
2145 set_packager_in_specfile
($changefile);
2146 if ( is_extension_package
($changefile) ) { set_prereq_in_specfile
($changefile); }
2147 set_license_in_specfile
($changefile, $variableshashref);
2148 set_tab_into_datafile
($changefile, $filesref);
2149 # check_requirements_in_specfile($changefile);
2150 installer
::files
::save_file
($completefilename, $changefile);
2151 if ( $installer::globals
::patch
) { collect_patch_files
($changefile, $packagename, $localrelocatablepath); }
2154 # removing the relocatable path in prototype file
2156 if ( $installer::globals
::issolarispkgbuild
)
2158 set_revision_in_pkginfo
($changefile, $filename, $variableshashref, $packagename);
2159 set_maxinst_in_pkginfo
($changefile, $filename);
2160 set_solaris_parameter_in_pkginfo
($changefile, $filename, $variableshashref);
2161 if ( $installer::globals
::issolarisx86build
) { fix_architecture_setting
($changefile); }
2162 if ( ! $installer::globals
::patch
) { set_patchlist_in_pkginfo_for_respin
($changefile, $filename, $variableshashref, $packagename); }
2163 if ( $installer::globals
::patch
) { include_patchinfos_into_pkginfo
($changefile, $filename, $variableshashref); }
2164 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo
($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
2165 installer
::files
::save_file
($completefilename, $changefile);
2167 my $prototypefilename = $packagename . ".prototype";
2168 $prototypefilename = $newepmdir . $prototypefilename;
2169 if (! -f
$prototypefilename) { installer
::exiter
::exit_program
("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
2171 my $prototypefile = installer
::files
::read_file
($prototypefilename);
2172 make_prototypefile_relocatable
($prototypefile, $relocatablepath);
2173 set_volatilefile_into_prototypefile
($prototypefile, $filesref);
2174 my $classesstring = set_tab_into_datafile
($prototypefile, $filesref);
2177 include_classes_into_pkginfo
($changefile, $classesstring);
2178 installer
::files
::save_file
($completefilename, $changefile);
2181 if ( $installer::globals
::patch
) { add_scripts_into_prototypefile
($prototypefile, $prototypefilename, $languagestringref, $staticpath); }
2183 installer
::files
::save_file
($prototypefilename, $prototypefile);
2184 if ( $installer::globals
::patch
) { collect_patch_files
($prototypefile, $packagename, ""); }
2186 # Adding package names into depend files for Solaris (not supported by epm)
2187 my $dependfilename = $packagename . ".depend";
2188 $dependfilename = $newepmdir . $dependfilename;
2189 if ( -f
$dependfilename)
2191 my $dependfile = installer
::files
::read_file
($dependfilename);
2192 put_packagenames_into_dependfile
($dependfile);
2193 installer
::files
::save_file
($dependfilename, $dependfile);
2200 ############################################################
2201 # Linux requirement for perl is changed by epm from
2202 # /usr/bin/perl to perl .
2204 ############################################################
2206 sub check_requirements_in_specfile
2208 my ( $specfile ) = @_;
2210 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
2212 if (( ${$specfile}[$i] =~ /^\s*Requires/ ) && ( ${$specfile}[$i] =~ /\bperl\b/ ) && ( ! ( ${$specfile}[$i] =~ /\/usr\
/bin\/perl
\b/ )))
2214 my $oldline = ${$specfile}[$i];
2215 ${$specfile}[$i] =~ s/perl/\/usr\
/bin\/perl
/;
2216 my $newline = ${$specfile}[$i];
2218 $oldline =~ s/\s*$//;
2219 $newline =~ s/\s*$//;
2220 my $infoline = "Spec File: Changing content from \"$oldline\" to \"$newline\".\n";
2221 push(@installer::globals
::logfileinfo
, $infoline);
2226 ###############################################################################
2227 # Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
2229 # The complete rootpath is stored in $installer::globals::rootpath
2230 # or for each package in $onepackage->{'destpath'}
2231 # The static rootpath is stored in $staticpath
2232 # The relocatable path is stored in $relocatablepath
2233 # PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
2234 # PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
2235 # In standard epm process:
2236 # No usage of package specific variables like $BASEDIR, because
2237 # 1. These variables would be replaced in epm process
2238 # 2. epm version 3.7 does not support relocatable packages
2239 ###############################################################################
2241 sub resolve_path_in_epm_list_before_packaging
2243 my ($listfile, $listfilename, $variable, $path) = @_;
2245 installer
::logger
::include_header_into_logfile
("Replacing variables in epm list file:");
2247 $path =~ s/\/\s*$//;
2248 replace_variables_in_shellscripts
($listfile, $listfilename, $variable, $path);
2252 #################################################################
2253 # Determining the rpm version. Beginning with rpm version 4.0
2254 # the tool to create RPMs is "rpmbuild" and no longer "rpm"
2255 #################################################################
2257 sub determine_rpm_version
2261 my $systemcall = "";
2263 # my $systemcall = "rpm --version |";
2264 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
2265 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
2266 # is saved in $installer::globals::rpm
2268 if ( $installer::globals
::rpm
ne "" )
2270 $systemcall = "$installer::globals::rpm --version |";
2274 $systemcall = "rpm --version |";
2277 open (RPM
, "$systemcall");
2281 if ( $rpmout ne "" )
2283 $rpmout =~ s/\s*$//g;
2285 my $infoline = "Systemcall: $systemcall\n";
2286 push( @installer::globals
::logfileinfo
, $infoline);
2288 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
2289 else { $infoline = "Success: rpm version: $rpmout\n"; }
2291 push( @installer::globals
::logfileinfo
, $infoline);
2293 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2294 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2295 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
2296 else { installer
::exiter
::exit_program
("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
2302 #################################################
2303 # Systemcall to start the packaging process
2304 #################################################
2306 sub create_packages_without_epm
2308 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
2310 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
2311 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
2312 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
2314 if ( $installer::globals
::issolarispkgbuild
)
2316 my $prototypefile = $epmdir . $packagename . ".prototype";
2317 if (! -f
$prototypefile) { installer
::exiter
::exit_program
("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
2319 my $destinationdir = $prototypefile;
2320 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destinationdir);
2321 $destinationdir =~ s/\/\s*$//; # removing ending slashes
2323 # my $systemcall = "pkgmk -o -f $prototypefile -d $destinationdir \> /dev/null 2\>\&1";
2324 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
2325 installer
::logger
::print_message
( "... $systemcall ...\n" );
2327 my $maxpkgmkcalls = 3;
2329 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
2331 my @pkgmkoutput = ();
2333 open (PKGMK
, "$systemcall");
2334 while (<PKGMK
>) {push(@pkgmkoutput, $_); }
2337 my $returnvalue = $?
; # $? contains the return value of the systemcall
2339 my $infoline = "Systemcall (Try $i): $systemcall\n";
2340 push( @installer::globals
::logfileinfo
, $infoline);
2342 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
2344 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2345 push( @installer::globals
::logfileinfo
, "$pkgmkoutput[$j]");
2350 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2351 push( @installer::globals
::logfileinfo
, $infoline);
2352 if ( $i == $maxpkgmkcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2356 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
2357 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2358 push( @installer::globals
::logfileinfo
, $infoline);
2363 # It might be necessary to save uncompressed Solaris packages
2365 if ( $allvariables->{'JDSBUILD'} )
2367 if ( ! $installer::globals
::jds_language_controlled
)
2369 my $correct_language = installer
::worker
::check_jds_language
($allvariables, $languagestringref);
2370 $installer::globals
::correct_jds_language
= $correct_language;
2371 $installer::globals
::jds_language_controlled
= 1;
2374 if ( $installer::globals
::correct_jds_language
)
2376 if ( $installer::globals
::saved_packages_path
eq "" )
2378 $packagestempdir = installer
::systemactions
::create_directories
("jds", $languagestringref);
2379 $installer::globals
::saved_packages_path
= $packagestempdir;
2380 push(@installer::globals
::jdsremovedirs
, $packagestempdir);
2383 $systemcall = "cd $destinationdir; cp -p -R $packagename $installer::globals::saved_packages_path;";
2384 make_systemcall
($systemcall);
2385 installer
::logger
::print_message
( "... $systemcall ...\n" );
2387 # Setting unix rights to "775" for all created directories inside the package,
2388 # that is saved in temp directory
2390 $systemcall = "cd $packagestempdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2391 installer
::logger
::print_message
( "... $systemcall ...\n" );
2393 $returnvalue = system($systemcall);
2395 $infoline = "Systemcall: $systemcall\n";
2396 push( @installer::globals
::logfileinfo
, $infoline);
2400 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2401 push( @installer::globals
::logfileinfo
, $infoline);
2405 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2406 push( @installer::globals
::logfileinfo
, $infoline);
2411 # compressing packages
2413 if ( ! $installer::globals
::solarisdontcompress
)
2415 my $faspac = "faspac-so.sh";
2417 my $compressorref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$faspac, $includepatharrayref, 0);
2418 if ($$compressorref ne "")
2420 # Saving original pkginfo, to set time stamp later
2421 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
2422 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
2423 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
2424 make_systemcall
($systemcall);
2426 $faspac = $$compressorref;
2427 $infoline = "Found compressor: $faspac\n";
2428 push( @installer::globals
::logfileinfo
, $infoline);
2430 installer
::logger
::print_message
( "... $faspac ...\n" );
2431 installer
::logger
::include_timestamp_into_logfile
("Starting $faspac");
2433 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
2434 make_systemcall
($systemcall);
2436 # Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file,
2437 # updated the size and checksum, but not the time stamp.
2438 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
2439 make_systemcall
($systemcall);
2440 if ( -f
$pkginfotmp ) { unlink($pkginfotmp); }
2442 installer
::logger
::include_timestamp_into_logfile
("End of $faspac");
2446 $infoline = "Not found: $faspac\n";
2447 push( @installer::globals
::logfileinfo
, $infoline);
2451 # Setting unix rights to "775" for all created directories inside the package
2453 $systemcall = "cd $destinationdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2454 installer
::logger
::print_message
( "... $systemcall ...\n" );
2456 $returnvalue = system($systemcall);
2458 $infoline = "Systemcall: $systemcall\n";
2459 push( @installer::globals
::logfileinfo
, $infoline);
2463 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2464 push( @installer::globals
::logfileinfo
, $infoline);
2468 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2469 push( @installer::globals
::logfileinfo
, $infoline);
2472 ######################
2474 ######################
2476 # my $streamname = $packagename . ".pkg";
2477 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
2478 # print "... $systemcall ...\n";
2480 # $returnvalue = system($systemcall);
2482 # $infoline = "Systemcall: $systemcall\n";
2483 # push( @installer::globals::logfileinfo, $infoline);
2487 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2488 # push( @installer::globals::logfileinfo, $infoline);
2492 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2493 # push( @installer::globals::logfileinfo, $infoline);
2496 #########################
2497 # making tar.gz files
2498 #########################
2500 # my $targzname = $packagename . ".tar.gz";
2501 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
2502 # print "... $systemcall ...\n";
2504 # $returnvalue = system($systemcall);
2506 # $infoline = "Systemcall: $systemcall\n";
2507 # push( @installer::globals::logfileinfo, $infoline);
2511 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2512 # push( @installer::globals::logfileinfo, $infoline);
2516 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2517 # push( @installer::globals::logfileinfo, $infoline);
2521 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2523 if ( $installer::globals
::islinuxrpmbuild
)
2525 my $specfilename = $epmdir . $packagename . ".spec";
2526 if (! -f
$specfilename) { installer
::exiter
::exit_program
("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2528 # my $rpmcommand = "rpm";
2529 my $rpmcommand = $installer::globals
::rpm
;
2530 my $rpmversion = determine_rpm_version
();
2532 # if ( $rpmversion >= 4 ) { $rpmcommand = "rpmbuild"; }
2534 # saving globally for later usage
2535 $installer::globals
::rpmcommand
= $rpmcommand;
2536 $installer::globals
::rpmquerycommand
= "rpm";
2539 if ( $installer::globals
::compiler
=~ /unxlngi/) { $target = "i586"; }
2540 elsif ( $installer::globals
::compiler
=~ /unxlng/) {$target = (POSIX
::uname
())[4]; }
2542 # rpm 4.6 ignores buildroot tag in spec file
2544 my $buildrootstring = "";
2546 if ( $rpmversion >= 4 )
2549 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2550 $buildrootstring = "--buildroot=$buildroot";
2553 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2555 installer
::logger
::print_message
( "... $systemcall ...\n" );
2557 my $maxrpmcalls = 3;
2560 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2564 open (RPM
, "$systemcall");
2565 while (<RPM
>) {push(@rpmoutput, $_); }
2568 my $returnvalue = $?
; # $? contains the return value of the systemcall
2570 my $infoline = "Systemcall (Try $i): $systemcall\n";
2571 push( @installer::globals
::logfileinfo
, $infoline);
2573 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2575 # if ( $i < $maxrpmcalls ) { $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2576 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2577 push( @installer::globals
::logfileinfo
, "$rpmoutput[$j]");
2582 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2583 push( @installer::globals
::logfileinfo
, $infoline);
2588 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
2589 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2590 push( @installer::globals
::logfileinfo
, $infoline);
2598 # Because of the problems with LD_LIBARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2600 if ( -f
"/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2601 elsif ( -f
"/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2603 if ( $rpmprog ne "" )
2605 installer
::logger
::print_message
( "... $rpmprog ...\n" );
2607 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2609 my @helperrpmoutput = ();
2611 open (RPM
, "$helpersystemcall");
2612 while (<RPM
>) {push(@helperrpmoutput, $_); }
2615 my $helperreturnvalue = $?
; # $? contains the return value of the systemcall
2617 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBARY_PATH)\n";
2618 push( @installer::globals
::logfileinfo
, $infoline);
2620 $infoline = "\nSystemcall: $helpersystemcall\n";
2621 push( @installer::globals
::logfileinfo
, $infoline);
2623 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals
::logfileinfo
, "$helperrpmoutput[$j]"); }
2625 if ($helperreturnvalue)
2627 $infoline = "Could not execute \"$helpersystemcall\"!\n";
2628 push( @installer::globals
::logfileinfo
, $infoline);
2632 installer
::logger
::print_message
( "Success: \"$helpersystemcall\"\n" );
2633 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2634 push( @installer::globals
::logfileinfo
, $infoline);
2639 # Now it is really time to exit this packaging process, if the error still occurs
2640 if ( $rpm_failed ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2645 #################################################
2646 # Removing all temporary files created by epm
2647 #################################################
2649 sub remove_temporary_epm_files
2651 my ($epmdir, $loggingdir, $packagename) = @_;
2653 # saving the files into the loggingdir
2655 if ( $installer::globals
::issolarispkgbuild
)
2657 my @extensions = ();
2658 push(@extensions, ".pkginfo");
2659 push(@extensions, ".prototype");
2660 push(@extensions, ".postinstall");
2661 push(@extensions, ".postremove");
2662 push(@extensions, ".preinstall");
2663 push(@extensions, ".preremove");
2664 push(@extensions, ".depend");
2666 for ( my $i = 0; $i <= $#extensions; $i++ )
2668 my $removefile = $epmdir . $packagename . $extensions[$i];
2669 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2671 if (! -f
$removefile) { next; }
2673 my $systemcall = "mv -f $removefile $destfile";
2674 system($systemcall); # ignoring the return value
2675 $infoline = "Systemcall: $systemcall\n";
2676 push( @installer::globals
::logfileinfo
, $infoline);
2679 # removing the package
2681 # my $removedir = $epmdir . $packagename;
2683 # my $systemcall = "rm -rf $removedir";
2685 # print "... $systemcall ...\n";
2687 # my $returnvalue = system($systemcall);
2689 # my $infoline = "Systemcall: $systemcall\n";
2690 # push( @installer::globals::logfileinfo, $infoline);
2694 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2695 # push( @installer::globals::logfileinfo, $infoline);
2699 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2700 # push( @installer::globals::logfileinfo, $infoline);
2704 if ( $installer::globals
::islinuxrpmbuild
)
2706 my $removefile = $epmdir . $packagename . ".spec";
2707 my $destfile = $loggingdir . $packagename . ".spec.log";
2709 # if (! -f $removefile) { next; }
2711 my $systemcall = "mv -f $removefile $destfile";
2712 system($systemcall); # ignoring the return value
2713 $infoline = "Systemcall: $systemcall\n";
2714 push( @installer::globals
::logfileinfo
, $infoline);
2716 # removing the directory "buildroot"
2718 my $removedir = $epmdir . "buildroot";
2720 $systemcall = "rm -rf $removedir";
2722 installer
::logger
::print_message
( "... $systemcall ...\n" );
2724 my $returnvalue = system($systemcall);
2726 my $infoline = "Systemcall: $systemcall\n";
2727 push( @installer::globals
::logfileinfo
, $infoline);
2731 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2732 push( @installer::globals
::logfileinfo
, $infoline);
2736 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2737 push( @installer::globals
::logfileinfo
, $infoline);
2742 ######################################################
2743 # Making the systemcall
2744 ######################################################
2748 my ($systemcall) = @_;
2750 my $returnvalue = system($systemcall);
2752 my $infoline = "Systemcall: $systemcall\n";
2753 push( @installer::globals
::logfileinfo
, $infoline);
2757 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2758 push( @installer::globals
::logfileinfo
, $infoline);
2762 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2763 push( @installer::globals
::logfileinfo
, $infoline);
2767 ###########################################################
2768 # Creating a better directory structure in the solver.
2769 ###########################################################
2771 sub create_new_directory_structure
2773 my ($newepmdir) = @_;
2775 my $newdir = $installer::globals
::epmoutpath
;
2777 if ( $installer::globals
::islinuxrpmbuild
)
2781 if ( $installer::globals
::compiler
=~ /unxlngi/) {
2782 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2784 elsif ( $installer::globals
::compiler
=~ /unxlng/) {
2785 $machine = (POSIX
::uname
())[4];
2786 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2788 else { installer
::exiter
::exit_program
("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2790 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2792 my $returnvalue = system($systemcall);
2794 my $infoline = "Systemcall: $systemcall\n";
2795 push( @installer::globals
::logfileinfo
, $infoline);
2799 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2800 push( @installer::globals
::logfileinfo
, $infoline);
2804 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2805 push( @installer::globals
::logfileinfo
, $infoline);
2808 # and removing the empty directory
2810 if ( $machine ne "" )
2812 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/$machine");
2814 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/x86_64");
2815 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/i586");
2816 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS/i386");
2817 installer
::systemactions
::remove_empty_directory
("$installer::globals::epmoutpath/RPMS");
2821 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2823 my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1";
2824 my $callreturnvalue = system($localcall);
2826 my $callinfoline = "Systemcall: $localcall\n";
2827 push( @installer::globals
::logfileinfo
, $callinfoline);
2829 if ($callreturnvalue)
2831 $callinfoline = "ERROR: Could not execute \"$localcall\"!\n";
2832 push( @installer::globals
::logfileinfo
, $callinfoline);
2836 $callinfoline = "Success: Executed \"$localcall\" successfully!\n";
2837 push( @installer::globals
::logfileinfo
, $callinfoline);
2841 ######################################################
2842 # Collect modules with product specific styles.
2843 ######################################################
2845 sub collect_modules_with_style
2847 my ($style, $modulesarrayref) = @_;
2849 my @allmodules = ();
2851 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2853 my $onemodule = ${$modulesarrayref}[$i];
2855 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2856 if ( $styles =~ /\b\Q$style\E\b/ )
2858 push(@allmodules, $onemodule);
2862 return \
@allmodules;
2865 ######################################################
2866 # Remove modules without packagecontent.
2867 ######################################################
2869 sub remove_modules_without_package
2871 my ($allmodules) = @_;
2873 my @allmodules = ();
2875 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2877 my $onemodule = ${$allmodules}[$i];
2878 my $packagename = "";
2879 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2880 if ( $packagename ne "" )
2882 push(@allmodules, $onemodule);
2886 return \
@allmodules;
2889 ######################################################
2890 # Unpacking tar.gz file and setting new packagename.
2891 ######################################################
2893 sub unpack_tar_gz_file
2895 my ($packagename, $destdir) = @_;
2897 my $newpackagename = "";
2899 if ( $packagename =~ /\.tar\.gz\s*$/ )
2901 # Collecting all packages in directory "packages"
2902 my $oldcontent = installer
::systemactions
::read_directory
($destdir);
2905 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -";
2906 make_systemcall
($systemcall);
2908 # deleting the tar.gz files
2909 $systemcall = "cd $destdir; rm -f $packagename";
2910 make_systemcall
($systemcall);
2912 # Finding new content -> that is the package name
2913 my ($newcontent, $allcontent ) = installer
::systemactions
::find_new_content_in_directory
($destdir, $oldcontent);
2914 $newpackagename = ${$newcontent}[0];
2915 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$newpackagename);
2918 if ( $newpackagename ne "" ) { $packagename = $newpackagename; }
2920 return $packagename;
2923 ######################################################
2924 # Copying files of child projects.
2925 ######################################################
2927 sub copy_childproject_files
2929 my ($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, $subdir, $includepatharrayref, $use_sopackpath) = @_;
2931 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2933 my $localdestdir = $destdir;
2934 my $onemodule = ${$allmodules}[$i];
2935 my $packagename = $onemodule->{'PackageName'};
2936 my $sourcefile = "";
2937 if ( $use_sopackpath )
2939 $sourcefile = $sopackpath . $installer::globals
::separator
. $installer::globals
::compiler
. $installer::globals
::separator
. $subdir . $installer::globals
::separator
. $packagename;
2943 my $sourcepathref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$packagename, $includepatharrayref, 1);
2944 $sourcefile = $$sourcepathref;
2947 if ( ! -f
$sourcefile ) { installer
::exiter
::exit_program
("ERROR: File not found: $sourcefile ($packagename) !", "copy_childproject_files"); }
2948 if ( $onemodule->{'Subdir'} )
2950 $localdestdir = $localdestdir . $installer::globals
::separator
. $onemodule->{'Subdir'};
2951 if ( ! -d
$localdestdir ) { installer
::systemactions
::create_directory
($localdestdir); }
2953 installer
::systemactions
::copy_one_file
($sourcefile, $localdestdir);
2954 # Solaris: unpacking tar.gz files and setting new packagename
2955 if ( $installer::globals
::issolarispkgbuild
) { $packagename = unpack_tar_gz_file
($packagename, $localdestdir); }
2957 if (( $installer::globals
::isxpdplatform
) && ( $allvariables->{'XPDINSTALLER'} ))
2959 installer
::xpdinstaller
::create_xpd_file_for_childproject
($onemodule, $localdestdir, $packagename, $allvariableshashref, $modulesarrayref);
2965 ######################################################
2966 # Copying files for system integration.
2967 ######################################################
2969 sub copy_and_unpack_tar_gz_files
2971 my ($sourcefile, $destdir) = @_;
2973 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2974 make_systemcall
($systemcall);
2977 ######################################################
2978 # Including child packages into the
2980 ######################################################
2982 sub put_childprojects_into_installset
2984 my ($newdir, $allvariables, $modulesarrayref, $includepatharrayref) = @_;
2988 my $sopackpath = "";
2989 if ( $ENV{'SO_PACK'} ) { $sopackpath = $ENV{'SO_PACK'}; }
2990 else { installer
::exiter
::exit_program
("ERROR: Environment variable SO_PACK not set!", "put_childprojects_into_installset"); }
2992 my $destdir = "$newdir";
2996 my $sourcefile = "";
2998 # Finding the modules defined in scp (with flag JAVAMODULE, ADAMODULE, ...)
2999 # Getting name of package from scp-Module
3000 # Copy file into installation set
3001 # Create xpd file and put it into xpd directory
3002 # xpd file has to be created completely from module and package itself (-> no packagelist!)
3004 if ( $allvariables->{'JAVAPRODUCT'} )
3006 # Collect all modules with flag "JAVAMODULE"
3007 my $allmodules = collect_modules_with_style
("JAVAMODULE", $modulesarrayref);
3008 $allmodules = remove_modules_without_package
($allmodules);
3009 copy_childproject_files
($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "jre", $includepatharrayref, 1);
3012 # Adding additional required packages (freetype).
3013 # This package names are stored in global array @installer::globals::requiredpackages
3015 if ( $allvariables->{'ADDREQUIREDPACKAGES'} )
3017 # Collect all modules with flag "REQUIREDPACKAGEMODULE"
3018 my $allmodules = collect_modules_with_style
("REQUIREDPACKAGEMODULE", $modulesarrayref);
3019 $allmodules = remove_modules_without_package
($allmodules);
3020 copy_childproject_files
($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "requiredpackages", $includepatharrayref, 1);
3023 # Collect all modules with flag "USERLANDMODULE"
3024 my $alluserlandmodules = collect_modules_with_style
("USERLANDMODULE", $modulesarrayref);
3025 $alluserlandmodules = remove_modules_without_package
($alluserlandmodules);
3026 copy_childproject_files
($alluserlandmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "", $includepatharrayref, 0);
3030 ######################################################
3031 # Checking whether the new content is a directory and
3032 # not a package. If it is a directory, the complete
3033 # content of the directory has to be added to the
3035 ######################################################
3037 sub control_subdirectories
3039 my ($content, $subdir) = @_;
3041 my @newcontent = ();
3043 for ( my $i = 0; $i <= $#{$content}; $i++ )
3045 if ( -d
${$content}[$i] )
3047 $subdir = ${$content}[$i];
3048 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$subdir);
3049 my $allpackages = installer
::systemactions
::read_directory
(${$content}[$i]);
3050 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
3052 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
3053 if (( $installer::globals
::islinuxbuild
) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
3054 push(@newcontent, ${$allpackages}[$j]);
3059 push(@newcontent, ${$content}[$i]);
3063 return (\
@newcontent, $subdir);
3066 ######################################################
3067 # Including the system integration files into the
3068 # installation sets.
3069 ######################################################
3071 sub put_systemintegration_into_installset
3073 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
3075 my $destdir = $newdir;
3077 # adding System integration files
3079 my $sourcefile = "";
3081 # Finding the modules defined in scp (with flag SYSTEMMODULE)
3082 # Getting name of package from scp-Module
3083 # Search package in list off all include files
3084 # Copy file into installation set and unpack it (always tar.gz)
3085 # Create xpd file and put it into xpd directory
3086 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
3087 # xpd file has to be created completely from module and package itself (-> no packagelist!)
3089 # Collect all modules with flag "SYSTEMMODULE"
3090 my $allmodules = collect_modules_with_style
("SYSTEMMODULE", $modulesarrayref);
3091 $allmodules = remove_modules_without_package
($allmodules);
3093 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
3095 my $onemodule = ${$allmodules}[$i];
3096 my $packagetarfilename = $onemodule->{'PackageName'};
3098 my $infoline = "Including into installation set: $packagetarfilename\n";
3099 push( @installer::globals
::logfileinfo
, $infoline);
3101 my $sourcepathref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$packagetarfilename, $includepatharrayref, 1);
3102 if ( $$sourcepathref eq "" ) { installer
::exiter
::exit_program
("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
3104 # Collecting all packages in directory "packages" or "RPMS"
3105 my $oldcontent = installer
::systemactions
::read_directory
($destdir);
3107 copy_and_unpack_tar_gz_files
($$sourcepathref, $destdir);
3109 # Finding new content -> that is the package name
3110 my ($newcontent, $allcontent ) = installer
::systemactions
::find_new_content_in_directory
($destdir, $oldcontent);
3112 # special handling, if new content is a directory
3114 if ( ! $installer::globals
::issolarispkgbuild
) { ($newcontent, $subdir) = control_subdirectories
($newcontent); }
3116 # Adding license content into Solaris packages
3117 if (( $installer::globals
::issolarispkgbuild
) && ( $installer::globals
::englishlicenseset
) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { installer
::worker
::add_license_into_systemintegrationpackages
($destdir, $newcontent); }
3119 if (( $installer::globals
::isxpdplatform
) && ( $allvariables->{'XPDINSTALLER'} ))
3121 installer
::xpdinstaller
::create_xpd_file_for_systemintegration
($onemodule, $newcontent, $modulesarrayref, $subdir);
3126 ######################################################
3127 # Analyzing the Unix installation path.
3128 # From the installation path /opt/openofficeorg20
3129 # is the part /opt relocatable and the part
3130 # openofficeorg20 static.
3131 ######################################################
3133 sub analyze_rootpath
3135 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
3137 $rootpath =~ s/\/\s*$//; # removing ending slash
3139 ##############################################################
3140 # Version 1: "/opt" is variable and "openofficeorg20" fixed
3141 ##############################################################
3143 # my $staticpath = $rootpath;
3144 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$staticpath);
3145 # $$staticpathref = $staticpath; # will be "openofficeorg20"
3147 # my $relocatablepath = $rootpath;
3148 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$relocatablepath);
3149 # $$relocatablepathref = $relocatablepath; # will be "/opt/"
3151 ##############################################################
3152 # Version 2: "/opt/openofficeorg20" is variable and "" fixed
3153 ##############################################################
3155 # if ( $$relocatablepathref eq "" ) # relocatablepath is not defined in package list
3157 # $$staticpathref = ""; # will be ""
3158 # $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/openofficeorg20/"
3159 # # setting the static path to the hostname of the directory with style OFFICEDIRECTORY
3160 # if ( $allvariables->{'SETSTATICPATH'} ) { $$staticpathref = $installer::globals::officedirhostname; }
3163 # else # relocatablepath is defined in package list
3165 # $$relocatablepathref =~ s/\/\s*$//; # removing ending slash
3166 # $$relocatablepathref = $$relocatablepathref . "\/"; # relocatable path must end with "/"
3167 # my $staticpath = $rootpath;
3168 # $staticpath =~ s/\Q$$relocatablepathref\E//;
3169 # $staticpath =~ s/\/\s*$//;
3170 # $$staticpathref = $staticpath;
3173 ##############################################################
3174 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
3175 ##############################################################
3177 $$relocatablepathref = "/";
3178 # Static path has to contain the office directory name. This is replaced in shellscripts.
3179 $$staticpathref = $rootpath . $installer::globals
::separator
. $installer::globals
::officedirhostname
;
3180 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
3181 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
3182 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
3183 if ( $installer::globals
::islinuxrpmbuild
)
3185 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
3186 $$staticpathref = $installer::globals
::officedirhostname
; # to be used as replacement in shell scripts
3189 if ( $installer::globals
::islinuxdebbuild
)
3191 $$relocatablepathref = "";
3192 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
3193 # $$staticpathref = $rootpath . $installer::globals::separator . $$staticpathref; # no relocatibility for Debian
3198 ######################################################
3199 # Including license and readme into
3200 # Unix installation sets.
3201 ######################################################
3203 sub put_installsetfiles_into_installset
3207 # All files for the installation set are saved in the global
3208 # array @installer::globals::installsetfiles
3210 for ( my $i = 0; $i <= $#installer::globals
::installsetfiles
; $i++ )
3212 my $onefile = $installer::globals
::installsetfiles
[$i];
3213 my $sourcefile = $onefile->{'sourcepath'};
3215 if ( $installer::globals
::addjavainstaller
) { $destfile = $onefile->{'Name'}; }
3216 else { $destfile = $destdir . $installer::globals
::separator
. $onefile->{'Name'}; }
3217 installer
::systemactions
::copy_one_file
($sourcefile, $destfile);
3219 my $infoline = "Adding to installation set \"$destfile\" from source \"$sourcefile\".\n";
3220 push( @installer::globals
::logfileinfo
, $infoline);
3224 ######################################################
3225 # Replacing one variable in patchinfo file
3226 ######################################################
3228 sub replace_one_variable_in_file
3230 my ( $file, $placeholder, $value ) = @_;
3232 for ( my $i = 0; $i <= $#{$file}; $i++ )
3234 ${$file}[$i] =~ s/$placeholder/$value/g;
3238 ######################################################
3239 # Setting variables in the patchinfo file
3240 ######################################################
3244 my ( $patchinfofile, $patchid, $allvariables ) = @_;
3246 # Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER
3248 replace_one_variable_in_file
($patchinfofile, "PATCHIDPLACEHOLDER", $patchid);
3250 my $architecture = "";
3251 if ( $installer::globals
::issolarissparcbuild
) { $architecture = "sparc"; }
3252 if ( $installer::globals
::issolarisx86build
) { $architecture = "i386"; }
3254 replace_one_variable_in_file
($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture);
3256 if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer
::exiter
::exit_program
("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); }
3257 my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'};
3259 replace_one_variable_in_file
($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects);
3261 # Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists
3262 my $requiresstring = "";
3263 if ( $installer::globals
::issolarissparcbuild
) { $requiresstring = "SOLSPARCPATCHREQUIRES"; }
3264 if ( $installer::globals
::issolarisx86build
) { $requiresstring = "SOLIAPATCHREQUIRES"; }
3266 if ( $allvariables->{$requiresstring} )
3268 my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n";
3269 push(@
{$patchinfofile}, $newline);
3273 ######################################################
3274 # Finalizing patch: Renaming directory and
3275 # including additional patch files.
3276 ######################################################
3280 my ( $newepmdir, $allvariables ) = @_;
3282 my $patchidname = "SOLSPARCPATCHID";
3283 if ( $installer::globals
::issolarisx86build
) { $patchidname = "SOLIAPATCHID"; }
3285 if ( ! $allvariables->{$patchidname} ) { installer
::exiter
::exit_program
("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); }
3286 my $patchid = $allvariables->{$patchidname};
3287 installer
::systemactions
::rename_directory
($newepmdir, $patchid);
3289 # Copying all typical patch files into the patch directory
3290 # All patch file names are stored in @installer::globals::solarispatchfiles
3291 # Location of the file is $installer::globals::patchincludepath
3293 my $sourcepath = $installer::globals
::patchincludepath
;
3294 $sourcepath =~ s/\/\s*$//;
3296 for ( my $i = 0; $i <= $#installer::globals
::solarispatchfiles
; $i++ )
3298 my $sourcefile = $sourcepath . $installer::globals
::separator
. $installer::globals
::solarispatchfiles
[$i];
3299 my $destfile = $patchid . $installer::globals
::separator
. $installer::globals
::solarispatchfiles
[$i];
3300 installer
::systemactions
::copy_one_file
($sourcefile, $destfile);
3303 # And editing the patchinfo file
3305 my $patchinfofilename = $patchid . $installer::globals
::separator
. "patchinfo";
3306 my $patchinfofile = installer
::files
::read_file
($patchinfofilename);
3307 set_patchinfo
($patchinfofile, $patchid, $allvariables);
3308 installer
::files
::save_file
($patchinfofilename, $patchinfofile);
3311 ######################################################
3312 # Finalizing Linux patch: Renaming directory and
3313 # including additional patch files.
3314 ######################################################
3316 sub finalize_linux_patch
3318 my ( $newepmdir, $allvariables, $includepatharrayref ) = @_;
3320 # Copying the setup into the patch directory
3321 # and including the list of RPMs into it
3323 print "... creating patch setup ...\n";
3325 installer
::logger
::include_header_into_logfile
("Creating Linux patch setup:");
3327 # find and read setup script template
3329 my $scriptfilename = "linuxpatchscript.sh";
3330 my $scriptref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$scriptfilename, $includepatharrayref, 0);
3331 if ($$scriptref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); }
3332 my $scriptfile = installer
::files
::read_file
($$scriptref);
3334 my $infoline = "Found script file $scriptfilename: $$scriptref \n";
3335 push( @installer::globals
::logfileinfo
, $infoline);
3337 # Collecting all RPMs in the patch directory
3339 my $fileextension = "rpm";
3340 my $rpmfiles = installer
::systemactions
::find_file_with_file_extension
($fileextension, $newepmdir);
3341 if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); }
3342 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); }
3344 # my $installline = "";
3346 # for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3348 # $installline = $installline . " rpm --prefix \$PRODUCTINSTALLLOCATION -U $newepmdir/${$rpmfiles}[$i]\n";
3351 # $installline =~ s/\s*$//;
3353 # for ( my $j = 0; $j <= $#{$scriptfile}; $j++ )
3355 # ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/;
3358 # Searching packagename containing -core01
3359 my $found_package = 0;
3360 my $searchpackagename = "";
3361 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3363 if ( ${$rpmfiles}[$i] =~ /-core01-/ )
3365 $searchpackagename = ${$rpmfiles}[$i];
3367 if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; }
3372 if ( ! $found_package ) { installer
::exiter
::exit_program
("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); }
3374 # Replacing the searchpackagename
3375 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; }
3377 # Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname
3378 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; }
3380 # Replacing the productname
3381 my $productname = $allvariables->{'PRODUCTNAME'};
3382 $productname = lc($productname);
3383 $productname =~ s/ /_/g; # abc office -> abc_office
3384 # $productname =~ s/\.//g; # openoffice.org -> openofficeorg
3386 $infoline = "Adding productname $productname into Linux patch script\n";
3387 push( @installer::globals
::logfileinfo
, $infoline);
3389 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; }
3393 my $newscriptfilename = "setup"; # $newepmdir . $installer::globals::separator . "setup";
3394 installer
::files
::save_file
($newscriptfilename, $scriptfile);
3396 $infoline = "Saved Linux patch setup $newscriptfilename \n";
3397 push( @installer::globals
::logfileinfo
, $infoline);
3399 # Setting unix rights 755
3400 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";