Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / solenv / bin / modules / installer / epmfile.pm
blobb33aad152bd1a0bd0be9b409494586ed59162ff5
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 # in the SDK it's in subdirectory sdk/share/readme
382 if ( $filename =~ /$possiblereadmefilename$/ )
384 $foundreadmefile = 1;
385 $line = "%readme" . " " . $onefile->{'sourcepath'} . "\n";
386 push(@epmheader, $line);
387 last;
392 # the readme file need not be packaged more times in the help content
393 # it needs to be installed in parallel with the main package anyway
394 # try to find the README file between all available files (not only between the packaged)
395 if (!($foundreadmefile) && $installer::globals::helppack)
397 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$readmefilenameen, "" , 0);
398 if($$fileref ne "" )
400 $infoline = "Fallback to readme file: \"$$fileref\"!\n";
401 push(@installer::globals::logfileinfo, $infoline);
403 $foundreadmefile = 1;
404 $line = "%readme" . " " . $$fileref . "\n";
405 push(@epmheader, $line);
409 # searching for and license file
411 if ( $license_in_package_defined )
413 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
415 if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (A)!", "create_epm_header"); }
417 # Special handling to add the content of the file "license_en-US" to the solaris copyrightfile. But not for all products
419 if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} ))
421 if ( ! $installer::globals::englishlicenseset ) { _set_english_license() }
423 # The location for the new file
424 my $languagestring = "";
425 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; }
426 $languagestring =~ s/^\s*_//;
428 my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring);
430 my $copyrightfile = installer::files::read_file($$fileref);
432 # Adding license content to copyright file
433 push(@{$copyrightfile}, "\n");
434 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
436 # New destination for $$fileref
437 $$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'};
438 if ( -f $$fileref ) { unlink $$fileref; }
439 installer::files::save_file($$fileref, $copyrightfile);
442 $infoline = "Using license file: \"$$fileref\"!\n";
443 push(@installer::globals::logfileinfo, $infoline);
445 $foundlicensefile = 1;
446 $line = "%license" . " " . $$fileref . "\n";
447 push(@epmheader, $line);
449 else
451 for my $onefile (@{$filesinproduct})
453 # in the SDK it's in subdirectory sdk/share/readme so try to match that
454 if ($onefile->{'Name'} =~ /$licensefilename$/)
456 push @epmheader, "%license" . " " . $onefile->{'sourcepath'} . "\n";
457 $foundlicensefile = 1;
458 last;
462 # the license file need not be packaged more times in the langpacks
463 # they need to be installed in parallel with the main package anyway
464 # try to find the LICENSE file between all available files (not only between the packaged)
465 if (!($foundlicensefile) && ($installer::globals::languagepack || $installer::globals::helppack))
467 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
468 if($$fileref ne "" )
470 $infoline = "Fallback to license file: \"$$fileref\"!\n";
471 push(@installer::globals::logfileinfo, $infoline);
473 $foundlicensefile = 1;
474 $line = "%license" . " " . $$fileref . "\n";
475 push(@epmheader, $line);
480 if (!($foundlicensefile))
482 installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (B)", "create_epm_header");
485 if (!($foundreadmefile))
487 installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename (C)", "create_epm_header");
490 # including %replaces
492 my $replaces = "";
494 if ( $installer::globals::issolarispkgbuild )
496 $replaces = "solarisreplaces"; # the name in the packagelist
498 elsif ( $installer::globals::islinuxbuild )
500 $replaces = "linuxreplaces"; # the name in the packagelist
503 if ( $replaces )
505 if ( $onepackage->{$replaces} )
507 my $replacesstring = $onepackage->{$replaces};
509 my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ",");
511 for ( my $i = 0; $i <= $#{$allreplaces}; $i++ )
513 my $onereplaces = ${$allreplaces}[$i];
514 $onereplaces =~ s/\s*$//;
515 installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1);
516 $onereplaces = debian_rewrite($onereplaces);
517 $line = "%replaces" . " " . $onereplaces . "\n";
518 push(@epmheader, $line);
523 # including %incompat
525 my $incompat = "";
527 if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch ))
529 $incompat = "solarisincompat"; # the name in the packagelist
531 elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch ))
533 $incompat = "linuxincompat"; # the name in the packagelist
536 if (( $incompat ) && ( ! $installer::globals::patch ))
538 if ( $onepackage->{$incompat} )
540 my $incompatstring = $onepackage->{$incompat};
542 my $allincompat = installer::converter::convert_stringlist_into_array(\$incompatstring, ",");
544 for ( my $i = 0; $i <= $#{$allincompat}; $i++ )
546 my $oneincompat = ${$allincompat}[$i];
547 $oneincompat =~ s/\s*$//;
548 installer::packagelist::resolve_packagevariables(\$oneincompat, $variableshashref, 1);
549 $oneincompat = debian_rewrite($oneincompat);
550 $line = "%incompat" . " " . $oneincompat . "\n";
551 push(@epmheader, $line);
556 # including the directives for %requires and %provides
558 my $provides = "";
559 my $requires = "";
561 if ( $installer::globals::issolarispkgbuild )
563 $provides = "solarisprovides"; # the name in the packagelist
564 $requires = "solarisrequires"; # the name in the packagelist
566 elsif ( $installer::globals::isfreebsdpkgbuild )
568 $provides = "freebsdprovides"; # the name in the packagelist
569 $requires = "freebsdrequires"; # the name in the packagelist
571 else
573 $provides = "provides"; # the name in the packagelist
574 $requires = "requires"; # the name in the packagelist
577 my $isdict = 0;
578 if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; }
580 if ( $onepackage->{$provides} )
582 my $providesstring = $onepackage->{$provides};
584 my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ",");
586 for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
588 my $oneprovides = ${$allprovides}[$i];
589 $oneprovides =~ s/\s*$//;
590 installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1);
591 $oneprovides = debian_rewrite($oneprovides);
592 $line = "%provides" . " " . $oneprovides . "\n";
593 push(@epmheader, $line);
597 if ( $onepackage->{$requires} )
599 my $requiresstring = $onepackage->{$requires};
601 # The requires string can contain the separator "," in the names (descriptions) of the packages
602 # (that are required for Solaris depend files). Therefore "," inside such a description has to
603 # masked with a backslash.
604 # This masked separator need to be found and replaced, before the stringlist is converted into an array.
605 # This replacement has to be turned back after the array is created.
607 my $replacementstring = "COMMAREPLACEMENT";
608 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
610 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
612 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
614 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
616 my $onerequires = ${$allrequires}[$i];
617 $onerequires =~ s/\s*$//;
618 installer::packagelist::resolve_packagevariables2(\$onerequires, $variableshashref, 0, $isdict);
619 $onerequires = debian_rewrite($onerequires);
620 $line = "%requires" . " " . $onerequires . "\n";
621 push(@epmheader, $line);
625 return \@epmheader;
628 #######################################
629 # Adding header to epm file
630 #######################################
632 sub adding_header_to_epm_file
634 my ($epmfileref, $epmheaderref) = @_;
636 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
638 push( @{$epmfileref}, ${$epmheaderref}[$i] );
641 push( @{$epmfileref}, "\n\n" );
644 #####################################################
645 # Replace one in shell scripts ( ${VARIABLENAME} )
646 #####################################################
648 sub replace_variable_in_shellscripts
650 my ($scriptref, $variable, $searchstring) = @_;
652 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
654 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
658 ################################################
659 # Replacing many variables in shell scripts
660 ################################################
662 sub replace_many_variables_in_shellscripts
664 my ($scriptref, $variableshashref) = @_;
666 my $key;
668 foreach $key (keys %{$variableshashref})
670 my $value = $variableshashref->{$key};
671 replace_variable_in_shellscripts($scriptref, $value, $key);
675 #######################################
676 # Adding shell scripts to epm file
677 #######################################
679 sub adding_shellscripts_to_epm_file
681 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
683 push( @{$epmfileref}, "\n\n" );
685 my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename);
687 replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath");
689 replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref);
691 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
693 push( @{$epmfileref}, ${$shellscriptsfileref}[$i] );
696 push( @{$epmfileref}, "\n" );
699 #################################################
700 # Determining the epm on the system
701 #################################################
703 sub find_epm_on_system
705 my ($includepatharrayref) = @_;
707 installer::logger::include_header_into_logfile("Check epm on system");
709 my $epmname = "epm";
711 # epm should be defined through the configure script but we need to
712 # check for it to be defined because of the Sun environment.
713 # Check the environment variable first and if it is not defined,
714 # or if it is but the location is not executable, search further.
715 # It has to be found in the solver or it has to be in the path
716 # (saved in $installer::globals::epm_in_path) or we get the specified
717 # one through the environment (i.e. when --with-epm=... is specified)
719 if ($ENV{'EPM'})
721 if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}"))
723 $epmname = $ENV{'EPM'};
725 else
727 installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
730 else
732 my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0);
734 if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
735 if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; }
736 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
739 my $infoline = "Using epmfile: $epmname\n";
740 push( @installer::globals::logfileinfo, $infoline);
742 return $epmname;
745 #################################################
746 # Determining the epm patch state
747 # saved in $installer::globals::is_special_epm
748 #################################################
750 sub set_patch_state
752 my ($epmexecutable) = @_;
754 my $infoline = "";
756 my $systemcall = "$epmexecutable |";
757 open (EPMPATCH, "$systemcall");
759 while (<EPMPATCH>)
761 chop;
762 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals::is_special_epm = 1; }
765 close (EPMPATCH);
767 if ( $installer::globals::is_special_epm )
769 $infoline = "\nPatch state: This is a patched version of epm!\n\n";
770 push( @installer::globals::logfileinfo, $infoline);
772 else
774 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
775 push( @installer::globals::logfileinfo, $infoline);
778 if ( ( $installer::globals::is_special_epm ) && (($installer::globals::isrpmbuild) || ($installer::globals::issolarispkgbuild)) )
780 # Special postprocess handling only for Linux RPM and Solaris packages
781 $installer::globals::postprocess_specialepm = 1;
782 $installer::globals::postprocess_standardepm = 0;
784 else
786 $installer::globals::postprocess_specialepm = 0;
787 $installer::globals::postprocess_standardepm = 1;
791 #################################################
792 # LD_PRELOAD string for Debian packages
793 #################################################
795 sub get_ld_preload_string
797 my $getuidlibrary = $ENV{'WORKDIR'} . '/LinkTarget/Library/libgetuid.so';
798 if ( ! -e $getuidlibrary ) { installer::exiter::exit_program("File $getuidlibrary does not exist!", "get_ld_preload_string"); }
799 return 'LD_PRELOAD=' . $getuidlibrary;
802 #################################################
803 # Calling epm to create the installation sets
804 #################################################
806 sub call_epm
808 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
810 installer::logger::include_header_into_logfile("epm call for $packagename");
812 my $packageformat = $installer::globals::packageformat;
814 my $localpackagename = $packagename;
815 # Debian allows only lowercase letters in package name
816 if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); }
818 my $outdirstring = "";
819 if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
821 # Debian package build needs a LD_PRELOAD for correct rights
823 my $ldpreloadstring = "";
825 if ( $installer::globals::debian ) { $ldpreloadstring = get_ld_preload_string($includepatharrayref) . " "; }
827 my $extraflags = "";
828 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
830 $extraflags .= ' -g' unless $installer::globals::strip;
832 my $verboseflag = "-v";
833 if ( ! $installer::globals::quiet ) { $verboseflag = "-v2"; };
835 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " " . $verboseflag . " " . " 2\>\&1 |";
837 installer::logger::print_message( "... $systemcall ...\n" );
839 my $maxepmcalls = 3;
841 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
843 my @epmoutput = ();
845 open (EPM, "$systemcall");
846 while (<EPM>) {push(@epmoutput, $_); }
847 close (EPM);
849 my $returnvalue = $?; # $? contains the return value of the systemcall
851 my $infoline = "Systemcall (Try $i): $systemcall\n";
852 push( @installer::globals::logfileinfo, $infoline);
854 for ( my $j = 0; $j <= $#epmoutput; $j++ )
856 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
857 push( @installer::globals::logfileinfo, "$epmoutput[$j]");
860 if ($returnvalue)
862 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
863 push( @installer::globals::logfileinfo, $infoline);
864 if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); }
866 else
868 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
869 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
870 push( @installer::globals::logfileinfo, $infoline);
871 last;
876 #####################################################################
877 # Adding the new line for relocatables into pkginfo file (Solaris)
878 # or spec file (Linux) created by epm
879 #####################################################################
881 sub add_one_line_into_file
883 my ($file, $insertline, $filename) = @_;
885 if ( $installer::globals::issolarispkgbuild )
887 push(@{$file}, $insertline); # simply adding at the end of pkginfo file
890 if ( $installer::globals::isrpmbuild )
892 # Adding behind the line beginning with: Group:
894 my $inserted_line = 0;
896 for ( my $i = 0; $i <= $#{$file}; $i++ )
898 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
900 splice(@{$file},$i+1,0,$insertline);
901 $inserted_line = 1;
902 last;
906 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
909 $insertline =~ s/\s*$//; # removing line end for correct logging
910 my $infoline = "Success: Added line $insertline into file $filename!\n";
911 push( @installer::globals::logfileinfo, $infoline);
914 #####################################################################
915 # Setting the revision VERSION=1.9,REV=66 .
916 # Also adding the new line: "AutoReqProv: no"
917 #####################################################################
919 sub set_revision_in_pkginfo
921 my ($file, $filename, $variables, $packagename) = @_;
923 my $revisionstring = "\,REV\=" . $installer::globals::packagerevision;
925 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
927 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
929 $mday = $mday;
930 $mon = $mon + 1;
931 $year = $year + 1900;
933 if ( $mday < 10 ) { $mday = "0" . $mday; }
934 if ( $mon < 10 ) { $mon = "0" . $mon; }
935 $datestring = $year . "." . $mon . "." . $mday;
936 $revisionstring = $revisionstring . "." . $datestring;
938 for ( my $i = 0; $i <= $#{$file}; $i++ )
940 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
942 my $oldstring = $1;
943 my $newstring = $oldstring . $revisionstring; # also adding the date string
944 ${$file}[$i] =~ s/$oldstring/$newstring/;
945 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
946 push( @installer::globals::logfileinfo, $infoline);
947 last;
951 # For Update and Patch reasons, this string can also be kept constant
953 my $pkgversion = "SOLSPARCPKGVERSION";
954 if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; }
956 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
958 if ( $variables->{$pkgversion} ne "FINALVERSION" )
960 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
961 # 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
962 # and therefore be set as $pkgversion.
963 # The first part "3.0.0" has to be derived from the
965 my $version = $installer::globals::packageversion;
966 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
968 my $major = $1;
969 my $minor = $2;
970 my $micro = $3;
972 my $finalmajor = $major;
973 my $finalminor = $minor;
974 my $finalmicro = 0;
976 $version = "$finalmajor.$finalminor.$finalmicro";
979 my $datestring = $variables->{$pkgversion};
981 # Allowing some packages to have another date of creation.
982 # They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename"
984 my $additionalkey = $pkgversion . "_" . $packagename;
985 if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; }
987 my $versionstring = "$version,$datestring";
989 for ( my $i = 0; $i <= $#{$file}; $i++ )
991 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
993 my $start = $1;
994 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
995 my $oldstring = ${$file}[$i];
996 ${$file}[$i] = $newstring;
997 $oldstring =~ s/\s*$//;
998 $newstring =~ s/\s*$//;
999 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1000 push( @installer::globals::logfileinfo, $infoline);
1001 last;
1008 ########################################################
1009 # Setting MAXINST=1000 into the pkginfo file.
1010 ########################################################
1012 sub set_maxinst_in_pkginfo
1014 my ($changefile, $filename) = @_;
1016 my $newline = "MAXINST\=1000\n";
1018 add_one_line_into_file($changefile, $newline, $filename);
1021 #############################################################
1022 # Setting several Solaris variables into the pkginfo file.
1023 #############################################################
1025 sub set_solaris_parameter_in_pkginfo
1027 my ($changefile, $filename, $allvariables) = @_;
1029 my $newline = "";
1031 # SUNW_PRODNAME
1032 # SUNW_PRODVERS
1033 # SUNW_PKGVERS
1034 # Not: SUNW_PKGTYPE
1035 # HOTLINE
1036 # EMAIL
1038 my $productname = $allvariables->{'PRODUCTNAME'};
1039 $newline = "SUNW_PRODNAME=$productname\n";
1040 add_one_line_into_file($changefile, $newline, $filename);
1042 my $productversion = "";
1043 if ( $allvariables->{'PRODUCTVERSION'} )
1045 $productversion = $allvariables->{'PRODUCTVERSION'};
1046 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1048 $newline = "SUNW_PRODVERS=$productversion\n";
1049 add_one_line_into_file($changefile, $newline, $filename);
1051 $newline = "SUNW_PKGVERS=1\.0\n";
1052 add_one_line_into_file($changefile, $newline, $filename);
1054 if ( $allvariables->{'SUNW_PKGTYPE'} )
1056 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1057 add_one_line_into_file($changefile, $newline, $filename);
1059 else
1061 $newline = "SUNW_PKGTYPE=\n";
1062 add_one_line_into_file($changefile, $newline, $filename);
1065 $newline = "HOTLINE=Please contact your local service provider\n";
1066 add_one_line_into_file($changefile, $newline, $filename);
1068 $newline = "EMAIL=\n";
1069 add_one_line_into_file($changefile, $newline, $filename);
1073 #####################################################################
1074 # epm uses as archtecture for Solaris x86 "i86pc". This has to be
1075 # changed to "i386".
1076 #####################################################################
1078 sub fix_architecture_setting
1080 my ($changefile) = @_;
1082 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1084 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1086 ${$changefile}[$i] =~ s/i86pc/i386/;
1087 last;
1093 #####################################################################
1094 # Adding a new line for topdir into specfile, removing old
1095 # topdir if set.
1096 #####################################################################
1098 sub set_topdir_in_specfile
1100 my ($changefile, $filename, $newepmdir) = @_;
1102 $newepmdir = Cwd::cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed
1104 # removing "%define _topdir", if existing
1106 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1108 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1110 my $removeline = ${$changefile}[$i];
1111 $removeline =~ s/\s*$//;
1112 splice(@{$changefile},$i,1);
1113 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1114 push( @installer::globals::logfileinfo, $infoline);
1115 last;
1119 # Adding "topdir" behind the line beginning with: Group:
1121 my $inserted_line = 0;
1123 my $topdirline = "\%define _topdir $newepmdir\n";
1125 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1127 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1129 splice(@{$changefile},$i+1,0,$topdirline);
1130 $inserted_line = 1;
1131 $topdirline =~ s/\s*$//;
1132 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1133 push( @installer::globals::logfileinfo, $infoline);
1137 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1141 #####################################################################
1142 # Setting the packager in the spec file
1143 # Syntax: Packager: abc@def
1144 #####################################################################
1146 sub set_packager_in_specfile
1148 my ($changefile) = @_;
1150 my $packager = $installer::globals::longmanufacturer;
1152 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1154 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1156 my $oldstring = $1;
1157 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1158 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1159 push( @installer::globals::logfileinfo, $infoline);
1160 last;
1165 #####################################################################
1166 # Setting the requirements in the spec file (i81494)
1167 # Syntax: PreReq: "requirements" (only for shared extensions)
1168 #####################################################################
1170 sub set_prereq_in_specfile
1172 my ($changefile) = @_;
1174 my $prereq = "PreReq:";
1176 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1178 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1180 my $oldstring = ${$changefile}[$i];
1181 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1182 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1183 push( @installer::globals::logfileinfo, $infoline);
1188 #####################################################################
1189 # Setting the Auto[Req]Prov line and __find_requires
1190 #####################################################################
1192 sub set_autoprovreq_in_specfile
1194 my ($changefile, $findrequires, $bindir) = @_;
1196 my $autoreqprovline;
1198 if ( $findrequires )
1200 $autoreqprovline = "AutoProv\: no\n%define _use_internal_dependency_generator 0\n%define __find_requires $bindir/$findrequires\n";
1202 else
1204 $autoreqprovline = "AutoReqProv\: no\n";
1207 $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n";
1209 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1211 # Adding "autoreqprov" behind the line beginning with: Group:
1212 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1214 splice(@{$changefile},$i+1,0,$autoreqprovline);
1215 $autoreqprovline =~ s/\s*$//;
1216 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1217 push( @installer::globals::logfileinfo, $infoline);
1219 last;
1224 #####################################################################
1225 # Replacing Copyright with License in the spec file
1226 # Syntax: License: LGPLv3 (or MPLv2 on ALv2, older usages were LGPL, SISSL)
1227 #####################################################################
1229 sub set_license_in_specfile
1231 my ($changefile, $variableshashref) = @_;
1233 my $license = $variableshashref->{'LICENSENAME'};
1235 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1237 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1239 ${$changefile}[$i] = "License: $license\n";
1240 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1241 push( @installer::globals::logfileinfo, $infoline);
1242 last;
1247 #########################################################
1248 # Building relocatable Solaris packages means:
1249 # 1. Add "BASEDIR=/opt" into pkginfo
1250 # 2. Remove "/opt/" from all objects in prototype file
1251 # For step2 this function exists
1252 # Sample: d none /opt/openofficeorg20/help 0755 root other
1253 # -> d none openofficeorg20/help 0755 root other
1254 #########################################################
1256 sub make_prototypefile_relocatable
1258 my ($prototypefile, $relocatablepath) = @_;
1260 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1262 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line
1264 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1268 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1269 # This line has to be removed now
1271 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash
1273 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1275 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1277 my $line = ${$prototypefile}[$i];
1278 splice(@{$prototypefile},$i,1); # removing the line
1279 $line =~ s/\s*$//;
1280 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1281 push( @installer::globals::logfileinfo, $infoline);
1282 last;
1286 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1288 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1290 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1292 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1293 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1294 push( @installer::globals::logfileinfo, $infoline2);
1299 #########################################################################
1300 # Replacing the variables in the shell scripts or in the epm list file
1301 # Linux: spec file
1302 # Solaris: preinstall, postinstall, preremove, postremove
1303 # If epm is used in the original version (not relocatable)
1304 # the variables have to be exchanged in the list file,
1305 # created for epm.
1306 #########################################################################
1308 sub replace_variables_in_shellscripts
1310 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1312 my $debug = 0;
1313 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1315 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1317 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1319 my $oldline = ${$scriptfile}[$i];
1320 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1321 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1322 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1323 push(@installer::globals::logfileinfo, $infoline);
1324 if ( $debug )
1326 $infoline = "Old Line: $oldline";
1327 push(@installer::globals::logfileinfo, $infoline);
1328 $infoline = "New Line: ${$scriptfile}[$i]";
1329 push(@installer::globals::logfileinfo, $infoline);
1335 ############################################################
1336 # Determinig the directory created by epm, in which the
1337 # RPMS or Solaris packages are created.
1338 ############################################################
1340 sub determine_installdir_ooo
1342 # A simple "ls" command returns the directory name
1344 my $dirname = "";
1346 my $systemcall = "ls |";
1347 open (LS, "$systemcall");
1348 $dirname = <LS>;
1349 close (LS);
1351 $dirname =~ s/\s*$//;
1353 my $infoline = "Info: Directory created by epm: $dirname\n";
1354 push(@installer::globals::logfileinfo, $infoline);
1356 return $dirname;
1359 ############################################################
1360 # Setting the tab content into the file container
1361 ############################################################
1363 sub set_tab_into_datafile
1365 my ($changefile, $filesref) = @_;
1367 my @newclasses = ();
1368 my $newclassesstring = "";
1370 if ( $installer::globals::issolarispkgbuild )
1372 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1374 my $onefile = ${$filesref}[$i];
1376 if ( $onefile->{'SolarisClass'} )
1378 my $sourcepath = $onefile->{'sourcepath'};
1380 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1382 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1384 my $oldline = ${$changefile}[$j];
1385 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1386 my $newline = ${$changefile}[$j];
1387 $oldline =~ s/\s*$//;
1388 $newline =~ s/\s*$//;
1390 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1391 push(@installer::globals::logfileinfo, $infoline);
1393 # collecting all new classes
1394 if (! grep {$_ eq $onefile->{'SolarisClass'}} @newclasses)
1396 push(@newclasses, $onefile->{'SolarisClass'});
1399 last;
1405 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1408 if ( $installer::globals::isrpmbuild )
1410 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1412 my $onefile = ${$filesref}[$i];
1414 if ( $onefile->{'SpecFileContent'} )
1416 my $destination = $onefile->{'destination'};
1418 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1420 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1422 my $begin = $1;
1423 my $end = $2;
1425 my $oldline = ${$changefile}[$j];
1426 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1427 my $newline = ${$changefile}[$j];
1429 $oldline =~ s/\s*$//;
1430 $newline =~ s/\s*$//;
1432 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1433 push(@installer::globals::logfileinfo, $infoline);
1435 last;
1442 return $newclassesstring;
1445 ############################################################
1446 # Including additional classes into the pkginfo file
1447 ############################################################
1449 sub include_classes_into_pkginfo
1451 my ($changefile, $classesstring) = @_;
1453 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1455 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1457 ${$changefile}[$i] =~ s/\s*$//;
1458 my $oldline = ${$changefile}[$i];
1459 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1460 my $newline = ${$changefile}[$i];
1461 $newline =~ s/\s*$//;
1463 my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n";
1464 push(@installer::globals::logfileinfo, $infoline);
1469 ##########################################################################################
1470 # Checking, if an extension is included into the package (Linux).
1471 # All extension files have to be installed into directory
1472 # share/extension/install
1473 # %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt"
1474 ##########################################################################################
1476 sub is_extension_package
1478 my ($specfile) = @_;
1480 my $is_extension_package = 0;
1482 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1484 my $line = ${$specfile}[$i];
1485 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1487 $is_extension_package = 1;
1488 last;
1492 return $is_extension_package;
1495 ######################################################################
1496 # Checking, if an extension is included into the package (Solaris).
1497 # All extension files have to be installed into directory
1498 # share/extension/install
1499 ######################################################################
1501 sub contains_extension_dir
1503 my ($prototypefile) = @_;
1505 my $contains_extension_dir = 0;
1507 # d none opt/openoffice.org3/share/extensions/
1509 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1511 my $line = ${$prototypefile}[$i];
1512 if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// )
1514 $contains_extension_dir = 1;
1515 last;
1519 return $contains_extension_dir;
1522 ############################################################
1523 # Setting the correct Solaris locales
1524 ############################################################
1526 sub get_solaris_language_for_langpack
1528 my ( $onelanguage ) = @_;
1530 my $sollanguage = $onelanguage;
1531 $sollanguage =~ s/\-/\_/;
1533 if ( $sollanguage eq "de" ) { $sollanguage = "de"; }
1534 elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; }
1535 elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; }
1536 elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; }
1537 elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; }
1538 elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; }
1539 elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; }
1540 elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; }
1541 elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; }
1542 elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; }
1543 elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; }
1544 elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; }
1545 elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; }
1546 elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; }
1547 elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; }
1548 elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; }
1550 return $sollanguage;
1553 ############################################################
1554 # Adding language infos in pkginfo file
1555 ############################################################
1557 sub include_languageinfos_into_pkginfo
1559 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1561 # SUNWPKG_LIST=core01
1562 # SUNW_LOC=de
1564 my $locallang = $onepackage->{'language'};
1565 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1567 my $newline = "SUNW_LOC=" . $solarislanguage . "\n";
1568 add_one_line_into_file($changefile, $newline, $filename);
1570 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1571 if ( $onepackage->{'pkg_list_entry'} )
1573 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1574 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1575 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1576 add_one_line_into_file($changefile, $newline, $filename);
1578 else
1580 # Using default package ooobasis30-core01.
1581 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01";
1582 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1583 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1584 add_one_line_into_file($changefile, $newline, $filename);
1588 ############################################################
1589 # Including package names into the depend files.
1590 # The package names have to be included into
1591 # packagelist. They are already saved in
1592 # %installer::globals::dependfilenames.
1593 ############################################################
1595 sub put_packagenames_into_dependfile
1597 my ( $file ) = @_;
1599 for ( my $i = 0; $i <= $#{$file}; $i++ )
1601 my $line = ${$file}[$i];
1602 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
1604 my $abbreviation = $1;
1606 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); }
1608 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
1610 my $packagename = $installer::globals::dependfilenames{$abbreviation};
1611 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); }
1613 $line =~ s/\s*$//;
1614 ${$file}[$i] = $line . "\t" . $packagename . "\n";
1616 else
1618 installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile");
1624 ############################################################
1625 # Including the relocatable directory into
1626 # spec file and pkginfo file
1627 # Linux: set topdir in specfile
1628 # Solaris: remove $relocatablepath (/opt/)
1629 # for all objects in prototype file
1630 # and changing "topdir" for Linux
1631 ############################################################
1633 sub prepare_packages
1635 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
1637 my $filename = "";
1638 my $newline = "";
1639 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
1641 my $localrelocatablepath = $relocatablepath;
1642 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; }
1644 if ( $installer::globals::issolarispkgbuild )
1646 $filename = $packagename . ".pkginfo";
1647 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
1650 if ( $installer::globals::isrpmbuild )
1652 $filename = $packagename . ".spec";
1653 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
1656 my $completefilename = $newepmdir . $filename;
1658 if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); }
1659 my $changefile = installer::files::read_file($completefilename);
1660 if ( $newline ne "" )
1662 add_one_line_into_file($changefile, $newline, $filename);
1663 installer::files::save_file($completefilename, $changefile);
1666 # adding new "topdir" and removing old "topdir" in specfile
1668 if ( $installer::globals::isrpmbuild )
1670 set_topdir_in_specfile($changefile, $filename, $newepmdir);
1671 set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::workpath" . "/bin");
1672 set_packager_in_specfile($changefile);
1673 if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); }
1674 set_license_in_specfile($changefile, $variableshashref);
1675 set_tab_into_datafile($changefile, $filesref);
1676 installer::files::save_file($completefilename, $changefile);
1679 # removing the relocatable path in prototype file
1681 if ( $installer::globals::issolarispkgbuild )
1683 set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename);
1684 set_maxinst_in_pkginfo($changefile, $filename);
1685 set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref);
1686 if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); }
1687 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
1688 installer::files::save_file($completefilename, $changefile);
1690 my $prototypefilename = $packagename . ".prototype";
1691 $prototypefilename = $newepmdir . $prototypefilename;
1692 if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
1694 my $prototypefile = installer::files::read_file($prototypefilename);
1695 make_prototypefile_relocatable($prototypefile, $relocatablepath);
1696 my $classesstring = set_tab_into_datafile($prototypefile, $filesref);
1697 if ($classesstring)
1699 include_classes_into_pkginfo($changefile, $classesstring);
1700 installer::files::save_file($completefilename, $changefile);
1703 installer::files::save_file($prototypefilename, $prototypefile);
1705 # Adding package names into depend files for Solaris (not supported by epm)
1706 my $dependfilename = $packagename . ".depend";
1707 $dependfilename = $newepmdir . $dependfilename;
1708 if ( -f $dependfilename)
1710 my $dependfile = installer::files::read_file($dependfilename);
1711 put_packagenames_into_dependfile($dependfile);
1712 installer::files::save_file($dependfilename, $dependfile);
1716 return $newepmdir;
1719 ###############################################################################
1720 # Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
1721 # epm list file.
1722 # The complete rootpath is stored in $installer::globals::rootpath
1723 # or for each package in $onepackage->{'destpath'}
1724 # The static rootpath is stored in $staticpath
1725 # The relocatable path is stored in $relocatablepath
1726 # PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
1727 # PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
1728 # In standard epm process:
1729 # No usage of package specific variables like $BASEDIR, because
1730 # 1. These variables would be replaced in epm process
1731 # 2. epm version 3.7 does not support relocatable packages
1732 ###############################################################################
1734 sub resolve_path_in_epm_list_before_packaging
1736 my ($listfile, $listfilename, $variable, $path) = @_;
1738 installer::logger::include_header_into_logfile("Replacing variables in epm list file:");
1740 $path =~ s/\/\s*$//;
1741 replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path);
1745 #################################################################
1746 # Determining the rpm version. Beginning with rpm version 4.0
1747 # the tool to create RPMs is "rpmbuild" and no longer "rpm"
1748 #################################################################
1750 sub determine_rpm_version
1752 my $rpmversion = 0;
1753 my $rpmout = "";
1754 my $systemcall = "";
1756 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
1757 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
1758 # is saved in $installer::globals::rpm
1760 if ( $installer::globals::rpm ne "" )
1762 $systemcall = "$installer::globals::rpm --version |";
1764 else
1766 $systemcall = "rpm --version |";
1769 open (RPM, "$systemcall");
1770 $rpmout = <RPM>;
1771 close (RPM);
1773 if ( $rpmout ne "" )
1775 $rpmout =~ s/\s*$//g;
1777 my $infoline = "Systemcall: $systemcall\n";
1778 push( @installer::globals::logfileinfo, $infoline);
1780 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
1781 else { $infoline = "Success: rpm version: $rpmout\n"; }
1783 push( @installer::globals::logfileinfo, $infoline);
1785 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
1786 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
1787 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
1788 else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
1791 return $rpmversion;
1794 ####################################################
1795 # Writing some info about rpm into the log file
1796 ####################################################
1798 sub log_rpm_info
1800 my $systemcall = "";
1801 my $infoline = "";
1803 $infoline = "\nLogging rpmrc content using --showrc\n\n";
1804 push( @installer::globals::logfileinfo, $infoline);
1806 if ( $installer::globals::rpm ne "" )
1808 $systemcall = "$installer::globals::rpm --showrc |";
1810 else
1812 $systemcall = "rpm --showrc |";
1815 my @fullrpmout = ();
1817 open (RPM, "$systemcall");
1818 while (<RPM>) {push(@fullrpmout, $_); }
1819 close (RPM);
1821 if ( $#fullrpmout > -1 )
1823 for ( my $i = 0; $i <= $#fullrpmout; $i++ )
1825 my $rpmout = $fullrpmout[$i];
1826 $rpmout =~ s/\s*$//g;
1828 $infoline = "$rpmout\n";
1829 $infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems
1830 push( @installer::globals::logfileinfo, $infoline);
1833 else
1835 $infoline = "Problem in systemcall: $systemcall : No return value\n";
1836 push( @installer::globals::logfileinfo, $infoline);
1839 $infoline = "End of logging rpmrc\n\n";
1840 push( @installer::globals::logfileinfo, $infoline);
1843 #################################################
1844 # Systemcall to start the packaging process
1845 #################################################
1847 sub create_packages_without_epm
1849 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
1851 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
1852 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
1853 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
1855 if ( $installer::globals::issolarispkgbuild )
1857 my $prototypefile = $epmdir . $packagename . ".prototype";
1858 if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
1860 my $destinationdir = $prototypefile;
1861 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir);
1862 $destinationdir =~ s/\/\s*$//; # removing ending slashes
1864 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
1865 installer::logger::print_message( "... $systemcall ...\n" );
1867 my $maxpkgmkcalls = 3;
1869 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
1871 my @pkgmkoutput = ();
1873 open (PKGMK, "$systemcall");
1874 while (<PKGMK>) {push(@pkgmkoutput, $_); }
1875 close (PKGMK);
1877 my $returnvalue = $?; # $? contains the return value of the systemcall
1879 my $infoline = "Systemcall (Try $i): $systemcall\n";
1880 push( @installer::globals::logfileinfo, $infoline);
1882 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
1884 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
1885 push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]");
1888 if ($returnvalue)
1890 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
1891 push( @installer::globals::logfileinfo, $infoline);
1892 if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
1894 else
1896 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
1897 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1898 push( @installer::globals::logfileinfo, $infoline);
1899 last;
1903 # It might be necessary to save uncompressed Solaris packages
1905 # compressing packages
1907 if ( ! $installer::globals::solarisdontcompress )
1909 my $faspac = "faspac-so.sh";
1911 my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0);
1912 if ($$compressorref ne "")
1914 # Saving original pkginfo, to set time stamp later
1915 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
1916 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
1917 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
1918 installer::systemactions::make_systemcall($systemcall);
1920 $faspac = $$compressorref;
1921 $infoline = "Found compressor: $faspac\n";
1922 push( @installer::globals::logfileinfo, $infoline);
1924 installer::logger::print_message( "... $faspac ...\n" );
1925 installer::logger::include_timestamp_into_logfile("Starting $faspac");
1927 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
1928 installer::systemactions::make_systemcall($systemcall);
1930 # Setting time stamp for pkginfo, because faspac-so.sh
1931 # changed the pkginfo file, updated the size and
1932 # checksum, but not the time stamp.
1933 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
1934 installer::systemactions::make_systemcall($systemcall);
1935 if ( -f $pkginfotmp ) { unlink($pkginfotmp); }
1937 installer::logger::include_timestamp_into_logfile("End of $faspac");
1939 else
1941 $infoline = "Not found: $faspac\n";
1942 push( @installer::globals::logfileinfo, $infoline);
1946 # Setting unix rights to "775" for all created directories inside the package
1948 $systemcall = "cd $destinationdir; find $packagename -type d | xargs -i chmod 775 \{\} \;";
1949 installer::logger::print_message( "... $systemcall ...\n" );
1951 $returnvalue = system($systemcall);
1953 $infoline = "Systemcall: $systemcall\n";
1954 push( @installer::globals::logfileinfo, $infoline);
1956 if ($returnvalue)
1958 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
1959 push( @installer::globals::logfileinfo, $infoline);
1961 else
1963 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1964 push( @installer::globals::logfileinfo, $infoline);
1968 ######################
1969 # making pkg files
1970 ######################
1972 # my $streamname = $packagename . ".pkg";
1973 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
1974 # print "... $systemcall ...\n";
1976 # $returnvalue = system($systemcall);
1978 # $infoline = "Systemcall: $systemcall\n";
1979 # push( @installer::globals::logfileinfo, $infoline);
1981 # if ($returnvalue)
1983 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
1984 # push( @installer::globals::logfileinfo, $infoline);
1986 # else
1988 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1989 # push( @installer::globals::logfileinfo, $infoline);
1992 #########################
1993 # making tar.gz files
1994 #########################
1996 # my $targzname = $packagename . ".tar.gz";
1997 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
1998 # print "... $systemcall ...\n";
2000 # $returnvalue = system($systemcall);
2002 # $infoline = "Systemcall: $systemcall\n";
2003 # push( @installer::globals::logfileinfo, $infoline);
2005 # if ($returnvalue)
2007 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2008 # push( @installer::globals::logfileinfo, $infoline);
2010 # else
2012 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2013 # push( @installer::globals::logfileinfo, $infoline);
2018 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2020 if ( $installer::globals::isrpmbuild )
2022 my $specfilename = $epmdir . $packagename . ".spec";
2023 if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2025 my $rpmcommand = $installer::globals::rpm;
2026 my $rpmversion = determine_rpm_version();
2028 my $target = "";
2029 if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; }
2030 elsif ( $installer::globals::compiler =~ /unxaigppc/) { $target = "ppc"; }
2031 elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; }
2033 # rpm 4.6 ignores buildroot tag in spec file
2035 my $buildrootstring = "";
2037 if ( $rpmversion >= 4 )
2039 my $dir = Cwd::getcwd;
2040 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2041 $buildrootstring = "--buildroot=$buildroot";
2042 mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/");
2045 if ( ! $installer::globals::rpminfologged )
2047 log_rpm_info();
2048 $installer::globals::rpminfologged = 1;
2051 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2053 installer::logger::print_message( "... $systemcall ...\n" );
2055 my $maxrpmcalls = 3;
2056 my $rpm_failed = 0;
2058 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2060 my @rpmoutput = ();
2062 open (RPM, "$systemcall");
2063 while (<RPM>) {push(@rpmoutput, $_); }
2064 close (RPM);
2066 my $returnvalue = $?; # $? contains the return value of the systemcall
2068 my $infoline = "Systemcall (Try $i): $systemcall\n";
2069 push( @installer::globals::logfileinfo, $infoline);
2071 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2073 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2074 push( @installer::globals::logfileinfo, "$rpmoutput[$j]");
2077 if ($returnvalue)
2079 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2080 push( @installer::globals::logfileinfo, $infoline);
2081 $rpm_failed = 1;
2083 else
2085 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2086 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2087 push( @installer::globals::logfileinfo, $infoline);
2088 $rpm_failed = 0;
2089 last;
2093 if ( $rpm_failed )
2095 # Because of the problems with LD_LIBRARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2096 my $rpmprog = "";
2097 if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2098 elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2100 if ( $rpmprog ne "" )
2102 installer::logger::print_message( "... $rpmprog ...\n" );
2104 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2106 my @helperrpmoutput = ();
2108 open (RPM, "$helpersystemcall");
2109 while (<RPM>) {push(@helperrpmoutput, $_); }
2110 close (RPM);
2112 my $helperreturnvalue = $?; # $? contains the return value of the systemcall
2114 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBRARY_PATH)\n";
2115 push( @installer::globals::logfileinfo, $infoline);
2117 $infoline = "\nSystemcall: $helpersystemcall\n";
2118 push( @installer::globals::logfileinfo, $infoline);
2120 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); }
2122 if ($helperreturnvalue)
2124 $infoline = "Could not execute \"$helpersystemcall\"!\n";
2125 push( @installer::globals::logfileinfo, $infoline);
2127 else
2129 installer::logger::print_message( "Success: \"$helpersystemcall\"\n" );
2130 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2131 push( @installer::globals::logfileinfo, $infoline);
2132 $rpm_failed = 0;
2136 # Now it is really time to exit this packaging process, if the error still occurs
2137 if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2142 #################################################
2143 # Removing all temporary files created by epm
2144 #################################################
2146 sub remove_temporary_epm_files
2148 my ($epmdir, $loggingdir, $packagename) = @_;
2150 # saving the files into the loggingdir
2152 if ( $installer::globals::issolarispkgbuild )
2154 my @extensions = ();
2155 push(@extensions, ".pkginfo");
2156 push(@extensions, ".prototype");
2157 push(@extensions, ".postinstall");
2158 push(@extensions, ".postremove");
2159 push(@extensions, ".preinstall");
2160 push(@extensions, ".preremove");
2161 push(@extensions, ".depend");
2163 for ( my $i = 0; $i <= $#extensions; $i++ )
2165 my $removefile = $epmdir . $packagename . $extensions[$i];
2166 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2168 if (! -f $removefile) { next; }
2170 my $systemcall = "mv -f $removefile $destfile";
2171 system($systemcall); # ignoring the return value
2172 $infoline = "Systemcall: $systemcall\n";
2173 push( @installer::globals::logfileinfo, $infoline);
2177 if ( $installer::globals::isrpmbuild )
2179 my $removefile = $epmdir . $packagename . ".spec";
2180 my $destfile = $loggingdir . $packagename . ".spec.log";
2182 my $systemcall = "mv -f $removefile $destfile";
2183 system($systemcall); # ignoring the return value
2184 $infoline = "Systemcall: $systemcall\n";
2185 push( @installer::globals::logfileinfo, $infoline);
2187 # removing the directory "buildroot"
2189 my $removedir = $epmdir . "buildroot";
2191 $systemcall = "rm -rf $removedir";
2193 installer::logger::print_message( "... $systemcall ...\n" );
2195 my $returnvalue = system($systemcall);
2197 $removedir = $epmdir . "BUILD";
2199 $systemcall = "rm -rf $removedir";
2201 installer::logger::print_message( "... $systemcall ...\n" );
2203 $returnvalue = system($systemcall);
2206 my $infoline = "Systemcall: $systemcall\n";
2207 push( @installer::globals::logfileinfo, $infoline);
2209 if ($returnvalue)
2211 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2212 push( @installer::globals::logfileinfo, $infoline);
2214 else
2216 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2217 push( @installer::globals::logfileinfo, $infoline);
2222 ###########################################################
2223 # Creating a better directory structure in the solver.
2224 ###########################################################
2226 sub create_new_directory_structure
2228 my ($newepmdir) = @_;
2230 my $newdir = $installer::globals::epmoutpath;
2232 if ( $installer::globals::isrpmbuild )
2234 my $rpmdir;
2235 my $machine = "";
2236 if ( $installer::globals::compiler =~ /unxlngi/) {
2237 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2239 elsif ( $installer::globals::compiler =~ /unxaigppc/) {
2240 $machine = "ppc";
2241 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2243 elsif ( $installer::globals::compiler =~ /unxlng/) {
2244 $machine = (POSIX::uname())[4];
2245 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2247 else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2249 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2251 my $returnvalue = system($systemcall);
2253 my $infoline = "Systemcall: $systemcall\n";
2254 push( @installer::globals::logfileinfo, $infoline);
2256 if ($returnvalue)
2258 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2259 push( @installer::globals::logfileinfo, $infoline);
2261 else
2263 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2264 push( @installer::globals::logfileinfo, $infoline);
2267 # and removing the empty directory
2269 if ( $machine ne "" )
2271 rmdir "$installer::globals::epmoutpath/RPMS/$machine";
2273 rmdir "$installer::globals::epmoutpath/RPMS/powerpc";
2274 rmdir "$installer::globals::epmoutpath/RPMS/x86_64";
2275 rmdir "$installer::globals::epmoutpath/RPMS/i586";
2276 rmdir "$installer::globals::epmoutpath/RPMS/i386";
2277 rmdir "$installer::globals::epmoutpath/RPMS"
2278 or warn "Could not remove RPMS dir: $!";
2281 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2282 chmod 0775, $newdir;
2285 ######################################################
2286 # Collect modules with product specific styles.
2287 ######################################################
2289 sub collect_modules_with_style
2291 my ($style, $modulesarrayref) = @_;
2293 my @allmodules = ();
2295 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2297 my $onemodule = ${$modulesarrayref}[$i];
2298 my $styles = "";
2299 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2300 if ( $styles =~ /\b\Q$style\E\b/ )
2302 push(@allmodules, $onemodule);
2306 return \@allmodules;
2309 ######################################################
2310 # Remove modules without packagecontent.
2311 ######################################################
2313 sub remove_modules_without_package
2315 my ($allmodules) = @_;
2317 my @allmodules = ();
2319 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2321 my $onemodule = ${$allmodules}[$i];
2322 my $packagename = "";
2323 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2324 if ( $packagename ne "" )
2326 push(@allmodules, $onemodule);
2330 return \@allmodules;
2333 ######################################################
2334 # Copying files for system integration.
2335 ######################################################
2337 sub copy_and_unpack_tar_gz_files
2339 my ($sourcefile, $destdir) = @_;
2341 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2342 installer::systemactions::make_systemcall($systemcall);
2345 ######################################################
2346 # Checking whether the new content is a directory and
2347 # not a package. If it is a directory, the complete
2348 # content of the directory has to be added to the
2349 # array newcontent.
2350 ######################################################
2352 sub control_subdirectories
2354 my ($content, $subdir) = @_;
2356 my @newcontent = ();
2358 for ( my $i = 0; $i <= $#{$content}; $i++ )
2360 if ( -d ${$content}[$i] )
2362 $subdir = ${$content}[$i];
2363 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir);
2364 my $allpackages = installer::systemactions::read_directory(${$content}[$i]);
2365 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
2367 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
2368 if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
2369 push(@newcontent, ${$allpackages}[$j]);
2372 else
2374 push(@newcontent, ${$content}[$i]);
2378 return (\@newcontent, $subdir);
2381 ######################################################
2382 # Including the system integration files into the
2383 # installation sets.
2384 ######################################################
2386 sub put_systemintegration_into_installset
2388 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
2390 my $destdir = $newdir;
2392 # adding System integration files
2394 my $sourcefile = "";
2396 # Finding the modules defined in scp (with flag SYSTEMMODULE)
2397 # Getting name of package from scp-Module
2398 # Search package in list off all include files
2399 # Copy file into installation set and unpack it (always tar.gz)
2400 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
2402 # Collect all modules with flag "SYSTEMMODULE"
2403 my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref);
2404 $allmodules = remove_modules_without_package($allmodules);
2406 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2408 my $onemodule = ${$allmodules}[$i];
2409 my $packagetarfilename = $onemodule->{'PackageName'};
2411 my $infoline = "Including into installation set: $packagetarfilename\n";
2412 push( @installer::globals::logfileinfo, $infoline);
2414 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1);
2415 if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
2417 # Collecting all packages in directory "packages" or "RPMS"
2418 my $oldcontent = installer::systemactions::read_directory($destdir);
2420 copy_and_unpack_tar_gz_files($$sourcepathref, $destdir);
2422 # Finding new content -> that is the package name
2423 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2425 # special handling, if new content is a directory
2426 my $subdir = "";
2427 if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); }
2429 # Adding license content into Solaris packages
2430 if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { _add_license_into_systemintegrationpackages($destdir, $newcontent); }
2434 ######################################################
2435 # Analyzing the Unix installation path.
2436 # From the installation path /opt/openofficeorg20
2437 # is the part /opt relocatable and the part
2438 # openofficeorg20 static.
2439 ######################################################
2441 sub analyze_rootpath
2443 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
2445 $rootpath =~ s/\/\s*$//; # removing ending slash
2447 ##############################################################
2448 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
2449 ##############################################################
2451 $$relocatablepathref = "/";
2452 # Static path has to contain the office directory name. This is replaced in shellscripts.
2453 $$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname;
2454 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
2455 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
2456 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
2457 if ( $installer::globals::isrpmbuild )
2459 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
2460 $$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts
2463 if ( $installer::globals::isdebbuild )
2465 $$relocatablepathref = "";
2466 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
2471 ################################################
2472 # Defining the English license text to add
2473 # it into Solaris packages.
2474 ################################################
2476 sub _set_english_license
2478 my $additional_license_name = $installer::globals::englishsolarislicensename; # always the English file
2479 my $licensefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$additional_license_name, "" , 0);
2480 if ( $$licensefileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $additional_license_name!", "set_english_license"); }
2481 $installer::globals::englishlicenseset = 1;
2482 $installer::globals::englishlicense = installer::files::read_file($$licensefileref);
2483 installer::scpzipfiles::replace_all_ziplistvariables_in_file($installer::globals::englishlicense, $variableshashref);
2486 ################################################
2487 # Adding the content of the English license
2488 # file into the system integration packages.
2489 ################################################
2491 sub _add_license_into_systemintegrationpackages
2493 my ($destdir, $packages) = @_;
2495 for ( my $i = 0; $i <= $#{$packages}; $i++ )
2497 my $copyrightfilename = ${$packages}[$i] . $installer::globals::separator . "install" . $installer::globals::separator . "copyright";
2498 if ( ! -f $copyrightfilename ) { installer::exiter::exit_program("ERROR: Could not find license file in system integration package: $copyrightfilename!", "add_license_into_systemintegrationpackages"); }
2499 my $copyrightfile = installer::files::read_file($copyrightfilename);
2501 # Saving time stamp of old copyrightfile
2502 my $savcopyrightfilename = $copyrightfilename . ".sav";
2503 installer::systemactions::copy_one_file($copyrightfilename, $savcopyrightfilename);
2504 _set_time_stamp_for_file($copyrightfilename, $savcopyrightfilename); # now $savcopyrightfile has the time stamp of $copyrightfile
2506 # Adding license content to copyright file
2507 push(@{$copyrightfile}, "\n");
2508 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
2509 installer::files::save_file($copyrightfilename, $copyrightfile);
2511 # Setting the old time stamp saved with $savcopyrightfilename
2512 _set_time_stamp_for_file($savcopyrightfilename, $copyrightfilename); # now $copyrightfile has the time stamp of $savcopyrightfile
2513 unlink($savcopyrightfilename);
2515 # Changing content of copyright file in pkgmap
2516 my $pkgmapfilename = ${$packages}[$i] . $installer::globals::separator . "pkgmap";
2517 if ( ! -f $pkgmapfilename ) { installer::exiter::exit_program("ERROR: Could not find pkgmap in system integration package: $pkgmapfilename!", "add_license_into_systemintegrationpackages"); }
2518 my $pkgmap = installer::files::read_file($pkgmapfilename);
2519 _change_onefile_in_pkgmap($pkgmap, $copyrightfilename, "copyright");
2520 installer::files::save_file($pkgmapfilename, $pkgmap);
2524 ##############################################
2525 # Setting time stamp of copied files to avoid
2526 # errors from pkgchk.
2527 ##############################################
2529 sub _set_time_stamp_for_file
2531 my ($sourcefile, $destfile) = @_;
2533 my $systemcall = "touch -r $sourcefile $destfile";
2535 my $returnvalue = system($systemcall);
2537 my $infoline = "Systemcall: $systemcall\n";
2538 push( @installer::globals::logfileinfo, $infoline);
2540 if ($returnvalue)
2542 $infoline = "ERROR: \"$systemcall\" failed!\n";
2543 push( @installer::globals::logfileinfo, $infoline);
2545 else
2547 $infoline = "Success: \"$systemcall\" !\n";
2548 push( @installer::globals::logfileinfo, $infoline);
2552 ##############################################
2553 # Setting checksum and wordcount for changed
2554 # pkginfo file into pkgmap.
2555 ##############################################
2557 sub _change_onefile_in_pkgmap
2559 my ($pkgmapfile, $fullfilename, $shortfilename) = @_;
2561 # 1 i pkginfo 442 34577 1166716297
2562 # ->
2563 # 1 i pkginfo 443 34737 1166716297
2565 # wc -c pkginfo | cut -f6 -d' ' -> 442 (variable)
2566 # sum pkginfo | cut -f1 -d' ' -> 34577 (variable)
2567 # grep 'pkginfo' pkgmap | cut -f6 -d' ' -> 1166716297 (fix)
2569 my $checksum = _call_sum($fullfilename);
2570 if ( $checksum =~ /^\s*(\d+)\s+.*$/ ) { $checksum = $1; }
2572 my $wordcount = _call_wc($fullfilename);
2573 if ( $wordcount =~ /^\s*(\d+)\s+.*$/ ) { $wordcount = $1; }
2575 for ( my $i = 0; $i <= $#{$pkgmapfile}; $i++ )
2577 if ( ${$pkgmapfile}[$i] =~ /(^.*\b\Q$shortfilename\E\b\s+)(\d+)(\s+)(\d+)(\s+)(\d+)(\s*$)/ )
2579 my $newline = $1 . $wordcount . $3 . $checksum . $5 . $6 . $7;
2580 ${$pkgmapfile}[$i] = $newline;
2581 last;
2586 #########################################################
2587 # Calling sum
2588 #########################################################
2590 sub _call_sum
2592 my ($filename) = @_;
2594 $sumfile = "/usr/bin/sum";
2596 if ( ! -f $sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/sum", "call_sum"); }
2598 my $systemcall = "$sumfile $filename |";
2600 my $sumoutput = "";
2602 open (SUM, "$systemcall");
2603 $sumoutput = <SUM>;
2604 close (SUM);
2606 my $returnvalue = $?; # $? contains the return value of the systemcall
2608 my $infoline = "Systemcall: $systemcall\n";
2609 push( @installer::globals::logfileinfo, $infoline);
2611 if ($returnvalue)
2613 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2614 push( @installer::globals::logfileinfo, $infoline);
2616 else
2618 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2619 push( @installer::globals::logfileinfo, $infoline);
2622 return $sumoutput;
2625 #########################################################
2626 # Calling wc
2627 # wc -c pkginfo | cut -f6 -d' '
2628 #########################################################
2630 sub _call_wc
2632 my ($filename) = @_;
2634 $wcfile = "/usr/bin/wc";
2636 if ( ! -f $wcfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/wc", "call_wc"); }
2638 my $systemcall = "$wcfile -c $filename |";
2640 my $wcoutput = "";
2642 open (WC, "$systemcall");
2643 $wcoutput = <WC>;
2644 close (WC);
2646 my $returnvalue = $?; # $? contains the return value of the systemcall
2648 my $infoline = "Systemcall: $systemcall\n";
2649 push( @installer::globals::logfileinfo, $infoline);
2651 if ($returnvalue)
2653 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2654 push( @installer::globals::logfileinfo, $infoline);
2656 else
2658 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2659 push( @installer::globals::logfileinfo, $infoline);
2662 return $wcoutput;