← Index
NYTProf Performance Profile   « block view • line view • sub view »
For C:/lo/libo-master/solenv/bin/make_installer.pl
  Run on Mon Sep 24 00:52:54 2012
Reported on Mon Sep 24 07:34:51 2012

Filename/cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer/epmfile.pm
StatementsExecuted 27 statements in 32.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1117.43ms7.86msinstaller::epmfile::::BEGIN@36installer::epmfile::BEGIN@36
1113.31ms22.2msinstaller::epmfile::::BEGIN@42installer::epmfile::BEGIN@42
111346µs445µsinstaller::epmfile::::BEGIN@30installer::epmfile::BEGIN@30
11118µs20µsinstaller::epmfile::::BEGIN@37installer::epmfile::BEGIN@37
11118µs20µsinstaller::epmfile::::BEGIN@41installer::epmfile::BEGIN@41
11116µs19µsinstaller::epmfile::::BEGIN@31installer::epmfile::BEGIN@31
11116µs18µsinstaller::epmfile::::BEGIN@40installer::epmfile::BEGIN@40
11115µs45µsinstaller::epmfile::::BEGIN@35installer::epmfile::BEGIN@35
11114µs17µsinstaller::epmfile::::BEGIN@38installer::epmfile::BEGIN@38
11114µs17µsinstaller::epmfile::::BEGIN@32installer::epmfile::BEGIN@32
11114µs17µsinstaller::epmfile::::BEGIN@33installer::epmfile::BEGIN@33
11113µs15µsinstaller::epmfile::::BEGIN@34installer::epmfile::BEGIN@34
11112µs15µsinstaller::epmfile::::BEGIN@39installer::epmfile::BEGIN@39
0000s0sinstaller::epmfile::::add_one_line_into_fileinstaller::epmfile::add_one_line_into_file
0000s0sinstaller::epmfile::::add_scripts_into_prototypefileinstaller::epmfile::add_scripts_into_prototypefile
0000s0sinstaller::epmfile::::adding_header_to_epm_fileinstaller::epmfile::adding_header_to_epm_file
0000s0sinstaller::epmfile::::adding_shellscripts_to_epm_fileinstaller::epmfile::adding_shellscripts_to_epm_file
0000s0sinstaller::epmfile::::analyze_rootpathinstaller::epmfile::analyze_rootpath
0000s0sinstaller::epmfile::::call_epminstaller::epmfile::call_epm
0000s0sinstaller::epmfile::::collect_modules_with_styleinstaller::epmfile::collect_modules_with_style
0000s0sinstaller::epmfile::::collect_patch_filesinstaller::epmfile::collect_patch_files
0000s0sinstaller::epmfile::::contains_extension_dirinstaller::epmfile::contains_extension_dir
0000s0sinstaller::epmfile::::control_subdirectoriesinstaller::epmfile::control_subdirectories
0000s0sinstaller::epmfile::::copy_and_unpack_tar_gz_filesinstaller::epmfile::copy_and_unpack_tar_gz_files
0000s0sinstaller::epmfile::::create_epm_headerinstaller::epmfile::create_epm_header
0000s0sinstaller::epmfile::::create_new_directory_structureinstaller::epmfile::create_new_directory_structure
0000s0sinstaller::epmfile::::create_packages_without_epminstaller::epmfile::create_packages_without_epm
0000s0sinstaller::epmfile::::determine_installdir_oooinstaller::epmfile::determine_installdir_ooo
0000s0sinstaller::epmfile::::determine_rpm_versioninstaller::epmfile::determine_rpm_version
0000s0sinstaller::epmfile::::finalize_linux_patchinstaller::epmfile::finalize_linux_patch
0000s0sinstaller::epmfile::::finalize_patchinstaller::epmfile::finalize_patch
0000s0sinstaller::epmfile::::find_epm_on_systeminstaller::epmfile::find_epm_on_system
0000s0sinstaller::epmfile::::fix_architecture_settinginstaller::epmfile::fix_architecture_setting
0000s0sinstaller::epmfile::::get_ld_preload_stringinstaller::epmfile::get_ld_preload_string
0000s0sinstaller::epmfile::::get_solaris_language_for_langpackinstaller::epmfile::get_solaris_language_for_langpack
0000s0sinstaller::epmfile::::include_classes_into_pkginfoinstaller::epmfile::include_classes_into_pkginfo
0000s0sinstaller::epmfile::::include_languageinfos_into_pkginfoinstaller::epmfile::include_languageinfos_into_pkginfo
0000s0sinstaller::epmfile::::include_patchinfos_into_pkginfoinstaller::epmfile::include_patchinfos_into_pkginfo
0000s0sinstaller::epmfile::::is_extension_packageinstaller::epmfile::is_extension_package
0000s0sinstaller::epmfile::::log_rpm_infoinstaller::epmfile::log_rpm_info
0000s0sinstaller::epmfile::::make_prototypefile_relocatableinstaller::epmfile::make_prototypefile_relocatable
0000s0sinstaller::epmfile::::make_systemcallinstaller::epmfile::make_systemcall
0000s0sinstaller::epmfile::::prepare_packagesinstaller::epmfile::prepare_packages
0000s0sinstaller::epmfile::::put_directories_into_epmfileinstaller::epmfile::put_directories_into_epmfile
0000s0sinstaller::epmfile::::put_files_into_epmfileinstaller::epmfile::put_files_into_epmfile
0000s0sinstaller::epmfile::::put_links_into_epmfileinstaller::epmfile::put_links_into_epmfile
0000s0sinstaller::epmfile::::put_packagenames_into_dependfileinstaller::epmfile::put_packagenames_into_dependfile
0000s0sinstaller::epmfile::::put_systemintegration_into_installsetinstaller::epmfile::put_systemintegration_into_installset
0000s0sinstaller::epmfile::::put_unixlinks_into_epmfileinstaller::epmfile::put_unixlinks_into_epmfile
0000s0sinstaller::epmfile::::read_packagemapinstaller::epmfile::read_packagemap
0000s0sinstaller::epmfile::::remove_modules_without_packageinstaller::epmfile::remove_modules_without_package
0000s0sinstaller::epmfile::::remove_temporary_epm_filesinstaller::epmfile::remove_temporary_epm_files
0000s0sinstaller::epmfile::::replace_many_variables_in_shellscriptsinstaller::epmfile::replace_many_variables_in_shellscripts
0000s0sinstaller::epmfile::::replace_one_variable_in_fileinstaller::epmfile::replace_one_variable_in_file
0000s0sinstaller::epmfile::::replace_variable_in_shellscriptsinstaller::epmfile::replace_variable_in_shellscripts
0000s0sinstaller::epmfile::::replace_variables_in_shellscriptsinstaller::epmfile::replace_variables_in_shellscripts
0000s0sinstaller::epmfile::::replace_variables_in_shellscripts_for_patchinstaller::epmfile::replace_variables_in_shellscripts_for_patch
0000s0sinstaller::epmfile::::resolve_path_in_epm_list_before_packaginginstaller::epmfile::resolve_path_in_epm_list_before_packaging
0000s0sinstaller::epmfile::::set_autoprovreq_in_specfileinstaller::epmfile::set_autoprovreq_in_specfile
0000s0sinstaller::epmfile::::set_license_in_specfileinstaller::epmfile::set_license_in_specfile
0000s0sinstaller::epmfile::::set_maxinst_in_pkginfoinstaller::epmfile::set_maxinst_in_pkginfo
0000s0sinstaller::epmfile::::set_packager_in_specfileinstaller::epmfile::set_packager_in_specfile
0000s0sinstaller::epmfile::::set_patch_stateinstaller::epmfile::set_patch_state
0000s0sinstaller::epmfile::::set_patchinfoinstaller::epmfile::set_patchinfo
0000s0sinstaller::epmfile::::set_patchlist_in_pkginfo_for_respininstaller::epmfile::set_patchlist_in_pkginfo_for_respin
0000s0sinstaller::epmfile::::set_prereq_in_specfileinstaller::epmfile::set_prereq_in_specfile
0000s0sinstaller::epmfile::::set_revision_in_pkginfoinstaller::epmfile::set_revision_in_pkginfo
0000s0sinstaller::epmfile::::set_solaris_parameter_in_pkginfoinstaller::epmfile::set_solaris_parameter_in_pkginfo
0000s0sinstaller::epmfile::::set_tab_into_datafileinstaller::epmfile::set_tab_into_datafile
0000s0sinstaller::epmfile::::set_timestamp_in_patchinfoinstaller::epmfile::set_timestamp_in_patchinfo
0000s0sinstaller::epmfile::::set_topdir_in_specfileinstaller::epmfile::set_topdir_in_specfile
0000s0sinstaller::epmfile::::unpack_tar_gz_fileinstaller::epmfile::unpack_tar_gz_file
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org. If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28package installer::epmfile;
29
30263µs2544µs
# spent 445µs (346+99) within installer::epmfile::BEGIN@30 which was called: # once (346µs+99µs) by installer::BEGIN@41 at line 30
use Cwd;
# spent 445µs making 1 call to installer::epmfile::BEGIN@30 # spent 99µs making 1 call to Exporter::import
31257µs222µs
# spent 19µs (16+3) within installer::epmfile::BEGIN@31 which was called: # once (16µs+3µs) by installer::BEGIN@41 at line 31
use installer::converter;
# spent 19µs making 1 call to installer::epmfile::BEGIN@31 # spent 3µs making 1 call to UNIVERSAL::import
32252µs220µs
# spent 17µs (14+3) within installer::epmfile::BEGIN@32 which was called: # once (14µs+3µs) by installer::BEGIN@41 at line 32
use installer::exiter;
# spent 17µs making 1 call to installer::epmfile::BEGIN@32 # spent 3µs making 1 call to UNIVERSAL::import
33253µs220µs
# spent 17µs (14+3) within installer::epmfile::BEGIN@33 which was called: # once (14µs+3µs) by installer::BEGIN@41 at line 33
use installer::files;
# spent 17µs making 1 call to installer::epmfile::BEGIN@33 # spent 3µs making 1 call to UNIVERSAL::import
34250µs217µs
# spent 15µs (13+2) within installer::epmfile::BEGIN@34 which was called: # once (13µs+2µs) by installer::BEGIN@41 at line 34
use installer::globals;
# spent 15µs making 1 call to installer::epmfile::BEGIN@34 # spent 2µs making 1 call to UNIVERSAL::import
35257µs274µs
# spent 45µs (15+30) within installer::epmfile::BEGIN@35 which was called: # once (15µs+30µs) by installer::BEGIN@41 at line 35
use installer::logger;
# spent 45µs making 1 call to installer::epmfile::BEGIN@35 # spent 30µs making 1 call to Exporter::import
3621.03ms27.87ms
# spent 7.86ms (7.43+429µs) within installer::epmfile::BEGIN@36 which was called: # once (7.43ms+429µs) by installer::BEGIN@41 at line 36
use installer::packagelist;
# spent 7.86ms making 1 call to installer::epmfile::BEGIN@36 # spent 4µs making 1 call to UNIVERSAL::import
37257µs223µs
# spent 20µs (18+3) within installer::epmfile::BEGIN@37 which was called: # once (18µs+3µs) by installer::BEGIN@41 at line 37
use installer::pathanalyzer;
# spent 20µs making 1 call to installer::epmfile::BEGIN@37 # spent 2µs making 1 call to UNIVERSAL::import
38251µs220µs
# spent 17µs (14+3) within installer::epmfile::BEGIN@38 which was called: # once (14µs+3µs) by installer::BEGIN@41 at line 38
use installer::remover;
# spent 17µs making 1 call to installer::epmfile::BEGIN@38 # spent 3µs making 1 call to UNIVERSAL::import
39251µs217µs
# spent 15µs (12+3) within installer::epmfile::BEGIN@39 which was called: # once (12µs+3µs) by installer::BEGIN@41 at line 39
use installer::scriptitems;
# spent 15µs making 1 call to installer::epmfile::BEGIN@39 # spent 3µs making 1 call to UNIVERSAL::import
40252µs220µs
# spent 18µs (16+2) within installer::epmfile::BEGIN@40 which was called: # once (16µs+2µs) by installer::BEGIN@41 at line 40
use installer::systemactions;
# spent 18µs making 1 call to installer::epmfile::BEGIN@40 # spent 2µs making 1 call to UNIVERSAL::import
41254µs223µs
# spent 20µs (18+3) within installer::epmfile::BEGIN@41 which was called: # once (18µs+3µs) by installer::BEGIN@41 at line 41
use installer::worker;
# spent 20µs making 1 call to installer::epmfile::BEGIN@41 # spent 2µs making 1 call to UNIVERSAL::import
42230.6ms232.1ms
# spent 22.2ms (3.31+18.9) within installer::epmfile::BEGIN@42 which was called: # once (3.31ms+18.9ms) by installer::BEGIN@41 at line 42
use POSIX;
# spent 22.2ms making 1 call to installer::epmfile::BEGIN@42 # spent 9.88ms making 1 call to POSIX::import
43
44############################################################################
45# Reading the package map to find Solaris package names for
46# the corresponding abbreviations
47############################################################################
48
49sub read_packagemap
50{
51 my ($allvariables, $includepatharrayref, $languagesarrayref) = @_;
52
53 my $packagemapname = "";
54 if ( $allvariables->{'PACKAGEMAP'} ) { $packagemapname = $allvariables->{'PACKAGEMAP'}; }
55 if ( $packagemapname eq "" ) { installer::exiter::exit_program("ERROR: Property PACKAGEMAP must be defined!", "read_packagemap"); }
56
57 my $infoline = "\n\nCollected abbreviations and package names:\n";
58 push(@installer::globals::logfileinfo, $infoline);
59
60 # Can be a comma separated list. All files have to be found in include paths
61 my $allpackagemapnames = installer::converter::convert_stringlist_into_hash(\$packagemapname, ",");
62 foreach my $onepackagemapname ( keys %{$allpackagemapnames} )
63 {
64 my $packagemapref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onepackagemapname, $includepatharrayref, 0);
65
66 if ( $$packagemapref eq "" ) { installer::exiter::exit_program("ERROR: Could not find package map file \"$onepackagemapname\" (propery PACKAGEMAP)!", "read_packagemap"); }
67
68 my $packagemapcontent = installer::files::read_file($$packagemapref);
69
70 for ( my $i = 0; $i <= $#{$packagemapcontent}; $i++ )
71 {
72 my $line = ${$packagemapcontent}[$i];
73
74 if ( $line =~ /^\s*\#/ ) { next; } # comment line
75 if ( $line =~ /^\s*$/ ) { next; } # empty line
76
77 if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ )
78 {
79 my $abbreviation = $1;
80 my $packagename = $2;
81 installer::packagelist::resolve_packagevariables(\$abbreviation, $allvariables, 0);
82 installer::packagelist::resolve_packagevariables(\$packagename, $allvariables, 0);
83
84 # Special handling for language strings %LANGUAGESTRING
85
86 if (( $abbreviation =~ /\%LANGUAGESTRING/ ) || ( $packagename =~ /\%LANGUAGESTRING/ ))
87 {
88 foreach my $onelang ( @{$languagesarrayref} )
89 {
90 my $local_abbreviation = $abbreviation;
91 my $local_packagename = $packagename;
92 $local_abbreviation =~ s/\%LANGUAGESTRING/$onelang/g;
93 $local_packagename =~ s/\%LANGUAGESTRING/$onelang/g;
94
95 # Logging all abbreviations and packagenames
96 $infoline = "$onelang : $local_abbreviation : $local_packagename\n";
97 push(@installer::globals::logfileinfo, $infoline);
98
99 if ( exists($installer::globals::dependfilenames{$local_abbreviation}) )
100 {
101 installer::exiter::exit_program("ERROR: Packagename for Solaris package $local_abbreviation already defined ($installer::globals::dependfilenames{$local_abbreviation})!", "read_packagemap");
102 }
103 else
104 {
105 $installer::globals::dependfilenames{$local_abbreviation} = $local_packagename;
106 }
107 }
108 }
109 else
110 {
111 # Logging all abbreviations and packagenames
112 $infoline = "$abbreviation : $packagename\n";
113 push(@installer::globals::logfileinfo, $infoline);
114
115 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
116 {
117 installer::exiter::exit_program("ERROR: Packagename for Solaris package $abbreviation already defined ($installer::globals::dependfilenames{$abbreviation})!", "read_packagemap");
118 }
119 else
120 {
121 $installer::globals::dependfilenames{$abbreviation} = $packagename;
122 }
123 }
124 }
125 else
126 {
127 my $errorline = $i + 1;
128 installer::exiter::exit_program("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap");
129 }
130 }
131 }
132
133 $infoline = "\n\n";
134 push(@installer::globals::logfileinfo, $infoline);
135
136}
137
138##########################################################
139# Filling the epm file with directories, files and links
140##########################################################
141
142sub put_directories_into_epmfile
143{
144 my ($directoriesarrayref, $epmfileref, $allvariables, $packagerootpath) = @_;
145 my $group = "bin";
146
147 if ( $installer::globals::islinuxbuild )
148 {
149 $group = "root";
150 }
151
152 for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ )
153 {
154 my $onedir = ${$directoriesarrayref}[$i];
155 my $dir = "";
156
157 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
158
159 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
160 {
161 my $hostname = $onedir->{'HostName'};
162
163 my $line = "d 755 root $group $hostname -\n";
164
165 push(@{$epmfileref}, $line)
166 }
167 }
168}
169
170sub put_files_into_epmfile
171{
172 my ($filesinproductarrayref, $epmfileref) = @_;
173
174 for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ )
175 {
176 my $onefile = ${$filesinproductarrayref}[$i];
177
178 my $unixrights = $onefile->{'UnixRights'};
179 my $destination = $onefile->{'destination'};
180 my $sourcepath = $onefile->{'sourcepath'};
181
182 my $filetype = "f";
183 my $styles = "";
184 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
185 if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; }
186
187 my $group = "bin";
188 if ( $installer::globals::islinuxbuild ) { $group = "root"; }
189 if (( $installer::globals::issolarisbuild ) && ( $onefile->{'SolarisGroup'} )) { $group = $onefile->{'SolarisGroup'}; }
190
191 my $line = "$filetype $unixrights root $group $destination $sourcepath\n";
192
193 push(@{$epmfileref}, $line);
194 }
195}
196
197sub put_links_into_epmfile
198{
199 my ($linksinproductarrayref, $epmfileref) = @_;
200 my $group = "bin";
201
202 if ( $installer::globals::islinuxbuild )
203 {
204 $group = "root";
205 }
206
207
208 for ( my $i = 0; $i <= $#{$linksinproductarrayref}; $i++ )
209 {
210 my $onelink = ${$linksinproductarrayref}[$i];
211 my $destination = $onelink->{'destination'};
212 my $destinationfile = $onelink->{'destinationfile'};
213
214 my $line = "l 000 root $group $destination $destinationfile\n";
215
216 push(@{$epmfileref}, $line)
217 }
218}
219
220sub put_unixlinks_into_epmfile
221{
222 my ($unixlinksinproductarrayref, $epmfileref) = @_;
223 my $group = "bin";
224
225 if ( $installer::globals::islinuxbuild ) { $group = "root"; }
226
227 for ( my $i = 0; $i <= $#{$unixlinksinproductarrayref}; $i++ )
228 {
229 my $onelink = ${$unixlinksinproductarrayref}[$i];
230 my $destination = $onelink->{'destination'};
231 my $target = $onelink->{'Target'};
232
233 my $line = "l 000 root $group $destination $target\n";
234
235 push(@{$epmfileref}, $line)
236 }
237}
238
239###############################################
240# Creating epm header file
241###############################################
242
243sub create_epm_header
244{
245 my ($variableshashref, $filesinproduct, $languagesref, $onepackage) = @_;
246
247 my @epmheader = ();
248
249 my ($licensefilename, $readmefilename, $readmefilenameen);
250
251 my $foundlicensefile = 0;
252 my $foundreadmefile = 0;
253
254 my $line = "";
255 my $infoline = "";
256
257 # %product LibreOffice Software
258 # %version 2.0
259 # %description A really great software
260 # %copyright 1999-2003 by OOo
261 # %vendor LibreOffice
262 # %license /test/replace/01/LICENSE01
263 # %readme /test/replace/01/README01
264 # %requires foo
265 # %provides bar
266
267 # The first language in the languages array determines the language of license and readme file
268
269 my $searchlanguage = ${$languagesref}[0];
270
271 # using the description for the %product line in the epm list file
272
273 my $productnamestring = $onepackage->{'description'};
274 installer::packagelist::resolve_packagevariables(\$productnamestring, $variableshashref, 0);
275 if ( $variableshashref->{'PRODUCTEXTENSION'} ) { $productnamestring = $productnamestring . " " . $variableshashref->{'PRODUCTEXTENSION'}; }
276
277 $line = "%product" . " " . $productnamestring . "\n";
278 push(@epmheader, $line);
279
280 # Determining the release version
281 # This release version has to be listed in the line %version : %version versionnumber releasenumber
282
283 if ( ! $onepackage->{'packageversion'} ) { installer::exiter::exit_program("ERROR: No packageversion defined for package: $onepackage->{'module'}!", "create_epm_header"); }
284 $installer::globals::packageversion = $onepackage->{'packageversion'};
285 installer::packagelist::resolve_packagevariables(\$installer::globals::packageversion, $variableshashref, 0);
286 if ( $variableshashref->{'PACKAGEREVISION'} ) { $installer::globals::packagerevision = $variableshashref->{'PACKAGEREVISION'}; }
287
288 $line = "%version" . " " . $installer::globals::packageversion . "\n";
289 push(@epmheader, $line);
290
291 $line = "%release" . " " . $installer::globals::packagerevision . "\n";
292 if ( $installer::globals::isrpmbuild ) { $line = "%release" . " " . $installer::globals::buildid . "\n"; }
293 push(@epmheader, $line);
294
295 # Description, Copyright and Vendor are multilingual and are defined in
296 # the string file for the header file ($headerfileref)
297
298 my $descriptionstring = $onepackage->{'description'};
299 installer::packagelist::resolve_packagevariables(\$descriptionstring, $variableshashref, 0);
300 $line = "%description" . " " . $descriptionstring . "\n";
301 push(@epmheader, $line);
302
303 my $copyrightstring = $onepackage->{'copyright'};
304 installer::packagelist::resolve_packagevariables(\$copyrightstring, $variableshashref, 0);
305 $line = "%copyright" . " " . $copyrightstring . "\n";
306 push(@epmheader, $line);
307
308 my $vendorstring = $onepackage->{'vendor'};
309 installer::packagelist::resolve_packagevariables(\$vendorstring, $variableshashref, 0);
310 $line = "%vendor" . " " . $vendorstring . "\n";
311 push(@epmheader, $line);
312
313 # License and Readme file can be included automatically from the file list
314
315 if ( $installer::globals::iswindowsbuild )
316 {
317 $licensefilename = "license.txt";
318 $readmefilename = "readme.txt";
319 $readmefilenameen = "readme_en-US.txt";
320 }
321 else
322 {
323 $licensefilename = "LICENSE";
324 $readmefilename = "README";
325 $readmefilenameen = "README_en-US";
326 }
327
328 if (( $installer::globals::languagepack ) # in language packs and help packs the files LICENSE and README are removed, because they are not language specific
329 || ( $installer::globals::helppack )
330 || ( $variableshashref->{'NO_README_IN_ROOTDIR'} ))
331 {
332 if ( $installer::globals::iswindowsbuild )
333 {
334 $licensefilename = "license.txt"; # _$searchlanguage.txt";
335 $readmefilename = "readme_$searchlanguage.txt";
336 }
337 else
338 {
339 $licensefilename = "LICENSE"; # _$searchlanguage";
340 $readmefilename = "README_$searchlanguage";
341 }
342 }
343
344 my $license_in_package_defined = 0;
345
346 if ( $installer::globals::issolarisbuild )
347 {
348 if ( $onepackage->{'solariscopyright'} )
349 {
350 $licensefilename = $onepackage->{'solariscopyright'};
351 $license_in_package_defined = 1;
352 }
353 }
354
355 # Process for Linux packages, in which only a very basic license file is
356 # included into the package.
357
358 if ( $installer::globals::islinuxbuild )
359 {
360 if ( $variableshashref->{'COPYRIGHT_INTO_LINUXPACKAGE'} )
361 {
362 $licensefilename = "linuxcopyrightfile";
363 $license_in_package_defined = 1;
364 }
365 }
366
367 # searching for and readme file;
368 # URE uses special README; others use README_en-US
369 # it does not matter which one is passed for epm if both are packaged
370 foreach my $possiblereadmefilename ($readmefilenameen, $readmefilename)
371 {
372 last if ($foundreadmefile);
373 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
374 {
375 my $onefile = ${$filesinproduct}[$i];
376 my $filename = $onefile->{'Name'};
377 if ( $filename eq $possiblereadmefilename )
378 {
379 $foundreadmefile = 1;
380 $line = "%readme" . " " . $onefile->{'sourcepath'} . "\n";
381 push(@epmheader, $line);
382 last;
383 }
384 }
385 }
386
387 # the readme file need not be packaged more times in the help content
388 # it needs to be installed in parallel with the main package anyway
389 # try to find the README file between all available files (not only between the packaged)
390 if (!($foundreadmefile) && $installer::globals::helppack)
391 {
392 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$readmefilenameen, "" , 0);
393 if($$fileref ne "" )
394 {
395 $infoline = "Fallback to readme file: \"$$fileref\"!\n";
396 push(@installer::globals::logfileinfo, $infoline);
397
398 $foundreadmefile = 1;
399 $line = "%readme" . " " . $$fileref . "\n";
400 push(@epmheader, $line);
401 }
402 }
403
404 # searching for and license file
405
406 if ( $license_in_package_defined )
407 {
408 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
409
410 if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (A)!", "create_epm_header"); }
411
412 # Special handling to add the content of the file "license_en-US" to the solaris copyrightfile. But not for all products
413
414 if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} ))
415 {
416 if ( ! $installer::globals::englishlicenseset ) { installer::worker::set_english_license() }
417
418 # The location for the new file
419 my $languagestring = "";
420 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; }
421 $languagestring =~ s/^\s*_//;
422
423 my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring);
424
425 my $copyrightfile = installer::files::read_file($$fileref);
426
427 # Adding license content to copyright file
428 push(@{$copyrightfile}, "\n");
429 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
430
431 # New destination for $$fileref
432 $$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'};
433 if ( -f $$fileref ) { unlink $$fileref; }
434 installer::files::save_file($$fileref, $copyrightfile);
435 }
436
437 $infoline = "Using license file: \"$$fileref\"!\n";
438 push(@installer::globals::logfileinfo, $infoline);
439
440 $foundlicensefile = 1;
441 $line = "%license" . " " . $$fileref . "\n";
442 push(@epmheader, $line);
443 }
444 else
445 {
446 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
447 {
448 my $onefile = ${$filesinproduct}[$i];
449 my $filename = $onefile->{'Name'};
450
451 if ( $filename eq $licensefilename )
452 {
453 $foundlicensefile = 1;
454 $line = "%license" . " " . $onefile->{'sourcepath'} . "\n";
455 push(@epmheader, $line);
456 last;
457 }
458 }
459
460 # the license file need not be packaged more times in the langpacks
461 # they need to be installed in parallel with the main package anyway
462 # try to find the LICENSE file between all available files (not only between the packaged)
463 if (!($foundlicensefile) && ($installer::globals::languagepack || $installer::globals::helppack))
464 {
465 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
466 if($$fileref ne "" )
467 {
468 $infoline = "Fallback to license file: \"$$fileref\"!\n";
469 push(@installer::globals::logfileinfo, $infoline);
470
471 $foundlicensefile = 1;
472 $line = "%license" . " " . $$fileref . "\n";
473 push(@epmheader, $line);
474 }
475 }
476 }
477
478 if (!($foundlicensefile))
479 {
480 installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (B)", "create_epm_header");
481 }
482
483 if (!($foundreadmefile))
484 {
485 installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename (C)", "create_epm_header");
486 }
487
488 # including %replaces
489
490 my $replaces = "";
491
492 if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch ))
493 {
494 $replaces = "solarisreplaces"; # the name in the packagelist
495 }
496 elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch ))
497 {
498 $replaces = "linuxreplaces"; # the name in the packagelist
499 }
500
501 if (( $replaces ) && ( ! $installer::globals::patch ))
502 {
503 if ( $onepackage->{$replaces} )
504 {
505 my $replacesstring = $onepackage->{$replaces};
506
507 my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ",");
508
509 for ( my $i = 0; $i <= $#{$allreplaces}; $i++ )
510 {
511 my $onereplaces = ${$allreplaces}[$i];
512 $onereplaces =~ s/\s*$//;
513 installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1);
514 $line = "%replaces" . " " . $onereplaces . "\n";
515 push(@epmheader, $line);
516
517 # Force the openofficeorg packages to get removed,
518 # see http://www.debian.org/doc/debian-policy/ch-relationships.html
519 # 7.5.2 Replacing whole packages, forcing their removal
520
521 if ( $installer::globals::debian )
522 {
523 $line = "%incompat" . " " . $onereplaces . "\n";
524 push(@epmheader, $line);
525 }
526 }
527
528 if ( $installer::globals::debian && $variableshashref->{'UNIXPRODUCTNAME'} eq 'libreoffice' )
529 {
530 $line = "%provides" . " libreoffice-unbundled\n";
531 push(@epmheader, $line);
532 $line = "%incompat" . " libreoffice-bundled\n";
533 push(@epmheader, $line);
534 }
535 }
536 }
537
538 # including the directives for %requires and %provides
539
540 my $provides = "";
541 my $requires = "";
542
543 if ( $installer::globals::issolarispkgbuild )
544 {
545 $provides = "solarisprovides"; # the name in the packagelist
546 $requires = "solarisrequires"; # the name in the packagelist
547 }
548 elsif ( $installer::globals::isfreebsdpkgbuild )
549 {
550 $provides = "freebsdprovides"; # the name in the packagelist
551 $requires = "freebsdrequires"; # the name in the packagelist
552 }
553 elsif (( $installer::globals::isrpmbuild ) &&
554 ( $installer::globals::patch ) &&
555 ( exists($onepackage->{'linuxpatchrequires'}) ))
556 {
557 $provides = "provides"; # the name in the packagelist
558 $requires = "linuxpatchrequires"; # the name in the packagelist
559 }
560 else
561 {
562 $provides = "provides"; # the name in the packagelist
563 $requires = "requires"; # the name in the packagelist
564 }
565
566 my $isdict = 0;
567 if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; }
568
569 if ( $onepackage->{$provides} )
570 {
571 my $providesstring = $onepackage->{$provides};
572
573 my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ",");
574
575 for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
576 {
577 my $oneprovides = ${$allprovides}[$i];
578 $oneprovides =~ s/\s*$//;
579 installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1);
580 $line = "%provides" . " " . $oneprovides . "\n";
581 push(@epmheader, $line);
582 }
583 }
584
585 if ( $onepackage->{$requires} )
586 {
587 my $requiresstring = $onepackage->{$requires};
588
589 # The requires string can contain the separator "," in the names (descriptions) of the packages
590 # (that are required for Solaris depend files). Therefore "," inside such a description has to
591 # masked with a backslash.
592 # This masked separator need to be found and replaced, before the stringlist is converted into an array.
593 # This replacement has to be turned back after the array is created.
594
595 my $replacementstring = "COMMAREPLACEMENT";
596 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
597
598 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
599
600 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
601
602 for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
603 {
604 my $onerequires = ${$allrequires}[$i];
605 $onerequires =~ s/\s*$//;
606 installer::packagelist::resolve_packagevariables2(\$onerequires, $variableshashref, 0, $isdict);
607
608 $line = "%requires" . " " . $onerequires . "\n";
609 push(@epmheader, $line);
610 }
611 }
612
613 return \@epmheader;
614}
615
616#######################################
617# Adding header to epm file
618#######################################
619
620sub adding_header_to_epm_file
621{
622 my ($epmfileref, $epmheaderref) = @_;
623
624 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
625 {
626 push( @{$epmfileref}, ${$epmheaderref}[$i] );
627 }
628
629 push( @{$epmfileref}, "\n\n" );
630}
631
632#####################################################
633# Replace one in shell scripts ( ${VARIABLENAME} )
634#####################################################
635
636sub replace_variable_in_shellscripts
637{
638 my ($scriptref, $variable, $searchstring) = @_;
639
640 for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
641 {
642 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
643 }
644}
645
646################################################
647# Replacing many variables in shell scripts
648################################################
649
650sub replace_many_variables_in_shellscripts
651{
652 my ($scriptref, $variableshashref) = @_;
653
654 my $key;
655
656 foreach $key (keys %{$variableshashref})
657 {
658 my $value = $variableshashref->{$key};
659 replace_variable_in_shellscripts($scriptref, $value, $key);
660 }
661}
662
663#######################################
664# Adding shell scripts to epm file
665#######################################
666
667sub adding_shellscripts_to_epm_file
668{
669 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
670
671 push( @{$epmfileref}, "\n\n" );
672
673 my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename);
674
675 replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath");
676
677 replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref);
678
679 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
680 {
681 push( @{$epmfileref}, ${$shellscriptsfileref}[$i] );
682 }
683
684 push( @{$epmfileref}, "\n" );
685}
686
687#################################################
688# Determining the epm on the system
689#################################################
690
691sub find_epm_on_system
692{
693 my ($includepatharrayref) = @_;
694
695 installer::logger::include_header_into_logfile("Check epm on system");
696
697 my $epmname = "epm";
698
699 # epm should be defined through the configure script but we need to
700 # check for it to be defined because of the Sun environment.
701 # Check the environment variable first and if it is not defined,
702 # or if it is but the location is not executable, search further.
703 # It has to be found in the solver or it has to be in the path
704 # (saved in $installer::globals::epm_in_path) or we get the specified
705 # one through the environment (i.e. when --with-epm=... is specified)
706
707 if ($ENV{'EPM'})
708 {
709 if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}"))
710 {
711 $epmname = $ENV{'EPM'};
712 }
713 elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") )
714 {
715 $epmname = "epm";
716 my $epmref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$epmname, $includepatharrayref, 0);
717 if ($$epmref eq "") { installer::exiter::exit_program("ERROR: Could not find program $epmname (EPM set to \"internal\" or \"no\")!", "find_epm_on_system"); }
718 $epmname = $$epmref;
719 }
720 else
721 {
722 installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
723 }
724 }
725 else
726 {
727 my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0);
728
729 if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
730 if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; }
731 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
732 }
733
734 my $infoline = "Using epmfile: $epmname\n";
735 push( @installer::globals::logfileinfo, $infoline);
736
737 return $epmname;
738}
739
740#################################################
741# Determining the epm patch state
742# saved in $installer::globals::is_special_epm
743#################################################
744
745sub set_patch_state
746{
747 my ($epmexecutable) = @_;
748
749 my $infoline = "";
750
751 my $systemcall = "$epmexecutable |";
752 open (EPMPATCH, "$systemcall");
753
754 while (<EPMPATCH>)
755 {
756 chop;
757 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals::is_special_epm = 1; }
758 }
759
760 close (EPMPATCH);
761
762 if ( $installer::globals::is_special_epm )
763 {
764 $infoline = "\nPatch state: This is a patched version of epm!\n\n";
765 push( @installer::globals::logfileinfo, $infoline);
766 }
767 else
768 {
769 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
770 push( @installer::globals::logfileinfo, $infoline);
771 }
772
773 if ( ( $installer::globals::is_special_epm ) && (($installer::globals::isrpmbuild) || ($installer::globals::issolarispkgbuild)) )
774 {
775 # Special postprocess handling only for Linux RPM and Solaris packages
776 $installer::globals::postprocess_specialepm = 1;
777 $installer::globals::postprocess_standardepm = 0;
778 }
779 else
780 {
781 $installer::globals::postprocess_specialepm = 0;
782 $installer::globals::postprocess_standardepm = 1;
783 }
784}
785
786#################################################
787# LD_PRELOAD string for Debian packages
788#################################################
789
790sub get_ld_preload_string
791{
792 my ($includepatharrayref) = @_;
793
794 my $getuidlibraryname = "getuid.so";
795
796 my $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0);
797 if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); }
798
799 my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
800
801 return $ldpreloadstring;
802}
803
804#################################################
805# Calling epm to create the installation sets
806#################################################
807
808sub call_epm
809{
810 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
811
812 installer::logger::include_header_into_logfile("epm call for $packagename");
813
814 my $packageformat = $installer::globals::packageformat;
815
816 my $localpackagename = $packagename;
817 # Debian allows only lowercase letters in package name
818 if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); }
819
820 my $outdirstring = "";
821 if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
822
823 # Debian package build needs a LD_PRELOAD for correct rights
824
825 my $ldpreloadstring = "";
826
827 if ( $installer::globals::debian ) { $ldpreloadstring = get_ld_preload_string($includepatharrayref) . " "; }
828
829 my $extraflags = "";
830 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
831
832 $extraflags .= ' -g' unless $installer::globals::strip;
833
834 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " -v " . " 2\>\&1 |";
835
836 installer::logger::print_message( "... $systemcall ...\n" );
837
838 my $maxepmcalls = 3;
839
840 for ( my $i = 1; $i <= $maxepmcalls; $i++ )
841 {
842 my @epmoutput = ();
843
844 open (EPM, "$systemcall");
845 while (<EPM>) {push(@epmoutput, $_); }
846 close (EPM);
847
848 my $returnvalue = $?; # $? contains the return value of the systemcall
849
850 my $infoline = "Systemcall (Try $i): $systemcall\n";
851 push( @installer::globals::logfileinfo, $infoline);
852
853 for ( my $j = 0; $j <= $#epmoutput; $j++ )
854 {
855 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
856 push( @installer::globals::logfileinfo, "$epmoutput[$j]");
857 }
858
859 if ($returnvalue)
860 {
861 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
862 push( @installer::globals::logfileinfo, $infoline);
863 if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); }
864 }
865 else
866 {
867 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
868 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
869 push( @installer::globals::logfileinfo, $infoline);
870 last;
871 }
872 }
873}
874
875#####################################################################
876# Adding the new line for relocatables into pkginfo file (Solaris)
877# or spec file (Linux) created by epm
878#####################################################################
879
880sub add_one_line_into_file
881{
882 my ($file, $insertline, $filename) = @_;
883
884 if ( $installer::globals::issolarispkgbuild )
885 {
886 push(@{$file}, $insertline); # simply adding at the end of pkginfo file
887 }
888
889 if ( $installer::globals::isrpmbuild )
890 {
891 # Adding behind the line beginning with: Group:
892
893 my $inserted_line = 0;
894
895 for ( my $i = 0; $i <= $#{$file}; $i++ )
896 {
897 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
898 {
899 splice(@{$file},$i+1,0,$insertline);
900 $inserted_line = 1;
901 last;
902 }
903 }
904
905 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
906 }
907
908 $insertline =~ s/\s*$//; # removing line end for correct logging
909 my $infoline = "Success: Added line $insertline into file $filename!\n";
910 push( @installer::globals::logfileinfo, $infoline);
911}
912
913#####################################################################
914# Setting the revision VERSION=1.9,REV=66 .
915# Also adding the new line: "AutoReqProv: no"
916#####################################################################
917
918sub set_revision_in_pkginfo
919{
920 my ($file, $filename, $variables, $packagename) = @_;
921
922 my $revisionstring = "\,REV\=" . $installer::globals::packagerevision;
923
924 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
925
926 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
927
928 $mday = $mday;
929 $mon = $mon + 1;
930 $year = $year + 1900;
931
932 if ( $mday < 10 ) { $mday = "0" . $mday; }
933 if ( $mon < 10 ) { $mon = "0" . $mon; }
934 $datestring = $year . "." . $mon . "." . $mday;
935 $revisionstring = $revisionstring . "." . $datestring;
936
937 for ( my $i = 0; $i <= $#{$file}; $i++ )
938 {
939 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
940 {
941 my $oldstring = $1;
942 my $newstring = $oldstring . $revisionstring; # also adding the date string
943 ${$file}[$i] =~ s/$oldstring/$newstring/;
944 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
945 push( @installer::globals::logfileinfo, $infoline);
946 last;
947 }
948 }
949
950 # For Update and Patch reasons, this string can also be kept constant
951
952 my $pkgversion = "SOLSPARCPKGVERSION";
953 if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; }
954
955 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
956 {
957 if ( $variables->{$pkgversion} ne "FINALVERSION" )
958 {
959 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
960 # 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
961 # and therefore be set as $pkgversion.
962 # The first part "3.0.0" has to be derived from the
963
964 my $version = $installer::globals::packageversion;
965 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
966 {
967 my $major = $1;
968 my $minor = $2;
969 my $micro = $3;
970
971 my $finalmajor = $major;
972 my $finalminor = $minor;
973 my $finalmicro = 0;
974
975 $version = "$finalmajor.$finalminor.$finalmicro";
976 }
977
978 my $datestring = $variables->{$pkgversion};
979
980 # Allowing some packages to have another date of creation.
981 # They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename"
982
983 my $additionalkey = $pkgversion . "_" . $packagename;
984 if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; }
985
986 my $versionstring = "$version,$datestring";
987
988 for ( my $i = 0; $i <= $#{$file}; $i++ )
989 {
990 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
991 {
992 my $start = $1;
993 my $newstring = $start . $versionstring . "\n"; # setting the complete new string
994 my $oldstring = ${$file}[$i];
995 ${$file}[$i] = $newstring;
996 $oldstring =~ s/\s*$//;
997 $newstring =~ s/\s*$//;
998 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
999 push( @installer::globals::logfileinfo, $infoline);
1000 last;
1001 }
1002 }
1003 }
1004 }
1005}
1006
1007########################################################
1008# Setting Patch information for Respin versions
1009# into pkginfo file. This prevents Respin versions
1010# from patching.
1011########################################################
1012
1013sub set_patchlist_in_pkginfo_for_respin
1014{
1015 my ($changefile, $filename, $allvariables, $packagename) = @_;
1016
1017 my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN";
1018 if ( $installer::globals::issolarisx86build ) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; }
1019
1020 if ( $allvariables->{$patchlistname} )
1021 {
1022 # patchlist separator is a blank
1023 my $allpatchesstring = $allvariables->{$patchlistname};
1024 my @usedpatches = ();
1025
1026 # Analyzing the patchlist
1027 # Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01
1028 # Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01
1029 my $allpatches = installer::converter::convert_whitespace_stringlist_into_array(\$allpatchesstring);
1030
1031 for ( my $i = 0; $i <= $#{$allpatches}; $i++ )
1032 {
1033 my $patchdefinition = ${$allpatches}[$i];
1034
1035 my $patchid = "";
1036 my $symbol = "";
1037 my $constraint = "";
1038 my $isusedpatch = 0;
1039
1040 if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ )
1041 {
1042 $patchid = $1;
1043 $symbol = $2;
1044 $constraint = $3;
1045 }
1046 elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ )) # small syntax check
1047 {
1048 # if there is a bracket in the $patchdefinition, but it does not
1049 # match the if-condition, this is an erroneous definition.
1050 installer::exiter::exit_program("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin");
1051 }
1052 else
1053 {
1054 $patchid = $patchdefinition;
1055 $isusedpatch = 1; # patches without constraint are always included
1056 }
1057
1058 if ( $symbol ne "" )
1059 {
1060 if ( $symbol eq "+" )
1061 {
1062 if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; }
1063 }
1064
1065 if ( $symbol eq "-" )
1066 {
1067 if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; }
1068 }
1069 }
1070
1071 if ( $isusedpatch ) { push(@usedpatches, $patchid); }
1072 }
1073
1074 if ( $#usedpatches > -1 )
1075 {
1076 my $patchstring = installer::converter::convert_array_to_space_separated_string(\@usedpatches);
1077
1078 my $newline = "PATCHLIST=" . $patchstring . "\n";
1079 add_one_line_into_file($changefile, $newline, $filename);
1080
1081 # Adding patch info for each used patch in the patchlist
1082
1083 for ( my $i = 0; $i <= $#usedpatches; $i++ )
1084 {
1085 my $patchid = $usedpatches[$i];
1086 my $key = "PATCH_INFO_" . $patchid;
1087 $key =~ s/\s*$//;
1088
1089 if ( ! $allvariables->{$key} ) { installer::exiter::exit_program("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); }
1090 my $value = set_timestamp_in_patchinfo($allvariables->{$key});
1091 $newline = $key . "=" . $value . "\n";
1092
1093 add_one_line_into_file($changefile, $newline, $filename);
1094 }
1095 }
1096 }
1097}
1098
1099########################################################
1100# Solaris requires, that the time of patch installation
1101# must not be empty.
1102# Format: Mon Mar 24 11:20:56 PDT 2008
1103# Log file: Tue Apr 29 23:26:19 2008 (04:31 min.)
1104# Replace string: ${TIMESTAMP}
1105########################################################
1106
1107sub set_timestamp_in_patchinfo
1108{
1109 my ($value) = @_;
1110
1111 my $currenttime = localtime();
1112
1113 if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ )
1114 {
1115 my $start = $1;
1116 my $year = $2;
1117 $currenttime = $start . "CET " . $year;
1118 }
1119
1120 $value =~ s/\$\{TIMESTAMP\}/$currenttime/;
1121
1122 return $value;
1123}
1124
1125########################################################
1126# Setting MAXINST=1000 into the pkginfo file.
1127########################################################
1128
1129sub set_maxinst_in_pkginfo
1130{
1131 my ($changefile, $filename) = @_;
1132
1133 my $newline = "MAXINST\=1000\n";
1134
1135 add_one_line_into_file($changefile, $newline, $filename);
1136}
1137
1138#############################################################
1139# Setting several Solaris variables into the pkginfo file.
1140#############################################################
1141
1142sub set_solaris_parameter_in_pkginfo
1143{
1144 my ($changefile, $filename, $allvariables) = @_;
1145
1146 my $newline = "";
1147
1148 # SUNW_PRODNAME
1149 # SUNW_PRODVERS
1150 # SUNW_PKGVERS
1151 # Not: SUNW_PKGTYPE
1152 # HOTLINE
1153 # EMAIL
1154
1155 my $productname = $allvariables->{'PRODUCTNAME'};
1156 $newline = "SUNW_PRODNAME=$productname\n";
1157 add_one_line_into_file($changefile, $newline, $filename);
1158
1159 my $productversion = "";
1160 if ( $allvariables->{'PRODUCTVERSION'} )
1161 {
1162 $productversion = $allvariables->{'PRODUCTVERSION'};
1163 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1164 }
1165 $newline = "SUNW_PRODVERS=$productversion\n";
1166 add_one_line_into_file($changefile, $newline, $filename);
1167
1168 $newline = "SUNW_PKGVERS=1\.0\n";
1169 add_one_line_into_file($changefile, $newline, $filename);
1170
1171 if ( $allvariables->{'SUNW_PKGTYPE'} )
1172 {
1173 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1174 add_one_line_into_file($changefile, $newline, $filename);
1175 }
1176 else
1177 {
1178 $newline = "SUNW_PKGTYPE=\n";
1179 add_one_line_into_file($changefile, $newline, $filename);
1180 }
1181
1182 $newline = "HOTLINE=Please contact your local service provider\n";
1183 add_one_line_into_file($changefile, $newline, $filename);
1184
1185 $newline = "EMAIL=\n";
1186 add_one_line_into_file($changefile, $newline, $filename);
1187
1188}
1189
1190#####################################################################
1191# epm uses as archtecture for Solaris x86 "i86pc". This has to be
1192# changed to "i386".
1193#####################################################################
1194
1195sub fix_architecture_setting
1196{
1197 my ($changefile) = @_;
1198
1199 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1200 {
1201 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1202 {
1203 ${$changefile}[$i] =~ s/i86pc/i386/;
1204 last;
1205 }
1206
1207 }
1208}
1209
1210#####################################################################
1211# Adding a new line for topdir into specfile, removing old
1212# topdir if set.
1213#####################################################################
1214
1215sub set_topdir_in_specfile
1216{
1217 my ($changefile, $filename, $newepmdir) = @_;
1218
1219 $newepmdir = cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed
1220
1221 # removing "%define _topdir", if existing
1222
1223 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1224 {
1225 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1226 {
1227 my $removeline = ${$changefile}[$i];
1228 $removeline =~ s/\s*$//;
1229 splice(@{$changefile},$i,1);
1230 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1231 push( @installer::globals::logfileinfo, $infoline);
1232 last;
1233 }
1234 }
1235
1236 # Adding "topdir" behind the line beginning with: Group:
1237
1238 my $inserted_line = 0;
1239
1240 my $topdirline = "\%define _topdir $newepmdir\n";
1241
1242 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1243 {
1244 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1245 {
1246 splice(@{$changefile},$i+1,0,$topdirline);
1247 $inserted_line = 1;
1248 $topdirline =~ s/\s*$//;
1249 my $infoline = "Success: Added line $topdirline into file $filename!\n";
1250 push( @installer::globals::logfileinfo, $infoline);
1251 }
1252 }
1253
1254 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1255
1256}
1257
1258#####################################################################
1259# Setting the packager in the spec file
1260# Syntax: Packager: abc@def
1261#####################################################################
1262
1263sub set_packager_in_specfile
1264{
1265 my ($changefile) = @_;
1266
1267 my $packager = $installer::globals::longmanufacturer;
1268
1269 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1270 {
1271 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1272 {
1273 my $oldstring = $1;
1274 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1275 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1276 push( @installer::globals::logfileinfo, $infoline);
1277 last;
1278 }
1279 }
1280}
1281
1282#####################################################################
1283# Setting the requirements in the spec file (i81494)
1284# Syntax: PreReq: "requirements" (only for shared extensions)
1285#####################################################################
1286
1287sub set_prereq_in_specfile
1288{
1289 my ($changefile) = @_;
1290
1291 my $prereq = "PreReq:";
1292
1293 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1294 {
1295 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1296 {
1297 my $oldstring = ${$changefile}[$i];
1298 ${$changefile}[$i] =~ s/Requires:/$prereq/;
1299 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1300 push( @installer::globals::logfileinfo, $infoline);
1301 }
1302 }
1303}
1304
1305#####################################################################
1306# Setting the Auto[Req]Prov line and __find_requires
1307#####################################################################
1308
1309sub set_autoprovreq_in_specfile
1310{
1311 my ($changefile, $findrequires, $bindir) = @_;
1312
1313 my $autoreqprovline;
1314
1315 if ( $findrequires )
1316 {
1317 $autoreqprovline = "AutoProv\: no\n%define _use_internal_dependency_generator 0\n%define __find_requires $bindir/$findrequires\n";
1318 }
1319 else
1320 {
1321 $autoreqprovline = "AutoReqProv\: no\n";
1322 }
1323
1324 $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n";
1325
1326 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1327 {
1328 # Adding "autoreqprov" behind the line beginning with: Group:
1329 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1330 {
1331 splice(@{$changefile},$i+1,0,$autoreqprovline);
1332 $autoreqprovline =~ s/\s*$//;
1333 $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1334 push( @installer::globals::logfileinfo, $infoline);
1335
1336 last;
1337 }
1338 }
1339}
1340
1341#####################################################################
1342# Replacing Copyright with License in the spec file
1343# Syntax: License: LGPL, SISSL
1344#####################################################################
1345
1346sub set_license_in_specfile
1347{
1348 my ($changefile, $variableshashref) = @_;
1349
1350 my $license = $variableshashref->{'LICENSENAME'};
1351
1352 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1353 {
1354 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1355 {
1356 ${$changefile}[$i] = "License: $license\n";
1357 my $infoline = "Info: Replaced Copyright with License: $license !\n";
1358 push( @installer::globals::logfileinfo, $infoline);
1359 last;
1360 }
1361 }
1362}
1363
1364#########################################################
1365# Building relocatable Solaris packages means:
1366# 1. Add "BASEDIR=/opt" into pkginfo
1367# 2. Remove "/opt/" from all objects in prototype file
1368# For step2 this function exists
1369# Sample: d none /opt/openofficeorg20/help 0755 root other
1370# -> d none openofficeorg20/help 0755 root other
1371#########################################################
1372
1373sub make_prototypefile_relocatable
1374{
1375 my ($prototypefile, $relocatablepath) = @_;
1376
1377 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1378 {
1379 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line
1380 {
1381 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/"
1382 }
1383 }
1384
1385 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1386 # This line has to be removed now
1387
1388 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash
1389
1390 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1391 {
1392 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1393 {
1394 my $line = ${$prototypefile}[$i];
1395 splice(@{$prototypefile},$i,1); # removing the line
1396 $line =~ s/\s*$//;
1397 my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1398 push( @installer::globals::logfileinfo, $infoline);
1399 last;
1400 }
1401 }
1402
1403 # Making "\$" to "$" in prototype file. "\$" was created by epm.
1404
1405 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1406 {
1407 if ( ${$prototypefile}[$i] =~ /\\\$/ )
1408 {
1409 ${$prototypefile}[$i] =~ s/\\\$/\$/g;
1410 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1411 push( @installer::globals::logfileinfo, $infoline2);
1412 }
1413 }
1414}
1415
1416#########################################################################
1417# Replacing the variables in the Solaris patch shell scripts.
1418# Taking care, that multiple slashes are not always removed.
1419#########################################################################
1420
1421sub replace_variables_in_shellscripts_for_patch
1422{
1423 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1424
1425 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1426 {
1427 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1428 {
1429 my $oldline = ${$scriptfile}[$i];
1430 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; }
1431 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1432 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1433 push(@installer::globals::logfileinfo, $infoline);
1434 }
1435 }
1436}
1437
1438#########################################################################
1439# Replacing the variables in the shell scripts or in the epm list file
1440# Linux: spec file
1441# Solaris: preinstall, postinstall, preremove, postremove
1442# If epm is used in the original version (not relocatable)
1443# the variables have to be exchanged in the list file,
1444# created for epm.
1445#########################################################################
1446
1447sub replace_variables_in_shellscripts
1448{
1449 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1450
1451 my $debug = 0;
1452 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1453
1454 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1455 {
1456 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1457 {
1458 my $oldline = ${$scriptfile}[$i];
1459 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1460 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty!
1461 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1462 push(@installer::globals::logfileinfo, $infoline);
1463 if ( $debug )
1464 {
1465 $infoline = "Old Line: $oldline";
1466 push(@installer::globals::logfileinfo, $infoline);
1467 $infoline = "New Line: ${$scriptfile}[$i]";
1468 push(@installer::globals::logfileinfo, $infoline);
1469 }
1470 }
1471 }
1472}
1473
1474############################################################
1475# Determinig the directory created by epm, in which the
1476# RPMS or Solaris packages are created.
1477############################################################
1478
1479sub determine_installdir_ooo
1480{
1481 # A simple "ls" command returns the directory name
1482
1483 my $dirname = "";
1484
1485 my $systemcall = "ls |";
1486 open (LS, "$systemcall");
1487 $dirname = <LS>;
1488 close (LS);
1489
1490 $dirname =~ s/\s*$//;
1491
1492 my $infoline = "Info: Directory created by epm: $dirname\n";
1493 push(@installer::globals::logfileinfo, $infoline);
1494
1495 return $dirname;
1496}
1497
1498############################################################
1499# Setting the tab content into the file container
1500############################################################
1501
1502sub set_tab_into_datafile
1503{
1504 my ($changefile, $filesref) = @_;
1505
1506 my @newclasses = ();
1507 my $newclassesstring = "";
1508
1509 if ( $installer::globals::issolarispkgbuild )
1510 {
1511 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1512 {
1513 my $onefile = ${$filesref}[$i];
1514
1515 if ( $onefile->{'SolarisClass'} )
1516 {
1517 my $sourcepath = $onefile->{'sourcepath'};
1518
1519 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1520 {
1521 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1522 {
1523 my $oldline = ${$changefile}[$j];
1524 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1525 my $newline = ${$changefile}[$j];
1526 $oldline =~ s/\s*$//;
1527 $newline =~ s/\s*$//;
1528
1529 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1530 push(@installer::globals::logfileinfo, $infoline);
1531
1532 # collecting all new classes
1533 if (! grep {$_ eq $onefile->{'SolarisClass'}} @newclasses)
1534 {
1535 push(@newclasses, $onefile->{'SolarisClass'});
1536 }
1537
1538 last;
1539 }
1540 }
1541 }
1542 }
1543
1544 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1545 }
1546
1547 if ( $installer::globals::isrpmbuild )
1548 {
1549 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1550 {
1551 my $onefile = ${$filesref}[$i];
1552
1553 if ( $onefile->{'SpecFileContent'} )
1554 {
1555 my $destination = $onefile->{'destination'};
1556
1557 for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1558 {
1559 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1560 {
1561 my $begin = $1;
1562 my $end = $2;
1563
1564 my $oldline = ${$changefile}[$j];
1565 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1566 my $newline = ${$changefile}[$j];
1567
1568 $oldline =~ s/\s*$//;
1569 $newline =~ s/\s*$//;
1570
1571 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1572 push(@installer::globals::logfileinfo, $infoline);
1573
1574 last;
1575 }
1576 }
1577 }
1578 }
1579 }
1580
1581 return $newclassesstring;
1582}
1583
1584############################################################
1585# Including additional classes into the pkginfo file
1586############################################################
1587
1588sub include_classes_into_pkginfo
1589{
1590 my ($changefile, $classesstring) = @_;
1591
1592 for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1593 {
1594 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1595 {
1596 ${$changefile}[$i] =~ s/\s*$//;
1597 my $oldline = ${$changefile}[$i];
1598 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1599 my $newline = ${$changefile}[$i];
1600 $newline =~ s/\s*$//;
1601
1602 my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n";
1603 push(@installer::globals::logfileinfo, $infoline);
1604 }
1605 }
1606}
1607
1608##########################################################################################
1609# Checking, if an extension is included into the package (Linux).
1610# All extension files have to be installed into directory
1611# share/extension/install
1612# %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt"
1613##########################################################################################
1614
1615sub is_extension_package
1616{
1617 my ($specfile) = @_;
1618
1619 my $is_extension_package = 0;
1620
1621 for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1622 {
1623 my $line = ${$specfile}[$i];
1624 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1625 {
1626 $is_extension_package = 1;
1627 last;
1628 }
1629 }
1630
1631 return $is_extension_package;
1632}
1633
1634######################################################################
1635# Checking, if an extension is included into the package (Solaris).
1636# All extension files have to be installed into directory
1637# share/extension/install
1638######################################################################
1639
1640sub contains_extension_dir
1641{
1642 my ($prototypefile) = @_;
1643
1644 my $contains_extension_dir = 0;
1645
1646 # d none opt/openoffice.org3/share/extensions/
1647
1648 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1649 {
1650 my $line = ${$prototypefile}[$i];
1651 if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// )
1652 {
1653 $contains_extension_dir = 1;
1654 last;
1655 }
1656 }
1657
1658 return $contains_extension_dir;
1659}
1660
1661############################################################
1662# A Solaris patch contains 7 specific scripts
1663############################################################
1664
1665sub add_scripts_into_prototypefile
1666{
1667 my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_;
1668
1669 # The files are stored in the directory $installer::globals::patchincludepath
1670 # The file names are available via @installer::globals::solarispatchscripts
1671
1672 my $path = $installer::globals::patchincludepath;
1673 $path =~ s/\/\s*$//;
1674 $path = $path . $installer::globals::separator;
1675
1676 my @newlines = ();
1677 my $is_extension_package = contains_extension_dir($prototypefile);
1678
1679 if ( $is_extension_package )
1680 {
1681 for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ )
1682 {
1683 my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i];
1684 my $destfile = $installer::globals::solarispatchscriptsforextensions[$i];
1685
1686 # If the sourcepath has "_extension" in its name, this has to be removed
1687 $destfile =~ s/_extensions\s*$//; # hard coded renaming of script name
1688
1689 # Creating unique directory name with $prototypefilename
1690 my $extensiondir = installer::systemactions::create_directories("extensionscripts", $languagestringref);
1691
1692 if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; }
1693 $prototypefilename =~ s/\./_/g;
1694 my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename;
1695 if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); }
1696 my $destpath = $destdir . $installer::globals::separator . $destfile;
1697 if ( -f $destpath ) { unlink($destpath); }
1698
1699 # Reading file
1700 my $scriptfile = installer::files::read_file($sourcefilename);
1701
1702 # Replacing variables
1703 my $oldstring = "PRODUCTDIRECTORYNAME";
1704 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath);
1705
1706 # Saving file
1707 installer::files::save_file($destpath, $scriptfile);
1708
1709 # Writing file destination into prototype file
1710 my $line = "i $destfile=" . $destpath . "\n";
1711 push(@newlines, $line);
1712 }
1713 }
1714 else
1715 {
1716 for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ )
1717 {
1718 my $line = "i $installer::globals::solarispatchscripts[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n";
1719 push(@newlines, $line);
1720 }
1721 }
1722
1723 # Including the new lines after the last line starting with "i"
1724
1725 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1726 {
1727 if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ )
1728 {
1729 splice(@{$prototypefile}, $i, 1); # ignoring old copyright text, using patch standard
1730 next;
1731 }
1732 if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; }
1733 splice(@{$prototypefile}, $i, 0, @newlines);
1734 last;
1735 }
1736}
1737
1738############################################################
1739# Adding patch infos in pkginfo file
1740############################################################
1741
1742sub include_patchinfos_into_pkginfo
1743{
1744 my ( $changefile, $filename, $variableshashref ) = @_;
1745
1746 # SUNW_PATCHID=101998-10
1747 # SUNW_OBSOLETES=114999-01 113999-01
1748 # SUNW_PKGTYPE=usr
1749 # SUNW_PKGVERS=1.0
1750 # SUNW_REQUIRES=126411-01
1751
1752 my $patchidname = "SOLSPARCPATCHID";
1753 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; }
1754
1755 if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "include_patchinfos_into_pkginfo"); }
1756
1757 my $newline = "SUNW_PATCHID=" . $variableshashref->{$patchidname} . "\n";
1758 add_one_line_into_file($changefile, $newline, $filename);
1759
1760 my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES";
1761 if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES"; }
1762
1763 my $obsoletes = "";
1764 if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; }
1765 $newline = "SUNW_OBSOLETES=" . $obsoletes . "\n";
1766 add_one_line_into_file($changefile, $newline, $filename);
1767
1768 my $patchrequiresname = "SOLSPARCPATCHREQUIRES";
1769 if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES"; }
1770
1771 if ( $variableshashref->{$patchrequiresname} )
1772 {
1773 my $requires = $variableshashref->{$patchrequiresname};
1774 $newline = "SUNW_REQUIRES=" . $requires . "\n";
1775 add_one_line_into_file($changefile, $newline, $filename);
1776 }
1777 $newline = "SUNW_PATCH_PROPERTIES=\n";
1778 add_one_line_into_file($changefile, $newline, $filename);
1779}
1780
1781############################################################
1782# Setting the correct Solaris locales
1783############################################################
1784
1785sub get_solaris_language_for_langpack
1786{
1787 my ( $onelanguage ) = @_;
1788
1789 my $sollanguage = $onelanguage;
1790 $sollanguage =~ s/\-/\_/;
1791
1792 if ( $sollanguage eq "de" ) { $sollanguage = "de"; }
1793 elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; }
1794 elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; }
1795 elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; }
1796 elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; }
1797 elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; }
1798 elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; }
1799 elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; }
1800 elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; }
1801 elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; }
1802 elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; }
1803 elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; }
1804 elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; }
1805 elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; }
1806 elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; }
1807 elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; }
1808
1809 return $sollanguage;
1810}
1811
1812############################################################
1813# Adding language infos in pkginfo file
1814############################################################
1815
1816sub include_languageinfos_into_pkginfo
1817{
1818 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1819
1820 # SUNWPKG_LIST=core01
1821 # SUNW_LOC=de
1822
1823 my $locallang = $onepackage->{'language'};
1824 my $solarislanguage = get_solaris_language_for_langpack($locallang);
1825
1826 my $newline = "SUNW_LOC=" . $solarislanguage . "\n";
1827 add_one_line_into_file($changefile, $newline, $filename);
1828
1829 # SUNW_PKGLIST is required, if SUNW_LOC is defined.
1830 if ( $onepackage->{'pkg_list_entry'} )
1831 {
1832 my $packagelistentry = $onepackage->{'pkg_list_entry'};
1833 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1834 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1835 add_one_line_into_file($changefile, $newline, $filename);
1836 }
1837 else
1838 {
1839 # Using default package ooobasis30-core01.
1840 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01";
1841 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1842 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1843 add_one_line_into_file($changefile, $newline, $filename);
1844 }
1845}
1846
1847############################################################
1848# Collecting all files included in patch in
1849# @installer::globals::patchfilecollector
1850############################################################
1851
1852sub collect_patch_files
1853{
1854 my ($file, $packagename, $prefix) = @_;
1855
1856 # $file is the spec file or the prototypefile
1857
1858 $prefix = $prefix . "/";
1859 my $packagenamestring = "Package " . $packagename . " \:\n";
1860 push(@installer::globals::patchfilecollector, $packagenamestring);
1861
1862 for ( my $i = 0; $i <= $#{$file}; $i++ )
1863 {
1864 my $line = ${$file}[$i];
1865
1866 if ( $installer::globals::isrpmbuild )
1867 {
1868 # %attr(0444,root,root) "/opt/openofficeorg20/program/about.bmp"
1869
1870 if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ )
1871 {
1872 my $filename = $1 . "\n";
1873 $filename =~ s/^\s*\Q$prefix\E//;
1874 push(@installer::globals::patchfilecollector, $filename);
1875 }
1876 }
1877
1878 if ( $installer::globals::issolarispkgbuild )
1879 {
1880 # f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin
1881
1882 if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ )
1883 {
1884 my $filename = $1 . "\n";
1885 push(@installer::globals::patchfilecollector, $filename);
1886 }
1887 }
1888 }
1889
1890 push(@installer::globals::patchfilecollector, "\n");
1891
1892}
1893
1894############################################################
1895# Including package names into the depend files.
1896# The package names have to be included into
1897# packagelist. They are already saved in
1898# %installer::globals::dependfilenames.
1899############################################################
1900
1901sub put_packagenames_into_dependfile
1902{
1903 my ( $file ) = @_;
1904
1905 for ( my $i = 0; $i <= $#{$file}; $i++ )
1906 {
1907 my $line = ${$file}[$i];
1908 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
1909 {
1910 my $abbreviation = $1;
1911
1912 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); }
1913
1914 if ( exists($installer::globals::dependfilenames{$abbreviation}) )
1915 {
1916 my $packagename = $installer::globals::dependfilenames{$abbreviation};
1917 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); }
1918
1919 $line =~ s/\s*$//;
1920 ${$file}[$i] = $line . "\t" . $packagename . "\n";
1921 }
1922 else
1923 {
1924 installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile");
1925 }
1926 }
1927 }
1928}
1929
1930############################################################
1931# Including the relocatable directory into
1932# spec file and pkginfo file
1933# Linux: set topdir in specfile
1934# Solaris: remove $relocatablepath (/opt/)
1935# for all objects in prototype file
1936# and changing "topdir" for Linux
1937############################################################
1938
1939sub prepare_packages
1940{
1941 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
1942
1943 my $filename = "";
1944 my $newline = "";
1945 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
1946
1947 my $localrelocatablepath = $relocatablepath;
1948 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; }
1949
1950 if ( $installer::globals::issolarispkgbuild )
1951 {
1952 $filename = $packagename . ".pkginfo";
1953 $newline = "BASEDIR\=" . $localrelocatablepath . "\n";
1954 }
1955
1956 if ( $installer::globals::isrpmbuild )
1957 {
1958 $filename = $packagename . ".spec";
1959 $newline = "Prefix\:\ " . $localrelocatablepath . "\n";
1960 }
1961
1962 my $completefilename = $newepmdir . $filename;
1963
1964 if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); }
1965 my $changefile = installer::files::read_file($completefilename);
1966 if ( $newline ne "" )
1967 {
1968 add_one_line_into_file($changefile, $newline, $filename);
1969 installer::files::save_file($completefilename, $changefile);
1970 }
1971
1972 # adding new "topdir" and removing old "topdir" in specfile
1973
1974 if ( $installer::globals::isrpmbuild )
1975 {
1976 set_topdir_in_specfile($changefile, $filename, $newepmdir);
1977 set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin");
1978 set_packager_in_specfile($changefile);
1979 if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); }
1980 set_license_in_specfile($changefile, $variableshashref);
1981 set_tab_into_datafile($changefile, $filesref);
1982 installer::files::save_file($completefilename, $changefile);
1983 if ( $installer::globals::patch ) { collect_patch_files($changefile, $packagename, $localrelocatablepath); }
1984 }
1985
1986 # removing the relocatable path in prototype file
1987
1988 if ( $installer::globals::issolarispkgbuild )
1989 {
1990 set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename);
1991 set_maxinst_in_pkginfo($changefile, $filename);
1992 set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref);
1993 if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); }
1994 if ( ! $installer::globals::patch ) { set_patchlist_in_pkginfo_for_respin($changefile, $filename, $variableshashref, $packagename); }
1995 if ( $installer::globals::patch ) { include_patchinfos_into_pkginfo($changefile, $filename, $variableshashref); }
1996 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
1997 installer::files::save_file($completefilename, $changefile);
1998
1999 my $prototypefilename = $packagename . ".prototype";
2000 $prototypefilename = $newepmdir . $prototypefilename;
2001 if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
2002
2003 my $prototypefile = installer::files::read_file($prototypefilename);
2004 make_prototypefile_relocatable($prototypefile, $relocatablepath);
2005 my $classesstring = set_tab_into_datafile($prototypefile, $filesref);
2006 if ($classesstring)
2007 {
2008 include_classes_into_pkginfo($changefile, $classesstring);
2009 installer::files::save_file($completefilename, $changefile);
2010 }
2011
2012 if ( $installer::globals::patch ) { add_scripts_into_prototypefile($prototypefile, $prototypefilename, $languagestringref, $staticpath); }
2013
2014 installer::files::save_file($prototypefilename, $prototypefile);
2015 if ( $installer::globals::patch ) { collect_patch_files($prototypefile, $packagename, ""); }
2016
2017 # Adding package names into depend files for Solaris (not supported by epm)
2018 my $dependfilename = $packagename . ".depend";
2019 $dependfilename = $newepmdir . $dependfilename;
2020 if ( -f $dependfilename)
2021 {
2022 my $dependfile = installer::files::read_file($dependfilename);
2023 put_packagenames_into_dependfile($dependfile);
2024 installer::files::save_file($dependfilename, $dependfile);
2025 }
2026 }
2027
2028 return $newepmdir;
2029}
2030
2031###############################################################################
2032# Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
2033# epm list file.
2034# The complete rootpath is stored in $installer::globals::rootpath
2035# or for each package in $onepackage->{'destpath'}
2036# The static rootpath is stored in $staticpath
2037# The relocatable path is stored in $relocatablepath
2038# PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
2039# PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
2040# In standard epm process:
2041# No usage of package specific variables like $BASEDIR, because
2042# 1. These variables would be replaced in epm process
2043# 2. epm version 3.7 does not support relocatable packages
2044###############################################################################
2045
2046sub resolve_path_in_epm_list_before_packaging
2047{
2048 my ($listfile, $listfilename, $variable, $path) = @_;
2049
2050 installer::logger::include_header_into_logfile("Replacing variables in epm list file:");
2051
2052 $path =~ s/\/\s*$//;
2053 replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path);
2054
2055}
2056
2057#################################################################
2058# Determining the rpm version. Beginning with rpm version 4.0
2059# the tool to create RPMs is "rpmbuild" and no longer "rpm"
2060#################################################################
2061
2062sub determine_rpm_version
2063{
2064 my $rpmversion = 0;
2065 my $rpmout = "";
2066 my $systemcall = "";
2067
2068 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
2069 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
2070 # is saved in $installer::globals::rpm
2071
2072 if ( $installer::globals::rpm ne "" )
2073 {
2074 $systemcall = "$installer::globals::rpm --version |";
2075 }
2076 else
2077 {
2078 $systemcall = "rpm --version |";
2079 }
2080
2081 open (RPM, "$systemcall");
2082 $rpmout = <RPM>;
2083 close (RPM);
2084
2085 if ( $rpmout ne "" )
2086 {
2087 $rpmout =~ s/\s*$//g;
2088
2089 my $infoline = "Systemcall: $systemcall\n";
2090 push( @installer::globals::logfileinfo, $infoline);
2091
2092 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
2093 else { $infoline = "Success: rpm version: $rpmout\n"; }
2094
2095 push( @installer::globals::logfileinfo, $infoline);
2096
2097 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2098 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2099 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
2100 else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
2101 }
2102
2103 return $rpmversion;
2104}
2105
2106####################################################
2107# Writing some info about rpm into the log file
2108####################################################
2109
2110sub log_rpm_info
2111{
2112 my $systemcall = "";
2113 my $infoline = "";
2114
2115 $infoline = "\nLogging rpmrc content using --showrc\n\n";
2116 push( @installer::globals::logfileinfo, $infoline);
2117
2118 if ( $installer::globals::rpm ne "" )
2119 {
2120 $systemcall = "$installer::globals::rpm --showrc |";
2121 }
2122 else
2123 {
2124 $systemcall = "rpm --showrc |";
2125 }
2126
2127 my @fullrpmout = ();
2128
2129 open (RPM, "$systemcall");
2130 while (<RPM>) {push(@fullrpmout, $_); }
2131 close (RPM);
2132
2133 if ( $#fullrpmout > -1 )
2134 {
2135 for ( my $i = 0; $i <= $#fullrpmout; $i++ )
2136 {
2137 my $rpmout = $fullrpmout[$i];
2138 $rpmout =~ s/\s*$//g;
2139
2140 $infoline = "$rpmout\n";
2141 $infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems
2142 push( @installer::globals::logfileinfo, $infoline);
2143 }
2144 }
2145 else
2146 {
2147 $infoline = "Problem in systemcall: $systemcall : No return value\n";
2148 push( @installer::globals::logfileinfo, $infoline);
2149 }
2150
2151 $infoline = "End of logging rpmrc\n\n";
2152 push( @installer::globals::logfileinfo, $infoline);
2153}
2154
2155#################################################
2156# Systemcall to start the packaging process
2157#################################################
2158
2159sub create_packages_without_epm
2160{
2161 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
2162
2163 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
2164 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
2165 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
2166
2167 if ( $installer::globals::issolarispkgbuild )
2168 {
2169 my $prototypefile = $epmdir . $packagename . ".prototype";
2170 if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
2171
2172 my $destinationdir = $prototypefile;
2173 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir);
2174 $destinationdir =~ s/\/\s*$//; # removing ending slashes
2175
2176 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
2177 installer::logger::print_message( "... $systemcall ...\n" );
2178
2179 my $maxpkgmkcalls = 3;
2180
2181 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
2182 {
2183 my @pkgmkoutput = ();
2184
2185 open (PKGMK, "$systemcall");
2186 while (<PKGMK>) {push(@pkgmkoutput, $_); }
2187 close (PKGMK);
2188
2189 my $returnvalue = $?; # $? contains the return value of the systemcall
2190
2191 my $infoline = "Systemcall (Try $i): $systemcall\n";
2192 push( @installer::globals::logfileinfo, $infoline);
2193
2194 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
2195 {
2196 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2197 push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]");
2198 }
2199
2200 if ($returnvalue)
2201 {
2202 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2203 push( @installer::globals::logfileinfo, $infoline);
2204 if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2205 }
2206 else
2207 {
2208 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2209 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2210 push( @installer::globals::logfileinfo, $infoline);
2211 last;
2212 }
2213 }
2214
2215 # It might be necessary to save uncompressed Solaris packages
2216
2217 # compressing packages
2218
2219 if ( ! $installer::globals::solarisdontcompress )
2220 {
2221 my $faspac = "faspac-so.sh";
2222
2223 my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0);
2224 if ($$compressorref ne "")
2225 {
2226 # Saving original pkginfo, to set time stamp later
2227 my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
2228 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
2229 $systemcall = "cp -p $pkginfoorig $pkginfotmp";
2230 make_systemcall($systemcall);
2231
2232 $faspac = $$compressorref;
2233 $infoline = "Found compressor: $faspac\n";
2234 push( @installer::globals::logfileinfo, $infoline);
2235
2236 installer::logger::print_message( "... $faspac ...\n" );
2237 installer::logger::include_timestamp_into_logfile("Starting $faspac");
2238
2239 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path!
2240 make_systemcall($systemcall);
2241
2242 # Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file,
2243 # updated the size and checksum, but not the time stamp.
2244 $systemcall = "touch -r $pkginfotmp $pkginfoorig";
2245 make_systemcall($systemcall);
2246 if ( -f $pkginfotmp ) { unlink($pkginfotmp); }
2247
2248 installer::logger::include_timestamp_into_logfile("End of $faspac");
2249 }
2250 else
2251 {
2252 $infoline = "Not found: $faspac\n";
2253 push( @installer::globals::logfileinfo, $infoline);
2254 }
2255 }
2256
2257 # Setting unix rights to "775" for all created directories inside the package
2258
2259 $systemcall = "cd $destinationdir; find $packagename -type d | xargs -i chmod 775 \{\} \;";
2260 installer::logger::print_message( "... $systemcall ...\n" );
2261
2262 $returnvalue = system($systemcall);
2263
2264 $infoline = "Systemcall: $systemcall\n";
2265 push( @installer::globals::logfileinfo, $infoline);
2266
2267 if ($returnvalue)
2268 {
2269 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2270 push( @installer::globals::logfileinfo, $infoline);
2271 }
2272 else
2273 {
2274 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2275 push( @installer::globals::logfileinfo, $infoline);
2276 }
2277
2278
2279 ######################
2280 # making pkg files
2281 ######################
2282
2283 # my $streamname = $packagename . ".pkg";
2284 # $systemcall = "pkgtrans $destinationdir $streamname $packagename";
2285 # print "... $systemcall ...\n";
2286
2287 # $returnvalue = system($systemcall);
2288
2289 # $infoline = "Systemcall: $systemcall\n";
2290 # push( @installer::globals::logfileinfo, $infoline);
2291
2292 # if ($returnvalue)
2293 # {
2294 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2295 # push( @installer::globals::logfileinfo, $infoline);
2296 # }
2297 # else
2298 # {
2299 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2300 # push( @installer::globals::logfileinfo, $infoline);
2301 # }
2302
2303 #########################
2304 # making tar.gz files
2305 #########################
2306
2307 # my $targzname = $packagename . ".tar.gz";
2308 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
2309 # print "... $systemcall ...\n";
2310
2311 # $returnvalue = system($systemcall);
2312
2313 # $infoline = "Systemcall: $systemcall\n";
2314 # push( @installer::globals::logfileinfo, $infoline);
2315
2316 # if ($returnvalue)
2317 # {
2318 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2319 # push( @installer::globals::logfileinfo, $infoline);
2320 # }
2321 # else
2322 # {
2323 # $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2324 # push( @installer::globals::logfileinfo, $infoline);
2325 # }
2326
2327 }
2328
2329 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? )
2330
2331 if ( $installer::globals::isrpmbuild )
2332 {
2333 my $specfilename = $epmdir . $packagename . ".spec";
2334 if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2335
2336 my $rpmcommand = $installer::globals::rpm;
2337 my $rpmversion = determine_rpm_version();
2338
2339 my $target = "";
2340 if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; }
2341 elsif ( $installer::globals::compiler =~ /unxaigppc/) { $target = "ppc"; }
2342 elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; }
2343
2344 # rpm 4.6 ignores buildroot tag in spec file
2345
2346 my $buildrootstring = "";
2347
2348 if ( $rpmversion >= 4 )
2349 {
2350 my $dir = getcwd;
2351 my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2352 $buildrootstring = "--buildroot=$buildroot";
2353 mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/");
2354 }
2355
2356 if ( ! $installer::globals::rpminfologged )
2357 {
2358 log_rpm_info();
2359 $installer::globals::rpminfologged = 1;
2360 }
2361
2362 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2363
2364 installer::logger::print_message( "... $systemcall ...\n" );
2365
2366 my $maxrpmcalls = 3;
2367 my $rpm_failed = 0;
2368
2369 for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2370 {
2371 my @rpmoutput = ();
2372
2373 open (RPM, "$systemcall");
2374 while (<RPM>) {push(@rpmoutput, $_); }
2375 close (RPM);
2376
2377 my $returnvalue = $?; # $? contains the return value of the systemcall
2378
2379 my $infoline = "Systemcall (Try $i): $systemcall\n";
2380 push( @installer::globals::logfileinfo, $infoline);
2381
2382 for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2383 {
2384 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2385 push( @installer::globals::logfileinfo, "$rpmoutput[$j]");
2386 }
2387
2388 if ($returnvalue)
2389 {
2390 $infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2391 push( @installer::globals::logfileinfo, $infoline);
2392 $rpm_failed = 1;
2393 }
2394 else
2395 {
2396 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2397 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2398 push( @installer::globals::logfileinfo, $infoline);
2399 $rpm_failed = 0;
2400 last;
2401 }
2402 }
2403
2404 if ( $rpm_failed )
2405 {
2406 # Because of the problems with LD_LIBRARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2407 my $rpmprog = "";
2408 if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2409 elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2410
2411 if ( $rpmprog ne "" )
2412 {
2413 installer::logger::print_message( "... $rpmprog ...\n" );
2414
2415 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2416
2417 my @helperrpmoutput = ();
2418
2419 open (RPM, "$helpersystemcall");
2420 while (<RPM>) {push(@helperrpmoutput, $_); }
2421 close (RPM);
2422
2423 my $helperreturnvalue = $?; # $? contains the return value of the systemcall
2424
2425 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBRARY_PATH)\n";
2426 push( @installer::globals::logfileinfo, $infoline);
2427
2428 $infoline = "\nSystemcall: $helpersystemcall\n";
2429 push( @installer::globals::logfileinfo, $infoline);
2430
2431 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); }
2432
2433 if ($helperreturnvalue)
2434 {
2435 $infoline = "Could not execute \"$helpersystemcall\"!\n";
2436 push( @installer::globals::logfileinfo, $infoline);
2437 }
2438 else
2439 {
2440 installer::logger::print_message( "Success: \"$helpersystemcall\"\n" );
2441 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2442 push( @installer::globals::logfileinfo, $infoline);
2443 $rpm_failed = 0;
2444 }
2445 }
2446
2447 # Now it is really time to exit this packaging process, if the error still occurs
2448 if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2449 }
2450 }
2451}
2452
2453#################################################
2454# Removing all temporary files created by epm
2455#################################################
2456
2457sub remove_temporary_epm_files
2458{
2459 my ($epmdir, $loggingdir, $packagename) = @_;
2460
2461 # saving the files into the loggingdir
2462
2463 if ( $installer::globals::issolarispkgbuild )
2464 {
2465 my @extensions = ();
2466 push(@extensions, ".pkginfo");
2467 push(@extensions, ".prototype");
2468 push(@extensions, ".postinstall");
2469 push(@extensions, ".postremove");
2470 push(@extensions, ".preinstall");
2471 push(@extensions, ".preremove");
2472 push(@extensions, ".depend");
2473
2474 for ( my $i = 0; $i <= $#extensions; $i++ )
2475 {
2476 my $removefile = $epmdir . $packagename . $extensions[$i];
2477 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2478
2479 if (! -f $removefile) { next; }
2480
2481 my $systemcall = "mv -f $removefile $destfile";
2482 system($systemcall); # ignoring the return value
2483 $infoline = "Systemcall: $systemcall\n";
2484 push( @installer::globals::logfileinfo, $infoline);
2485 }
2486 }
2487
2488 if ( $installer::globals::isrpmbuild )
2489 {
2490 my $removefile = $epmdir . $packagename . ".spec";
2491 my $destfile = $loggingdir . $packagename . ".spec.log";
2492
2493 my $systemcall = "mv -f $removefile $destfile";
2494 system($systemcall); # ignoring the return value
2495 $infoline = "Systemcall: $systemcall\n";
2496 push( @installer::globals::logfileinfo, $infoline);
2497
2498 # removing the directory "buildroot"
2499
2500 my $removedir = $epmdir . "buildroot";
2501
2502 $systemcall = "rm -rf $removedir";
2503
2504 installer::logger::print_message( "... $systemcall ...\n" );
2505
2506 my $returnvalue = system($systemcall);
2507
2508 $removedir = $epmdir . "BUILD";
2509
2510 $systemcall = "rm -rf $removedir";
2511
2512 installer::logger::print_message( "... $systemcall ...\n" );
2513
2514 $returnvalue = system($systemcall);
2515
2516
2517 my $infoline = "Systemcall: $systemcall\n";
2518 push( @installer::globals::logfileinfo, $infoline);
2519
2520 if ($returnvalue)
2521 {
2522 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2523 push( @installer::globals::logfileinfo, $infoline);
2524 }
2525 else
2526 {
2527 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2528 push( @installer::globals::logfileinfo, $infoline);
2529 }
2530 }
2531}
2532
2533######################################################
2534# Making the systemcall
2535######################################################
2536
2537sub make_systemcall
2538{
2539 my ($systemcall) = @_;
2540
2541 my $returnvalue = system($systemcall);
2542
2543 my $infoline = "Systemcall: $systemcall\n";
2544 push( @installer::globals::logfileinfo, $infoline);
2545
2546 if ($returnvalue)
2547 {
2548 $infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2549 push( @installer::globals::logfileinfo, $infoline);
2550 }
2551 else
2552 {
2553 $infoline = "Success: Executed \"$systemcall\" successfully!\n";
2554 push( @installer::globals::logfileinfo, $infoline);
2555 }
2556}
2557
2558###########################################################
2559# Creating a better directory structure in the solver.
2560###########################################################
2561
2562sub create_new_directory_structure
2563{
2564 my ($newepmdir) = @_;
2565
2566 my $newdir = $installer::globals::epmoutpath;
2567
2568 if ( $installer::globals::isrpmbuild )
2569 {
2570 my $rpmdir;
2571 my $machine = "";
2572 if ( $installer::globals::compiler =~ /unxlngi/) {
2573 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2574 }
2575 elsif ( $installer::globals::compiler =~ /unxaigppc/) {
2576 $machine = "ppc";
2577 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2578 }
2579 elsif ( $installer::globals::compiler =~ /unxlng/) {
2580 $machine = (POSIX::uname())[4];
2581 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2582 }
2583 else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2584
2585 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS"
2586
2587 my $returnvalue = system($systemcall);
2588
2589 my $infoline = "Systemcall: $systemcall\n";
2590 push( @installer::globals::logfileinfo, $infoline);
2591
2592 if ($returnvalue)
2593 {
2594 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2595 push( @installer::globals::logfileinfo, $infoline);
2596 }
2597 else
2598 {
2599 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2600 push( @installer::globals::logfileinfo, $infoline);
2601 }
2602
2603 # and removing the empty directory
2604
2605 if ( $machine ne "" )
2606 {
2607 rmdir "$installer::globals::epmoutpath/RPMS/$machine";
2608 }
2609 rmdir "$installer::globals::epmoutpath/RPMS/powerpc";
2610 rmdir "$installer::globals::epmoutpath/RPMS/x86_64";
2611 rmdir "$installer::globals::epmoutpath/RPMS/i586";
2612 rmdir "$installer::globals::epmoutpath/RPMS/i386";
2613 rmdir "$installer::globals::epmoutpath/RPMS"
2614 or warn "Could not remove RPMS dir: $!";
2615 }
2616
2617 # Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2618 chmod 0775, $newdir;
2619}
2620
2621######################################################
2622# Collect modules with product specific styles.
2623######################################################
2624
2625sub collect_modules_with_style
2626{
2627 my ($style, $modulesarrayref) = @_;
2628
2629 my @allmodules = ();
2630
2631 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2632 {
2633 my $onemodule = ${$modulesarrayref}[$i];
2634 my $styles = "";
2635 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2636 if ( $styles =~ /\b\Q$style\E\b/ )
2637 {
2638 push(@allmodules, $onemodule);
2639 }
2640 }
2641
2642 return \@allmodules;
2643}
2644
2645######################################################
2646# Remove modules without packagecontent.
2647######################################################
2648
2649sub remove_modules_without_package
2650{
2651 my ($allmodules) = @_;
2652
2653 my @allmodules = ();
2654
2655 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2656 {
2657 my $onemodule = ${$allmodules}[$i];
2658 my $packagename = "";
2659 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2660 if ( $packagename ne "" )
2661 {
2662 push(@allmodules, $onemodule);
2663 }
2664 }
2665
2666 return \@allmodules;
2667}
2668
2669######################################################
2670# Unpacking tar.gz file and setting new packagename.
2671######################################################
2672
2673sub unpack_tar_gz_file
2674{
2675 my ($packagename, $destdir) = @_;
2676
2677 my $newpackagename = "";
2678
2679 if ( $packagename =~ /\.tar\.gz\s*$/ )
2680 {
2681 # Collecting all packages in directory "packages"
2682 my $oldcontent = installer::systemactions::read_directory($destdir);
2683
2684 # unpacking gunzip
2685 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -";
2686 make_systemcall($systemcall);
2687
2688 # deleting the tar.gz files
2689 $systemcall = "cd $destdir; rm -f $packagename";
2690 make_systemcall($systemcall);
2691
2692 # Finding new content -> that is the package name
2693 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2694 $newpackagename = ${$newcontent}[0];
2695 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename);
2696 }
2697
2698 if ( $newpackagename ne "" ) { $packagename = $newpackagename; }
2699
2700 return $packagename;
2701}
2702
2703######################################################
2704# Copying files for system integration.
2705######################################################
2706
2707sub copy_and_unpack_tar_gz_files
2708{
2709 my ($sourcefile, $destdir) = @_;
2710
2711 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
2712 make_systemcall($systemcall);
2713}
2714
2715######################################################
2716# Checking whether the new content is a directory and
2717# not a package. If it is a directory, the complete
2718# content of the directory has to be added to the
2719# array newcontent.
2720######################################################
2721
2722sub control_subdirectories
2723{
2724 my ($content, $subdir) = @_;
2725
2726 my @newcontent = ();
2727
2728 for ( my $i = 0; $i <= $#{$content}; $i++ )
2729 {
2730 if ( -d ${$content}[$i] )
2731 {
2732 $subdir = ${$content}[$i];
2733 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir);
2734 my $allpackages = installer::systemactions::read_directory(${$content}[$i]);
2735 for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
2736 {
2737 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
2738 if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
2739 push(@newcontent, ${$allpackages}[$j]);
2740 }
2741 }
2742 else
2743 {
2744 push(@newcontent, ${$content}[$i]);
2745 }
2746 }
2747
2748 return (\@newcontent, $subdir);
2749}
2750
2751######################################################
2752# Including the system integration files into the
2753# installation sets.
2754######################################################
2755
2756sub put_systemintegration_into_installset
2757{
2758 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
2759
2760 my $destdir = $newdir;
2761
2762 # adding System integration files
2763
2764 my $sourcefile = "";
2765
2766 # Finding the modules defined in scp (with flag SYSTEMMODULE)
2767 # Getting name of package from scp-Module
2768 # Search package in list off all include files
2769 # Copy file into installation set and unpack it (always tar.gz)
2770 # tar.gz can contain a different number of packages -> automatically create hidden sub modules
2771
2772 # Collect all modules with flag "SYSTEMMODULE"
2773 my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref);
2774 $allmodules = remove_modules_without_package($allmodules);
2775
2776 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2777 {
2778 my $onemodule = ${$allmodules}[$i];
2779 my $packagetarfilename = $onemodule->{'PackageName'};
2780
2781 my $infoline = "Including into installation set: $packagetarfilename\n";
2782 push( @installer::globals::logfileinfo, $infoline);
2783
2784 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1);
2785 if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
2786
2787 # Collecting all packages in directory "packages" or "RPMS"
2788 my $oldcontent = installer::systemactions::read_directory($destdir);
2789
2790 copy_and_unpack_tar_gz_files($$sourcepathref, $destdir);
2791
2792 # Finding new content -> that is the package name
2793 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2794
2795 # special handling, if new content is a directory
2796 my $subdir = "";
2797 if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); }
2798
2799 # Adding license content into Solaris packages
2800 if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { installer::worker::add_license_into_systemintegrationpackages($destdir, $newcontent); }
2801 }
2802}
2803
2804######################################################
2805# Analyzing the Unix installation path.
2806# From the installation path /opt/openofficeorg20
2807# is the part /opt relocatable and the part
2808# openofficeorg20 static.
2809######################################################
2810
2811sub analyze_rootpath
2812{
2813 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
2814
2815 $rootpath =~ s/\/\s*$//; # removing ending slash
2816
2817 ##############################################################
2818 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed
2819 ##############################################################
2820
2821 $$relocatablepathref = "/";
2822 # Static path has to contain the office directory name. This is replaced in shellscripts.
2823 $$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname;
2824 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
2825 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
2826 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
2827 if ( $installer::globals::isrpmbuild )
2828 {
2829 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
2830 $$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts
2831 }
2832
2833 if ( $installer::globals::isdebbuild )
2834 {
2835 $$relocatablepathref = "";
2836 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
2837 }
2838
2839}
2840
2841######################################################
2842# Replacing one variable in patchinfo file
2843######################################################
2844
2845sub replace_one_variable_in_file
2846{
2847 my ( $file, $placeholder, $value ) = @_;
2848
2849 for ( my $i = 0; $i <= $#{$file}; $i++ )
2850 {
2851 ${$file}[$i] =~ s/$placeholder/$value/g;
2852 }
2853}
2854
2855######################################################
2856# Setting variables in the patchinfo file
2857######################################################
2858
2859sub set_patchinfo
2860{
2861 my ( $patchinfofile, $patchid, $allvariables ) = @_;
2862
2863 # Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER
2864
2865 replace_one_variable_in_file($patchinfofile, "PATCHIDPLACEHOLDER", $patchid);
2866
2867 my $architecture = "";
2868 if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; }
2869 if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; }
2870
2871 replace_one_variable_in_file($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture);
2872
2873 if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer::exiter::exit_program("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); }
2874 my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'};
2875
2876 replace_one_variable_in_file($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects);
2877
2878 # Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists
2879 my $requiresstring = "";
2880 if ( $installer::globals::issolarissparcbuild ) { $requiresstring = "SOLSPARCPATCHREQUIRES"; }
2881 if ( $installer::globals::issolarisx86build ) { $requiresstring = "SOLIAPATCHREQUIRES"; }
2882
2883 if ( $allvariables->{$requiresstring} )
2884 {
2885 my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n";
2886 push(@{$patchinfofile}, $newline);
2887 }
2888}
2889
2890######################################################
2891# Finalizing patch: Renaming directory and
2892# including additional patch files.
2893######################################################
2894
2895sub finalize_patch
2896{
2897 my ( $newepmdir, $allvariables ) = @_;
2898
2899 my $patchidname = "SOLSPARCPATCHID";
2900 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; }
2901
2902 if ( ! $allvariables->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); }
2903 my $patchid = $allvariables->{$patchidname};
2904 installer::systemactions::rename_directory($newepmdir, $patchid);
2905
2906 # Copying all typical patch files into the patch directory
2907 # All patch file names are stored in @installer::globals::solarispatchfiles
2908 # Location of the file is $installer::globals::patchincludepath
2909
2910 my $sourcepath = $installer::globals::patchincludepath;
2911 $sourcepath =~ s/\/\s*$//;
2912
2913 for ( my $i = 0; $i <= $#installer::globals::solarispatchfiles; $i++ )
2914 {
2915 my $sourcefile = $sourcepath . $installer::globals::separator . $installer::globals::solarispatchfiles[$i];
2916 my $destfile = $patchid . $installer::globals::separator . $installer::globals::solarispatchfiles[$i];
2917 installer::systemactions::copy_one_file($sourcefile, $destfile);
2918 }
2919
2920 # And editing the patchinfo file
2921
2922 my $patchinfofilename = $patchid . $installer::globals::separator . "patchinfo";
2923 my $patchinfofile = installer::files::read_file($patchinfofilename);
2924 set_patchinfo($patchinfofile, $patchid, $allvariables);
2925 installer::files::save_file($patchinfofilename, $patchinfofile);
2926}
2927
2928######################################################
2929# Finalizing Linux patch: Renaming directory and
2930# including additional patch files.
2931######################################################
2932
2933sub finalize_linux_patch
2934{
2935 my ( $newepmdir, $allvariables, $includepatharrayref ) = @_;
2936
2937 # Copying the setup into the patch directory
2938 # and including the list of RPMs into it
2939
2940 print "... creating patch setup ...\n";
2941
2942 installer::logger::include_header_into_logfile("Creating Linux patch setup:");
2943
2944 # find and read setup script template
2945
2946 my $scriptfilename = "linuxpatchscript.sh";
2947 my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0);
2948 if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); }
2949 my $scriptfile = installer::files::read_file($$scriptref);
2950
2951 my $infoline = "Found script file $scriptfilename: $$scriptref \n";
2952 push( @installer::globals::logfileinfo, $infoline);
2953
2954 # Collecting all RPMs in the patch directory
2955
2956 my $fileextension = "rpm";
2957 my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $newepmdir);
2958 if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); }
2959 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); }
2960
2961 # Searching packagename containing -core01
2962 my $found_package = 0;
2963 my $searchpackagename = "";
2964 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
2965 {
2966 if ( ${$rpmfiles}[$i] =~ /-core01-/ )
2967 {
2968 $searchpackagename = ${$rpmfiles}[$i];
2969 $found_package = 1;
2970 if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; }
2971 last;
2972 }
2973 }
2974
2975 if ( ! $found_package ) { installer::exiter::exit_program("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); }
2976
2977 # Replacing the searchpackagename
2978 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; }
2979
2980 # Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname
2981 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; }
2982
2983 # Replacing the productname
2984 my $productname = $allvariables->{'PRODUCTNAME'};
2985 $productname = lc($productname);
2986 $productname =~ s/ /_/g; # abc office -> abc_office
2987
2988 $infoline = "Adding productname $productname into Linux patch script\n";
2989 push( @installer::globals::logfileinfo, $infoline);
2990
2991 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; }
2992
2993 # Saving the file
2994
2995 my $newscriptfilename = "setup";
2996 installer::files::save_file($newscriptfilename, $scriptfile);
2997
2998 $infoline = "Saved Linux patch setup $newscriptfilename \n";
2999 push( @installer::globals::logfileinfo, $infoline);
3000
3001 # Setting unix rights 755
3002 chmod 0755, $newscriptfilename;
3003}
3004
300519µs1;