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
;
22 use installer
::converter
;
23 use installer
::exiter
;
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
;
35 # please Debian packaging, fdo#53341
39 if ( $installer::globals
::debian
) {
40 $dep =~ s/_/-/g; # Debian allows no underline in package name
46 ############################################################################
47 # Reading the package map to find Solaris package names for
48 # the corresponding abbreviations
49 ############################################################################
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\" (property 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;
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");
107 $installer::globals
::dependfilenames
{$local_abbreviation} = $local_packagename;
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");
123 $installer::globals
::dependfilenames
{$abbreviation} = $packagename;
129 my $errorline = $i + 1;
130 installer
::exiter
::exit_program
("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap");
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) = @_;
149 if ( $installer::globals
::islinuxbuild
)
154 for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ )
156 my $onedir = ${$directoriesarrayref}[$i];
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'};
186 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
187 if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; }
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) = @_;
204 if ( $installer::globals
::islinuxbuild
)
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) = @_;
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) = @_;
251 my ($licensefilename, $readmefilename, $readmefilenameen);
253 my $foundlicensefile = 0;
254 my $foundreadmefile = 0;
259 # %product LibreOffice Software
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
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";
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";
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);
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);
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);
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;
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);
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
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
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
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
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
573 $provides = "provides"; # the name in the packagelist
574 $requires = "requires"; # the name in the packagelist
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);
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) = @_;
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");
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)
721 if (($ENV{'EPM'} ne "") && (-x
"$ENV{'EPM'}"))
723 $epmname = $ENV{'EPM'};
727 installer
::exiter
::exit_program
("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
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);
745 #################################################
746 # Determining the epm patch state
747 # saved in $installer::globals::is_special_epm
748 #################################################
752 my ($epmexecutable) = @_;
756 my $systemcall = "$epmexecutable |";
757 open (EPMPATCH
, "$systemcall");
762 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals
::is_special_epm
= 1; }
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);
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;
786 $installer::globals
::postprocess_specialepm
= 0;
787 $installer::globals
::postprocess_standardepm
= 1;
791 #################################################
792 # Calling epm to create the installation sets
793 #################################################
797 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
799 installer
::logger
::include_header_into_logfile
("epm call for $packagename");
801 my $packageformat = $installer::globals
::packageformat
;
803 my $localpackagename = $packagename;
804 # Debian allows only lowercase letters in package name
805 if ( $installer::globals
::debian
) { $localpackagename = lc($localpackagename); }
807 my $outdirstring = "";
808 if ( $installer::globals
::epmoutpath
ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
810 # Debian package build needs to be run with fakeroot for correct ownerships/permissions
812 my $fakerootstring = "";
814 if ( $installer::globals
::debian
) { $fakerootstring = "fakeroot "; }
817 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
819 $extraflags .= ' -g' unless $installer::globals
::strip
;
821 my $verboseflag = "-v";
822 if ( ! $installer::globals
::quiet
) { $verboseflag = "-v2"; };
824 my $systemcall = $fakerootstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " " . $verboseflag . " " . " 2\>\&1 |";
826 installer
::logger
::print_message
( "... $systemcall ...\n" );
830 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
834 open (EPM
, "$systemcall");
835 while (<EPM
>) {push(@epmoutput, $_); }
838 my $returnvalue = $?
; # $? contains the return value of the systemcall
840 my $infoline = "Systemcall (Try $i): $systemcall\n";
841 push( @installer::globals
::logfileinfo
, $infoline);
843 for ( my $j = 0; $j <= $#epmoutput; $j++ )
845 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
846 push( @installer::globals
::logfileinfo
, "$epmoutput[$j]");
851 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
852 push( @installer::globals
::logfileinfo
, $infoline);
853 if ( $i == $maxepmcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "call_epm"); }
857 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
858 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
859 push( @installer::globals
::logfileinfo
, $infoline);
865 #####################################################################
866 # Adding the new line for relocatables into pkginfo file (Solaris)
867 # or spec file (Linux) created by epm
868 #####################################################################
870 sub add_one_line_into_file
872 my ($file, $insertline, $filename) = @_;
874 if ( $installer::globals
::issolarispkgbuild
)
876 push(@
{$file}, $insertline); # simply adding at the end of pkginfo file
879 if ( $installer::globals
::isrpmbuild
)
881 # Adding behind the line beginning with: Group:
883 my $inserted_line = 0;
885 for ( my $i = 0; $i <= $#{$file}; $i++ )
887 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
889 splice(@
{$file},$i+1,0,$insertline);
895 if (! $inserted_line) { installer
::exiter
::exit_program
("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
898 $insertline =~ s/\s*$//; # removing line end for correct logging
899 my $infoline = "Success: Added line $insertline into file $filename!\n";
900 push( @installer::globals
::logfileinfo
, $infoline);
903 #####################################################################
904 # Setting the revision VERSION=1.9,REV=66 .
905 # Also adding the new line: "AutoReqProv: no"
906 #####################################################################
908 sub set_revision_in_pkginfo
910 my ($file, $filename, $variables, $packagename) = @_;
912 my $revisionstring = "\,REV\=" . $installer::globals
::packagerevision
;
914 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
916 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
920 $year = $year + 1900;
922 if ( $mday < 10 ) { $mday = "0" . $mday; }
923 if ( $mon < 10 ) { $mon = "0" . $mon; }
924 $datestring = $year . "." . $mon . "." . $mday;
925 $revisionstring = $revisionstring . "." . $datestring;
927 for ( my $i = 0; $i <= $#{$file}; $i++ )
929 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
932 my $newstring = $oldstring . $revisionstring; # also adding the date string
933 ${$file}[$i] =~ s/$oldstring/$newstring/;
934 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
935 push( @installer::globals
::logfileinfo
, $infoline);
940 # For Update and Patch reasons, this string can also be kept constant
942 my $pkgversion = "SOLSPARCPKGVERSION";
943 if ( $installer::globals
::issolarisx86build
) { $pkgversion = "SOLIAPKGVERSION"; }
945 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
947 if ( $variables->{$pkgversion} ne "FINALVERSION" )
949 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
950 # 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
951 # and therefore be set as $pkgversion.
952 # The first part "3.0.0" has to be derived from the
954 my $version = $installer::globals
::packageversion
;
955 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
961 my $finalmajor = $major;
962 my $finalminor = $minor;
965 $version = "$finalmajor.$finalminor.$finalmicro";
968 my $datestring = $variables->{$pkgversion};
970 # Allowing some packages to have another date of creation.
971 # They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename"
973 my $additionalkey = $pkgversion . "_" . $packagename;
974 if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; }
976 my $versionstring = "$version,$datestring";
978 for ( my $i = 0; $i <= $#{$file}; $i++ )
980 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
983 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
984 my $oldstring = ${$file}[$i];
985 ${$file}[$i] = $newstring;
986 $oldstring =~ s/\s*$//;
987 $newstring =~ s/\s*$//;
988 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
989 push( @installer::globals
::logfileinfo
, $infoline);
997 ########################################################
998 # Setting MAXINST=1000 into the pkginfo file.
999 ########################################################
1001 sub set_maxinst_in_pkginfo
1003 my ($changefile, $filename) = @_;
1005 my $newline = "MAXINST\=1000\n";
1007 add_one_line_into_file
($changefile, $newline, $filename);
1010 #############################################################
1011 # Setting several Solaris variables into the pkginfo file.
1012 #############################################################
1014 sub set_solaris_parameter_in_pkginfo
1016 my ($changefile, $filename, $allvariables) = @_;
1027 my $productname = $allvariables->{'PRODUCTNAME'};
1028 $newline = "SUNW_PRODNAME=$productname\n";
1029 add_one_line_into_file
($changefile, $newline, $filename);
1031 my $productversion = "";
1032 if ( $allvariables->{'PRODUCTVERSION'} )
1034 $productversion = $allvariables->{'PRODUCTVERSION'};
1035 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1037 $newline = "SUNW_PRODVERS=$productversion\n";
1038 add_one_line_into_file
($changefile, $newline, $filename);
1040 $newline = "SUNW_PKGVERS=1\.0\n";
1041 add_one_line_into_file
($changefile, $newline, $filename);
1043 if ( $allvariables->{'SUNW_PKGTYPE'} )
1045 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1046 add_one_line_into_file
($changefile, $newline, $filename);
1050 $newline = "SUNW_PKGTYPE=\n";
1051 add_one_line_into_file
($changefile, $newline, $filename);
1054 $newline = "HOTLINE=Please contact your local service provider\n";
1055 add_one_line_into_file
($changefile, $newline, $filename);
1057 $newline = "EMAIL=\n";
1058 add_one_line_into_file
($changefile, $newline, $filename);
1062 #####################################################################
1063 # epm uses as architecture for Solaris x86 "i86pc". This has to be
1064 # changed to "i386".
1065 #####################################################################
1067 sub fix_architecture_setting
1069 my ($changefile) = @_;
1071 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1073 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1075 ${$changefile}[$i] =~ s/i86pc/i386/;
1082 #####################################################################
1083 # Adding a new line for topdir into specfile, removing old
1085 #####################################################################
1087 sub set_topdir_in_specfile
1089 my ($changefile, $filename, $newepmdir) = @_;
1091 $newepmdir = Cwd
::cwd
() . $installer::globals
::separator
. $newepmdir; # only absolute path allowed
1093 # removing "%define _topdir", if existing
1095 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1097 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1099 my $removeline = ${$changefile}[$i];
1100 $removeline =~ s/\s*$//;
1101 splice(@
{$changefile},$i,1);
1102 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1103 push( @installer::globals
::logfileinfo
, $infoline);
1108 # Adding "topdir" behind the line beginning with: Group:
1110 my $inserted_line = 0;
1112 my $topdirline = "\%define _topdir $newepmdir\n";
1114 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1116 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1118 splice(@
{$changefile},$i+1,0,$topdirline);
1120 $topdirline =~ s/\s*$//;
1121 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1122 push( @installer::globals
::logfileinfo
, $infoline);
1126 if (! $inserted_line) { installer
::exiter
::exit_program
("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1130 #####################################################################
1131 # Setting the packager in the spec file
1132 # Syntax: Packager: abc@def
1133 #####################################################################
1135 sub set_packager_in_specfile
1137 my ($changefile) = @_;
1139 my $packager = $installer::globals
::longmanufacturer
;
1141 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1143 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1146 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1147 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1148 push( @installer::globals
::logfileinfo
, $infoline);
1154 #####################################################################
1155 # Setting the requirements in the spec file (i81494)
1156 # Syntax: PreReq: "requirements" (only for shared extensions)
1157 #####################################################################
1159 sub set_prereq_in_specfile
1161 my ($changefile) = @_;
1163 my $prereq = "PreReq:";
1165 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1167 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1169 my $oldstring = ${$changefile}[$i];
1170 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1171 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1172 push( @installer::globals
::logfileinfo
, $infoline);
1177 #####################################################################
1178 # Setting the Auto[Req]Prov line and __find_requires
1179 #####################################################################
1181 sub set_autoprovreq_in_specfile
1183 my ($changefile, $findrequires, $bindir) = @_;
1185 my $autoreqprovline;
1187 if ( $findrequires )
1189 $autoreqprovline = "AutoProv\: no\n%define _use_internal_dependency_generator 0\n%define __find_requires $bindir/$findrequires\n";
1193 $autoreqprovline = "AutoReqProv\: no\n";
1196 $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n";
1198 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1200 # Adding "autoreqprov" behind the line beginning with: Group:
1201 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1203 splice(@
{$changefile},$i+1,0,$autoreqprovline);
1204 $autoreqprovline =~ s/\s*$//;
1205 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1206 push( @installer::globals
::logfileinfo
, $infoline);
1213 #####################################################################
1214 # Replacing Copyright with License in the spec file
1215 # Syntax: License: LGPLv3 (or MPLv2 on ALv2, older usages were LGPL, SISSL)
1216 #####################################################################
1218 sub set_license_in_specfile
1220 my ($changefile, $variableshashref) = @_;
1222 my $license = $variableshashref->{'LICENSENAME'};
1224 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1226 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1228 ${$changefile}[$i] = "License: $license\n";
1229 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1230 push( @installer::globals
::logfileinfo
, $infoline);
1236 #########################################################
1237 # Building relocatable Solaris packages means:
1238 # 1. Add "BASEDIR=/opt" into pkginfo
1239 # 2. Remove "/opt/" from all objects in prototype file
1240 # For step2 this function exists
1241 # Sample: d none /opt/openofficeorg20/help 0755 root other
1242 # -> d none openofficeorg20/help 0755 root other
1243 #########################################################
1245 sub make_prototypefile_relocatable
1247 my ($prototypefile, $relocatablepath) = @_;
1249 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1251 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w
+/ ) # this is an object line
1253 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1257 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1258 # This line has to be removed now
1260 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s
/\
/\s*$//; } # removing the ending slash
1262 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1264 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1266 my $line = ${$prototypefile}[$i];
1267 splice(@
{$prototypefile},$i,1); # removing the line
1269 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1270 push( @installer::globals
::logfileinfo
, $infoline);
1275 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1277 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1279 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1281 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1282 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1283 push( @installer::globals
::logfileinfo
, $infoline2);
1288 #########################################################################
1289 # Replacing the variables in the shell scripts or in the epm list file
1291 # Solaris: preinstall, postinstall, preremove, postremove
1292 # If epm is used in the original version (not relocatable)
1293 # the variables have to be exchanged in the list file,
1295 #########################################################################
1297 sub replace_variables_in_shellscripts
1299 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1302 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1304 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1306 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1308 my $oldline = ${$scriptfile}[$i];
1309 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1310 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1311 my $infoline = "Info
: Substituting
in $scriptfilename $oldstring by
$newstring\n";
1312 push(@installer::globals::logfileinfo, $infoline);
1315 $infoline = "Old Line
: $oldline";
1316 push(@installer::globals::logfileinfo, $infoline);
1317 $infoline = "New Line
: ${$scriptfile}[$i]";
1318 push(@installer::globals::logfileinfo, $infoline);
1324 ############################################################
1325 # Determining the directory created by epm, in which the
1326 # RPMS or Solaris packages are created.
1327 ############################################################
1329 sub determine_installdir_ooo
1331 # A simple "ls
" command returns the directory name
1335 my $systemcall = "ls
|";
1336 open (LS, "$systemcall");
1340 $dirname =~ s/\s*$//;
1342 my $infoline = "Info
: Directory created by epm
: $dirname\n";
1343 push(@installer::globals::logfileinfo, $infoline);
1348 ############################################################
1349 # Setting the tab content into the file container
1350 ############################################################
1352 sub set_tab_into_datafile
1354 my ($changefile, $filesref) = @_;
1356 my @newclasses = ();
1357 my $newclassesstring = "";
1359 if ( $installer::globals::issolarispkgbuild )
1361 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1363 my $onefile = ${$filesref}[$i];
1365 if ( $onefile->{'SolarisClass'} )
1367 my $sourcepath = $onefile->{'sourcepath'};
1369 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1371 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1373 my $oldline = ${$changefile}[$j];
1374 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1375 my $newline = ${$changefile}[$j];
1376 $oldline =~ s/\s*$//;
1377 $newline =~ s/\s*$//;
1379 my $infoline = "TAB
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1380 push(@installer::globals::logfileinfo, $infoline);
1382 # collecting all new classes
1383 if (! grep {$_ eq $onefile->{'SolarisClass'}} @newclasses)
1385 push(@newclasses, $onefile->{'SolarisClass'});
1394 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1397 if ( $installer::globals::isrpmbuild )
1399 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1401 my $onefile = ${$filesref}[$i];
1403 if ( $onefile->{'SpecFileContent'} )
1405 my $destination = $onefile->{'destination'};
1407 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1409 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1414 my $oldline = ${$changefile}[$j];
1415 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1416 my $newline = ${$changefile}[$j];
1418 $oldline =~ s/\s*$//;
1419 $newline =~ s/\s*$//;
1421 my $infoline = "TAB
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1422 push(@installer::globals::logfileinfo, $infoline);
1431 return $newclassesstring;
1434 ############################################################
1435 # Including additional classes into the pkginfo file
1436 ############################################################
1438 sub include_classes_into_pkginfo
1440 my ($changefile, $classesstring) = @_;
1442 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1444 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1446 ${$changefile}[$i] =~ s/\s*$//;
1447 my $oldline = ${$changefile}[$i];
1448 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1449 my $newline = ${$changefile}[$i];
1450 $newline =~ s/\s*$//;
1452 my $infoline = "pkginfo file
: Changing content from
\"$oldline\" to
\"$newline\" .\n";
1453 push(@installer::globals::logfileinfo, $infoline);
1458 ##########################################################################################
1459 # Checking, if an extension is included into the package (Linux).
1460 # All extension files have to be installed into directory
1461 # share/extension/install
1462 # %attr(0444,root,root) "/opt/staroffice
8/share/extension
/install/SunSearchToolbar
.oxt
"
1463 ##########################################################################################
1465 sub is_extension_package
1467 my ($specfile) = @_;
1469 my $is_extension_package = 0;
1471 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1473 my $line = ${$specfile}[$i];
1474 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1476 $is_extension_package = 1;
1481 return $is_extension_package;
1484 ######################################################################
1485 # Checking, if an extension is included into the package (Solaris).
1486 # All extension files have to be installed into directory
1487 # share/extension/install
1488 ######################################################################
1490 sub contains_extension_dir
1492 my ($prototypefile) = @_;
1494 my $contains_extension_dir = 0;
1496 # d none opt/libreoffice/share/extensions/
1498 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1500 my $line = ${$prototypefile}[$i];
1501 if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// )
1503 $contains_extension_dir = 1;
1508 return $contains_extension_dir;
1511 ############################################################
1512 # Setting the correct Solaris locales
1513 ############################################################
1515 sub get_solaris_language_for_langpack
1517 my ( $onelanguage ) = @_;
1519 my $sollanguage = $onelanguage;
1520 $sollanguage =~ s/\-/\_/;
1522 if ( $sollanguage eq "de
" ) { $sollanguage = "de
"; }
1523 elsif ( $sollanguage eq "en_US
" ) { $sollanguage = "en_AU
,en_CA
,en_GB
,en_IE
,en_MT
,en_NZ
,en_US
,en_US
.UTF
-8"; }
1524 elsif ( $sollanguage eq "es
" ) { $sollanguage = "es
"; }
1525 elsif ( $sollanguage eq "fr
" ) { $sollanguage = "fr
"; }
1526 elsif ( $sollanguage eq "hu
" ) { $sollanguage = "hu_HU
"; }
1527 elsif ( $sollanguage eq "it
" ) { $sollanguage = "it
"; }
1528 elsif ( $sollanguage eq "nl
" ) { $sollanguage = "nl_BE
,nl_NL
"; }
1529 elsif ( $sollanguage eq "pl
" ) { $sollanguage = "pl_PL
"; }
1530 elsif ( $sollanguage eq "sv
" ) { $sollanguage = "sv
"; }
1531 elsif ( $sollanguage eq "pt
" ) { $sollanguage = "pt_PT
"; }
1532 elsif ( $sollanguage eq "pt_BR
" ) { $sollanguage = "pt_BR
"; }
1533 elsif ( $sollanguage eq "ru
" ) { $sollanguage = "ru_RU
"; }
1534 elsif ( $sollanguage eq "ja
" ) { $sollanguage = "ja
,ja_JP
,ja_JP
.PCK
,ja_JP
.UTF
-8"; }
1535 elsif ( $sollanguage eq "ko
" ) { $sollanguage = "ko
,ko
.UTF
-8"; }
1536 elsif ( $sollanguage eq "zh_CN
" ) { $sollanguage = "zh
,zh
.GBK
,zh_CN
.GB18030
,zh
.UTF
-8"; }
1537 elsif ( $sollanguage eq "zh_TW
" ) { $sollanguage = "zh_TW
,zh_TW
.BIG5
,zh_TW
.UTF
-8,zh_HK
.BIG5HK
,zh_HK
.UTF
-8"; }
1539 return $sollanguage;
1542 ############################################################
1543 # Adding language infos in pkginfo file
1544 ############################################################
1546 sub include_languageinfos_into_pkginfo
1548 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1550 # SUNWPKG_LIST=core01
1553 my $locallang = $onepackage->{'language'};
1554 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1556 my $newline = "SUNW_LOC
=" . $solarislanguage . "\n";
1557 add_one_line_into_file($changefile, $newline, $filename);
1559 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1560 if ( $onepackage->{'pkg_list_entry'} )
1562 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1563 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1564 $newline = "SUNW_PKGLIST
=" . $packagelistentry . "\n";
1565 add_one_line_into_file($changefile, $newline, $filename);
1569 # Using default package ooobasis30-core01.
1570 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01
";
1571 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1572 $newline = "SUNW_PKGLIST
=" . $packagelistentry . "\n";
1573 add_one_line_into_file($changefile, $newline, $filename);
1577 ############################################################
1578 # Including package names into the depend files.
1579 # The package names have to be included into
1580 # packagelist. They are already saved in
1581 # %installer::globals::dependfilenames.
1582 ############################################################
1584 sub put_packagenames_into_dependfile
1588 for ( my $i = 0; $i <= $#{$file}; $i++ )
1590 my $line = ${$file}[$i];
1591 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
1593 my $abbreviation = $1;
1595 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR
: Could
not resolve all properties
in Solaris
package abbreviation
\"$abbreviation\"!", "read_packagemap
"); }
1597 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
1599 my $packagename = $installer::globals::dependfilenames{$abbreviation};
1600 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR
: Could
not resolve all properties
in Solaris
package name
\"$packagename\"!", "read_packagemap
"); }
1603 ${$file}[$i] = $line . "\t" . $packagename . "\n";
1607 installer::exiter::exit_program("ERROR
: Missing packagename
for Solaris
package \"$abbreviation\"!", "put_packagenames_into_dependfile
");
1613 ############################################################
1614 # Including the relocatable directory into
1615 # spec file and pkginfo file
1616 # Linux: set topdir in specfile
1617 # Solaris: remove $relocatablepath (/opt/)
1618 # for all objects in prototype file
1619 # and changing "topdir
" for Linux
1620 ############################################################
1622 sub prepare_packages
1624 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
1628 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
1630 my $localrelocatablepath = $relocatablepath;
1631 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\
/\s*$//; }
1633 if ( $installer::globals
::issolarispkgbuild
)
1635 $filename = $packagename . ".pkginfo";
1636 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
1639 if ( $installer::globals
::isrpmbuild
)
1641 $filename = $packagename . ".spec";
1642 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
1645 my $completefilename = $newepmdir . $filename;
1647 if ( ! -f
$completefilename) { installer
::exiter
::exit_program
("ERROR: Did not find file: $completefilename", "prepare_packages"); }
1648 my $changefile = installer
::files
::read_file
($completefilename);
1649 if ( $newline ne "" )
1651 add_one_line_into_file
($changefile, $newline, $filename);
1652 installer
::files
::save_file
($completefilename, $changefile);
1655 # adding new "topdir" and removing old "topdir" in specfile
1657 if ( $installer::globals
::isrpmbuild
)
1659 set_topdir_in_specfile
($changefile, $filename, $newepmdir);
1660 set_autoprovreq_in_specfile
($changefile, $onepackage->{'findrequires'}, "$installer::globals::workpath" . "/bin");
1661 set_packager_in_specfile
($changefile);
1662 if ( is_extension_package
($changefile) ) { set_prereq_in_specfile
($changefile); }
1663 set_license_in_specfile
($changefile, $variableshashref);
1664 set_tab_into_datafile
($changefile, $filesref);
1665 installer
::files
::save_file
($completefilename, $changefile);
1668 # removing the relocatable path in prototype file
1670 if ( $installer::globals
::issolarispkgbuild
)
1672 set_revision_in_pkginfo
($changefile, $filename, $variableshashref, $packagename);
1673 set_maxinst_in_pkginfo
($changefile, $filename);
1674 set_solaris_parameter_in_pkginfo
($changefile, $filename, $variableshashref);
1675 if ( $installer::globals
::issolarisx86build
) { fix_architecture_setting
($changefile); }
1676 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo
($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
1677 installer
::files
::save_file
($completefilename, $changefile);
1679 my $prototypefilename = $packagename . ".prototype";
1680 $prototypefilename = $newepmdir . $prototypefilename;
1681 if (! -f
$prototypefilename) { installer
::exiter
::exit_program
("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
1683 my $prototypefile = installer
::files
::read_file
($prototypefilename);
1684 make_prototypefile_relocatable
($prototypefile, $relocatablepath);
1685 my $classesstring = set_tab_into_datafile
($prototypefile, $filesref);
1688 include_classes_into_pkginfo
($changefile, $classesstring);
1689 installer
::files
::save_file
($completefilename, $changefile);
1692 installer
::files
::save_file
($prototypefilename, $prototypefile);
1694 # Adding package names into depend files for Solaris (not supported by epm)
1695 my $dependfilename = $packagename . ".depend";
1696 $dependfilename = $newepmdir . $dependfilename;
1697 if ( -f
$dependfilename)
1699 my $dependfile = installer
::files
::read_file
($dependfilename);
1700 put_packagenames_into_dependfile
($dependfile);
1701 installer
::files
::save_file
($dependfilename, $dependfile);
1708 ###############################################################################
1709 # Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
1711 # The complete rootpath is stored in $installer::globals::rootpath
1712 # or for each package in $onepackage->{'destpath'}
1713 # The static rootpath is stored in $staticpath
1714 # The relocatable path is stored in $relocatablepath
1715 # PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
1716 # PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
1717 # In standard epm process:
1718 # No usage of package specific variables like $BASEDIR, because
1719 # 1. These variables would be replaced in epm process
1720 # 2. epm version 3.7 does not support relocatable packages
1721 ###############################################################################
1723 sub resolve_path_in_epm_list_before_packaging
1725 my ($listfile, $listfilename, $variable, $path) = @_;
1727 installer
::logger
::include_header_into_logfile
("Replacing variables in epm list file:");
1729 $path =~ s/\/\s*$//;
1730 replace_variables_in_shellscripts
($listfile, $listfilename, $variable, $path);
1734 #################################################################
1735 # Determining the rpm version. Beginning with rpm version 4.0
1736 # the tool to create RPMs is "rpmbuild" and no longer "rpm"
1737 #################################################################
1739 sub determine_rpm_version
1743 my $systemcall = "";
1745 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
1746 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
1747 # is saved in $installer::globals::rpm
1749 if ( $installer::globals
::rpm
ne "" )
1751 $systemcall = "$installer::globals::rpm --version |";
1755 $systemcall = "rpm --version |";
1758 open (RPM
, "$systemcall");
1762 if ( $rpmout ne "" )
1764 $rpmout =~ s/\s*$//g;
1766 my $infoline = "Systemcall: $systemcall\n";
1767 push( @installer::globals
::logfileinfo
, $infoline);
1769 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
1770 else { $infoline = "Success: rpm version: $rpmout\n"; }
1772 push( @installer::globals
::logfileinfo
, $infoline);
1774 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
1775 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
1776 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
1777 else { installer
::exiter
::exit_program
("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
1783 ####################################################
1784 # Writing some info about rpm into the log file
1785 ####################################################
1789 my $systemcall = "";
1792 $infoline = "\nLogging rpmrc content using --showrc\n\n";
1793 push( @installer::globals
::logfileinfo
, $infoline);
1795 if ( $installer::globals
::rpm
ne "" )
1797 $systemcall = "$installer::globals::rpm --showrc |";
1801 $systemcall = "rpm --showrc |";
1804 my @fullrpmout = ();
1806 open (RPM
, "$systemcall");
1807 while (<RPM
>) {push(@fullrpmout, $_); }
1810 if ( $#fullrpmout > -1 )
1812 for ( my $i = 0; $i <= $#fullrpmout; $i++ )
1814 my $rpmout = $fullrpmout[$i];
1815 $rpmout =~ s/\s*$//g;
1817 $infoline = "$rpmout\n";
1818 $infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems
1819 push( @installer::globals
::logfileinfo
, $infoline);
1824 $infoline = "Problem in systemcall: $systemcall : No return value\n";
1825 push( @installer::globals
::logfileinfo
, $infoline);
1828 $infoline = "End of logging rpmrc\n\n";
1829 push( @installer::globals
::logfileinfo
, $infoline);
1832 #################################################
1833 # Systemcall to start the packaging process
1834 #################################################
1836 sub create_packages_without_epm
1838 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
1840 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
1841 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
1842 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
1844 if ( $installer::globals
::issolarispkgbuild
)
1846 my $prototypefile = $epmdir . $packagename . ".prototype";
1847 if (! -f
$prototypefile) { installer
::exiter
::exit_program
("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
1849 my $destinationdir = $prototypefile;
1850 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destinationdir);
1851 $destinationdir =~ s/\/\s*$//; # removing ending slashes
1853 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
1854 installer
::logger
::print_message
( "... $systemcall ...\n" );
1856 my $maxpkgmkcalls = 3;
1858 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
1860 my @pkgmkoutput = ();
1862 open (PKGMK
, "$systemcall");
1863 while (<PKGMK
>) {push(@pkgmkoutput, $_); }
1866 my $returnvalue = $?
; # $? contains the return value of the systemcall
1868 my $infoline = "Systemcall (Try $i): $systemcall\n";
1869 push( @installer::globals
::logfileinfo
, $infoline);
1871 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
1873 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
1874 push( @installer::globals
::logfileinfo
, "$pkgmkoutput[$j]");
1879 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
1880 push( @installer::globals
::logfileinfo
, $infoline);
1881 if ( $i == $maxpkgmkcalls ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
1885 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
1886 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1887 push( @installer::globals
::logfileinfo
, $infoline);
1892 # It might be necessary to save uncompressed Solaris packages
1894 # compressing packages
1896 if ( ! $installer::globals
::solarisdontcompress
)
1898 my $faspac = "faspac-so.sh";
1900 my $compressorref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$faspac, $includepatharrayref, 0);
1901 if ($$compressorref ne "")
1903 # Saving original pkginfo, to set time stamp later
1904 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
1905 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
1906 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
1907 installer
::systemactions
::make_systemcall
($systemcall);
1909 $faspac = $$compressorref;
1910 $infoline = "Found compressor: $faspac\n";
1911 push( @installer::globals
::logfileinfo
, $infoline);
1913 installer
::logger
::print_message
( "... $faspac ...\n" );
1914 installer
::logger
::include_timestamp_into_logfile
("Starting $faspac");
1916 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
1917 installer
::systemactions
::make_systemcall
($systemcall);
1919 # Setting time stamp for pkginfo, because faspac-so.sh
1920 # changed the pkginfo file, updated the size and
1921 # checksum, but not the time stamp.
1922 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
1923 installer
::systemactions
::make_systemcall
($systemcall);
1924 if ( -f
$pkginfotmp ) { unlink($pkginfotmp); }
1926 installer
::logger
::include_timestamp_into_logfile
("End of $faspac");
1930 $infoline = "Not found: $faspac\n";
1931 push( @installer::globals
::logfileinfo
, $infoline);
1935 # Setting unix rights to "775" for all created directories inside the package
1937 $systemcall = "cd $destinationdir; find $packagename -type d | xargs -i chmod 775 \{\} \;";
1938 installer
::logger
::print_message
( "... $systemcall ...\n" );
1940 $returnvalue = system($systemcall);
1942 $infoline = "Systemcall: $systemcall\n";
1943 push( @installer::globals
::logfileinfo
, $infoline);
1947 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
1948 push( @installer::globals
::logfileinfo
, $infoline);
1952 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1953 push( @installer::globals
::logfileinfo
, $infoline);
1957 ######################
1959 ######################
1961 # my $streamname = $packagename . ".pkg";
1962 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
1963 # print "... $systemcall ...\n";
1965 # $returnvalue = system($systemcall);
1967 # $infoline = "Systemcall: $systemcall\n";
1968 # push( @installer::globals::logfileinfo, $infoline);
1972 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
1973 # push( @installer::globals::logfileinfo, $infoline);
1977 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
1978 # push( @installer::globals::logfileinfo, $infoline);
1981 #########################
1982 # making tar.gz files
1983 #########################
1985 # my $targzname = $packagename . ".tar.gz";
1986 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
1987 # print "... $systemcall ...\n";
1989 # $returnvalue = system($systemcall);
1991 # $infoline = "Systemcall: $systemcall\n";
1992 # push( @installer::globals::logfileinfo, $infoline);
1996 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
1997 # push( @installer::globals::logfileinfo, $infoline);
2001 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2002 # push( @installer::globals::logfileinfo, $infoline);
2007 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2009 if ( $installer::globals
::isrpmbuild
)
2011 my $specfilename = $epmdir . $packagename . ".spec";
2012 if (! -f
$specfilename) { installer
::exiter
::exit_program
("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2014 my $rpmcommand = $installer::globals
::rpm
;
2015 my $rpmversion = determine_rpm_version
();
2018 if ( $installer::globals
::platformid
eq 'linux_x86')
2022 elsif ( $installer::globals
::platformid
eq 'aix_powerpc')
2026 elsif ( $installer::globals
::os
eq 'LINUX')
2028 $target = (POSIX
::uname
())[4];
2031 # rpm 4.6 ignores buildroot tag in spec file
2033 my $buildrootstring = "";
2035 if ( $rpmversion >= 4 )
2037 my $dir = Cwd
::getcwd
;
2038 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2039 $buildrootstring = "--buildroot=$buildroot";
2040 mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/");
2043 if ( ! $installer::globals
::rpminfologged
)
2046 $installer::globals
::rpminfologged
= 1;
2049 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2051 installer
::logger
::print_message
( "... $systemcall ...\n" );
2053 my $maxrpmcalls = 3;
2056 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2060 open (RPM
, "$systemcall");
2061 while (<RPM
>) {push(@rpmoutput, $_); }
2064 my $returnvalue = $?
; # $? contains the return value of the systemcall
2066 my $infoline = "Systemcall (Try $i): $systemcall\n";
2067 push( @installer::globals
::logfileinfo
, $infoline);
2069 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2071 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2072 push( @installer::globals
::logfileinfo
, "$rpmoutput[$j]");
2077 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2078 push( @installer::globals
::logfileinfo
, $infoline);
2083 installer
::logger
::print_message
( "Success (Try $i): \"$systemcall\"\n" );
2084 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2085 push( @installer::globals
::logfileinfo
, $infoline);
2093 # Because of the problems with LD_LIBRARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2095 if ( -f
"/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2096 elsif ( -f
"/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2098 if ( $rpmprog ne "" )
2100 installer
::logger
::print_message
( "... $rpmprog ...\n" );
2102 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2104 my @helperrpmoutput = ();
2106 open (RPM
, "$helpersystemcall");
2107 while (<RPM
>) {push(@helperrpmoutput, $_); }
2110 my $helperreturnvalue = $?
; # $? contains the return value of the systemcall
2112 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBRARY_PATH)\n";
2113 push( @installer::globals
::logfileinfo
, $infoline);
2115 $infoline = "\nSystemcall: $helpersystemcall\n";
2116 push( @installer::globals
::logfileinfo
, $infoline);
2118 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals
::logfileinfo
, "$helperrpmoutput[$j]"); }
2120 if ($helperreturnvalue)
2122 $infoline = "Could not execute \"$helpersystemcall\"!\n";
2123 push( @installer::globals
::logfileinfo
, $infoline);
2127 installer
::logger
::print_message
( "Success: \"$helpersystemcall\"\n" );
2128 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2129 push( @installer::globals
::logfileinfo
, $infoline);
2134 # Now it is really time to exit this packaging process, if the error still occurs
2135 if ( $rpm_failed ) { installer
::exiter
::exit_program
("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2140 #################################################
2141 # Removing all temporary files created by epm
2142 #################################################
2144 sub remove_temporary_epm_files
2146 my ($epmdir, $loggingdir, $packagename) = @_;
2148 # saving the files into the loggingdir
2150 if ( $installer::globals
::issolarispkgbuild
)
2152 my @extensions = ();
2153 push(@extensions, ".pkginfo");
2154 push(@extensions, ".prototype");
2155 push(@extensions, ".postinstall");
2156 push(@extensions, ".postremove");
2157 push(@extensions, ".preinstall");
2158 push(@extensions, ".preremove");
2159 push(@extensions, ".depend");
2161 for ( my $i = 0; $i <= $#extensions; $i++ )
2163 my $removefile = $epmdir . $packagename . $extensions[$i];
2164 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2166 if (! -f
$removefile) { next; }
2168 my $systemcall = "mv -f $removefile $destfile";
2169 system($systemcall); # ignoring the return value
2170 $infoline = "Systemcall: $systemcall\n";
2171 push( @installer::globals
::logfileinfo
, $infoline);
2175 if ( $installer::globals
::isrpmbuild
)
2177 my $removefile = $epmdir . $packagename . ".spec";
2178 my $destfile = $loggingdir . $packagename . ".spec.log";
2180 my $systemcall = "mv -f $removefile $destfile";
2181 system($systemcall); # ignoring the return value
2182 $infoline = "Systemcall: $systemcall\n";
2183 push( @installer::globals
::logfileinfo
, $infoline);
2185 # removing the directory "buildroot"
2187 my $removedir = $epmdir . "buildroot";
2189 $systemcall = "rm -rf $removedir";
2191 installer
::logger
::print_message
( "... $systemcall ...\n" );
2193 my $returnvalue = system($systemcall);
2195 $removedir = $epmdir . "BUILD";
2197 $systemcall = "rm -rf $removedir";
2199 installer
::logger
::print_message
( "... $systemcall ...\n" );
2201 $returnvalue = system($systemcall);
2204 my $infoline = "Systemcall: $systemcall\n";
2205 push( @installer::globals
::logfileinfo
, $infoline);
2209 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2210 push( @installer::globals
::logfileinfo
, $infoline);
2214 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2215 push( @installer::globals
::logfileinfo
, $infoline);
2220 ###########################################################
2221 # Creating a better directory structure in the solver.
2222 ###########################################################
2224 sub create_new_directory_structure
2226 my ($newepmdir) = @_;
2228 my $newdir = $installer::globals
::epmoutpath
;
2230 if ( $installer::globals
::isrpmbuild
)
2234 if ( $installer::globals
::platformid
eq 'linux_x86')
2236 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2238 elsif ( $installer::globals
::platformid
eq 'aix_powerpc')
2241 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2243 elsif ( $installer::globals
::os
eq 'LINUX')
2245 $machine = (POSIX
::uname
())[4];
2246 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2250 installer
::exiter
::exit_program
("ERROR: rpmdir undefined !", "create_new_directory_structure");
2253 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2255 my $returnvalue = system($systemcall);
2257 my $infoline = "Systemcall: $systemcall\n";
2258 push( @installer::globals
::logfileinfo
, $infoline);
2262 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2263 push( @installer::globals
::logfileinfo
, $infoline);
2267 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2268 push( @installer::globals
::logfileinfo
, $infoline);
2271 # and removing the empty directory
2273 if ( $machine ne "" )
2275 rmdir "$installer::globals::epmoutpath/RPMS/$machine";
2277 rmdir "$installer::globals::epmoutpath/RPMS/powerpc";
2278 rmdir "$installer::globals::epmoutpath/RPMS/x86_64";
2279 rmdir "$installer::globals::epmoutpath/RPMS/i586";
2280 rmdir "$installer::globals::epmoutpath/RPMS/i386";
2281 rmdir "$installer::globals::epmoutpath/RPMS"
2282 or warn "Could not remove RPMS dir: $!";
2285 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2286 chmod 0775, $newdir;
2289 ######################################################
2290 # Collect modules with product specific styles.
2291 ######################################################
2293 sub collect_modules_with_style
2295 my ($style, $modulesarrayref) = @_;
2297 my @allmodules = ();
2299 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2301 my $onemodule = ${$modulesarrayref}[$i];
2303 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2304 if ( $styles =~ /\b\Q$style\E\b/ )
2306 push(@allmodules, $onemodule);
2310 return \
@allmodules;
2313 ######################################################
2314 # Remove modules without packagecontent.
2315 ######################################################
2317 sub remove_modules_without_package
2319 my ($allmodules) = @_;
2321 my @allmodules = ();
2323 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2325 my $onemodule = ${$allmodules}[$i];
2326 my $packagename = "";
2327 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2328 if ( $packagename ne "" )
2330 push(@allmodules, $onemodule);
2334 return \
@allmodules;
2337 ######################################################
2338 # Copying files for system integration.
2339 ######################################################
2341 sub copy_and_unpack_tar_gz_files
2343 my ($sourcefile, $destdir) = @_;
2345 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2346 installer
::systemactions
::make_systemcall
($systemcall);
2349 ######################################################
2350 # Checking whether the new content is a directory and
2351 # not a package. If it is a directory, the complete
2352 # content of the directory has to be added to the
2354 ######################################################
2356 sub control_subdirectories
2358 my ($content, $subdir) = @_;
2360 my @newcontent = ();
2362 for ( my $i = 0; $i <= $#{$content}; $i++ )
2364 if ( -d
${$content}[$i] )
2366 $subdir = ${$content}[$i];
2367 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$subdir);
2368 my $allpackages = installer
::systemactions
::read_directory
(${$content}[$i]);
2369 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
2371 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
2372 if (( $installer::globals
::islinuxbuild
) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
2373 push(@newcontent, ${$allpackages}[$j]);
2378 push(@newcontent, ${$content}[$i]);
2382 return (\
@newcontent, $subdir);
2385 ######################################################
2386 # Including the system integration files into the
2387 # installation sets.
2388 ######################################################
2390 sub put_systemintegration_into_installset
2392 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
2394 my $destdir = $newdir;
2396 # adding System integration files
2398 my $sourcefile = "";
2400 # Finding the modules defined in scp (with flag SYSTEMMODULE)
2401 # Getting name of package from scp-Module
2402 # Search package in list off all include files
2403 # Copy file into installation set and unpack it (always tar.gz)
2404 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
2406 # Collect all modules with flag "SYSTEMMODULE"
2407 my $allmodules = collect_modules_with_style
("SYSTEMMODULE", $modulesarrayref);
2408 $allmodules = remove_modules_without_package
($allmodules);
2410 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2412 my $onemodule = ${$allmodules}[$i];
2413 my $packagetarfilename = $onemodule->{'PackageName'};
2415 my $infoline = "Including into installation set: $packagetarfilename\n";
2416 push( @installer::globals
::logfileinfo
, $infoline);
2418 my $sourcepathref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$packagetarfilename, $includepatharrayref, 1);
2419 if ( $$sourcepathref eq "" ) { installer
::exiter
::exit_program
("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
2421 # Collecting all packages in directory "packages" or "RPMS"
2422 my $oldcontent = installer
::systemactions
::read_directory
($destdir);
2424 copy_and_unpack_tar_gz_files
($$sourcepathref, $destdir);
2426 # Finding new content -> that is the package name
2427 my ($newcontent, $allcontent ) = installer
::systemactions
::find_new_content_in_directory
($destdir, $oldcontent);
2429 # special handling, if new content is a directory
2431 if ( ! $installer::globals
::issolarispkgbuild
) { ($newcontent, $subdir) = control_subdirectories
($newcontent); }
2433 # Adding license content into Solaris packages
2434 if (( $installer::globals
::issolarispkgbuild
) && ( $installer::globals
::englishlicenseset
) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { _add_license_into_systemintegrationpackages
($destdir, $newcontent); }
2438 ######################################################
2439 # Analyzing the Unix installation path.
2440 # From the installation path /opt/openofficeorg20
2441 # is the part /opt relocatable and the part
2442 # openofficeorg20 static.
2443 ######################################################
2445 sub analyze_rootpath
2447 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
2449 $rootpath =~ s/\/\s*$//; # removing ending slash
2451 ##############################################################
2452 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
2453 ##############################################################
2455 $$relocatablepathref = "/";
2456 # Static path has to contain the office directory name. This is replaced in shellscripts.
2457 $$staticpathref = $rootpath . $installer::globals
::separator
. $installer::globals
::officedirhostname
;
2458 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
2459 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
2460 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
2461 if ( $installer::globals
::isrpmbuild
)
2463 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
2464 $$staticpathref = $installer::globals
::officedirhostname
; # to be used as replacement in shell scripts
2467 if ( $installer::globals
::isdebbuild
)
2469 $$relocatablepathref = "";
2470 # $$staticpathref is already "/opt/libreoffice", no additional $rootpath required.
2475 ################################################
2476 # Defining the English license text to add
2477 # it into Solaris packages.
2478 ################################################
2480 sub _set_english_license
2482 my $additional_license_name = $installer::globals
::englishsolarislicensename
; # always the English file
2483 my $licensefileref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$additional_license_name, "" , 0);
2484 if ( $$licensefileref eq "" ) { installer
::exiter
::exit_program
("ERROR: Could not find license file $additional_license_name!", "set_english_license"); }
2485 $installer::globals
::englishlicenseset
= 1;
2486 $installer::globals
::englishlicense
= installer
::files
::read_file
($$licensefileref);
2487 installer
::scpzipfiles
::replace_all_ziplistvariables_in_file
($installer::globals
::englishlicense
, $variableshashref);
2490 ################################################
2491 # Adding the content of the English license
2492 # file into the system integration packages.
2493 ################################################
2495 sub _add_license_into_systemintegrationpackages
2497 my ($destdir, $packages) = @_;
2499 for ( my $i = 0; $i <= $#{$packages}; $i++ )
2501 my $copyrightfilename = ${$packages}[$i] . $installer::globals
::separator
. "install" . $installer::globals
::separator
. "copyright";
2502 if ( ! -f
$copyrightfilename ) { installer
::exiter
::exit_program
("ERROR: Could not find license file in system integration package: $copyrightfilename!", "add_license_into_systemintegrationpackages"); }
2503 my $copyrightfile = installer
::files
::read_file
($copyrightfilename);
2505 # Saving time stamp of old copyrightfile
2506 my $savcopyrightfilename = $copyrightfilename . ".sav";
2507 installer
::systemactions
::copy_one_file
($copyrightfilename, $savcopyrightfilename);
2508 _set_time_stamp_for_file
($copyrightfilename, $savcopyrightfilename); # now $savcopyrightfile has the time stamp of $copyrightfile
2510 # Adding license content to copyright file
2511 push(@
{$copyrightfile}, "\n");
2512 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
2513 installer
::files
::save_file
($copyrightfilename, $copyrightfile);
2515 # Setting the old time stamp saved with $savcopyrightfilename
2516 _set_time_stamp_for_file
($savcopyrightfilename, $copyrightfilename); # now $copyrightfile has the time stamp of $savcopyrightfile
2517 unlink($savcopyrightfilename);
2519 # Changing content of copyright file in pkgmap
2520 my $pkgmapfilename = ${$packages}[$i] . $installer::globals
::separator
. "pkgmap";
2521 if ( ! -f
$pkgmapfilename ) { installer
::exiter
::exit_program
("ERROR: Could not find pkgmap in system integration package: $pkgmapfilename!", "add_license_into_systemintegrationpackages"); }
2522 my $pkgmap = installer
::files
::read_file
($pkgmapfilename);
2523 _change_onefile_in_pkgmap
($pkgmap, $copyrightfilename, "copyright");
2524 installer
::files
::save_file
($pkgmapfilename, $pkgmap);
2528 ##############################################
2529 # Setting time stamp of copied files to avoid
2530 # errors from pkgchk.
2531 ##############################################
2533 sub _set_time_stamp_for_file
2535 my ($sourcefile, $destfile) = @_;
2537 my $systemcall = "touch -r $sourcefile $destfile";
2539 my $returnvalue = system($systemcall);
2541 my $infoline = "Systemcall: $systemcall\n";
2542 push( @installer::globals
::logfileinfo
, $infoline);
2546 $infoline = "ERROR: \"$systemcall\" failed!\n";
2547 push( @installer::globals
::logfileinfo
, $infoline);
2551 $infoline = "Success: \"$systemcall\" !\n";
2552 push( @installer::globals
::logfileinfo
, $infoline);
2556 ##############################################
2557 # Setting checksum and wordcount for changed
2558 # pkginfo file into pkgmap.
2559 ##############################################
2561 sub _change_onefile_in_pkgmap
2563 my ($pkgmapfile, $fullfilename, $shortfilename) = @_;
2565 # 1 i pkginfo 442 34577 1166716297
2567 # 1 i pkginfo 443 34737 1166716297
2569 # wc -c pkginfo | cut -f6 -d' ' -> 442 (variable)
2570 # sum pkginfo | cut -f1 -d' ' -> 34577 (variable)
2571 # grep 'pkginfo' pkgmap | cut -f6 -d' ' -> 1166716297 (fix)
2573 my $checksum = _call_sum
($fullfilename);
2574 if ( $checksum =~ /^\s*(\d+)\s+.*$/ ) { $checksum = $1; }
2576 my $wordcount = _call_wc
($fullfilename);
2577 if ( $wordcount =~ /^\s*(\d+)\s+.*$/ ) { $wordcount = $1; }
2579 for ( my $i = 0; $i <= $#{$pkgmapfile}; $i++ )
2581 if ( ${$pkgmapfile}[$i] =~ /(^.*\b\Q$shortfilename\E\b\s+)(\d+)(\s+)(\d+)(\s+)(\d+)(\s*$)/ )
2583 my $newline = $1 . $wordcount . $3 . $checksum . $5 . $6 . $7;
2584 ${$pkgmapfile}[$i] = $newline;
2590 #########################################################
2592 #########################################################
2596 my ($filename) = @_;
2598 $sumfile = "/usr/bin/sum";
2600 if ( ! -f
$sumfile ) { installer
::exiter
::exit_program
("ERROR: No file /usr/bin/sum", "call_sum"); }
2602 my $systemcall = "$sumfile $filename |";
2606 open (SUM
, "$systemcall");
2610 my $returnvalue = $?
; # $? contains the return value of the systemcall
2612 my $infoline = "Systemcall: $systemcall\n";
2613 push( @installer::globals
::logfileinfo
, $infoline);
2617 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2618 push( @installer::globals
::logfileinfo
, $infoline);
2622 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2623 push( @installer::globals
::logfileinfo
, $infoline);
2629 #########################################################
2631 # wc -c pkginfo | cut -f6 -d' '
2632 #########################################################
2636 my ($filename) = @_;
2638 $wcfile = "/usr/bin/wc";
2640 if ( ! -f
$wcfile ) { installer
::exiter
::exit_program
("ERROR: No file /usr/bin/wc", "call_wc"); }
2642 my $systemcall = "$wcfile -c $filename |";
2646 open (WC
, "$systemcall");
2650 my $returnvalue = $?
; # $? contains the return value of the systemcall
2652 my $infoline = "Systemcall: $systemcall\n";
2653 push( @installer::globals
::logfileinfo
, $infoline);
2657 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2658 push( @installer::globals
::logfileinfo
, $infoline);
2662 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2663 push( @installer::globals
::logfileinfo
, $infoline);