bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / modules / installer / epmfile.pm
blobc1dd768b797e0e307667a46623bb984e0dcd8473
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::epmfile;
21 use Cwd qw();
22 use installer::converter;
23 use installer::exiter;
24 use installer::files;
25 use installer::globals;
26 use installer::logger;
27 use installer::packagelist;
28 use installer::pathanalyzer;
29 use installer::remover;
30 use installer::scpzipfiles;
31 use installer::scriptitems;
32 use installer::systemactions;
33 use POSIX;
35 # please Debian packaging, fdo#53341
36 sub debian_rewrite($)
38 my $dep = shift;
39 if ( $installer::globals::debian ) {
40 $dep =~ s/_/-/g; # Debian allows no underline in package name
41 $dep = lc ($dep);
43 return $dep;
46 ############################################################################
47 # Reading the package map to find Solaris package names for
48 # the corresponding abbreviations
49 ############################################################################
51 sub read_packagemap
53 my ($allvariables, $includepatharrayref, $languagesarrayref) = @_;
55 my $packagemapname = "";
56 if ( $allvariables->{'PACKAGEMAP'} ) { $packagemapname = $allvariables->{'PACKAGEMAP'}; }
57 if ( $packagemapname eq "" ) { installer::exiter::exit_program("ERROR: Property PACKAGEMAP must be defined!", "read_packagemap"); }
59 my $infoline = "\n\nCollected abbreviations and package names:\n";
60 push(@installer::globals::logfileinfo, $infoline);
62 # Can be a comma separated list. All files have to be found in include paths
63 my $allpackagemapnames = installer::converter::convert_stringlist_into_hash(\$packagemapname, ",");
64 foreach my $onepackagemapname ( keys %{$allpackagemapnames} )
66 my $packagemapref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onepackagemapname, $includepatharrayref, 0);
68 if ( $$packagemapref eq "" ) { installer::exiter::exit_program("ERROR: Could not find package map file \"$onepackagemapname\" (propery PACKAGEMAP)!", "read_packagemap"); }
70 my $packagemapcontent = installer::files::read_file($$packagemapref);
72 for ( my $i = 0; $i <= $#{$packagemapcontent}; $i++ )
74 my $line = ${$packagemapcontent}[$i];
76 if ( $line =~ /^\s*\#/ ) { next; } # comment line
77 if ( $line =~ /^\s*$/ ) { next; } # empty line
79 if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ )
81 my $abbreviation = $1;
82 my $packagename = $2;
83 installer::packagelist::resolve_packagevariables(\$abbreviation, $allvariables, 0);
84 installer::packagelist::resolve_packagevariables(\$packagename, $allvariables, 0);
86 # Special handling for language strings %LANGUAGESTRING
88 if (( $abbreviation =~ /\%LANGUAGESTRING/ ) || ( $packagename =~ /\%LANGUAGESTRING/ ))
90 foreach my $onelang ( @{$languagesarrayref} )
92 my $local_abbreviation = $abbreviation;
93 my $local_packagename = $packagename;
94 $local_abbreviation =~ s/\%LANGUAGESTRING/$onelang/g;
95 $local_packagename =~ s/\%LANGUAGESTRING/$onelang/g;
97 # Logging all abbreviations and packagenames
98 $infoline = "$onelang : $local_abbreviation : $local_packagename\n";
99 push(@installer::globals::logfileinfo, $infoline);
101 if ( exists($installer::globals::dependfilenames{$local_abbreviation}) )
103 installer::exiter::exit_program("ERROR: Packagename for Solaris package $local_abbreviation already defined ($installer::globals::dependfilenames{$local_abbreviation})!", "read_packagemap");
105 else
107 $installer::globals::dependfilenames{$local_abbreviation} = $local_packagename;
111 else
113 # Logging all abbreviations and packagenames
114 $infoline = "$abbreviation : $packagename\n";
115 push(@installer::globals::logfileinfo, $infoline);
117 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
119 installer::exiter::exit_program("ERROR: Packagename for Solaris package $abbreviation already defined ($installer::globals::dependfilenames{$abbreviation})!", "read_packagemap");
121 else
123 $installer::globals::dependfilenames{$abbreviation} = $packagename;
127 else
129 my $errorline = $i + 1;
130 installer::exiter::exit_program("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap");
135 $infoline = "\n\n";
136 push(@installer::globals::logfileinfo, $infoline);
140 ##########################################################
141 # Filling the epm file with directories, files and links
142 ##########################################################
144 sub put_directories_into_epmfile
146 my ($directoriesarrayref, $epmfileref, $allvariables, $packagerootpath) = @_;
147 my $group = "bin";
149 if ( $installer::globals::islinuxbuild )
151 $group = "root";
154 for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ )
156 my $onedir = ${$directoriesarrayref}[$i];
157 my $dir = "";
159 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
161 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
163 my $hostname = $onedir->{'HostName'};
165 my $line = "d 755 root $group $hostname -\n";
167 push(@{$epmfileref}, $line)
172 sub put_files_into_epmfile
174 my ($filesinproductarrayref, $epmfileref) = @_;
176 for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ )
178 my $onefile = ${$filesinproductarrayref}[$i];
180 my $unixrights = $onefile->{'UnixRights'};
181 my $destination = $onefile->{'destination'};
182 my $sourcepath = $onefile->{'sourcepath'};
184 my $filetype = "f";
185 my $styles = "";
186 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
187 if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; }
189 my $group = "bin";
190 if ( $installer::globals::islinuxbuild ) { $group = "root"; }
191 if (( $installer::globals::issolarisbuild ) && ( $onefile->{'SolarisGroup'} )) { $group = $onefile->{'SolarisGroup'}; }
193 my $line = "$filetype $unixrights root $group $destination $sourcepath\n";
195 push(@{$epmfileref}, $line);
199 sub put_links_into_epmfile
201 my ($linksinproductarrayref, $epmfileref) = @_;
202 my $group = "bin";
204 if ( $installer::globals::islinuxbuild )
206 $group = "root";
210 for ( my $i = 0; $i <= $#{$linksinproductarrayref}; $i++ )
212 my $onelink = ${$linksinproductarrayref}[$i];
213 my $destination = $onelink->{'destination'};
214 my $destinationfile = $onelink->{'destinationfile'};
216 my $line = "l 000 root $group $destination $destinationfile\n";
218 push(@{$epmfileref}, $line)
222 sub put_unixlinks_into_epmfile
224 my ($unixlinksinproductarrayref, $epmfileref) = @_;
225 my $group = "bin";
227 if ( $installer::globals::islinuxbuild ) { $group = "root"; }
229 for ( my $i = 0; $i <= $#{$unixlinksinproductarrayref}; $i++ )
231 my $onelink = ${$unixlinksinproductarrayref}[$i];
232 my $destination = $onelink->{'destination'};
233 my $target = $onelink->{'Target'};
235 my $line = "l 000 root $group $destination $target\n";
237 push(@{$epmfileref}, $line)
241 ###############################################
242 # Creating epm header file
243 ###############################################
245 sub create_epm_header
247 my ($variableshashref, $filesinproduct, $languagesref, $onepackage) = @_;
249 my @epmheader = ();
251 my ($licensefilename, $readmefilename, $readmefilenameen);
253 my $foundlicensefile = 0;
254 my $foundreadmefile = 0;
256 my $line = "";
257 my $infoline = "";
259 # %product LibreOffice Software
260 # %version 2.0
261 # %description A really great software
262 # %copyright 1999-2003 by OOo
263 # %vendor LibreOffice
264 # %license /test/replace/01/LICENSE01
265 # %readme /test/replace/01/README01
266 # %requires foo
267 # %provides bar
268 # %replaces bar
269 # %incompat bar
271 # The first language in the languages array determines the language of license and readme file
273 my $searchlanguage = ${$languagesref}[0];
275 # using the description for the %product line in the epm list file
277 my $productnamestring = $onepackage->{'description'};
278 installer::packagelist::resolve_packagevariables(\$productnamestring, $variableshashref, 0);
279 if ( $variableshashref->{'PRODUCTEXTENSION'} ) { $productnamestring = $productnamestring . " " . $variableshashref->{'PRODUCTEXTENSION'}; }
281 $line = "%product" . " " . $productnamestring . "\n";
282 push(@epmheader, $line);
284 # Determining the release version
285 # This release version has to be listed in the line %version : %version versionnumber releasenumber
287 if ( ! $onepackage->{'packageversion'} ) { installer::exiter::exit_program("ERROR: No packageversion defined for package: $onepackage->{'module'}!", "create_epm_header"); }
288 $installer::globals::packageversion = $onepackage->{'packageversion'};
289 installer::packagelist::resolve_packagevariables(\$installer::globals::packageversion, $variableshashref, 0);
290 if ( $variableshashref->{'PACKAGEREVISION'} ) { $installer::globals::packagerevision = $variableshashref->{'PACKAGEREVISION'}; }
292 $line = "%version" . " " . $installer::globals::packageversion . "\n";
293 push(@epmheader, $line);
295 $line = "%release" . " " . $installer::globals::packagerevision . "\n";
296 if ( $installer::globals::isrpmbuild ) { $line = "%release" . " " . $installer::globals::buildid . "\n"; }
297 push(@epmheader, $line);
299 # Description, Copyright and Vendor are multilingual and are defined in
300 # the string file for the header file ($headerfileref)
302 my $descriptionstring = $onepackage->{'description'};
303 installer::packagelist::resolve_packagevariables(\$descriptionstring, $variableshashref, 0);
304 $line = "%description" . " " . $descriptionstring . "\n";
305 push(@epmheader, $line);
307 my $copyrightstring = $onepackage->{'copyright'};
308 installer::packagelist::resolve_packagevariables(\$copyrightstring, $variableshashref, 0);
309 $line = "%copyright" . " " . $copyrightstring . "\n";
310 push(@epmheader, $line);
312 my $vendorstring = $onepackage->{'vendor'};
313 installer::packagelist::resolve_packagevariables(\$vendorstring, $variableshashref, 0);
314 $line = "%vendor" . " " . $vendorstring . "\n";
315 push(@epmheader, $line);
317 # License and Readme file can be included automatically from the file list
319 if ( $installer::globals::iswindowsbuild )
321 $licensefilename = "license.txt";
322 $readmefilename = "readme.txt";
323 $readmefilenameen = "readme_en-US.txt";
325 else
327 $licensefilename = "LICENSE";
328 $readmefilename = "README";
329 $readmefilenameen = "README_en-US";
332 if (( $installer::globals::languagepack ) # in language packs and help packs the files LICENSE and README are removed, because they are not language specific
333 || ( $installer::globals::helppack )
334 || ( $variableshashref->{'NO_README_IN_ROOTDIR'} ))
336 if ( $installer::globals::iswindowsbuild )
338 $licensefilename = "license.txt";
339 $readmefilename = "readme_$searchlanguage.txt";
341 else
343 $licensefilename = "LICENSE";
344 $readmefilename = "README_$searchlanguage";
348 my $license_in_package_defined = 0;
350 if ( $installer::globals::issolarisbuild )
352 if ( $onepackage->{'solariscopyright'} )
354 $licensefilename = $onepackage->{'solariscopyright'};
355 $license_in_package_defined = 1;
359 # Process for Linux packages, in which only a very basic license file is
360 # included into the package.
362 if ( $installer::globals::islinuxbuild )
364 if ( $variableshashref->{'COPYRIGHT_INTO_LINUXPACKAGE'} )
366 $licensefilename = "linuxcopyrightfile";
367 $license_in_package_defined = 1;
371 # searching for and readme file;
372 # URE uses special README; others use README_en-US
373 # it does not matter which one is passed for epm if both are packaged
374 foreach my $possiblereadmefilename ($readmefilenameen, $readmefilename)
376 last if ($foundreadmefile);
377 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
379 my $onefile = ${$filesinproduct}[$i];
380 my $filename = $onefile->{'Name'};
381 if ( $filename eq $possiblereadmefilename )
383 $foundreadmefile = 1;
384 $line = "%readme" . " " . $onefile->{'sourcepath'} . "\n";
385 push(@epmheader, $line);
386 last;
391 # the readme file need not be packaged more times in the help content
392 # it needs to be installed in parallel with the main package anyway
393 # try to find the README file between all available files (not only between the packaged)
394 if (!($foundreadmefile) && $installer::globals::helppack)
396 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$readmefilenameen, "" , 0);
397 if($$fileref ne "" )
399 $infoline = "Fallback to readme file: \"$$fileref\"!\n";
400 push(@installer::globals::logfileinfo, $infoline);
402 $foundreadmefile = 1;
403 $line = "%readme" . " " . $$fileref . "\n";
404 push(@epmheader, $line);
408 # searching for and license file
410 if ( $license_in_package_defined )
412 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
414 if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (A)!", "create_epm_header"); }
416 # Special handling to add the content of the file "license_en-US" to the solaris copyrightfile. But not for all products
418 if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} ))
420 if ( ! $installer::globals::englishlicenseset ) { _set_english_license() }
422 # The location for the new file
423 my $languagestring = "";
424 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; }
425 $languagestring =~ s/^\s*_//;
427 my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring);
429 my $copyrightfile = installer::files::read_file($$fileref);
431 # Adding license content to copyright file
432 push(@{$copyrightfile}, "\n");
433 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
435 # New destination for $$fileref
436 $$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'};
437 if ( -f $$fileref ) { unlink $$fileref; }
438 installer::files::save_file($$fileref, $copyrightfile);
441 $infoline = "Using license file: \"$$fileref\"!\n";
442 push(@installer::globals::logfileinfo, $infoline);
444 $foundlicensefile = 1;
445 $line = "%license" . " " . $$fileref . "\n";
446 push(@epmheader, $line);
448 else
450 for my $onefile (@{$filesinproduct})
452 if ($licensefilename eq $onefile->{'Name'})
454 push @epmheader, "%license" . " " . $onefile->{'sourcepath'} . "\n";
455 $foundlicensefile = 1;
456 last;
460 # the license file need not be packaged more times in the langpacks
461 # they need to be installed in parallel with the main package anyway
462 # try to find the LICENSE file between all available files (not only between the packaged)
463 if (!($foundlicensefile) && ($installer::globals::languagepack || $installer::globals::helppack))
465 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
466 if($$fileref ne "" )
468 $infoline = "Fallback to license file: \"$$fileref\"!\n";
469 push(@installer::globals::logfileinfo, $infoline);
471 $foundlicensefile = 1;
472 $line = "%license" . " " . $$fileref . "\n";
473 push(@epmheader, $line);
478 if (!($foundlicensefile))
480 installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (B)", "create_epm_header");
483 if (!($foundreadmefile))
485 installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename (C)", "create_epm_header");
488 # including %replaces
490 my $replaces = "";
492 if ( $installer::globals::issolarispkgbuild )
494 $replaces = "solarisreplaces"; # the name in the packagelist
496 elsif ( $installer::globals::islinuxbuild )
498 $replaces = "linuxreplaces"; # the name in the packagelist
501 if ( $replaces )
503 if ( $onepackage->{$replaces} )
505 my $replacesstring = $onepackage->{$replaces};
507 my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ",");
509 for ( my $i = 0; $i <= $#{$allreplaces}; $i++ )
511 my $onereplaces = ${$allreplaces}[$i];
512 $onereplaces =~ s/\s*$//;
513 installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1);
514 $onereplaces = debian_rewrite($onereplaces);
515 $line = "%replaces" . " " . $onereplaces . "\n";
516 push(@epmheader, $line);
521 # including %incompat
523 my $incompat = "";
525 if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch ))
527 $incompat = "solarisincompat"; # the name in the packagelist
529 elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch ))
531 $incompat = "linuxincompat"; # the name in the packagelist
534 if (( $incompat ) && ( ! $installer::globals::patch ))
536 if ( $onepackage->{$incompat} )
538 my $incompatstring = $onepackage->{$incompat};
540 my $allincompat = installer::converter::convert_stringlist_into_array(\$incompatstring, ",");
542 for ( my $i = 0; $i <= $#{$allincompat}; $i++ )
544 my $oneincompat = ${$allincompat}[$i];
545 $oneincompat =~ s/\s*$//;
546 installer::packagelist::resolve_packagevariables(\$oneincompat, $variableshashref, 1);
547 $oneincompat = debian_rewrite($oneincompat);
548 $line = "%incompat" . " " . $oneincompat . "\n";
549 push(@epmheader, $line);
554 # including the directives for %requires and %provides
556 my $provides = "";
557 my $requires = "";
559 if ( $installer::globals::issolarispkgbuild )
561 $provides = "solarisprovides"; # the name in the packagelist
562 $requires = "solarisrequires"; # the name in the packagelist
564 elsif ( $installer::globals::isfreebsdpkgbuild )
566 $provides = "freebsdprovides"; # the name in the packagelist
567 $requires = "freebsdrequires"; # the name in the packagelist
569 else
571 $provides = "provides"; # the name in the packagelist
572 $requires = "requires"; # the name in the packagelist
575 my $isdict = 0;
576 if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; }
578 if ( $onepackage->{$provides} )
580 my $providesstring = $onepackage->{$provides};
582 my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ",");
584 for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
586 my $oneprovides = ${$allprovides}[$i];
587 $oneprovides =~ s/\s*$//;
588 installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1);
589 $oneprovides = debian_rewrite($oneprovides);
590 $line = "%provides" . " " . $oneprovides . "\n";
591 push(@epmheader, $line);
595 if ( $onepackage->{$requires} )
597 my $requiresstring = $onepackage->{$requires};
599 # The requires string can contain the separator "," in the names (descriptions) of the packages
600 # (that are required for Solaris depend files). Therefore "," inside such a description has to
601 # masked with a backslash.
602 # This masked separator need to be found and replaced, before the stringlist is converted into an array.
603 # This replacement has to be turned back after the array is created.
605 my $replacementstring = "COMMAREPLACEMENT";
606 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
608 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
610 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
612 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
614 my $onerequires = ${$allrequires}[$i];
615 $onerequires =~ s/\s*$//;
616 installer::packagelist::resolve_packagevariables2(\$onerequires, $variableshashref, 0, $isdict);
617 $onerequires = debian_rewrite($onerequires);
618 $line = "%requires" . " " . $onerequires . "\n";
619 push(@epmheader, $line);
623 return \@epmheader;
626 #######################################
627 # Adding header to epm file
628 #######################################
630 sub adding_header_to_epm_file
632 my ($epmfileref, $epmheaderref) = @_;
634 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
636 push( @{$epmfileref}, ${$epmheaderref}[$i] );
639 push( @{$epmfileref}, "\n\n" );
642 #####################################################
643 # Replace one in shell scripts ( ${VARIABLENAME} )
644 #####################################################
646 sub replace_variable_in_shellscripts
648 my ($scriptref, $variable, $searchstring) = @_;
650 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
652 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
656 ################################################
657 # Replacing many variables in shell scripts
658 ################################################
660 sub replace_many_variables_in_shellscripts
662 my ($scriptref, $variableshashref) = @_;
664 my $key;
666 foreach $key (keys %{$variableshashref})
668 my $value = $variableshashref->{$key};
669 replace_variable_in_shellscripts($scriptref, $value, $key);
673 #######################################
674 # Adding shell scripts to epm file
675 #######################################
677 sub adding_shellscripts_to_epm_file
679 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
681 push( @{$epmfileref}, "\n\n" );
683 my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename);
685 replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath");
687 replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref);
689 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
691 push( @{$epmfileref}, ${$shellscriptsfileref}[$i] );
694 push( @{$epmfileref}, "\n" );
697 #################################################
698 # Determining the epm on the system
699 #################################################
701 sub find_epm_on_system
703 my ($includepatharrayref) = @_;
705 installer::logger::include_header_into_logfile("Check epm on system");
707 my $epmname = "epm";
709 # epm should be defined through the configure script but we need to
710 # check for it to be defined because of the Sun environment.
711 # Check the environment variable first and if it is not defined,
712 # or if it is but the location is not executable, search further.
713 # It has to be found in the solver or it has to be in the path
714 # (saved in $installer::globals::epm_in_path) or we get the specified
715 # one through the environment (i.e. when --with-epm=... is specified)
717 if ($ENV{'EPM'})
719 if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}"))
721 $epmname = $ENV{'EPM'};
723 elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") )
725 $epmname = "epm";
726 my $epmref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$epmname, $includepatharrayref, 0);
727 if ($$epmref eq "") { installer::exiter::exit_program("ERROR: Could not find program $epmname (EPM set to \"internal\" or \"no\")!", "find_epm_on_system"); }
728 $epmname = $$epmref;
730 else
732 installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
735 else
737 my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0);
739 if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
740 if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; }
741 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
744 my $infoline = "Using epmfile: $epmname\n";
745 push( @installer::globals::logfileinfo, $infoline);
747 return $epmname;
750 #################################################
751 # Determining the epm patch state
752 # saved in $installer::globals::is_special_epm
753 #################################################
755 sub set_patch_state
757 my ($epmexecutable) = @_;
759 my $infoline = "";
761 my $systemcall = "$epmexecutable |";
762 open (EPMPATCH, "$systemcall");
764 while (<EPMPATCH>)
766 chop;
767 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals::is_special_epm = 1; }
770 close (EPMPATCH);
772 if ( $installer::globals::is_special_epm )
774 $infoline = "\nPatch state: This is a patched version of epm!\n\n";
775 push( @installer::globals::logfileinfo, $infoline);
777 else
779 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
780 push( @installer::globals::logfileinfo, $infoline);
783 if ( ( $installer::globals::is_special_epm ) && (($installer::globals::isrpmbuild) || ($installer::globals::issolarispkgbuild)) )
785 # Special postprocess handling only for Linux RPM and Solaris packages
786 $installer::globals::postprocess_specialepm = 1;
787 $installer::globals::postprocess_standardepm = 0;
789 else
791 $installer::globals::postprocess_specialepm = 0;
792 $installer::globals::postprocess_standardepm = 1;
796 #################################################
797 # LD_PRELOAD string for Debian packages
798 #################################################
800 sub get_ld_preload_string
802 my ($includepatharrayref) = @_;
804 my $getuidlibraryname = "libgetuid.so";
806 my $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0);
807 if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); }
809 my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
811 return $ldpreloadstring;
814 #################################################
815 # Calling epm to create the installation sets
816 #################################################
818 sub call_epm
820 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
822 installer::logger::include_header_into_logfile("epm call for $packagename");
824 my $packageformat = $installer::globals::packageformat;
826 my $localpackagename = $packagename;
827 # Debian allows only lowercase letters in package name
828 if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); }
830 my $outdirstring = "";
831 if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
833 # Debian package build needs a LD_PRELOAD for correct rights
835 my $ldpreloadstring = "";
837 if ( $installer::globals::debian ) { $ldpreloadstring = get_ld_preload_string($includepatharrayref) . " "; }
839 my $extraflags = "";
840 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
842 $extraflags .= ' -g' unless $installer::globals::strip;
844 my $verboseflag = "-v";
845 if ( ! $installer::globals::quiet ) { $verboseflag = "-v2"; };
847 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " " . $verboseflag . " " . " 2\>\&1 |";
849 installer::logger::print_message( "... $systemcall ...\n" );
851 my $maxepmcalls = 3;
853 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
855 my @epmoutput = ();
857 open (EPM, "$systemcall");
858 while (<EPM>) {push(@epmoutput, $_); }
859 close (EPM);
861 my $returnvalue = $?; # $? contains the return value of the systemcall
863 my $infoline = "Systemcall (Try $i): $systemcall\n";
864 push( @installer::globals::logfileinfo, $infoline);
866 for ( my $j = 0; $j <= $#epmoutput; $j++ )
868 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
869 push( @installer::globals::logfileinfo, "$epmoutput[$j]");
872 if ($returnvalue)
874 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
875 push( @installer::globals::logfileinfo, $infoline);
876 if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); }
878 else
880 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
881 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
882 push( @installer::globals::logfileinfo, $infoline);
883 last;
888 #####################################################################
889 # Adding the new line for relocatables into pkginfo file (Solaris)
890 # or spec file (Linux) created by epm
891 #####################################################################
893 sub add_one_line_into_file
895 my ($file, $insertline, $filename) = @_;
897 if ( $installer::globals::issolarispkgbuild )
899 push(@{$file}, $insertline); # simply adding at the end of pkginfo file
902 if ( $installer::globals::isrpmbuild )
904 # Adding behind the line beginning with: Group:
906 my $inserted_line = 0;
908 for ( my $i = 0; $i <= $#{$file}; $i++ )
910 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
912 splice(@{$file},$i+1,0,$insertline);
913 $inserted_line = 1;
914 last;
918 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
921 $insertline =~ s/\s*$//; # removing line end for correct logging
922 my $infoline = "Success: Added line $insertline into file $filename!\n";
923 push( @installer::globals::logfileinfo, $infoline);
926 #####################################################################
927 # Setting the revision VERSION=1.9,REV=66 .
928 # Also adding the new line: "AutoReqProv: no"
929 #####################################################################
931 sub set_revision_in_pkginfo
933 my ($file, $filename, $variables, $packagename) = @_;
935 my $revisionstring = "\,REV\=" . $installer::globals::packagerevision;
937 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
939 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
941 $mday = $mday;
942 $mon = $mon + 1;
943 $year = $year + 1900;
945 if ( $mday < 10 ) { $mday = "0" . $mday; }
946 if ( $mon < 10 ) { $mon = "0" . $mon; }
947 $datestring = $year . "." . $mon . "." . $mday;
948 $revisionstring = $revisionstring . "." . $datestring;
950 for ( my $i = 0; $i <= $#{$file}; $i++ )
952 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
954 my $oldstring = $1;
955 my $newstring = $oldstring . $revisionstring; # also adding the date string
956 ${$file}[$i] =~ s/$oldstring/$newstring/;
957 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
958 push( @installer::globals::logfileinfo, $infoline);
959 last;
963 # For Update and Patch reasons, this string can also be kept constant
965 my $pkgversion = "SOLSPARCPKGVERSION";
966 if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; }
968 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
970 if ( $variables->{$pkgversion} ne "FINALVERSION" )
972 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
973 # 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
974 # and therefore be set as $pkgversion.
975 # The first part "3.0.0" has to be derived from the
977 my $version = $installer::globals::packageversion;
978 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
980 my $major = $1;
981 my $minor = $2;
982 my $micro = $3;
984 my $finalmajor = $major;
985 my $finalminor = $minor;
986 my $finalmicro = 0;
988 $version = "$finalmajor.$finalminor.$finalmicro";
991 my $datestring = $variables->{$pkgversion};
993 # Allowing some packages to have another date of creation.
994 # They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename"
996 my $additionalkey = $pkgversion . "_" . $packagename;
997 if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; }
999 my $versionstring = "$version,$datestring";
1001 for ( my $i = 0; $i <= $#{$file}; $i++ )
1003 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
1005 my $start = $1;
1006 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
1007 my $oldstring = ${$file}[$i];
1008 ${$file}[$i] = $newstring;
1009 $oldstring =~ s/\s*$//;
1010 $newstring =~ s/\s*$//;
1011 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1012 push( @installer::globals::logfileinfo, $infoline);
1013 last;
1020 ########################################################
1021 # Setting MAXINST=1000 into the pkginfo file.
1022 ########################################################
1024 sub set_maxinst_in_pkginfo
1026 my ($changefile, $filename) = @_;
1028 my $newline = "MAXINST\=1000\n";
1030 add_one_line_into_file($changefile, $newline, $filename);
1033 #############################################################
1034 # Setting several Solaris variables into the pkginfo file.
1035 #############################################################
1037 sub set_solaris_parameter_in_pkginfo
1039 my ($changefile, $filename, $allvariables) = @_;
1041 my $newline = "";
1043 # SUNW_PRODNAME
1044 # SUNW_PRODVERS
1045 # SUNW_PKGVERS
1046 # Not: SUNW_PKGTYPE
1047 # HOTLINE
1048 # EMAIL
1050 my $productname = $allvariables->{'PRODUCTNAME'};
1051 $newline = "SUNW_PRODNAME=$productname\n";
1052 add_one_line_into_file($changefile, $newline, $filename);
1054 my $productversion = "";
1055 if ( $allvariables->{'PRODUCTVERSION'} )
1057 $productversion = $allvariables->{'PRODUCTVERSION'};
1058 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1060 $newline = "SUNW_PRODVERS=$productversion\n";
1061 add_one_line_into_file($changefile, $newline, $filename);
1063 $newline = "SUNW_PKGVERS=1\.0\n";
1064 add_one_line_into_file($changefile, $newline, $filename);
1066 if ( $allvariables->{'SUNW_PKGTYPE'} )
1068 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1069 add_one_line_into_file($changefile, $newline, $filename);
1071 else
1073 $newline = "SUNW_PKGTYPE=\n";
1074 add_one_line_into_file($changefile, $newline, $filename);
1077 $newline = "HOTLINE=Please contact your local service provider\n";
1078 add_one_line_into_file($changefile, $newline, $filename);
1080 $newline = "EMAIL=\n";
1081 add_one_line_into_file($changefile, $newline, $filename);
1085 #####################################################################
1086 # epm uses as archtecture for Solaris x86 "i86pc". This has to be
1087 # changed to "i386".
1088 #####################################################################
1090 sub fix_architecture_setting
1092 my ($changefile) = @_;
1094 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1096 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1098 ${$changefile}[$i] =~ s/i86pc/i386/;
1099 last;
1105 #####################################################################
1106 # Adding a new line for topdir into specfile, removing old
1107 # topdir if set.
1108 #####################################################################
1110 sub set_topdir_in_specfile
1112 my ($changefile, $filename, $newepmdir) = @_;
1114 $newepmdir = Cwd::cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed
1116 # removing "%define _topdir", if existing
1118 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1120 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1122 my $removeline = ${$changefile}[$i];
1123 $removeline =~ s/\s*$//;
1124 splice(@{$changefile},$i,1);
1125 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1126 push( @installer::globals::logfileinfo, $infoline);
1127 last;
1131 # Adding "topdir" behind the line beginning with: Group:
1133 my $inserted_line = 0;
1135 my $topdirline = "\%define _topdir $newepmdir\n";
1137 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1139 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1141 splice(@{$changefile},$i+1,0,$topdirline);
1142 $inserted_line = 1;
1143 $topdirline =~ s/\s*$//;
1144 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1145 push( @installer::globals::logfileinfo, $infoline);
1149 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1153 #####################################################################
1154 # Setting the packager in the spec file
1155 # Syntax: Packager: abc@def
1156 #####################################################################
1158 sub set_packager_in_specfile
1160 my ($changefile) = @_;
1162 my $packager = $installer::globals::longmanufacturer;
1164 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1166 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1168 my $oldstring = $1;
1169 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1170 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1171 push( @installer::globals::logfileinfo, $infoline);
1172 last;
1177 #####################################################################
1178 # Setting the requirements in the spec file (i81494)
1179 # Syntax: PreReq: "requirements" (only for shared extensions)
1180 #####################################################################
1182 sub set_prereq_in_specfile
1184 my ($changefile) = @_;
1186 my $prereq = "PreReq:";
1188 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1190 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1192 my $oldstring = ${$changefile}[$i];
1193 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1194 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1195 push( @installer::globals::logfileinfo, $infoline);
1200 #####################################################################
1201 # Setting the Auto[Req]Prov line and __find_requires
1202 #####################################################################
1204 sub set_autoprovreq_in_specfile
1206 my ($changefile, $findrequires, $bindir) = @_;
1208 my $autoreqprovline;
1210 if ( $findrequires )
1212 $autoreqprovline = "AutoProv\: no\n%define _use_internal_dependency_generator 0\n%define __find_requires $bindir/$findrequires\n";
1214 else
1216 $autoreqprovline = "AutoReqProv\: no\n";
1219 $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n";
1221 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1223 # Adding "autoreqprov" behind the line beginning with: Group:
1224 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1226 splice(@{$changefile},$i+1,0,$autoreqprovline);
1227 $autoreqprovline =~ s/\s*$//;
1228 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1229 push( @installer::globals::logfileinfo, $infoline);
1231 last;
1236 #####################################################################
1237 # Replacing Copyright with License in the spec file
1238 # Syntax: License: LGPLv3 (or MPLv2 on ALv2, older usages were LGPL, SISSL)
1239 #####################################################################
1241 sub set_license_in_specfile
1243 my ($changefile, $variableshashref) = @_;
1245 my $license = $variableshashref->{'LICENSENAME'};
1247 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1249 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1251 ${$changefile}[$i] = "License: $license\n";
1252 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1253 push( @installer::globals::logfileinfo, $infoline);
1254 last;
1259 #########################################################
1260 # Building relocatable Solaris packages means:
1261 # 1. Add "BASEDIR=/opt" into pkginfo
1262 # 2. Remove "/opt/" from all objects in prototype file
1263 # For step2 this function exists
1264 # Sample: d none /opt/openofficeorg20/help 0755 root other
1265 # -> d none openofficeorg20/help 0755 root other
1266 #########################################################
1268 sub make_prototypefile_relocatable
1270 my ($prototypefile, $relocatablepath) = @_;
1272 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1274 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line
1276 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1280 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1281 # This line has to be removed now
1283 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash
1285 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1287 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1289 my $line = ${$prototypefile}[$i];
1290 splice(@{$prototypefile},$i,1); # removing the line
1291 $line =~ s/\s*$//;
1292 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1293 push( @installer::globals::logfileinfo, $infoline);
1294 last;
1298 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1300 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1302 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1304 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1305 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1306 push( @installer::globals::logfileinfo, $infoline2);
1311 #########################################################################
1312 # Replacing the variables in the Solaris patch shell scripts.
1313 # Taking care, that multiple slashes are not always removed.
1314 #########################################################################
1316 sub replace_variables_in_shellscripts_for_patch
1318 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1320 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1322 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1324 my $oldline = ${$scriptfile}[$i];
1325 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; }
1326 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1327 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1328 push(@installer::globals::logfileinfo, $infoline);
1333 #########################################################################
1334 # Replacing the variables in the shell scripts or in the epm list file
1335 # Linux: spec file
1336 # Solaris: preinstall, postinstall, preremove, postremove
1337 # If epm is used in the original version (not relocatable)
1338 # the variables have to be exchanged in the list file,
1339 # created for epm.
1340 #########################################################################
1342 sub replace_variables_in_shellscripts
1344 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1346 my $debug = 0;
1347 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1349 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1351 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1353 my $oldline = ${$scriptfile}[$i];
1354 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1355 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1356 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1357 push(@installer::globals::logfileinfo, $infoline);
1358 if ( $debug )
1360 $infoline = "Old Line: $oldline";
1361 push(@installer::globals::logfileinfo, $infoline);
1362 $infoline = "New Line: ${$scriptfile}[$i]";
1363 push(@installer::globals::logfileinfo, $infoline);
1369 ############################################################
1370 # Determinig the directory created by epm, in which the
1371 # RPMS or Solaris packages are created.
1372 ############################################################
1374 sub determine_installdir_ooo
1376 # A simple "ls" command returns the directory name
1378 my $dirname = "";
1380 my $systemcall = "ls |";
1381 open (LS, "$systemcall");
1382 $dirname = <LS>;
1383 close (LS);
1385 $dirname =~ s/\s*$//;
1387 my $infoline = "Info: Directory created by epm: $dirname\n";
1388 push(@installer::globals::logfileinfo, $infoline);
1390 return $dirname;
1393 ############################################################
1394 # Setting the tab content into the file container
1395 ############################################################
1397 sub set_tab_into_datafile
1399 my ($changefile, $filesref) = @_;
1401 my @newclasses = ();
1402 my $newclassesstring = "";
1404 if ( $installer::globals::issolarispkgbuild )
1406 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1408 my $onefile = ${$filesref}[$i];
1410 if ( $onefile->{'SolarisClass'} )
1412 my $sourcepath = $onefile->{'sourcepath'};
1414 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1416 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1418 my $oldline = ${$changefile}[$j];
1419 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1420 my $newline = ${$changefile}[$j];
1421 $oldline =~ s/\s*$//;
1422 $newline =~ s/\s*$//;
1424 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1425 push(@installer::globals::logfileinfo, $infoline);
1427 # collecting all new classes
1428 if (! grep {$_ eq $onefile->{'SolarisClass'}} @newclasses)
1430 push(@newclasses, $onefile->{'SolarisClass'});
1433 last;
1439 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1442 if ( $installer::globals::isrpmbuild )
1444 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1446 my $onefile = ${$filesref}[$i];
1448 if ( $onefile->{'SpecFileContent'} )
1450 my $destination = $onefile->{'destination'};
1452 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1454 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1456 my $begin = $1;
1457 my $end = $2;
1459 my $oldline = ${$changefile}[$j];
1460 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1461 my $newline = ${$changefile}[$j];
1463 $oldline =~ s/\s*$//;
1464 $newline =~ s/\s*$//;
1466 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1467 push(@installer::globals::logfileinfo, $infoline);
1469 last;
1476 return $newclassesstring;
1479 ############################################################
1480 # Including additional classes into the pkginfo file
1481 ############################################################
1483 sub include_classes_into_pkginfo
1485 my ($changefile, $classesstring) = @_;
1487 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1489 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1491 ${$changefile}[$i] =~ s/\s*$//;
1492 my $oldline = ${$changefile}[$i];
1493 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1494 my $newline = ${$changefile}[$i];
1495 $newline =~ s/\s*$//;
1497 my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n";
1498 push(@installer::globals::logfileinfo, $infoline);
1503 ##########################################################################################
1504 # Checking, if an extension is included into the package (Linux).
1505 # All extension files have to be installed into directory
1506 # share/extension/install
1507 # %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt"
1508 ##########################################################################################
1510 sub is_extension_package
1512 my ($specfile) = @_;
1514 my $is_extension_package = 0;
1516 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1518 my $line = ${$specfile}[$i];
1519 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1521 $is_extension_package = 1;
1522 last;
1526 return $is_extension_package;
1529 ######################################################################
1530 # Checking, if an extension is included into the package (Solaris).
1531 # All extension files have to be installed into directory
1532 # share/extension/install
1533 ######################################################################
1535 sub contains_extension_dir
1537 my ($prototypefile) = @_;
1539 my $contains_extension_dir = 0;
1541 # d none opt/openoffice.org3/share/extensions/
1543 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1545 my $line = ${$prototypefile}[$i];
1546 if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// )
1548 $contains_extension_dir = 1;
1549 last;
1553 return $contains_extension_dir;
1556 ############################################################
1557 # Setting the correct Solaris locales
1558 ############################################################
1560 sub get_solaris_language_for_langpack
1562 my ( $onelanguage ) = @_;
1564 my $sollanguage = $onelanguage;
1565 $sollanguage =~ s/\-/\_/;
1567 if ( $sollanguage eq "de" ) { $sollanguage = "de"; }
1568 elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; }
1569 elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; }
1570 elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; }
1571 elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; }
1572 elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; }
1573 elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; }
1574 elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; }
1575 elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; }
1576 elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; }
1577 elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; }
1578 elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; }
1579 elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; }
1580 elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; }
1581 elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; }
1582 elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; }
1584 return $sollanguage;
1587 ############################################################
1588 # Adding language infos in pkginfo file
1589 ############################################################
1591 sub include_languageinfos_into_pkginfo
1593 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1595 # SUNWPKG_LIST=core01
1596 # SUNW_LOC=de
1598 my $locallang = $onepackage->{'language'};
1599 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1601 my $newline = "SUNW_LOC=" . $solarislanguage . "\n";
1602 add_one_line_into_file($changefile, $newline, $filename);
1604 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1605 if ( $onepackage->{'pkg_list_entry'} )
1607 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1608 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1609 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1610 add_one_line_into_file($changefile, $newline, $filename);
1612 else
1614 # Using default package ooobasis30-core01.
1615 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01";
1616 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1617 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1618 add_one_line_into_file($changefile, $newline, $filename);
1622 ############################################################
1623 # Including package names into the depend files.
1624 # The package names have to be included into
1625 # packagelist. They are already saved in
1626 # %installer::globals::dependfilenames.
1627 ############################################################
1629 sub put_packagenames_into_dependfile
1631 my ( $file ) = @_;
1633 for ( my $i = 0; $i <= $#{$file}; $i++ )
1635 my $line = ${$file}[$i];
1636 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
1638 my $abbreviation = $1;
1640 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); }
1642 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
1644 my $packagename = $installer::globals::dependfilenames{$abbreviation};
1645 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); }
1647 $line =~ s/\s*$//;
1648 ${$file}[$i] = $line . "\t" . $packagename . "\n";
1650 else
1652 installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile");
1658 ############################################################
1659 # Including the relocatable directory into
1660 # spec file and pkginfo file
1661 # Linux: set topdir in specfile
1662 # Solaris: remove $relocatablepath (/opt/)
1663 # for all objects in prototype file
1664 # and changing "topdir" for Linux
1665 ############################################################
1667 sub prepare_packages
1669 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
1671 my $filename = "";
1672 my $newline = "";
1673 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
1675 my $localrelocatablepath = $relocatablepath;
1676 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; }
1678 if ( $installer::globals::issolarispkgbuild )
1680 $filename = $packagename . ".pkginfo";
1681 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
1684 if ( $installer::globals::isrpmbuild )
1686 $filename = $packagename . ".spec";
1687 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
1690 my $completefilename = $newepmdir . $filename;
1692 if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); }
1693 my $changefile = installer::files::read_file($completefilename);
1694 if ( $newline ne "" )
1696 add_one_line_into_file($changefile, $newline, $filename);
1697 installer::files::save_file($completefilename, $changefile);
1700 # adding new "topdir" and removing old "topdir" in specfile
1702 if ( $installer::globals::isrpmbuild )
1704 set_topdir_in_specfile($changefile, $filename, $newepmdir);
1705 set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::workpath" . "/bin");
1706 set_packager_in_specfile($changefile);
1707 if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); }
1708 set_license_in_specfile($changefile, $variableshashref);
1709 set_tab_into_datafile($changefile, $filesref);
1710 installer::files::save_file($completefilename, $changefile);
1713 # removing the relocatable path in prototype file
1715 if ( $installer::globals::issolarispkgbuild )
1717 set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename);
1718 set_maxinst_in_pkginfo($changefile, $filename);
1719 set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref);
1720 if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); }
1721 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
1722 installer::files::save_file($completefilename, $changefile);
1724 my $prototypefilename = $packagename . ".prototype";
1725 $prototypefilename = $newepmdir . $prototypefilename;
1726 if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
1728 my $prototypefile = installer::files::read_file($prototypefilename);
1729 make_prototypefile_relocatable($prototypefile, $relocatablepath);
1730 my $classesstring = set_tab_into_datafile($prototypefile, $filesref);
1731 if ($classesstring)
1733 include_classes_into_pkginfo($changefile, $classesstring);
1734 installer::files::save_file($completefilename, $changefile);
1737 installer::files::save_file($prototypefilename, $prototypefile);
1739 # Adding package names into depend files for Solaris (not supported by epm)
1740 my $dependfilename = $packagename . ".depend";
1741 $dependfilename = $newepmdir . $dependfilename;
1742 if ( -f $dependfilename)
1744 my $dependfile = installer::files::read_file($dependfilename);
1745 put_packagenames_into_dependfile($dependfile);
1746 installer::files::save_file($dependfilename, $dependfile);
1750 return $newepmdir;
1753 ###############################################################################
1754 # Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
1755 # epm list file.
1756 # The complete rootpath is stored in $installer::globals::rootpath
1757 # or for each package in $onepackage->{'destpath'}
1758 # The static rootpath is stored in $staticpath
1759 # The relocatable path is stored in $relocatablepath
1760 # PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
1761 # PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
1762 # In standard epm process:
1763 # No usage of package specific variables like $BASEDIR, because
1764 # 1. These variables would be replaced in epm process
1765 # 2. epm version 3.7 does not support relocatable packages
1766 ###############################################################################
1768 sub resolve_path_in_epm_list_before_packaging
1770 my ($listfile, $listfilename, $variable, $path) = @_;
1772 installer::logger::include_header_into_logfile("Replacing variables in epm list file:");
1774 $path =~ s/\/\s*$//;
1775 replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path);
1779 #################################################################
1780 # Determining the rpm version. Beginning with rpm version 4.0
1781 # the tool to create RPMs is "rpmbuild" and no longer "rpm"
1782 #################################################################
1784 sub determine_rpm_version
1786 my $rpmversion = 0;
1787 my $rpmout = "";
1788 my $systemcall = "";
1790 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
1791 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
1792 # is saved in $installer::globals::rpm
1794 if ( $installer::globals::rpm ne "" )
1796 $systemcall = "$installer::globals::rpm --version |";
1798 else
1800 $systemcall = "rpm --version |";
1803 open (RPM, "$systemcall");
1804 $rpmout = <RPM>;
1805 close (RPM);
1807 if ( $rpmout ne "" )
1809 $rpmout =~ s/\s*$//g;
1811 my $infoline = "Systemcall: $systemcall\n";
1812 push( @installer::globals::logfileinfo, $infoline);
1814 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
1815 else { $infoline = "Success: rpm version: $rpmout\n"; }
1817 push( @installer::globals::logfileinfo, $infoline);
1819 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
1820 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
1821 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
1822 else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
1825 return $rpmversion;
1828 ####################################################
1829 # Writing some info about rpm into the log file
1830 ####################################################
1832 sub log_rpm_info
1834 my $systemcall = "";
1835 my $infoline = "";
1837 $infoline = "\nLogging rpmrc content using --showrc\n\n";
1838 push( @installer::globals::logfileinfo, $infoline);
1840 if ( $installer::globals::rpm ne "" )
1842 $systemcall = "$installer::globals::rpm --showrc |";
1844 else
1846 $systemcall = "rpm --showrc |";
1849 my @fullrpmout = ();
1851 open (RPM, "$systemcall");
1852 while (<RPM>) {push(@fullrpmout, $_); }
1853 close (RPM);
1855 if ( $#fullrpmout > -1 )
1857 for ( my $i = 0; $i <= $#fullrpmout; $i++ )
1859 my $rpmout = $fullrpmout[$i];
1860 $rpmout =~ s/\s*$//g;
1862 $infoline = "$rpmout\n";
1863 $infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems
1864 push( @installer::globals::logfileinfo, $infoline);
1867 else
1869 $infoline = "Problem in systemcall: $systemcall : No return value\n";
1870 push( @installer::globals::logfileinfo, $infoline);
1873 $infoline = "End of logging rpmrc\n\n";
1874 push( @installer::globals::logfileinfo, $infoline);
1877 #################################################
1878 # Systemcall to start the packaging process
1879 #################################################
1881 sub create_packages_without_epm
1883 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
1885 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
1886 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
1887 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
1889 if ( $installer::globals::issolarispkgbuild )
1891 my $prototypefile = $epmdir . $packagename . ".prototype";
1892 if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
1894 my $destinationdir = $prototypefile;
1895 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir);
1896 $destinationdir =~ s/\/\s*$//; # removing ending slashes
1898 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
1899 installer::logger::print_message( "... $systemcall ...\n" );
1901 my $maxpkgmkcalls = 3;
1903 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
1905 my @pkgmkoutput = ();
1907 open (PKGMK, "$systemcall");
1908 while (<PKGMK>) {push(@pkgmkoutput, $_); }
1909 close (PKGMK);
1911 my $returnvalue = $?; # $? contains the return value of the systemcall
1913 my $infoline = "Systemcall (Try $i): $systemcall\n";
1914 push( @installer::globals::logfileinfo, $infoline);
1916 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
1918 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
1919 push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]");
1922 if ($returnvalue)
1924 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
1925 push( @installer::globals::logfileinfo, $infoline);
1926 if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
1928 else
1930 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
1931 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1932 push( @installer::globals::logfileinfo, $infoline);
1933 last;
1937 # It might be necessary to save uncompressed Solaris packages
1939 # compressing packages
1941 if ( ! $installer::globals::solarisdontcompress )
1943 my $faspac = "faspac-so.sh";
1945 my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0);
1946 if ($$compressorref ne "")
1948 # Saving original pkginfo, to set time stamp later
1949 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
1950 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
1951 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
1952 installer::systemactions::make_systemcall($systemcall);
1954 $faspac = $$compressorref;
1955 $infoline = "Found compressor: $faspac\n";
1956 push( @installer::globals::logfileinfo, $infoline);
1958 installer::logger::print_message( "... $faspac ...\n" );
1959 installer::logger::include_timestamp_into_logfile("Starting $faspac");
1961 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
1962 installer::systemactions::make_systemcall($systemcall);
1964 # Setting time stamp for pkginfo, because faspac-so.sh
1965 # changed the pkginfo file, updated the size and
1966 # checksum, but not the time stamp.
1967 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
1968 installer::systemactions::make_systemcall($systemcall);
1969 if ( -f $pkginfotmp ) { unlink($pkginfotmp); }
1971 installer::logger::include_timestamp_into_logfile("End of $faspac");
1973 else
1975 $infoline = "Not found: $faspac\n";
1976 push( @installer::globals::logfileinfo, $infoline);
1980 # Setting unix rights to "775" for all created directories inside the package
1982 $systemcall = "cd $destinationdir; find $packagename -type d | xargs -i chmod 775 \{\} \;";
1983 installer::logger::print_message( "... $systemcall ...\n" );
1985 $returnvalue = system($systemcall);
1987 $infoline = "Systemcall: $systemcall\n";
1988 push( @installer::globals::logfileinfo, $infoline);
1990 if ($returnvalue)
1992 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
1993 push( @installer::globals::logfileinfo, $infoline);
1995 else
1997 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1998 push( @installer::globals::logfileinfo, $infoline);
2002 ######################
2003 # making pkg files
2004 ######################
2006 # my $streamname = $packagename . ".pkg";
2007 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
2008 # print "... $systemcall ...\n";
2010 # $returnvalue = system($systemcall);
2012 # $infoline = "Systemcall: $systemcall\n";
2013 # push( @installer::globals::logfileinfo, $infoline);
2015 # if ($returnvalue)
2017 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2018 # push( @installer::globals::logfileinfo, $infoline);
2020 # else
2022 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2023 # push( @installer::globals::logfileinfo, $infoline);
2026 #########################
2027 # making tar.gz files
2028 #########################
2030 # my $targzname = $packagename . ".tar.gz";
2031 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
2032 # print "... $systemcall ...\n";
2034 # $returnvalue = system($systemcall);
2036 # $infoline = "Systemcall: $systemcall\n";
2037 # push( @installer::globals::logfileinfo, $infoline);
2039 # if ($returnvalue)
2041 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2042 # push( @installer::globals::logfileinfo, $infoline);
2044 # else
2046 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2047 # push( @installer::globals::logfileinfo, $infoline);
2052 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2054 if ( $installer::globals::isrpmbuild )
2056 my $specfilename = $epmdir . $packagename . ".spec";
2057 if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2059 my $rpmcommand = $installer::globals::rpm;
2060 my $rpmversion = determine_rpm_version();
2062 my $target = "";
2063 if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; }
2064 elsif ( $installer::globals::compiler =~ /unxaigppc/) { $target = "ppc"; }
2065 elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; }
2067 # rpm 4.6 ignores buildroot tag in spec file
2069 my $buildrootstring = "";
2071 if ( $rpmversion >= 4 )
2073 my $dir = Cwd::getcwd;
2074 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2075 $buildrootstring = "--buildroot=$buildroot";
2076 mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/");
2079 if ( ! $installer::globals::rpminfologged )
2081 log_rpm_info();
2082 $installer::globals::rpminfologged = 1;
2085 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2087 installer::logger::print_message( "... $systemcall ...\n" );
2089 my $maxrpmcalls = 3;
2090 my $rpm_failed = 0;
2092 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2094 my @rpmoutput = ();
2096 open (RPM, "$systemcall");
2097 while (<RPM>) {push(@rpmoutput, $_); }
2098 close (RPM);
2100 my $returnvalue = $?; # $? contains the return value of the systemcall
2102 my $infoline = "Systemcall (Try $i): $systemcall\n";
2103 push( @installer::globals::logfileinfo, $infoline);
2105 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2107 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2108 push( @installer::globals::logfileinfo, "$rpmoutput[$j]");
2111 if ($returnvalue)
2113 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2114 push( @installer::globals::logfileinfo, $infoline);
2115 $rpm_failed = 1;
2117 else
2119 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2120 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2121 push( @installer::globals::logfileinfo, $infoline);
2122 $rpm_failed = 0;
2123 last;
2127 if ( $rpm_failed )
2129 # Because of the problems with LD_LIBRARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2130 my $rpmprog = "";
2131 if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2132 elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2134 if ( $rpmprog ne "" )
2136 installer::logger::print_message( "... $rpmprog ...\n" );
2138 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2140 my @helperrpmoutput = ();
2142 open (RPM, "$helpersystemcall");
2143 while (<RPM>) {push(@helperrpmoutput, $_); }
2144 close (RPM);
2146 my $helperreturnvalue = $?; # $? contains the return value of the systemcall
2148 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBRARY_PATH)\n";
2149 push( @installer::globals::logfileinfo, $infoline);
2151 $infoline = "\nSystemcall: $helpersystemcall\n";
2152 push( @installer::globals::logfileinfo, $infoline);
2154 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); }
2156 if ($helperreturnvalue)
2158 $infoline = "Could not execute \"$helpersystemcall\"!\n";
2159 push( @installer::globals::logfileinfo, $infoline);
2161 else
2163 installer::logger::print_message( "Success: \"$helpersystemcall\"\n" );
2164 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2165 push( @installer::globals::logfileinfo, $infoline);
2166 $rpm_failed = 0;
2170 # Now it is really time to exit this packaging process, if the error still occurs
2171 if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2176 #################################################
2177 # Removing all temporary files created by epm
2178 #################################################
2180 sub remove_temporary_epm_files
2182 my ($epmdir, $loggingdir, $packagename) = @_;
2184 # saving the files into the loggingdir
2186 if ( $installer::globals::issolarispkgbuild )
2188 my @extensions = ();
2189 push(@extensions, ".pkginfo");
2190 push(@extensions, ".prototype");
2191 push(@extensions, ".postinstall");
2192 push(@extensions, ".postremove");
2193 push(@extensions, ".preinstall");
2194 push(@extensions, ".preremove");
2195 push(@extensions, ".depend");
2197 for ( my $i = 0; $i <= $#extensions; $i++ )
2199 my $removefile = $epmdir . $packagename . $extensions[$i];
2200 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2202 if (! -f $removefile) { next; }
2204 my $systemcall = "mv -f $removefile $destfile";
2205 system($systemcall); # ignoring the return value
2206 $infoline = "Systemcall: $systemcall\n";
2207 push( @installer::globals::logfileinfo, $infoline);
2211 if ( $installer::globals::isrpmbuild )
2213 my $removefile = $epmdir . $packagename . ".spec";
2214 my $destfile = $loggingdir . $packagename . ".spec.log";
2216 my $systemcall = "mv -f $removefile $destfile";
2217 system($systemcall); # ignoring the return value
2218 $infoline = "Systemcall: $systemcall\n";
2219 push( @installer::globals::logfileinfo, $infoline);
2221 # removing the directory "buildroot"
2223 my $removedir = $epmdir . "buildroot";
2225 $systemcall = "rm -rf $removedir";
2227 installer::logger::print_message( "... $systemcall ...\n" );
2229 my $returnvalue = system($systemcall);
2231 $removedir = $epmdir . "BUILD";
2233 $systemcall = "rm -rf $removedir";
2235 installer::logger::print_message( "... $systemcall ...\n" );
2237 $returnvalue = system($systemcall);
2240 my $infoline = "Systemcall: $systemcall\n";
2241 push( @installer::globals::logfileinfo, $infoline);
2243 if ($returnvalue)
2245 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2246 push( @installer::globals::logfileinfo, $infoline);
2248 else
2250 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2251 push( @installer::globals::logfileinfo, $infoline);
2256 ###########################################################
2257 # Creating a better directory structure in the solver.
2258 ###########################################################
2260 sub create_new_directory_structure
2262 my ($newepmdir) = @_;
2264 my $newdir = $installer::globals::epmoutpath;
2266 if ( $installer::globals::isrpmbuild )
2268 my $rpmdir;
2269 my $machine = "";
2270 if ( $installer::globals::compiler =~ /unxlngi/) {
2271 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2273 elsif ( $installer::globals::compiler =~ /unxaigppc/) {
2274 $machine = "ppc";
2275 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2277 elsif ( $installer::globals::compiler =~ /unxlng/) {
2278 $machine = (POSIX::uname())[4];
2279 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2281 else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2283 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2285 my $returnvalue = system($systemcall);
2287 my $infoline = "Systemcall: $systemcall\n";
2288 push( @installer::globals::logfileinfo, $infoline);
2290 if ($returnvalue)
2292 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2293 push( @installer::globals::logfileinfo, $infoline);
2295 else
2297 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2298 push( @installer::globals::logfileinfo, $infoline);
2301 # and removing the empty directory
2303 if ( $machine ne "" )
2305 rmdir "$installer::globals::epmoutpath/RPMS/$machine";
2307 rmdir "$installer::globals::epmoutpath/RPMS/powerpc";
2308 rmdir "$installer::globals::epmoutpath/RPMS/x86_64";
2309 rmdir "$installer::globals::epmoutpath/RPMS/i586";
2310 rmdir "$installer::globals::epmoutpath/RPMS/i386";
2311 rmdir "$installer::globals::epmoutpath/RPMS"
2312 or warn "Could not remove RPMS dir: $!";
2315 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2316 chmod 0775, $newdir;
2319 ######################################################
2320 # Collect modules with product specific styles.
2321 ######################################################
2323 sub collect_modules_with_style
2325 my ($style, $modulesarrayref) = @_;
2327 my @allmodules = ();
2329 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2331 my $onemodule = ${$modulesarrayref}[$i];
2332 my $styles = "";
2333 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2334 if ( $styles =~ /\b\Q$style\E\b/ )
2336 push(@allmodules, $onemodule);
2340 return \@allmodules;
2343 ######################################################
2344 # Remove modules without packagecontent.
2345 ######################################################
2347 sub remove_modules_without_package
2349 my ($allmodules) = @_;
2351 my @allmodules = ();
2353 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2355 my $onemodule = ${$allmodules}[$i];
2356 my $packagename = "";
2357 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2358 if ( $packagename ne "" )
2360 push(@allmodules, $onemodule);
2364 return \@allmodules;
2367 ######################################################
2368 # Unpacking tar.gz file and setting new packagename.
2369 ######################################################
2371 sub unpack_tar_gz_file
2373 my ($packagename, $destdir) = @_;
2375 my $newpackagename = "";
2377 if ( $packagename =~ /\.tar\.gz\s*$/ )
2379 # Collecting all packages in directory "packages"
2380 my $oldcontent = installer::systemactions::read_directory($destdir);
2382 # unpacking gunzip
2383 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -";
2384 installer::systemactions::make_systemcall($systemcall);
2386 # deleting the tar.gz files
2387 $systemcall = "cd $destdir; rm -f $packagename";
2388 installer::systemactions::make_systemcall($systemcall);
2390 # Finding new content -> that is the package name
2391 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2392 $newpackagename = ${$newcontent}[0];
2393 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename);
2396 if ( $newpackagename ne "" ) { $packagename = $newpackagename; }
2398 return $packagename;
2401 ######################################################
2402 # Copying files for system integration.
2403 ######################################################
2405 sub copy_and_unpack_tar_gz_files
2407 my ($sourcefile, $destdir) = @_;
2409 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2410 installer::systemactions::make_systemcall($systemcall);
2413 ######################################################
2414 # Checking whether the new content is a directory and
2415 # not a package. If it is a directory, the complete
2416 # content of the directory has to be added to the
2417 # array newcontent.
2418 ######################################################
2420 sub control_subdirectories
2422 my ($content, $subdir) = @_;
2424 my @newcontent = ();
2426 for ( my $i = 0; $i <= $#{$content}; $i++ )
2428 if ( -d ${$content}[$i] )
2430 $subdir = ${$content}[$i];
2431 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir);
2432 my $allpackages = installer::systemactions::read_directory(${$content}[$i]);
2433 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
2435 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
2436 if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
2437 push(@newcontent, ${$allpackages}[$j]);
2440 else
2442 push(@newcontent, ${$content}[$i]);
2446 return (\@newcontent, $subdir);
2449 ######################################################
2450 # Including the system integration files into the
2451 # installation sets.
2452 ######################################################
2454 sub put_systemintegration_into_installset
2456 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
2458 my $destdir = $newdir;
2460 # adding System integration files
2462 my $sourcefile = "";
2464 # Finding the modules defined in scp (with flag SYSTEMMODULE)
2465 # Getting name of package from scp-Module
2466 # Search package in list off all include files
2467 # Copy file into installation set and unpack it (always tar.gz)
2468 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
2470 # Collect all modules with flag "SYSTEMMODULE"
2471 my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref);
2472 $allmodules = remove_modules_without_package($allmodules);
2474 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2476 my $onemodule = ${$allmodules}[$i];
2477 my $packagetarfilename = $onemodule->{'PackageName'};
2479 my $infoline = "Including into installation set: $packagetarfilename\n";
2480 push( @installer::globals::logfileinfo, $infoline);
2482 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1);
2483 if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
2485 # Collecting all packages in directory "packages" or "RPMS"
2486 my $oldcontent = installer::systemactions::read_directory($destdir);
2488 copy_and_unpack_tar_gz_files($$sourcepathref, $destdir);
2490 # Finding new content -> that is the package name
2491 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2493 # special handling, if new content is a directory
2494 my $subdir = "";
2495 if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); }
2497 # Adding license content into Solaris packages
2498 if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { _add_license_into_systemintegrationpackages($destdir, $newcontent); }
2502 ######################################################
2503 # Analyzing the Unix installation path.
2504 # From the installation path /opt/openofficeorg20
2505 # is the part /opt relocatable and the part
2506 # openofficeorg20 static.
2507 ######################################################
2509 sub analyze_rootpath
2511 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
2513 $rootpath =~ s/\/\s*$//; # removing ending slash
2515 ##############################################################
2516 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
2517 ##############################################################
2519 $$relocatablepathref = "/";
2520 # Static path has to contain the office directory name. This is replaced in shellscripts.
2521 $$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname;
2522 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
2523 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
2524 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
2525 if ( $installer::globals::isrpmbuild )
2527 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
2528 $$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts
2531 if ( $installer::globals::isdebbuild )
2533 $$relocatablepathref = "";
2534 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
2539 ################################################
2540 # Defining the English license text to add
2541 # it into Solaris packages.
2542 ################################################
2544 sub _set_english_license
2546 my $additional_license_name = $installer::globals::englishsolarislicensename; # always the English file
2547 my $licensefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$additional_license_name, "" , 0);
2548 if ( $$licensefileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $additional_license_name!", "set_english_license"); }
2549 $installer::globals::englishlicenseset = 1;
2550 $installer::globals::englishlicense = installer::files::read_file($$licensefileref);
2551 installer::scpzipfiles::replace_all_ziplistvariables_in_file($installer::globals::englishlicense, $variableshashref);
2554 ################################################
2555 # Adding the content of the English license
2556 # file into the system integration packages.
2557 ################################################
2559 sub _add_license_into_systemintegrationpackages
2561 my ($destdir, $packages) = @_;
2563 for ( my $i = 0; $i <= $#{$packages}; $i++ )
2565 my $copyrightfilename = ${$packages}[$i] . $installer::globals::separator . "install" . $installer::globals::separator . "copyright";
2566 if ( ! -f $copyrightfilename ) { installer::exiter::exit_program("ERROR: Could not find license file in system integration package: $copyrightfilename!", "add_license_into_systemintegrationpackages"); }
2567 my $copyrightfile = installer::files::read_file($copyrightfilename);
2569 # Saving time stamp of old copyrightfile
2570 my $savcopyrightfilename = $copyrightfilename . ".sav";
2571 installer::systemactions::copy_one_file($copyrightfilename, $savcopyrightfilename);
2572 _set_time_stamp_for_file($copyrightfilename, $savcopyrightfilename); # now $savcopyrightfile has the time stamp of $copyrightfile
2574 # Adding license content to copyright file
2575 push(@{$copyrightfile}, "\n");
2576 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
2577 installer::files::save_file($copyrightfilename, $copyrightfile);
2579 # Setting the old time stamp saved with $savcopyrightfilename
2580 _set_time_stamp_for_file($savcopyrightfilename, $copyrightfilename); # now $copyrightfile has the time stamp of $savcopyrightfile
2581 unlink($savcopyrightfilename);
2583 # Changing content of copyright file in pkgmap
2584 my $pkgmapfilename = ${$packages}[$i] . $installer::globals::separator . "pkgmap";
2585 if ( ! -f $pkgmapfilename ) { installer::exiter::exit_program("ERROR: Could not find pkgmap in system integration package: $pkgmapfilename!", "add_license_into_systemintegrationpackages"); }
2586 my $pkgmap = installer::files::read_file($pkgmapfilename);
2587 _change_onefile_in_pkgmap($pkgmap, $copyrightfilename, "copyright");
2588 installer::files::save_file($pkgmapfilename, $pkgmap);
2592 ##############################################
2593 # Setting time stamp of copied files to avoid
2594 # errors from pkgchk.
2595 ##############################################
2597 sub _set_time_stamp_for_file
2599 my ($sourcefile, $destfile) = @_;
2601 my $systemcall = "touch -r $sourcefile $destfile";
2603 my $returnvalue = system($systemcall);
2605 my $infoline = "Systemcall: $systemcall\n";
2606 push( @installer::globals::logfileinfo, $infoline);
2608 if ($returnvalue)
2610 $infoline = "ERROR: \"$systemcall\" failed!\n";
2611 push( @installer::globals::logfileinfo, $infoline);
2613 else
2615 $infoline = "Success: \"$systemcall\" !\n";
2616 push( @installer::globals::logfileinfo, $infoline);
2620 ##############################################
2621 # Setting checksum and wordcount for changed
2622 # pkginfo file into pkgmap.
2623 ##############################################
2625 sub _change_onefile_in_pkgmap
2627 my ($pkgmapfile, $fullfilename, $shortfilename) = @_;
2629 # 1 i pkginfo 442 34577 1166716297
2630 # ->
2631 # 1 i pkginfo 443 34737 1166716297
2633 # wc -c pkginfo | cut -f6 -d' ' -> 442 (variable)
2634 # sum pkginfo | cut -f1 -d' ' -> 34577 (variable)
2635 # grep 'pkginfo' pkgmap | cut -f6 -d' ' -> 1166716297 (fix)
2637 my $checksum = _call_sum($fullfilename);
2638 if ( $checksum =~ /^\s*(\d+)\s+.*$/ ) { $checksum = $1; }
2640 my $wordcount = _call_wc($fullfilename);
2641 if ( $wordcount =~ /^\s*(\d+)\s+.*$/ ) { $wordcount = $1; }
2643 for ( my $i = 0; $i <= $#{$pkgmapfile}; $i++ )
2645 if ( ${$pkgmapfile}[$i] =~ /(^.*\b\Q$shortfilename\E\b\s+)(\d+)(\s+)(\d+)(\s+)(\d+)(\s*$)/ )
2647 my $newline = $1 . $wordcount . $3 . $checksum . $5 . $6 . $7;
2648 ${$pkgmapfile}[$i] = $newline;
2649 last;
2654 #########################################################
2655 # Calling sum
2656 #########################################################
2658 sub _call_sum
2660 my ($filename) = @_;
2662 $sumfile = "/usr/bin/sum";
2664 if ( ! -f $sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/sum", "call_sum"); }
2666 my $systemcall = "$sumfile $filename |";
2668 my $sumoutput = "";
2670 open (SUM, "$systemcall");
2671 $sumoutput = <SUM>;
2672 close (SUM);
2674 my $returnvalue = $?; # $? contains the return value of the systemcall
2676 my $infoline = "Systemcall: $systemcall\n";
2677 push( @installer::globals::logfileinfo, $infoline);
2679 if ($returnvalue)
2681 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2682 push( @installer::globals::logfileinfo, $infoline);
2684 else
2686 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2687 push( @installer::globals::logfileinfo, $infoline);
2690 return $sumoutput;
2693 #########################################################
2694 # Calling wc
2695 # wc -c pkginfo | cut -f6 -d' '
2696 #########################################################
2698 sub _call_wc
2700 my ($filename) = @_;
2702 $wcfile = "/usr/bin/wc";
2704 if ( ! -f $wcfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/wc", "call_wc"); }
2706 my $systemcall = "$wcfile -c $filename |";
2708 my $wcoutput = "";
2710 open (WC, "$systemcall");
2711 $wcoutput = <WC>;
2712 close (WC);
2714 my $returnvalue = $?; # $? contains the return value of the systemcall
2716 my $infoline = "Systemcall: $systemcall\n";
2717 push( @installer::globals::logfileinfo, $infoline);
2719 if ($returnvalue)
2721 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2722 push( @installer::globals::logfileinfo, $infoline);
2724 else
2726 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2727 push( @installer::globals::logfileinfo, $infoline);
2730 return $wcoutput;