1*9780544fSAndrew Rist#************************************************************** 2cdf0e10cSrcweir# 3*9780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*9780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 5*9780544fSAndrew Rist# distributed with this work for additional information 6*9780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*9780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 8*9780544fSAndrew Rist# "License"); you may not use this file except in compliance 9*9780544fSAndrew Rist# with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir# 11*9780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir# 13*9780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 14*9780544fSAndrew Rist# software distributed under the License is distributed on an 15*9780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9780544fSAndrew Rist# KIND, either express or implied. See the License for the 17*9780544fSAndrew Rist# specific language governing permissions and limitations 18*9780544fSAndrew Rist# under the License. 19cdf0e10cSrcweir# 20*9780544fSAndrew Rist#************************************************************** 21*9780544fSAndrew Rist 22*9780544fSAndrew Rist 23cdf0e10cSrcweirpackage installer::javainstaller; 24cdf0e10cSrcweir 25cdf0e10cSrcweiruse Cwd; 26cdf0e10cSrcweiruse installer::exiter; 27cdf0e10cSrcweiruse installer::files; 28cdf0e10cSrcweiruse installer::globals; 29cdf0e10cSrcweiruse installer::languages; 30cdf0e10cSrcweiruse installer::pathanalyzer; 31cdf0e10cSrcweiruse installer::scriptitems; 32cdf0e10cSrcweiruse installer::systemactions; 33cdf0e10cSrcweiruse installer::worker; 34cdf0e10cSrcweiruse installer::logger; 35cdf0e10cSrcweir 36cdf0e10cSrcweir############################################################## 37cdf0e10cSrcweir# Returning a specific language string from the block 38cdf0e10cSrcweir# of all translations 39cdf0e10cSrcweir############################################################## 40cdf0e10cSrcweir 41cdf0e10cSrcweirsub get_language_string_from_language_block 42cdf0e10cSrcweir{ 43cdf0e10cSrcweir my ($language_block, $language, $oldstring) = @_; 44cdf0e10cSrcweir 45cdf0e10cSrcweir my $newstring = ""; 46cdf0e10cSrcweir 47cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$language_block}; $i++ ) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir $newstring = $1; 52cdf0e10cSrcweir last; 53cdf0e10cSrcweir } 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir if ( $newstring eq "" ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir $language = "en-US"; # defaulting to english 59cdf0e10cSrcweir 60cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$language_block}; $i++ ) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir $newstring = $1; 65cdf0e10cSrcweir last; 66cdf0e10cSrcweir } 67cdf0e10cSrcweir } 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir return $newstring; 71cdf0e10cSrcweir} 72cdf0e10cSrcweir 73cdf0e10cSrcweir############################################################## 74cdf0e10cSrcweir# Returning the complete block in all languages 75cdf0e10cSrcweir# for a specified string 76cdf0e10cSrcweir############################################################## 77cdf0e10cSrcweir 78cdf0e10cSrcweirsub get_language_block_from_language_file 79cdf0e10cSrcweir{ 80cdf0e10cSrcweir my ($searchstring, $languagefile) = @_; 81cdf0e10cSrcweir 82cdf0e10cSrcweir my @language_block = (); 83cdf0e10cSrcweir 84cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagefile}; $i++ ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir my $counter = $i; 89cdf0e10cSrcweir 90cdf0e10cSrcweir push(@language_block, ${$languagefile}[$counter]); 91cdf0e10cSrcweir $counter++; 92cdf0e10cSrcweir 93cdf0e10cSrcweir while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ ))) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir push(@language_block, ${$languagefile}[$counter]); 96cdf0e10cSrcweir $counter++; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir last; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir return \@language_block; 104cdf0e10cSrcweir} 105cdf0e10cSrcweir 106cdf0e10cSrcweir####################################################### 107cdf0e10cSrcweir# Searching for the module name and description in the 108cdf0e10cSrcweir# modules collector 109cdf0e10cSrcweir####################################################### 110cdf0e10cSrcweir 111cdf0e10cSrcweirsub get_module_name_description 112cdf0e10cSrcweir{ 113cdf0e10cSrcweir my ($modulesarrayref, $onelanguage, $gid, $type) = @_; 114cdf0e10cSrcweir 115cdf0e10cSrcweir my $found = 0; 116cdf0e10cSrcweir 117cdf0e10cSrcweir my $newstring = ""; 118cdf0e10cSrcweir 119cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir my $onemodule = ${$modulesarrayref}[$i]; 122cdf0e10cSrcweir 123cdf0e10cSrcweir if ( $onemodule->{'gid'} eq $gid ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir my $typestring = $type . " " . "(" . $onelanguage . ")"; 126cdf0e10cSrcweir if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; } 127cdf0e10cSrcweir $found = 1; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir if ( $found ) { last; } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir # defaulting to english 134cdf0e10cSrcweir 135cdf0e10cSrcweir if ( ! $found ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir my $defaultlanguage = "en-US"; 138cdf0e10cSrcweir 139cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir my $onemodule = ${$modulesarrayref}[$i]; 142cdf0e10cSrcweir 143cdf0e10cSrcweir if ( $onemodule->{'gid'} eq $gid ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir my $typestring = $type . " " . "(" . $defaultlanguage . ")"; 146cdf0e10cSrcweir if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; } 147cdf0e10cSrcweir $found = 1; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir if ( $found ) { last; } 151cdf0e10cSrcweir } 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir return $newstring; 155cdf0e10cSrcweir} 156cdf0e10cSrcweir 157cdf0e10cSrcweir####################################################### 158cdf0e10cSrcweir# Setting the productname and productversion 159cdf0e10cSrcweir####################################################### 160cdf0e10cSrcweir 161cdf0e10cSrcweirsub set_productname_and_productversion 162cdf0e10cSrcweir{ 163cdf0e10cSrcweir my ($templatefile, $variableshashref) = @_; 164cdf0e10cSrcweir 165cdf0e10cSrcweir my $infoline = "\nSetting product name and product version in Java template file\n"; 166cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 167cdf0e10cSrcweir 168cdf0e10cSrcweir my $productname = $variableshashref->{'PRODUCTNAME'}; 169cdf0e10cSrcweir my $productversion = $variableshashref->{'PRODUCTVERSION'}; 170cdf0e10cSrcweir 171cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$templatefile}; $i++ ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir ${$templatefile}[$i] =~ s/\{PRODUCTNAME\}/$productname/g; 174cdf0e10cSrcweir ${$templatefile}[$i] =~ s/\{PRODUCTVERSION\}/$productversion/g; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir $infoline = "End of: Setting product name and product version in Java template file\n\n"; 178cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 179cdf0e10cSrcweir} 180cdf0e10cSrcweir 181cdf0e10cSrcweir####################################################### 182cdf0e10cSrcweir# Setting the localized Module name and description 183cdf0e10cSrcweir####################################################### 184cdf0e10cSrcweir 185cdf0e10cSrcweirsub set_component_name_and_description 186cdf0e10cSrcweir{ 187cdf0e10cSrcweir my ($templatefile, $modulesarrayref, $onelanguage) = @_; 188cdf0e10cSrcweir 189cdf0e10cSrcweir my $infoline = "\nSetting component names and description in Java template file\n"; 190cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 191cdf0e10cSrcweir 192cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$templatefile}; $i++ ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir # OOO_gid_Module_Prg_Wrt_Name 195cdf0e10cSrcweir # OOO_gid_Module_Prg_Wrt_Description 196cdf0e10cSrcweir 197cdf0e10cSrcweir my $oneline = ${$templatefile}[$i]; 198cdf0e10cSrcweir my $oldstring = ""; 199cdf0e10cSrcweir my $gid = ""; 200cdf0e10cSrcweir my $type = ""; 201cdf0e10cSrcweir 202cdf0e10cSrcweir if ( $oneline =~ /\b(OOO_gid_\w+)\b/ ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir $oldstring = $1; 205cdf0e10cSrcweir 206cdf0e10cSrcweir $infoline = "Found: $oldstring\n"; 207cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 208cdf0e10cSrcweir 209cdf0e10cSrcweir if ( $oldstring =~ /^\s*OOO_(gid_\w+)_(\w+?)\s*$/ ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir $gid = $1; 212cdf0e10cSrcweir $type = $2; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir my $newstring = get_module_name_description($modulesarrayref, $onelanguage, $gid, $type); 216cdf0e10cSrcweir 217cdf0e10cSrcweir $infoline = "\tReplacing (language $onelanguage): OLDSTRING: $oldstring NEWSTRING $newstring\n"; 218cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 219cdf0e10cSrcweir 220cdf0e10cSrcweir ${$templatefile}[$i] =~ s/$oldstring/$newstring/; # always substitute, even if $newstring eq "" 221cdf0e10cSrcweir } 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir $infoline = "End of: Setting component names and description in Java template file\n\n"; 225cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 226cdf0e10cSrcweir} 227cdf0e10cSrcweir 228cdf0e10cSrcweir####################################################### 229cdf0e10cSrcweir# Translating the Java file 230cdf0e10cSrcweir####################################################### 231cdf0e10cSrcweir 232cdf0e10cSrcweirsub translate_javafile 233cdf0e10cSrcweir{ 234cdf0e10cSrcweir my ($templatefile, $languagefile, $onelanguage) = @_; 235cdf0e10cSrcweir 236cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$templatefile}; $i++ ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir my @allstrings = (); 239cdf0e10cSrcweir 240cdf0e10cSrcweir my $oneline = ${$templatefile}[$i]; 241cdf0e10cSrcweir 242cdf0e10cSrcweir while ( $oneline =~ /\b(OOO_\w+)\b/ ) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir my $replacestring = $1; 245cdf0e10cSrcweir push(@allstrings, $replacestring); 246cdf0e10cSrcweir $oneline =~ s/$replacestring//; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir my $oldstring; 250cdf0e10cSrcweir 251cdf0e10cSrcweir foreach $oldstring (@allstrings) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir my $language_block = get_language_block_from_language_file($oldstring, $languagefile); 254cdf0e10cSrcweir my $newstring = get_language_string_from_language_block($language_block, $onelanguage, $oldstring); 255cdf0e10cSrcweir 256cdf0e10cSrcweir $newstring =~ s/\"/\\\"/g; # masquerading the " 257cdf0e10cSrcweir $newstring =~ s/\\\\\"/\\\"/g; # unmasquerading if \" was converted to \\" (because " was already masked) 258cdf0e10cSrcweir 259cdf0e10cSrcweir # if (!( $newstring eq "" )) { ${$idtfile}[$i] =~ s/$oldstring/$newstring/; } 260cdf0e10cSrcweir ${$templatefile}[$i] =~ s/$oldstring/$newstring/; # always substitute, even if $newstring eq "" 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir} 264cdf0e10cSrcweir 265cdf0e10cSrcweir########################################################### 266cdf0e10cSrcweir# Returning the license file name for a defined language 267cdf0e10cSrcweir########################################################### 268cdf0e10cSrcweir 269cdf0e10cSrcweirsub get_licensefilesource 270cdf0e10cSrcweir{ 271cdf0e10cSrcweir my ($language, $includepatharrayref) = @_; 272cdf0e10cSrcweir 273cdf0e10cSrcweir my $licensefilename = "LICENSE_" . $language; 274cdf0e10cSrcweir 275cdf0e10cSrcweir my $licenseref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $includepatharrayref, 0); 276cdf0e10cSrcweir if ($$licenseref eq "") { installer::exiter::exit_program("ERROR: Could not find License file $licensefilename!", "get_licensefilesource"); } 277cdf0e10cSrcweir 278cdf0e10cSrcweir my $infoline = "Found licensefile $licensefilename: $$licenseref \n"; 279cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 280cdf0e10cSrcweir 281cdf0e10cSrcweir return $$licenseref; 282cdf0e10cSrcweir} 283cdf0e10cSrcweir 284cdf0e10cSrcweir####################################################### 285cdf0e10cSrcweir# Converting the license string into the 286cdf0e10cSrcweir# Java specific encoding. 287cdf0e10cSrcweir####################################################### 288cdf0e10cSrcweir 289cdf0e10cSrcweirsub convert_licenstring 290cdf0e10cSrcweir{ 291cdf0e10cSrcweir my ($licensefile, $includepatharrayref, $javadir, $onelanguage) = @_; 292cdf0e10cSrcweir 293cdf0e10cSrcweir my $licensedir = $javadir . $installer::globals::separator . "license"; 294cdf0e10cSrcweir installer::systemactions::create_directory($licensedir); 295cdf0e10cSrcweir 296cdf0e10cSrcweir # saving the original license file 297cdf0e10cSrcweir 298cdf0e10cSrcweir my $licensefilename = $licensedir . $installer::globals::separator . "licensefile.txt"; 299cdf0e10cSrcweir installer::files::save_file($licensefilename, $licensefile); 300cdf0e10cSrcweir 301cdf0e10cSrcweir # creating the ulf file from the license file 302cdf0e10cSrcweir 303cdf0e10cSrcweir $licensefilename = $licensedir . $installer::globals::separator . "licensefile.ulf"; 304cdf0e10cSrcweir my @licensearray = (); 305cdf0e10cSrcweir 306cdf0e10cSrcweir my $section = "\[TRANSLATE\]\n"; 307cdf0e10cSrcweir push(@licensearray, $section); 308cdf0e10cSrcweir 309cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$licensefile}; $i++ ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir my $oneline = ${$licensefile}[$i]; 312cdf0e10cSrcweir 313cdf0e10cSrcweir if ($i == 0) { $oneline =~ s/^\s*\�\�\�//; } 314cdf0e10cSrcweir 315cdf0e10cSrcweir $oneline =~ s/\s*$//; 316cdf0e10cSrcweir $oneline =~ s/\"/\\\"/g; # masquerading the " 317cdf0e10cSrcweir $oneline =~ s/\'/\\\'/g; # masquerading the ' 318cdf0e10cSrcweir 319cdf0e10cSrcweir $oneline =~ s/\$\{/\{/g; # replacement of variables, only {PRODUCTNAME}, not ${PRODUCTNAME} 320cdf0e10cSrcweir 321cdf0e10cSrcweir my $ulfstring = $onelanguage . " = " . "\"" . $oneline . "\"\n"; 322cdf0e10cSrcweir push(@licensearray, $ulfstring); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir installer::files::save_file($licensefilename, \@licensearray); 326cdf0e10cSrcweir 327cdf0e10cSrcweir # converting the ulf file to the jlf file with ulfconv 328cdf0e10cSrcweir 329cdf0e10cSrcweir @licensearray = (); 330cdf0e10cSrcweir 331cdf0e10cSrcweir my $converter = "ulfconv"; 332cdf0e10cSrcweir 333cdf0e10cSrcweir my $converterref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$converter, $includepatharrayref, 0); 334cdf0e10cSrcweir if ($$converterref eq "") { installer::exiter::exit_program("ERROR: Could not find converter $converter!", "convert_licenstring"); } 335cdf0e10cSrcweir 336cdf0e10cSrcweir my $infoline = "Found converter file $converter: $$converterref \n"; 337cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 338cdf0e10cSrcweir 339cdf0e10cSrcweir my $systemcall = "$$converterref $licensefilename |"; 340cdf0e10cSrcweir open (CONV, "$systemcall"); 341cdf0e10cSrcweir @licensearray = <CONV>; 342cdf0e10cSrcweir close (CONV); 343cdf0e10cSrcweir 344cdf0e10cSrcweir $licensefilename = $licensedir . $installer::globals::separator . "licensefile.jlf"; 345cdf0e10cSrcweir installer::files::save_file($licensefilename, \@licensearray); 346cdf0e10cSrcweir 347cdf0e10cSrcweir # creating the license string from the jlf file 348cdf0e10cSrcweir 349cdf0e10cSrcweir $licensestring = ""; 350cdf0e10cSrcweir 351cdf0e10cSrcweir for ( my $i = 1; $i <= $#licensearray; $i++ ) # not the first line! 352cdf0e10cSrcweir { 353cdf0e10cSrcweir my $oneline = $licensearray[$i]; 354cdf0e10cSrcweir $oneline =~ s/^\s*$onelanguage\s*\=\s*\"//; 355cdf0e10cSrcweir $oneline =~ s/\"\s*$//; 356cdf0e10cSrcweir $licensestring = $licensestring . $oneline . "\\n"; 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir $infoline = "Systemcall: $systemcall\n"; 360cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 361cdf0e10cSrcweir 362cdf0e10cSrcweir if ( $licensestring eq "" ) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir $infoline = "ERROR: Could not convert $licensefilename !\n"; 365cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir return $licensestring; 369cdf0e10cSrcweir} 370cdf0e10cSrcweir 371cdf0e10cSrcweir####################################################### 372cdf0e10cSrcweir# Adding the license file into the java file 373cdf0e10cSrcweir# In the template java file there are two 374cdf0e10cSrcweir# occurences of INSTALLSDK_GUI_LICENSE 375cdf0e10cSrcweir# and INSTALLSDK_CONSOLE_LICENSE 376cdf0e10cSrcweir####################################################### 377cdf0e10cSrcweir 378cdf0e10cSrcweirsub add_license_file_into_javafile 379cdf0e10cSrcweir{ 380cdf0e10cSrcweir my ( $templatefile, $licensefile, $includepatharrayref, $javadir, $onelanguage ) = @_; 381cdf0e10cSrcweir 382cdf0e10cSrcweir my $licensestring = convert_licenstring($licensefile, $includepatharrayref, $javadir, $onelanguage); 383cdf0e10cSrcweir 384cdf0e10cSrcweir # saving the licensestring in an ulf file 385cdf0e10cSrcweir # converting the file using "ulfconv license.ulf" 386cdf0e10cSrcweir # including the new string into the java file 387cdf0e10cSrcweir 388cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$templatefile}; $i++ ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir ${$templatefile}[$i] =~ s/INSTALLSDK_GUI_LICENSE/$licensestring/; 391cdf0e10cSrcweir ${$templatefile}[$i] =~ s/INSTALLSDK_CONSOLE_LICENSE/$licensestring/; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir} 394cdf0e10cSrcweir 395cdf0e10cSrcweir####################################################### 396cdf0e10cSrcweir# Executing one system call 397cdf0e10cSrcweir####################################################### 398cdf0e10cSrcweir 399cdf0e10cSrcweirsub make_systemcall 400cdf0e10cSrcweir{ 401cdf0e10cSrcweir my ( $systemcall, $logreturn ) = @_; 402cdf0e10cSrcweir 403cdf0e10cSrcweir my @returns = (); 404cdf0e10cSrcweir 405cdf0e10cSrcweir installer::logger::print_message( "... $systemcall ...\n" ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir open (REG, "$systemcall"); 408cdf0e10cSrcweir while (<REG>) {push(@returns, $_); } 409cdf0e10cSrcweir close (REG); 410cdf0e10cSrcweir 411cdf0e10cSrcweir my $returnvalue = $?; # $? contains the return value of the systemcall 412cdf0e10cSrcweir 413cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 414cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 415cdf0e10cSrcweir 416cdf0e10cSrcweir if ( $logreturn ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir for ( my $j = 0; $j <= $#returns; $j++ ) { push( @installer::globals::logfileinfo, "$returns[$j]"); } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir if ($returnvalue) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir $infoline = "ERROR: $systemcall\n"; 424cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 425cdf0e10cSrcweir $error_occured = 1; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir else 428cdf0e10cSrcweir { 429cdf0e10cSrcweir $infoline = "SUCCESS: $systemcall\n"; 430cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir return \@returns; 434cdf0e10cSrcweir} 435cdf0e10cSrcweir 436cdf0e10cSrcweir####################################################### 437cdf0e10cSrcweir# Setting the class path for the Installer SDK 438cdf0e10cSrcweir####################################################### 439cdf0e10cSrcweir 440cdf0e10cSrcweirsub set_classpath_for_install_sdk 441cdf0e10cSrcweir{ 442cdf0e10cSrcweir my ( $directory ) = @_; 443cdf0e10cSrcweir 444cdf0e10cSrcweir my $installsdk = ""; 445cdf0e10cSrcweir my $solarVersion = ""; 446cdf0e10cSrcweir my $inPath = ""; 447cdf0e10cSrcweir my $updMinorExt = ""; 448cdf0e10cSrcweir 449cdf0e10cSrcweir if ( defined( $ENV{ 'SOLARVERSION' } ) ) { $solarVersion = $ENV{'SOLARVERSION'}; } 450cdf0e10cSrcweir else { installer::exiter::exit_program("ERROR: Environment variable \"SOLARVERSION\" not set!", "set_classpath_for_install_sdk"); } 451cdf0e10cSrcweir 452cdf0e10cSrcweir if ( defined( $ENV{ 'INPATH' } ) ) { $inPath = $ENV{'INPATH'}; } 453cdf0e10cSrcweir else { installer::exiter::exit_program("ERROR: Environment variable \"INPATH\" not set!", "set_classpath_for_install_sdk"); } 454cdf0e10cSrcweir 455cdf0e10cSrcweir if ( defined( $ENV{ 'UPDMINOREXT' } ) ) { $updMinorExt = $ENV{'UPDMINOREXT'}; } 456cdf0e10cSrcweir 457cdf0e10cSrcweir $installsdk = $solarVersion . $installer::globals::separator . $inPath . $installer::globals::separator . "bin" . $updMinorExt; 458cdf0e10cSrcweir $installsdk = $installsdk . $installer::globals::separator . "javainstaller"; 459cdf0e10cSrcweir 460cdf0e10cSrcweir if ( $ENV{'INSTALLSDK_SOURCE'} ) { $installsdk = $ENV{'INSTALLSDK_SOURCE'}; } # overriding the Install SDK with INSTALLSDK_SOURCE 461cdf0e10cSrcweir 462cdf0e10cSrcweir # The variable CLASSPATH has to contain: 463cdf0e10cSrcweir # $installsdk/classes:$installsdk/classes/setupsdk.jar: 464cdf0e10cSrcweir # $installsdk/classes/parser.jar:$installsdk/classes/jaxp.jar: 465cdf0e10cSrcweir # $installsdk/classes/ldapjdk.jar:$directory 466cdf0e10cSrcweir 467cdf0e10cSrcweir my @additional_classpath = (); 468cdf0e10cSrcweir push(@additional_classpath, "$installsdk\/classes"); 469cdf0e10cSrcweir push(@additional_classpath, "$installsdk\/installsdk.jar"); 470cdf0e10cSrcweir push(@additional_classpath, "$installsdk\/classes\/parser.jar"); 471cdf0e10cSrcweir push(@additional_classpath, "$installsdk\/classes\/jaxp.jar"); 472cdf0e10cSrcweir push(@additional_classpath, "$directory"); 473cdf0e10cSrcweir 474cdf0e10cSrcweir my $newclasspathstring = ""; 475cdf0e10cSrcweir my $oldclasspathstring = ""; 476cdf0e10cSrcweir if ( $ENV{'CLASSPATH'} ) { $oldclasspathstring = $ENV{'CLASSPATH'}; } 477cdf0e10cSrcweir else { $oldclasspathstring = "\."; } 478cdf0e10cSrcweir 479cdf0e10cSrcweir for ( my $i = 0; $i <= $#additional_classpath; $i++ ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir $newclasspathstring = $newclasspathstring . $additional_classpath[$i] . ":"; 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir $newclasspathstring = $newclasspathstring . $oldclasspathstring; 485cdf0e10cSrcweir 486cdf0e10cSrcweir $ENV{'CLASSPATH'} = $newclasspathstring; 487cdf0e10cSrcweir 488cdf0e10cSrcweir my $infoline = "Setting CLASSPATH to $ENV{'CLASSPATH'}\n"; 489cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 490cdf0e10cSrcweir} 491cdf0e10cSrcweir 492cdf0e10cSrcweir####################################################### 493cdf0e10cSrcweir# Setting the class file name in the Java locale file 494cdf0e10cSrcweir####################################################### 495cdf0e10cSrcweir 496cdf0e10cSrcweirsub set_classfilename 497cdf0e10cSrcweir{ 498cdf0e10cSrcweir my ($templatefile, $classfilename, $searchstring) = @_; 499cdf0e10cSrcweir 500cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$templatefile}; $j++ ) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir if ( ${$templatefile}[$j] =~ /\Q$searchstring\E/ ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir ${$templatefile}[$j] =~ s/$searchstring/$classfilename/; 505cdf0e10cSrcweir last; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir } 508cdf0e10cSrcweir} 509cdf0e10cSrcweir 510cdf0e10cSrcweir####################################################### 511cdf0e10cSrcweir# Substituting one variable in the xml file 512cdf0e10cSrcweir####################################################### 513cdf0e10cSrcweir 514cdf0e10cSrcweirsub replace_one_variable 515cdf0e10cSrcweir{ 516cdf0e10cSrcweir my ($xmlfile, $variable, $searchstring) = @_; 517cdf0e10cSrcweir 518cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir ${$xmlfile}[$i] =~ s/\$\{$searchstring\}/$variable/g; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir} 523cdf0e10cSrcweir 524cdf0e10cSrcweir####################################################### 525cdf0e10cSrcweir# Substituting the variables in the xml file 526cdf0e10cSrcweir####################################################### 527cdf0e10cSrcweir 528cdf0e10cSrcweirsub substitute_variables 529cdf0e10cSrcweir{ 530cdf0e10cSrcweir my ($xmlfile, $variableshashref) = @_; 531cdf0e10cSrcweir 532cdf0e10cSrcweir my $key; 533cdf0e10cSrcweir 534cdf0e10cSrcweir foreach $key (keys %{$variableshashref}) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir my $value = $variableshashref->{$key}; 537cdf0e10cSrcweir replace_one_variable($xmlfile, $value, $key); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir} 540cdf0e10cSrcweir 541cdf0e10cSrcweir########################################################## 542cdf0e10cSrcweir# Finding the line number in xml file of a special 543cdf0e10cSrcweir# component 544cdf0e10cSrcweir########################################################## 545cdf0e10cSrcweir 546cdf0e10cSrcweirsub find_component_line 547cdf0e10cSrcweir{ 548cdf0e10cSrcweir my ($xmlfile, $componentname) = @_; 549cdf0e10cSrcweir 550cdf0e10cSrcweir my $linenumber = 0; 551cdf0e10cSrcweir 552cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*$componentname/ ) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir $linenumber = $i; 557cdf0e10cSrcweir last; 558cdf0e10cSrcweir } 559cdf0e10cSrcweir } 560cdf0e10cSrcweir 561cdf0e10cSrcweir return $linenumber; 562cdf0e10cSrcweir} 563cdf0e10cSrcweir 564cdf0e10cSrcweir########################################################## 565cdf0e10cSrcweir# Removing one package from the xml file 566cdf0e10cSrcweir########################################################## 567cdf0e10cSrcweir 568cdf0e10cSrcweirsub remove_package 569cdf0e10cSrcweir{ 570cdf0e10cSrcweir my ($xmlfile, $packagename) = @_; 571cdf0e10cSrcweir 572cdf0e10cSrcweir my $searchstring = $packagename; 573cdf0e10cSrcweir if ( $searchstring =~ /\-(\S+?)\s*$/ ) { $searchstring = $1; } # "SUNW%PRODUCTNAME-mailcap" -> "mailcap" 574cdf0e10cSrcweir 575cdf0e10cSrcweir my $packagestring = ""; 576cdf0e10cSrcweir my $namestring = ""; 577cdf0e10cSrcweir my $infoline = ""; 578cdf0e10cSrcweir 579cdf0e10cSrcweir if ( $installer::globals::issolarispkgbuild ) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir $packagestring = "\<pkgunit"; 582cdf0e10cSrcweir $namestring = "pkgName"; 583cdf0e10cSrcweir } 584cdf0e10cSrcweir elsif ( $installer::globals::islinuxrpmbuild ) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir $packagestring = "\<rpmunit"; 587cdf0e10cSrcweir $namestring = "rpmUniqueName"; 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir my $removed_packge = 0; 591cdf0e10cSrcweir 592cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /^\s*\Q$packagestring\E/ ) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir # this is a package, but is it the correct one? 597cdf0e10cSrcweir 598cdf0e10cSrcweir my $do_delete = 0; 599cdf0e10cSrcweir my $linecounter = 1; 600cdf0e10cSrcweir my $startline = $i+1; 601cdf0e10cSrcweir my $line = ${$xmlfile}[$startline]; 602cdf0e10cSrcweir if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\-\Q$searchstring\E/)) { $do_delete = 1; } 603cdf0e10cSrcweir 604cdf0e10cSrcweir # but not deleting fonts package in language packs 605cdf0e10cSrcweir if ( $line =~ /-ONELANGUAGE-/ ) { $do_delete = 0; } 606cdf0e10cSrcweir 607cdf0e10cSrcweir my $endcounter = 0; 608cdf0e10cSrcweir 609cdf0e10cSrcweir while ((!( $line =~ /\/\>/ )) && ( $startline <= $#{$xmlfile} )) 610cdf0e10cSrcweir { 611cdf0e10cSrcweir $linecounter++; 612cdf0e10cSrcweir $startline++; 613cdf0e10cSrcweir $line = ${$xmlfile}[$startline]; 614cdf0e10cSrcweir if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\-\Q$searchstring\E/)) { $do_delete = 1; } 615cdf0e10cSrcweir } 616cdf0e10cSrcweir 617cdf0e10cSrcweir $linecounter = $linecounter + 1; 618cdf0e10cSrcweir 619cdf0e10cSrcweir if ( $do_delete ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir my $infoline = "\tReally removing package $packagename from xml file.\n"; 622cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 623cdf0e10cSrcweir splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i 624cdf0e10cSrcweir $removed_packge = 1; 625cdf0e10cSrcweir last; 626cdf0e10cSrcweir } 627cdf0e10cSrcweir } 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir if ( $removed_packge ) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir $infoline = "Package $packagename successfully removed from xml file.\n"; 633cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 634cdf0e10cSrcweir } 635cdf0e10cSrcweir else 636cdf0e10cSrcweir { 637cdf0e10cSrcweir $infoline = "Did not find package $packagename in xml file.\n"; 638cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir 641cdf0e10cSrcweir} 642cdf0e10cSrcweir 643cdf0e10cSrcweir########################################################## 644cdf0e10cSrcweir# Removing one component from the xml file 645cdf0e10cSrcweir########################################################## 646cdf0e10cSrcweir 647cdf0e10cSrcweirsub remove_component 648cdf0e10cSrcweir{ 649cdf0e10cSrcweir my ($xmlfile, $componentname) = @_; 650cdf0e10cSrcweir 651cdf0e10cSrcweir my @removed_lines = (); 652cdf0e10cSrcweir 653cdf0e10cSrcweir push(@removed_lines, "\n"); 654cdf0e10cSrcweir 655cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*$componentname/ ) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir # Counting the lines till the second "</component>" 660cdf0e10cSrcweir 661cdf0e10cSrcweir push(@removed_lines, ${$xmlfile}[$i]); 662cdf0e10cSrcweir my $linecounter = 1; 663cdf0e10cSrcweir my $startline = $i+1; 664cdf0e10cSrcweir my $line = ${$xmlfile}[$startline]; 665cdf0e10cSrcweir push(@removed_lines, $line); 666cdf0e10cSrcweir my $endcounter = 0; 667cdf0e10cSrcweir 668cdf0e10cSrcweir while ((!( $line =~ /^\s*\<\/component\>\s*$/ )) && ( $startline <= $#{$xmlfile} )) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir $linecounter++; 671cdf0e10cSrcweir $startline++; 672cdf0e10cSrcweir $line = ${$xmlfile}[$startline]; 673cdf0e10cSrcweir push(@removed_lines, $line); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir 676cdf0e10cSrcweir $linecounter = $linecounter + 2; # last line and following empty line 677cdf0e10cSrcweir 678cdf0e10cSrcweir splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i 679cdf0e10cSrcweir last; 680cdf0e10cSrcweir } 681cdf0e10cSrcweir } 682cdf0e10cSrcweir 683cdf0e10cSrcweir return \@removed_lines; 684cdf0e10cSrcweir} 685cdf0e10cSrcweir 686cdf0e10cSrcweir########################################################## 687cdf0e10cSrcweir# If this is an installation set without language packs 688cdf0e10cSrcweir# the language pack module can be removed 689cdf0e10cSrcweir########################################################## 690cdf0e10cSrcweir 691cdf0e10cSrcweirsub remove_languagepack_from_xmlfile 692cdf0e10cSrcweir{ 693cdf0e10cSrcweir my ($xmlfile) = @_; 694cdf0e10cSrcweir 695cdf0e10cSrcweir # Component begins with "<component selected="true" name='module_languagepacks' componentVersion="${PRODUCTVERSION}">" 696cdf0e10cSrcweir # and ends with "</component>" (the second "</component>" !) 697cdf0e10cSrcweir 698cdf0e10cSrcweir remove_component($xmlfile, "languagepack_DEFAULT"); 699cdf0e10cSrcweir remove_component($xmlfile, "languagepack_ONELANGUAGE"); 700cdf0e10cSrcweir remove_component($xmlfile, "module_languagepacks"); 701cdf0e10cSrcweir} 702cdf0e10cSrcweir 703cdf0e10cSrcweir########################################################## 704cdf0e10cSrcweir# Duplicating a component 705cdf0e10cSrcweir########################################################## 706cdf0e10cSrcweir 707cdf0e10cSrcweirsub duplicate_component 708cdf0e10cSrcweir{ 709cdf0e10cSrcweir my ( $arrayref ) = @_; 710cdf0e10cSrcweir 711cdf0e10cSrcweir @newarray = (); 712cdf0e10cSrcweir 713cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$arrayref}; $i++ ) 714cdf0e10cSrcweir { 715cdf0e10cSrcweir push(@newarray, ${$arrayref}[$i]); 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir return \@newarray; 719cdf0e10cSrcweir} 720cdf0e10cSrcweir 721cdf0e10cSrcweir########################################################## 722cdf0e10cSrcweir# Including a component into the xml file 723cdf0e10cSrcweir# at a specified line 724cdf0e10cSrcweir########################################################## 725cdf0e10cSrcweir 726cdf0e10cSrcweirsub include_component_at_specific_line 727cdf0e10cSrcweir{ 728cdf0e10cSrcweir my ($xmlfile, $unit, $line) = @_; 729cdf0e10cSrcweir 730cdf0e10cSrcweir splice(@{$xmlfile},$line, 0, @{$unit}); 731cdf0e10cSrcweir} 732cdf0e10cSrcweir 733cdf0e10cSrcweir########################################################## 734cdf0e10cSrcweir# Font packages do not exist for all languages. 735cdf0e10cSrcweir########################################################## 736cdf0e10cSrcweir 737cdf0e10cSrcweirsub remove_font_package_from_unit 738cdf0e10cSrcweir{ 739cdf0e10cSrcweir my ( $unitcopy, $onelanguage ) = @_; 740cdf0e10cSrcweir 741cdf0e10cSrcweir my $searchstring = "-fonts"; 742cdf0e10cSrcweir 743cdf0e10cSrcweir my $packagestring = ""; 744cdf0e10cSrcweir my $namestring = ""; 745cdf0e10cSrcweir 746cdf0e10cSrcweir if ( $installer::globals::issolarispkgbuild ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir $packagestring = "\<pkgunit"; 749cdf0e10cSrcweir $namestring = "pkgName"; 750cdf0e10cSrcweir } 751cdf0e10cSrcweir elsif ( $installer::globals::islinuxrpmbuild ) 752cdf0e10cSrcweir { 753cdf0e10cSrcweir $packagestring = "\<rpmunit"; 754cdf0e10cSrcweir $namestring = "rpmUniqueName"; 755cdf0e10cSrcweir } 756cdf0e10cSrcweir 757cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$unitcopy}; $i++ ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir if ( ${$unitcopy}[$i] =~ /^\s*\Q$packagestring\E/ ) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir # this is a package, but is it the correct one? 762cdf0e10cSrcweir 763cdf0e10cSrcweir my $do_delete = 0; 764cdf0e10cSrcweir my $linecounter = 1; 765cdf0e10cSrcweir my $startline = $i+1; 766cdf0e10cSrcweir my $line = ${$unitcopy}[$startline]; 767cdf0e10cSrcweir if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\Q$searchstring\E/)) { $do_delete = 1; } 768cdf0e10cSrcweir 769cdf0e10cSrcweir my $endcounter = 0; 770cdf0e10cSrcweir 771cdf0e10cSrcweir while ((!( $line =~ /\/\>/ )) && ( $startline <= $#{$unitcopy} )) 772cdf0e10cSrcweir { 773cdf0e10cSrcweir $linecounter++; 774cdf0e10cSrcweir $startline++; 775cdf0e10cSrcweir $line = ${$unitcopy}[$startline]; 776cdf0e10cSrcweir if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\Q$searchstring\E/)) { $do_delete = 1; } 777cdf0e10cSrcweir } 778cdf0e10cSrcweir 779cdf0e10cSrcweir $linecounter = $linecounter + 1; 780cdf0e10cSrcweir 781cdf0e10cSrcweir if ( $do_delete ) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir splice(@{$unitcopy},$i, $linecounter); # removing $linecounter lines, beginning in line $i 784cdf0e10cSrcweir last; 785cdf0e10cSrcweir } 786cdf0e10cSrcweir } 787cdf0e10cSrcweir } 788cdf0e10cSrcweir} 789cdf0e10cSrcweir 790cdf0e10cSrcweir########################################################## 791cdf0e10cSrcweir# If this is an installation set with language packs, 792cdf0e10cSrcweir# modules for each language pack have to be created 793cdf0e10cSrcweir# dynamically 794cdf0e10cSrcweir########################################################## 795cdf0e10cSrcweir 796cdf0e10cSrcweirsub duplicate_languagepack_in_xmlfile 797cdf0e10cSrcweir{ 798cdf0e10cSrcweir my ($xmlfile, $languagesarrayref) = @_; 799cdf0e10cSrcweir 800cdf0e10cSrcweir my $unit = remove_component($xmlfile, "languagepack_ONELANGUAGE"); 801cdf0e10cSrcweir my $startline = find_component_line($xmlfile, "module_languagepacks"); 802cdf0e10cSrcweir my $infoline = ""; 803cdf0e10cSrcweir $startline = $startline + 1; 804cdf0e10cSrcweir 805cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ ) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir my $onelanguage = ${$languagesarrayref}[$i]; 808cdf0e10cSrcweir my $unitcopy = duplicate_component($unit); 809cdf0e10cSrcweir 810cdf0e10cSrcweir # replacing string ONELANGUAGE in the unit copy 811cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$unitcopy}; $j++ ) { ${$unitcopy}[$j] =~ s/ONELANGUAGE/$onelanguage/g; } 812cdf0e10cSrcweir 813cdf0e10cSrcweir # including the unitcopy into the xml file 814cdf0e10cSrcweir include_component_at_specific_line($xmlfile, $unitcopy, $startline); 815cdf0e10cSrcweir $startline = $startline + $#{$unitcopy} + 1; 816cdf0e10cSrcweir } 817cdf0e10cSrcweir 818cdf0e10cSrcweir # adding the default language as language pack, too 819cdf0e10cSrcweir $unit = remove_component($xmlfile, "languagepack_DEFAULT"); 820cdf0e10cSrcweir $startline = find_component_line($xmlfile, "module_languagepacks"); 821cdf0e10cSrcweir $startline = $startline + 1; 822cdf0e10cSrcweir 823cdf0e10cSrcweir $onelanguage = ${$languagesarrayref}[0]; 824cdf0e10cSrcweir $unitcopy = duplicate_component($unit); 825cdf0e10cSrcweir 826cdf0e10cSrcweir # replacing string DEFAULT in the unit copy 827cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$unitcopy}; $j++ ) { ${$unitcopy}[$j] =~ s/DEFAULT/$onelanguage/g; } 828cdf0e10cSrcweir 829cdf0e10cSrcweir # including the unitcopy into the xml file 830cdf0e10cSrcweir include_component_at_specific_line($xmlfile, $unitcopy, $startline); 831cdf0e10cSrcweir $startline = $startline + $#{$unitcopy} + 1; 832cdf0e10cSrcweir} 833cdf0e10cSrcweir 834cdf0e10cSrcweir####################################################### 835cdf0e10cSrcweir# Removing empty packages from xml file. The names 836cdf0e10cSrcweir# are stored in @installer::globals::emptypackages 837cdf0e10cSrcweir####################################################### 838cdf0e10cSrcweir 839cdf0e10cSrcweirsub remove_empty_packages_in_xmlfile 840cdf0e10cSrcweir{ 841cdf0e10cSrcweir my ($xmlfile) = @_; 842cdf0e10cSrcweir 843cdf0e10cSrcweir for ( my $i = 0; $i <= $#installer::globals::emptypackages; $i++ ) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir my $packagename = $installer::globals::emptypackages[$i]; 846cdf0e10cSrcweir my $infoline = "Try to remove package $packagename from xml file.\n"; 847cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 848cdf0e10cSrcweir remove_package($xmlfile, $packagename); 849cdf0e10cSrcweir } 850cdf0e10cSrcweir} 851cdf0e10cSrcweir 852cdf0e10cSrcweir####################################################### 853cdf0e10cSrcweir# Preparing the language packs in the xml file 854cdf0e10cSrcweir####################################################### 855cdf0e10cSrcweir 856cdf0e10cSrcweirsub prepare_language_pack_in_xmlfile 857cdf0e10cSrcweir{ 858cdf0e10cSrcweir my ($xmlfile, $languagesarrayref) = @_; 859cdf0e10cSrcweir 860cdf0e10cSrcweir # if ( ! $installer::globals::is_unix_multi ) 861cdf0e10cSrcweir # { 862cdf0e10cSrcweir # remove_languagepack_from_xmlfile($xmlfile); 863cdf0e10cSrcweir # } 864cdf0e10cSrcweir # else 865cdf0e10cSrcweir # { 866cdf0e10cSrcweir duplicate_languagepack_in_xmlfile($xmlfile, $languagesarrayref); 867cdf0e10cSrcweir # } 868cdf0e10cSrcweir 869cdf0e10cSrcweir} 870cdf0e10cSrcweir 871cdf0e10cSrcweir####################################################### 872cdf0e10cSrcweir# Returning a rpm unit from a xml file 873cdf0e10cSrcweir####################################################### 874cdf0e10cSrcweir 875cdf0e10cSrcweirsub get_rpm_unit_from_xmlfile 876cdf0e10cSrcweir{ 877cdf0e10cSrcweir my ($rpmname, $xmlfile) = @_; 878cdf0e10cSrcweir 879cdf0e10cSrcweir my $infoline = "Searching for $rpmname in xml file.\n"; 880cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 881cdf0e10cSrcweir 882cdf0e10cSrcweir my @rpmunit = (); 883cdf0e10cSrcweir my $includeline = 0; 884cdf0e10cSrcweir my $record = 0; 885cdf0e10cSrcweir my $foundrpm = 0; 886cdf0e10cSrcweir 887cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir my $oneline = ${$xmlfile}[$i]; 890cdf0e10cSrcweir 891cdf0e10cSrcweir if ( $oneline =~ /^\s*\<rpmunit/ ) { $record = 1; } 892cdf0e10cSrcweir 893cdf0e10cSrcweir if ( $record ) { push(@rpmunit, $oneline); } 894cdf0e10cSrcweir 895cdf0e10cSrcweir if ( $oneline =~ /^\s*rpmUniqueName\s*=\s*\"\Q$rpmname\E\"\s*$/ ) { $foundrpm = 1; } 896cdf0e10cSrcweir 897cdf0e10cSrcweir if (( $record ) && ( $oneline =~ /\/\>\s*$/ )) { $record = 0; } 898cdf0e10cSrcweir 899cdf0e10cSrcweir if (( ! $foundrpm ) && ( ! $record )) { @rpmunit = (); } 900cdf0e10cSrcweir 901cdf0e10cSrcweir if (( $foundrpm ) && ( ! $record )) { $includeline = $i + 1; } 902cdf0e10cSrcweir 903cdf0e10cSrcweir if (( $foundrpm ) && ( ! $record )) { last; } 904cdf0e10cSrcweir } 905cdf0e10cSrcweir 906cdf0e10cSrcweir if ( ! $foundrpm ) { installer::exiter::exit_program("ERROR: Did not find rpmunit $rpmname in xml file!", "get_rpm_unit_from_xmlfile"); } 907cdf0e10cSrcweir 908cdf0e10cSrcweir $infoline = "Found $rpmname in xml file. Returning block lines: $#rpmunit + 1. Includeline: $includeline \n"; 909cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 910cdf0e10cSrcweir 911cdf0e10cSrcweir return (\@rpmunit, $includeline); 912cdf0e10cSrcweir} 913cdf0e10cSrcweir 914cdf0e10cSrcweir####################################################### 915cdf0e10cSrcweir# Exchanging package names in xml file 916cdf0e10cSrcweir####################################################### 917cdf0e10cSrcweir 918cdf0e10cSrcweirsub exchange_name_in_rpmunit 919cdf0e10cSrcweir{ 920cdf0e10cSrcweir my ($rpmunit, $oldpackagename, $newpackagename) = @_; 921cdf0e10cSrcweir 922cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$rpmunit}; $i++ ) 923cdf0e10cSrcweir { 924cdf0e10cSrcweir ${$rpmunit}[$i] =~ s/$oldpackagename/$newpackagename/; 925cdf0e10cSrcweir } 926cdf0e10cSrcweir} 927cdf0e10cSrcweir 928cdf0e10cSrcweir####################################################### 929cdf0e10cSrcweir# Preparing link RPMs in the xml file 930cdf0e10cSrcweir####################################################### 931cdf0e10cSrcweir 932cdf0e10cSrcweirsub prepare_linkrpm_in_xmlfile 933cdf0e10cSrcweir{ 934cdf0e10cSrcweir my ($xmlfile, $rpmlist) = @_; 935cdf0e10cSrcweir 936cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$rpmlist}; $i++ ) 937cdf0e10cSrcweir { 938cdf0e10cSrcweir my $oldpackagename = ""; 939cdf0e10cSrcweir my $newpackagename = ""; 940cdf0e10cSrcweir 941cdf0e10cSrcweir my $rpmline = ${$rpmlist}[$i]; 942cdf0e10cSrcweir 943cdf0e10cSrcweir my $infoline = "Preparing link/patch RPM: $rpmline\n"; 944cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 945cdf0e10cSrcweir 946cdf0e10cSrcweir if ( $rpmline =~ /^\s*(\S.*?\S)\s+(\S.*?\S)\s*$/ ) 947cdf0e10cSrcweir { 948cdf0e10cSrcweir $oldpackagename = $1; 949cdf0e10cSrcweir $newpackagename = $2; 950cdf0e10cSrcweir } 951cdf0e10cSrcweir 952cdf0e10cSrcweir my ($rpmunit, $includeline) = get_rpm_unit_from_xmlfile($oldpackagename, $xmlfile); 953cdf0e10cSrcweir exchange_name_in_rpmunit($rpmunit, $oldpackagename, $newpackagename); 954cdf0e10cSrcweir include_component_at_specific_line($xmlfile, $rpmunit, $includeline); 955cdf0e10cSrcweir } 956cdf0e10cSrcweir} 957cdf0e10cSrcweir 958cdf0e10cSrcweir####################################################################### 959cdf0e10cSrcweir# Removing w4w filter module from xml file for Solaris x86 and Linux 960cdf0e10cSrcweir####################################################################### 961cdf0e10cSrcweir 962cdf0e10cSrcweirsub remove_w4w_from_xmlfile 963cdf0e10cSrcweir{ 964cdf0e10cSrcweir my ($xmlfile) = @_; 965cdf0e10cSrcweir 966cdf0e10cSrcweir # Component begins with "<component selected='true' name='gid_Module_Prg_Wrt_Flt_W4w' componentVersion="8">" 967cdf0e10cSrcweir # and ends with "</component>" 968cdf0e10cSrcweir 969cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 970cdf0e10cSrcweir { 971cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*gid_Module_Prg_Wrt_Flt_W4w/ ) 972cdf0e10cSrcweir { 973cdf0e10cSrcweir # Counting the lines till "</component>" 974cdf0e10cSrcweir 975cdf0e10cSrcweir my $linecounter = 1; 976cdf0e10cSrcweir my $startline = $i+1; 977cdf0e10cSrcweir my $line = ${$xmlfile}[$startline]; 978cdf0e10cSrcweir 979cdf0e10cSrcweir while ((!( $line =~ /^\s*\<\/component\>\s*$/ )) && ( $startline <= $#{$xmlfile} )) 980cdf0e10cSrcweir { 981cdf0e10cSrcweir $linecounter++; 982cdf0e10cSrcweir $startline++; 983cdf0e10cSrcweir $line = ${$xmlfile}[$startline]; 984cdf0e10cSrcweir } 985cdf0e10cSrcweir 986cdf0e10cSrcweir $linecounter = $linecounter + 2; # last line and following empty line 987cdf0e10cSrcweir 988cdf0e10cSrcweir splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i 989cdf0e10cSrcweir last; 990cdf0e10cSrcweir } 991cdf0e10cSrcweir } 992cdf0e10cSrcweir} 993cdf0e10cSrcweir 994cdf0e10cSrcweir####################################################################### 995cdf0e10cSrcweir# Removing module from xml file, if not defined in scp 996cdf0e10cSrcweir####################################################################### 997cdf0e10cSrcweir 998cdf0e10cSrcweirsub remove_scpgid_from_xmlfile 999cdf0e10cSrcweir{ 1000cdf0e10cSrcweir my ($xmlfile, $scpgid) = @_; 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir # Component begins with "<component selected='true' name='$scpgid' componentVersion="8">" 1003cdf0e10cSrcweir # and ends with "</component>" 1004cdf0e10cSrcweir 1005cdf0e10cSrcweir my $successfully_removed = 0; 1006cdf0e10cSrcweir 1007cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*\Q$scpgid\E/ ) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir # Counting the lines till "</component>" 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir my $linecounter = 1; 1014cdf0e10cSrcweir my $startline = $i+1; 1015cdf0e10cSrcweir my $line = ${$xmlfile}[$startline]; 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir while ((!( $line =~ /^\s*\<\/component\>\s*$/ )) && ( $startline <= $#{$xmlfile} )) 1018cdf0e10cSrcweir { 1019cdf0e10cSrcweir $linecounter++; 1020cdf0e10cSrcweir $startline++; 1021cdf0e10cSrcweir $line = ${$xmlfile}[$startline]; 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir $linecounter = $linecounter + 2; # last line and following empty line 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i 1027cdf0e10cSrcweir $successfully_removed = 1; 1028cdf0e10cSrcweir last; 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir my $infoline = ""; 1033cdf0e10cSrcweir if ($successfully_removed) 1034cdf0e10cSrcweir { 1035cdf0e10cSrcweir $infoline = "Module $scpgid successfully removed from xml file.\n"; 1036cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir else 1039cdf0e10cSrcweir { 1040cdf0e10cSrcweir $infoline = "Module $scpgid not found in xml file (no problem).\n"; 1041cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir} 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir####################################################################### 1046cdf0e10cSrcweir# Special mechanism for removing modules for xml file, if they are 1047cdf0e10cSrcweir# not defined in scp (introduced for onlineupdate module). 1048cdf0e10cSrcweir####################################################################### 1049cdf0e10cSrcweir 1050cdf0e10cSrcweirsub remove_module_if_not_defined 1051cdf0e10cSrcweir{ 1052cdf0e10cSrcweir my ($xmlfile, $modulesarrayref, $scpgid) = @_; 1053cdf0e10cSrcweir 1054cdf0e10cSrcweir my $infoline = "Checking existence of $scpgid in scp definition\n"; 1055cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1056cdf0e10cSrcweir 1057cdf0e10cSrcweir my $found = 0; 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 1060cdf0e10cSrcweir { 1061cdf0e10cSrcweir my $onemodule = ${$modulesarrayref}[$i]; 1062cdf0e10cSrcweir if ( $onemodule->{'gid'} eq $scpgid ) { $found = 1; } 1063cdf0e10cSrcweir if ( $found ) { last; } 1064cdf0e10cSrcweir } 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir if ( ! $found ) 1067cdf0e10cSrcweir { 1068cdf0e10cSrcweir $infoline = "Module $scpgid not found -> Removing from xml file.\n"; 1069cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1070cdf0e10cSrcweir remove_scpgid_from_xmlfile($xmlfile, $scpgid); 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir} 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir########################################################### 1075cdf0e10cSrcweir# Preparing the package subdirectory 1076cdf0e10cSrcweir########################################################### 1077cdf0e10cSrcweir 1078cdf0e10cSrcweirsub create_empty_packages 1079cdf0e10cSrcweir{ 1080cdf0e10cSrcweir my ( $xmlfile ) = @_; 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir if ( $installer::globals::issolarispkgbuild ) 1083cdf0e10cSrcweir { 1084cdf0e10cSrcweir my $path = ""; 1085cdf0e10cSrcweir 1086cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1087cdf0e10cSrcweir { 1088cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /pkgRelativePath\s*\=\s*\'(.*?)\'\s*$/ ) 1089cdf0e10cSrcweir { 1090cdf0e10cSrcweir $path = $1; 1091cdf0e10cSrcweir installer::systemactions::create_directory_structure($path); 1092cdf0e10cSrcweir last; # only creating one path 1093cdf0e10cSrcweir } 1094cdf0e10cSrcweir } 1095cdf0e10cSrcweir 1096cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1097cdf0e10cSrcweir { 1098cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /pkgName\s*\=\s*\'(.*?)\'\s*$/ ) 1099cdf0e10cSrcweir { 1100cdf0e10cSrcweir my $pkgname = $1; 1101cdf0e10cSrcweir if ( $path ne "" ) { $pkgname = $path . $installer::globals::separator . $pkgname; } 1102cdf0e10cSrcweir installer::systemactions::create_directory_structure($pkgname); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir } 1105cdf0e10cSrcweir } 1106cdf0e10cSrcweir 1107cdf0e10cSrcweir # "-novalidate" does not work for Linux RPMs 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1112cdf0e10cSrcweir { 1113cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /rpmPath\s*\=\s*\"(.*?)\"\s*$/ ) 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir my $rpmpath = $1; 1116cdf0e10cSrcweir my $path = ""; 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir if ( $rpmpath =~ /^\s*(.*)\/(.*?)\s*$/ ) 1119cdf0e10cSrcweir { 1120cdf0e10cSrcweir $path = $1; 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir if ( $path ne "" ) { installer::systemactions::create_directory_structure($path); } 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir my $systemcall = "touch $rpmpath"; # creating empty rpm 1126cdf0e10cSrcweir system($systemcall); 1127cdf0e10cSrcweir } 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir } 1130cdf0e10cSrcweir} 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir########################################################### 1133cdf0e10cSrcweir# Reading the archive file name from the xml file 1134cdf0e10cSrcweir########################################################### 1135cdf0e10cSrcweir 1136cdf0e10cSrcweirsub get_archivefilename 1137cdf0e10cSrcweir{ 1138cdf0e10cSrcweir my ( $xmlfile ) = @_; 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir my $archivefilename = ""; 1141cdf0e10cSrcweir 1142cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$xmlfile}; $j++ ) 1143cdf0e10cSrcweir { 1144cdf0e10cSrcweir if ( ${$xmlfile}[$j] =~ /archiveFileName\s*=\s*\'(.*?)\'/ ) 1145cdf0e10cSrcweir { 1146cdf0e10cSrcweir $archivefilename = $1; 1147cdf0e10cSrcweir last; 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir return $archivefilename; 1152cdf0e10cSrcweir} 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir####################################################### 1155cdf0e10cSrcweir# Copying the loader locally 1156cdf0e10cSrcweir####################################################### 1157cdf0e10cSrcweir 1158cdf0e10cSrcweirsub copy_setup_locally 1159cdf0e10cSrcweir{ 1160cdf0e10cSrcweir my ($includepatharrayref, $loadername, $newname) = @_; 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir my $loadernameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$loadername, $includepatharrayref, 0); 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir if ($$loadernameref eq "") { installer::exiter::exit_program("ERROR: Could not find Java loader $loadername!", "copy_setup_locally"); } 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir installer::systemactions::copy_one_file($$loadernameref, $newname); 1167cdf0e10cSrcweir my $localcall = "chmod 775 $newname \>\/dev\/null 2\>\&1"; 1168cdf0e10cSrcweir system($localcall); 1169cdf0e10cSrcweir} 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir####################################################### 1173cdf0e10cSrcweir# Copying the loader into the installation set 1174cdf0e10cSrcweir####################################################### 1175cdf0e10cSrcweir 1176cdf0e10cSrcweirsub put_loader_into_installset 1177cdf0e10cSrcweir{ 1178cdf0e10cSrcweir my ($installdir, $filename) = @_; 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir my $installname = $installdir . $installer::globals::separator . $filename; 1181cdf0e10cSrcweir 1182cdf0e10cSrcweir installer::systemactions::copy_one_file($filename, $installname); 1183cdf0e10cSrcweir 1184cdf0e10cSrcweir my $localcall = "chmod 775 $installname \>\/dev\/null 2\>\&1"; 1185cdf0e10cSrcweir system($localcall); 1186cdf0e10cSrcweir} 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir################################################################# 1189cdf0e10cSrcweir# Setting for Solaris the package names in the Java translation 1190cdf0e10cSrcweir# file. The name is used for the 1191cdf0e10cSrcweir# This name is displayed tools like prodreg. 1192cdf0e10cSrcweir# Unfortunately this name in the component is also used 1193cdf0e10cSrcweir# in the translation template file for the module name 1194cdf0e10cSrcweir# and module description translations. 1195cdf0e10cSrcweir################################################################# 1196cdf0e10cSrcweir 1197cdf0e10cSrcweirsub replace_component_name_in_java_file 1198cdf0e10cSrcweir{ 1199cdf0e10cSrcweir my ($alljavafiles, $oldname, $newname) = @_; 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir # The new name must not contain white spaces 1202cdf0e10cSrcweir 1203cdf0e10cSrcweir $newname =~ s/ /\_/g; 1204cdf0e10cSrcweir 1205cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alljavafiles}; $i++ ) 1206cdf0e10cSrcweir { 1207cdf0e10cSrcweir my $javafilename = ${$alljavafiles}[$i]; 1208cdf0e10cSrcweir my $javafile = installer::files::read_file($javafilename); 1209cdf0e10cSrcweir 1210cdf0e10cSrcweir my $oldstring = "ComponentDescription-" . $oldname; 1211cdf0e10cSrcweir my $newstring = "ComponentDescription-" . $newname; 1212cdf0e10cSrcweir 1213cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$javafile}; $j++ ) { ${$javafile}[$j] =~ s/\b$oldstring\b/$newstring/; } 1214cdf0e10cSrcweir 1215cdf0e10cSrcweir $oldstring = $oldname . "-install-DisplayName"; 1216cdf0e10cSrcweir $newstring = $newname . "-install-DisplayName"; 1217cdf0e10cSrcweir 1218cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$javafile}; $j++ ) { ${$javafile}[$j] =~ s/\b$oldstring\b/$newstring/; } 1219cdf0e10cSrcweir 1220cdf0e10cSrcweir $oldstring = $oldname . "-uninstall-DisplayName"; 1221cdf0e10cSrcweir $newstring = $newname . "-uninstall-DisplayName"; 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$javafile}; $j++ ) { ${$javafile}[$j] =~ s/\b$oldstring\b/$newstring/; } 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir installer::files::save_file($javafilename, $javafile); 1226cdf0e10cSrcweir $infoline = "Changes in Java file: $javafilename : $oldname \-\> $newname\n"; 1227cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir} 1230cdf0e10cSrcweir 1231cdf0e10cSrcweir################################################################# 1232cdf0e10cSrcweir# Some module names are not defined in the scp project. 1233cdf0e10cSrcweir# The names for this modules are searched in the base Java 1234cdf0e10cSrcweir# translation file. 1235cdf0e10cSrcweir################################################################# 1236cdf0e10cSrcweir 1237cdf0e10cSrcweirsub get_module_name_from_basejavafile 1238cdf0e10cSrcweir{ 1239cdf0e10cSrcweir my ($componentname, $javatemplateorigfile, $ulffile) = @_; 1240cdf0e10cSrcweir 1241cdf0e10cSrcweir my $searchname = $componentname . "-install-DisplayName"; 1242cdf0e10cSrcweir my $modulename = ""; 1243cdf0e10cSrcweir my $replacename = ""; 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir # line content: { "coremodule-install-DisplayName", "OOO_INSTALLSDK_117" }, 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$javatemplateorigfile}; $i++ ) 1248cdf0e10cSrcweir { 1249cdf0e10cSrcweir if ( ${$javatemplateorigfile}[$i] =~ /\"\s*\Q$searchname\E\s*\"\s*\,\s*\"\s*(.*?)\s*\"\s*\}\s*\,\s*$/ ) 1250cdf0e10cSrcweir { 1251cdf0e10cSrcweir $replacename = $1; 1252cdf0e10cSrcweir last; 1253cdf0e10cSrcweir } 1254cdf0e10cSrcweir } 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir if ( $replacename ne "" ) 1257cdf0e10cSrcweir { 1258cdf0e10cSrcweir my $language_block = get_language_block_from_language_file($replacename, $ulffile); 1259cdf0e10cSrcweir $modulename = get_language_string_from_language_block($language_block, "en-US", $replacename); 1260cdf0e10cSrcweir } 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir return $modulename; 1263cdf0e10cSrcweir} 1264cdf0e10cSrcweir 1265cdf0e10cSrcweir################################################################# 1266cdf0e10cSrcweir# Setting for Solaris the package names in the xml file. 1267cdf0e10cSrcweir# This name is displayed tools like prodreg. 1268cdf0e10cSrcweir# Unfortunately this name in the component is also used 1269cdf0e10cSrcweir# in the translation template file for the module name 1270cdf0e10cSrcweir# and module description translations. 1271cdf0e10cSrcweir################################################################# 1272cdf0e10cSrcweir 1273cdf0e10cSrcweirsub replace_component_names 1274cdf0e10cSrcweir{ 1275cdf0e10cSrcweir my ($xmlfile, $templatefilename, $modulesarrayref, $javatemplateorigfile, $ulffile) = @_; 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir # path in which all java languages files are located 1278cdf0e10cSrcweir 1279cdf0e10cSrcweir my $javafilesdir = $templatefilename; 1280cdf0e10cSrcweir installer::pathanalyzer::get_path_from_fullqualifiedname(\$javafilesdir); 1281cdf0e10cSrcweir my $alljavafiles = installer::systemactions::find_file_with_file_extension("java", $javafilesdir); 1282cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alljavafiles}; $i++ ) { ${$alljavafiles}[$i] = $javafilesdir . ${$alljavafiles}[$i]; } 1283cdf0e10cSrcweir 1284cdf0e10cSrcweir # analyzing the xml file 1285cdf0e10cSrcweir 1286cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1287cdf0e10cSrcweir { 1288cdf0e10cSrcweir my $newstring = ""; 1289cdf0e10cSrcweir my $componentname = ""; 1290cdf0e10cSrcweir 1291cdf0e10cSrcweir if ( ${$xmlfile}[$i] =~ /\bcomponent\b.*\bname\s*\=\'\s*(.*?)\s*\'/ ) 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir $componentname = $1; 1294cdf0e10cSrcweir 1295cdf0e10cSrcweir # Getting module name from the scp files in $modulesarrayref 1296cdf0e10cSrcweir 1297cdf0e10cSrcweir my $onelanguage = "en-US"; 1298cdf0e10cSrcweir my $gid = $componentname; 1299cdf0e10cSrcweir my $type = "Name"; 1300cdf0e10cSrcweir 1301cdf0e10cSrcweir my $modulename = ""; 1302cdf0e10cSrcweir $modulename = get_module_name_description($modulesarrayref, $onelanguage, $gid, $type); 1303cdf0e10cSrcweir 1304cdf0e10cSrcweir if ( $modulename eq "" ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir $infoline = "Info: Modulename for $gid not defined in modules collector. Looking in Java ulf file.\n"; 1307cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir 1310cdf0e10cSrcweir if ( $modulename eq "" ) # the modulename can also be set in the Java ulf file 1311cdf0e10cSrcweir { 1312cdf0e10cSrcweir $modulename = get_module_name_from_basejavafile($componentname, $javatemplateorigfile, $ulffile); 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir 1315cdf0e10cSrcweir if ( $modulename ne "" ) # only do something, if the modulename was found 1316cdf0e10cSrcweir { 1317cdf0e10cSrcweir ${$xmlfile}[$i] =~ s/$componentname/$modulename/; 1318cdf0e10cSrcweir 1319cdf0e10cSrcweir $infoline = "Replacement in xml file (Solaris): $componentname \-\> $modulename\n"; 1320cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1321cdf0e10cSrcweir 1322cdf0e10cSrcweir # Replacement has to be done in all Java language files 1323cdf0e10cSrcweir replace_component_name_in_java_file($alljavafiles, $componentname, $modulename); 1324cdf0e10cSrcweir } 1325cdf0e10cSrcweir 1326cdf0e10cSrcweir if ( $modulename eq "" ) # the modulename can also be set in the Java ulf file 1327cdf0e10cSrcweir { 1328cdf0e10cSrcweir $infoline = "WARNING: No replacement in xml file for component: $componentname\n"; 1329cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1330cdf0e10cSrcweir } 1331cdf0e10cSrcweir } 1332cdf0e10cSrcweir } 1333cdf0e10cSrcweir} 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir############################################################################# 1336cdf0e10cSrcweir# Collecting all packages or rpms located in the installation directory 1337cdf0e10cSrcweir############################################################################# 1338cdf0e10cSrcweir 1339cdf0e10cSrcweirsub get_all_packages_in_installdir 1340cdf0e10cSrcweir{ 1341cdf0e10cSrcweir my ($installdir, $subdir) = @_; 1342cdf0e10cSrcweir 1343cdf0e10cSrcweir my $infoline = ""; 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir my @allrpms = (); # not needed for Solaris at the moment 1346cdf0e10cSrcweir my $allrpms = \@allrpms; 1347cdf0e10cSrcweir 1348cdf0e10cSrcweir $installdir =~ s/\Q$installer::globals::separator\E\s*$//; 1349cdf0e10cSrcweir my $directory = $installdir . $installer::globals::separator . $subdir; 1350cdf0e10cSrcweir $directory =~ s/\Q$installer::globals::separator\E\s*$//; 1351cdf0e10cSrcweir 1352cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) 1353cdf0e10cSrcweir { 1354cdf0e10cSrcweir $allrpms = installer::systemactions::find_file_with_file_extension("rpm", $directory); 1355cdf0e10cSrcweir 1356cdf0e10cSrcweir # collecting rpms with the complete path 1357cdf0e10cSrcweir 1358cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allrpms}; $i++ ) 1359cdf0e10cSrcweir { 1360cdf0e10cSrcweir ${$allrpms}[$i] = $directory . $installer::globals::separator . ${$allrpms}[$i]; 1361cdf0e10cSrcweir $infoline = "Found RPM: ${$allrpms}[$i]\n"; 1362cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir 1366cdf0e10cSrcweir return $allrpms; 1367cdf0e10cSrcweir} 1368cdf0e10cSrcweir 1369cdf0e10cSrcweir####################################################### 1370cdf0e10cSrcweir# Adding the values of the array 1371cdf0e10cSrcweir####################################################### 1372cdf0e10cSrcweir 1373cdf0e10cSrcweirsub do_sum 1374cdf0e10cSrcweir{ 1375cdf0e10cSrcweir my ( $allnumbers ) = @_; 1376cdf0e10cSrcweir 1377cdf0e10cSrcweir my $sum = 0; 1378cdf0e10cSrcweir 1379cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allnumbers}; $i++ ) 1380cdf0e10cSrcweir { 1381cdf0e10cSrcweir $sum = $sum + ${$allnumbers}[$i]; 1382cdf0e10cSrcweir } 1383cdf0e10cSrcweir 1384cdf0e10cSrcweir return $sum; 1385cdf0e10cSrcweir} 1386cdf0e10cSrcweir 1387cdf0e10cSrcweir####################################################### 1388cdf0e10cSrcweir# Setting the filesize for the RPMs in the xml file 1389cdf0e10cSrcweir####################################################### 1390cdf0e10cSrcweir 1391cdf0e10cSrcweirsub set_filesize_in_xmlfile 1392cdf0e10cSrcweir{ 1393cdf0e10cSrcweir my ($filesize, $rpmname, $xmlfile) = @_; 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir my $infoline = ""; 1396cdf0e10cSrcweir my $foundrpm = 0; 1397cdf0e10cSrcweir my $filesizeset = 0; 1398cdf0e10cSrcweir 1399cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1400cdf0e10cSrcweir { 1401cdf0e10cSrcweir my $line = ${$xmlfile}[$i]; 1402cdf0e10cSrcweir 1403cdf0e10cSrcweir # searching for "rpmPath="RPMS/${UNIXPRODUCTNAME}-core01-${PACKAGEVERSION}-${PACKAGEREVISION}.i586.rpm"" 1404cdf0e10cSrcweir 1405cdf0e10cSrcweir if (( $line =~ /rpmPath\s*=/ ) && ( $line =~ /\Q$rpmname\E\"\s*$/ )) 1406cdf0e10cSrcweir { 1407cdf0e10cSrcweir $foundrpm = 1; 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir my $number = $i; 1410cdf0e10cSrcweir $number++; 1411cdf0e10cSrcweir 1412cdf0e10cSrcweir while ( ! ( ${$xmlfile}[$number] =~ /\/\>\s*$/ )) 1413cdf0e10cSrcweir { 1414cdf0e10cSrcweir if ( ${$xmlfile}[$number] =~ /FILESIZEPLACEHOLDER/ ) 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir ${$xmlfile}[$number] =~ s/FILESIZEPLACEHOLDER/$filesize/; 1417cdf0e10cSrcweir $filesizeset = 1; 1418cdf0e10cSrcweir $infoline = "Setting filesize for $rpmname : $filesize\n"; 1419cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1420cdf0e10cSrcweir last; 1421cdf0e10cSrcweir } 1422cdf0e10cSrcweir 1423cdf0e10cSrcweir $number++; 1424cdf0e10cSrcweir } 1425cdf0e10cSrcweir 1426cdf0e10cSrcweir last; 1427cdf0e10cSrcweir } 1428cdf0e10cSrcweir } 1429cdf0e10cSrcweir 1430cdf0e10cSrcweir if ( ! $foundrpm ) 1431cdf0e10cSrcweir { 1432cdf0e10cSrcweir $infoline = "ERROR: Did not find $rpmname in xml file !\n"; 1433cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir if ( ! $filesizeset ) 1437cdf0e10cSrcweir { 1438cdf0e10cSrcweir $infoline = "ERROR: Did not set filesize for $rpmname in xml file !\n"; 1439cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1440cdf0e10cSrcweir } 1441cdf0e10cSrcweir} 1442cdf0e10cSrcweir 1443cdf0e10cSrcweir############################################################ 1444cdf0e10cSrcweir# Collecting all rpmUniqueName in xml file. 1445cdf0e10cSrcweir############################################################ 1446cdf0e10cSrcweir 1447cdf0e10cSrcweirsub collect_uniquenames_in_xmlfile 1448cdf0e10cSrcweir{ 1449cdf0e10cSrcweir my ($xmlfile) = @_; 1450cdf0e10cSrcweir 1451cdf0e10cSrcweir my @rpmuniquenames = (); 1452cdf0e10cSrcweir 1453cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1454cdf0e10cSrcweir { 1455cdf0e10cSrcweir my $oneline = ${$xmlfile}[$i]; 1456cdf0e10cSrcweir 1457cdf0e10cSrcweir if ( $oneline =~ /^\s*rpmUniqueName\s*\=\s*\"(.*)\"\s*$/ ) 1458cdf0e10cSrcweir { 1459cdf0e10cSrcweir my $rpmuniquename = $1; 1460cdf0e10cSrcweir push(@rpmuniquenames, $rpmuniquename) 1461cdf0e10cSrcweir } 1462cdf0e10cSrcweir } 1463cdf0e10cSrcweir 1464cdf0e10cSrcweir return \@rpmuniquenames; 1465cdf0e10cSrcweir} 1466cdf0e10cSrcweir 1467cdf0e10cSrcweir############################################################ 1468cdf0e10cSrcweir# Searching for the corresponding rpm, that fits to 1469cdf0e10cSrcweir# the unique rpm name. 1470cdf0e10cSrcweir# Simple mechanism: The name of the rpm starts with the 1471cdf0e10cSrcweir# unique rpm name followed by a "-". 1472cdf0e10cSrcweir############################################################ 1473cdf0e10cSrcweir 1474cdf0e10cSrcweirsub find_rpmname_to_uniquename 1475cdf0e10cSrcweir{ 1476cdf0e10cSrcweir my ($uniquename, $listofpackages) = @_; 1477cdf0e10cSrcweir 1478cdf0e10cSrcweir my @all_correct_rpms = (); 1479cdf0e10cSrcweir my $infoline = ""; 1480cdf0e10cSrcweir 1481cdf0e10cSrcweir # special handling for java RPMs, which have a very strange naming schema 1482cdf0e10cSrcweir my $localuniquename = $uniquename; 1483cdf0e10cSrcweir if ( $uniquename =~ /^\s*jre\-/ ) { $localuniquename = "jre"; } 1484cdf0e10cSrcweir 1485cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$listofpackages}; $i++ ) 1486cdf0e10cSrcweir { 1487cdf0e10cSrcweir my $completerpmname = ${$listofpackages}[$i]; 1488cdf0e10cSrcweir my $rpmname = $completerpmname; 1489cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname); 1490cdf0e10cSrcweir 1491cdf0e10cSrcweir if ( $rpmname =~ /^\s*\Q$localuniquename\E\-\d/ ) { push(@all_correct_rpms, $rpmname); } 1492cdf0e10cSrcweir } 1493cdf0e10cSrcweir 1494cdf0e10cSrcweir # @all_correct_rpms has to contain exactly one value 1495cdf0e10cSrcweir 1496cdf0e10cSrcweir if ( $#all_correct_rpms > 0 ) 1497cdf0e10cSrcweir { 1498cdf0e10cSrcweir my $number = $#all_correct_rpms + 1; 1499cdf0e10cSrcweir $infoline = "There are $number RPMs for the unique name \"$uniquename\" :\n"; 1500cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1501cdf0e10cSrcweir my $allrpmstring = ""; 1502cdf0e10cSrcweir for ( my $i = 0; $i <= $#all_correct_rpms; $i++ ) { $allrpmstring = $allrpmstring . $all_correct_rpms[$i] . "\n"; } 1503cdf0e10cSrcweir push( @installer::globals::logfileinfo, $allrpmstring); 1504cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Found $number RPMs that start with unique name \"$uniquename\". Only one allowed!", "find_rpmname_to_uniquename"); 1505cdf0e10cSrcweir } 1506cdf0e10cSrcweir 1507cdf0e10cSrcweir if ( $#all_correct_rpms < 0 ) 1508cdf0e10cSrcweir { 1509cdf0e10cSrcweir $infoline = "There is no rpm for the unique name \"$uniquename\"\n"; 1510cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1511cdf0e10cSrcweir installer::exiter::exit_program("ERROR: There is no RPM that start with unique name \"$uniquename\"!", "find_rpmname_to_uniquename"); 1512cdf0e10cSrcweir } 1513cdf0e10cSrcweir 1514cdf0e10cSrcweir if ( $#all_correct_rpms == 0 ) 1515cdf0e10cSrcweir { 1516cdf0e10cSrcweir $infoline = "Found one rpm for the unique name \"$uniquename\" : $all_correct_rpms[0]\n"; 1517cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1518cdf0e10cSrcweir } 1519cdf0e10cSrcweir 1520cdf0e10cSrcweir return $all_correct_rpms[0]; 1521cdf0e10cSrcweir} 1522cdf0e10cSrcweir 1523cdf0e10cSrcweir####################################################### 1524cdf0e10cSrcweir# Including the complete RPM name into the xml file 1525cdf0e10cSrcweir####################################################### 1526cdf0e10cSrcweir 1527cdf0e10cSrcweirsub set_rpmname_into_xmlfile 1528cdf0e10cSrcweir{ 1529cdf0e10cSrcweir my ($rpmname, $uniquename, $xmlfile) = @_; 1530cdf0e10cSrcweir 1531cdf0e10cSrcweir my $foundrpm = 0; 1532cdf0e10cSrcweir my $rpmnameset = 0; 1533cdf0e10cSrcweir 1534cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$xmlfile}; $i++ ) 1535cdf0e10cSrcweir { 1536cdf0e10cSrcweir my $oneline = ${$xmlfile}[$i]; 1537cdf0e10cSrcweir 1538cdf0e10cSrcweir if ( $oneline =~ /^\s*rpmUniqueName\s*\=\s*\"\Q$uniquename\E\"\s*$/ ) 1539cdf0e10cSrcweir { 1540cdf0e10cSrcweir $foundrpm = 1; 1541cdf0e10cSrcweir 1542cdf0e10cSrcweir my $number = $i; 1543cdf0e10cSrcweir $number++; 1544cdf0e10cSrcweir 1545cdf0e10cSrcweir while ( ! ( ${$xmlfile}[$number] =~ /\/\>\s*$/ )) 1546cdf0e10cSrcweir { 1547cdf0e10cSrcweir if ( ${$xmlfile}[$number] =~ /RPMFILENAMEPLACEHOLDER/ ) 1548cdf0e10cSrcweir { 1549cdf0e10cSrcweir ${$xmlfile}[$number] =~ s/RPMFILENAMEPLACEHOLDER/$rpmname/; 1550cdf0e10cSrcweir $rpmnameset = 1; 1551cdf0e10cSrcweir $infoline = "Setting RPM name for $uniquename : $rpmname\n"; 1552cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1553cdf0e10cSrcweir last; 1554cdf0e10cSrcweir } 1555cdf0e10cSrcweir 1556cdf0e10cSrcweir $number++; 1557cdf0e10cSrcweir } 1558cdf0e10cSrcweir 1559cdf0e10cSrcweir last; 1560cdf0e10cSrcweir } 1561cdf0e10cSrcweir } 1562cdf0e10cSrcweir 1563cdf0e10cSrcweir if ( ! $foundrpm ) 1564cdf0e10cSrcweir { 1565cdf0e10cSrcweir $infoline = "ERROR: Did not find $rpmname in xml file !\n"; 1566cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1567cdf0e10cSrcweir } 1568cdf0e10cSrcweir 1569cdf0e10cSrcweir if ( ! $rpmnameset ) 1570cdf0e10cSrcweir { 1571cdf0e10cSrcweir $infoline = "ERROR: Did not set rpm name for $uniquename in xml file !\n"; 1572cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1573cdf0e10cSrcweir } 1574cdf0e10cSrcweir 1575cdf0e10cSrcweir} 1576cdf0e10cSrcweir 1577cdf0e10cSrcweir############################################################ 1578cdf0e10cSrcweir# Including the rpm path dynamically into the xml file. 1579cdf0e10cSrcweir# This is introduced, because system integration has 1580cdf0e10cSrcweir# variable PackageVersion and PackageRevision in xml file. 1581cdf0e10cSrcweir############################################################ 1582cdf0e10cSrcweir 1583cdf0e10cSrcweirsub put_rpmpath_into_xmlfile 1584cdf0e10cSrcweir{ 1585cdf0e10cSrcweir my ($xmlfile, $listofpackages) = @_; 1586cdf0e10cSrcweir 1587cdf0e10cSrcweir my $infoline = ""; 1588cdf0e10cSrcweir 1589cdf0e10cSrcweir my $alluniquenames = collect_uniquenames_in_xmlfile($xmlfile); 1590cdf0e10cSrcweir 1591cdf0e10cSrcweir my $number = $#{$listofpackages} + 1; 1592cdf0e10cSrcweir $infoline = "Number of packages in installation set: $number\n"; 1593cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1594cdf0e10cSrcweir $number = $#{$alluniquenames} + 1; 1595cdf0e10cSrcweir $infoline = "Number of unique RPM names in xml file: $number\n"; 1596cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1597cdf0e10cSrcweir 1598cdf0e10cSrcweir $infoline = "\nPackages in installation set:\n"; 1599cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1600cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$listofpackages}; $i++ ) 1601cdf0e10cSrcweir { 1602cdf0e10cSrcweir $infoline = "${$listofpackages}[$i]\n"; 1603cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1604cdf0e10cSrcweir } 1605cdf0e10cSrcweir 1606cdf0e10cSrcweir $infoline = "\nUnique RPM names in xml file:\n"; 1607cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1608cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alluniquenames}; $i++ ) 1609cdf0e10cSrcweir { 1610cdf0e10cSrcweir $infoline = "${$alluniquenames}[$i]\n"; 1611cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1612cdf0e10cSrcweir } 1613cdf0e10cSrcweir 1614cdf0e10cSrcweir if ( $#{$alluniquenames} != $#{$listofpackages} ) { installer::exiter::exit_program("ERROR: xml file contains $#{$alluniquenames} unique names, but there are $#{$listofpackages} packages in installation set!", "put_rpmpath_into_xmlfile"); } 1615cdf0e10cSrcweir 1616cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alluniquenames}; $i++ ) 1617cdf0e10cSrcweir { 1618cdf0e10cSrcweir my $uniquename = ${$alluniquenames}[$i]; 1619cdf0e10cSrcweir my $rpmname = find_rpmname_to_uniquename($uniquename, $listofpackages); 1620cdf0e10cSrcweir set_rpmname_into_xmlfile($rpmname, $uniquename, $xmlfile); 1621cdf0e10cSrcweir } 1622cdf0e10cSrcweir} 1623cdf0e10cSrcweir 1624cdf0e10cSrcweir####################################################### 1625cdf0e10cSrcweir# Including the file size of the rpms into the 1626cdf0e10cSrcweir# xml file 1627cdf0e10cSrcweir####################################################### 1628cdf0e10cSrcweir 1629cdf0e10cSrcweirsub put_filesize_into_xmlfile 1630cdf0e10cSrcweir{ 1631cdf0e10cSrcweir my ($xmlfile, $listofpackages) = @_; 1632cdf0e10cSrcweir 1633cdf0e10cSrcweir my $infoline = ""; 1634cdf0e10cSrcweir 1635cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$listofpackages}; $i++ ) 1636cdf0e10cSrcweir { 1637cdf0e10cSrcweir my $completerpmname = ${$listofpackages}[$i]; 1638cdf0e10cSrcweir my $rpmname = $completerpmname; 1639cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname); 1640cdf0e10cSrcweir 1641cdf0e10cSrcweir if ( ! $installer::globals::rpmquerycommand ) { installer::exiter::exit_program("ERROR: rpm not found for querying packages!", "put_filesize_into_xmlfile"); } 1642cdf0e10cSrcweir my $systemcall = "$installer::globals::rpmquerycommand -qp --queryformat \"\[\%\{FILESIZES\}\\n\]\" $completerpmname 2\>\&1 |"; 1643cdf0e10cSrcweir my $rpmout = make_systemcall($systemcall, 0); 1644cdf0e10cSrcweir my $filesize = do_sum($rpmout); 1645cdf0e10cSrcweir 1646cdf0e10cSrcweir $infoline = "Filesize $rpmname : $filesize\n"; 1647cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1648cdf0e10cSrcweir 1649cdf0e10cSrcweir set_filesize_in_xmlfile($filesize, $rpmname, $xmlfile); 1650cdf0e10cSrcweir } 1651cdf0e10cSrcweir} 1652cdf0e10cSrcweir 1653cdf0e10cSrcweir####################################################### 1654cdf0e10cSrcweir# Creating the java installer class file dynamically 1655cdf0e10cSrcweir####################################################### 1656cdf0e10cSrcweir 1657cdf0e10cSrcweirsub create_java_installer 1658cdf0e10cSrcweir{ 1659cdf0e10cSrcweir my ( $installdir, $newdir, $languagestringref, $languagesarrayref, $allvariableshashref, $includepatharrayref, $modulesarrayref ) = @_; 1660cdf0e10cSrcweir 1661cdf0e10cSrcweir installer::logger::include_header_into_logfile("Creating Java installer:"); 1662cdf0e10cSrcweir 1663cdf0e10cSrcweir my $infoline = ""; 1664cdf0e10cSrcweir 1665cdf0e10cSrcweir # collecting all packages or rpms located in the installation directory 1666cdf0e10cSrcweir my $listofpackages = get_all_packages_in_installdir($installdir, $newdir); 1667cdf0e10cSrcweir 1668cdf0e10cSrcweir # creating the directory 1669cdf0e10cSrcweir my $javadir = installer::systemactions::create_directories("javainstaller", $languagestringref); 1670cdf0e10cSrcweir $javadir =~ s/\/\s*$//; 1671cdf0e10cSrcweir# push(@installer::globals::removedirs, $javadir); 1672cdf0e10cSrcweir 1673cdf0e10cSrcweir # copying the content from directory install_sdk into the java directory 1674cdf0e10cSrcweir 1675cdf0e10cSrcweir my $projectroot = ""; 1676cdf0e10cSrcweir if ( $ENV{'PRJ'} ) { $projectroot = $ENV{'PRJ'}; } 1677cdf0e10cSrcweir else { installer::exiter::exit_program("ERROR: Environment variable PRJ not set", "create_java_installer"); } 1678cdf0e10cSrcweir 1679cdf0e10cSrcweir $projectroot =~ s/\/\s*$//; 1680cdf0e10cSrcweir my $sourcedir = "$projectroot/inc_global/unix/install_sdk"; 1681cdf0e10cSrcweir installer::systemactions::copy_complete_directory_without_cvs($sourcedir, $javadir); 1682cdf0e10cSrcweir 1683cdf0e10cSrcweir # determining the java template file 1684cdf0e10cSrcweir 1685cdf0e10cSrcweir my $templatefilename = $javadir . $installer::globals::separator . "locale/resources/MyResources_template.java"; 1686cdf0e10cSrcweir 1687cdf0e10cSrcweir # Saving the content of the template file. It is used in the xml files 1688cdf0e10cSrcweir 1689cdf0e10cSrcweir my $javatemplateorigfile = installer::files::read_file($templatefilename); 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir # determining the ulf language file 1692cdf0e10cSrcweir 1693cdf0e10cSrcweir # my $ulffilename = "installsdk.ulf"; 1694cdf0e10cSrcweir my $ulffilename = "installsdk.jlf"; 1695cdf0e10cSrcweir $ulffilename = $installer::globals::javalanguagepath . $installer::globals::separator . $ulffilename; 1696cdf0e10cSrcweir my $ulffile = installer::files::read_file($ulffilename); 1697cdf0e10cSrcweir 1698cdf0e10cSrcweir $infoline = "\nReading ulf file: $ulffilename\n"; 1699cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1700cdf0e10cSrcweir 1701cdf0e10cSrcweir $infoline = "Translating the Java template file\n"; 1702cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ ) 1705cdf0e10cSrcweir { 1706cdf0e10cSrcweir my $onelanguage = ${$languagesarrayref}[$i]; 1707cdf0e10cSrcweir 1708cdf0e10cSrcweir # replacing all strings in the Java file with content of ulf files 1709cdf0e10cSrcweir 1710cdf0e10cSrcweir my $templatefile = installer::files::read_file($templatefilename); 1711cdf0e10cSrcweir 1712cdf0e10cSrcweir set_component_name_and_description($templatefile, $modulesarrayref, $onelanguage); 1713cdf0e10cSrcweir translate_javafile($templatefile, $ulffile, $onelanguage); 1714cdf0e10cSrcweir 1715cdf0e10cSrcweir # adding the license file into the Java file 1716cdf0e10cSrcweir 1717cdf0e10cSrcweir my $licensefilesource = get_licensefilesource($onelanguage, $includepatharrayref); 1718cdf0e10cSrcweir my $licensefile = installer::files::read_file($licensefilesource); 1719cdf0e10cSrcweir add_license_file_into_javafile($templatefile, $licensefile, $includepatharrayref, $javadir, $onelanguage); 1720cdf0e10cSrcweir 1721cdf0e10cSrcweir # setting productname and productversion 1722cdf0e10cSrcweir 1723cdf0e10cSrcweir set_productname_and_productversion($templatefile, $allvariableshashref); 1724cdf0e10cSrcweir 1725cdf0e10cSrcweir # setting the class name in the java file ( "MyResources_TEMPLATE" -> "MyResources_en" ) 1726cdf0e10cSrcweir 1727cdf0e10cSrcweir # if ( $onelanguage =~ /^\s*(\w+)\-(\w+)\s*$/ ) { $onelanguage = $1; } 1728cdf0e10cSrcweir $onelanguage =~ s/en-US/en/; # java file name and class name contain only "_en" 1729cdf0e10cSrcweir $onelanguage =~ s/\-/\_/; # "pt-BR" -> "pt_BR" 1730cdf0e10cSrcweir my $classfilename = "MyResources_" . $onelanguage; 1731cdf0e10cSrcweir set_classfilename($templatefile, $classfilename, "MyResources_TEMPLATE"); 1732cdf0e10cSrcweir 1733cdf0e10cSrcweir # saving the new file 1734cdf0e10cSrcweir 1735cdf0e10cSrcweir my $newfilename = $templatefilename; 1736cdf0e10cSrcweir $newfilename =~ s/_template\.java\s*$/_$onelanguage\.java/; 1737cdf0e10cSrcweir 1738cdf0e10cSrcweir installer::files::save_file($newfilename, $templatefile); 1739cdf0e10cSrcweir 1740cdf0e10cSrcweir $infoline = "Saving Java file: $newfilename\n"; 1741cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir 1744cdf0e10cSrcweir # renaming one language java file to "MyResources.java" 1745cdf0e10cSrcweir 1746cdf0e10cSrcweir my $baselanguage = installer::languages::get_default_language($languagesarrayref); 1747cdf0e10cSrcweir $baselanguage =~ s/\-/\_/; # "pt-BR" -> "pt_BR" 1748cdf0e10cSrcweir $baselanguage =~ s/en_US/en/; # java file name and class name contain only "_en" 1749cdf0e10cSrcweir # if ( $baselanguage =~ /^\s*(\w+)\-(\w+)\s*$/ ) { $baselanguage = $1; } # java file name and class name contain only "_en" 1750cdf0e10cSrcweir # $baselanguage =~ s/en-US/en/; # java file name and class name contain only "_en" 1751cdf0e10cSrcweir my $baselanguagefilename = $javadir . $installer::globals::separator . "locale/resources/MyResources_" . $baselanguage . "\.java"; 1752cdf0e10cSrcweir my $basedestfilename = $javadir . $installer::globals::separator . "locale/resources/MyResources.java"; 1753cdf0e10cSrcweir installer::systemactions::copy_one_file($baselanguagefilename, $basedestfilename); 1754cdf0e10cSrcweir 1755cdf0e10cSrcweir # setting the class file name also for the base class 1756cdf0e10cSrcweir 1757cdf0e10cSrcweir my $basetemplatefile = installer::files::read_file($basedestfilename); 1758cdf0e10cSrcweir my $oldclassfilename = $baselanguagefilename; 1759cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$oldclassfilename); 1760cdf0e10cSrcweir $oldclassfilename =~ s/\.java//; 1761cdf0e10cSrcweir my $newclassfilename = $basedestfilename; 1762cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newclassfilename); 1763cdf0e10cSrcweir $newclassfilename =~ s/\.java//; 1764cdf0e10cSrcweir 1765cdf0e10cSrcweir set_classfilename($basetemplatefile, $newclassfilename, $oldclassfilename); 1766cdf0e10cSrcweir 1767cdf0e10cSrcweir installer::files::save_file($basedestfilename, $basetemplatefile); 1768cdf0e10cSrcweir 1769cdf0e10cSrcweir $infoline = "Created base Java file: $basedestfilename\n"; 1770cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1771cdf0e10cSrcweir 1772cdf0e10cSrcweir # deleting the template file 1773cdf0e10cSrcweir 1774cdf0e10cSrcweir unlink($templatefilename); 1775cdf0e10cSrcweir 1776cdf0e10cSrcweir $infoline = "Deleted template Java resource file: $templatefilename\n"; 1777cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1778cdf0e10cSrcweir 1779cdf0e10cSrcweir # changing into Java directory 1780cdf0e10cSrcweir 1781cdf0e10cSrcweir my $from = cwd(); 1782cdf0e10cSrcweir 1783cdf0e10cSrcweir chdir($javadir); 1784cdf0e10cSrcweir 1785cdf0e10cSrcweir $infoline = "Changing into directory: $javadir\n"; 1786cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1787cdf0e10cSrcweir 1788cdf0e10cSrcweir # preparing the xml file 1789cdf0e10cSrcweir 1790cdf0e10cSrcweir my $xmlfilename = ""; 1791cdf0e10cSrcweir my $subdir = ""; 1792cdf0e10cSrcweir 1793cdf0e10cSrcweir if ( $installer::globals::issolarispkgbuild ) 1794cdf0e10cSrcweir { 1795cdf0e10cSrcweir $xmlfilename = "pkgUnit.xml"; 1796cdf0e10cSrcweir } 1797cdf0e10cSrcweir elsif ( $installer::globals::islinuxrpmbuild ) 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir $xmlfilename = "rpmUnit.xml"; 1800cdf0e10cSrcweir } 1801cdf0e10cSrcweir else 1802cdf0e10cSrcweir { 1803cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No platform for Install SDK", "create_java_installer"); 1804cdf0e10cSrcweir } 1805cdf0e10cSrcweir 1806cdf0e10cSrcweir # reading, editing and saving the xmlfile 1807cdf0e10cSrcweir 1808cdf0e10cSrcweir my $xmlfile = installer::files::read_file($xmlfilename); 1809cdf0e10cSrcweir prepare_language_pack_in_xmlfile($xmlfile, $languagesarrayref); 1810cdf0e10cSrcweir my $xmlfilename2 = $xmlfilename . ".test2"; 1811cdf0e10cSrcweir installer::files::save_file($xmlfilename2, $xmlfile); 1812cdf0e10cSrcweir remove_empty_packages_in_xmlfile($xmlfile); 1813cdf0e10cSrcweir my $xmlfilename3 = $xmlfilename . ".test3"; 1814cdf0e10cSrcweir installer::files::save_file($xmlfilename3, $xmlfile); 1815cdf0e10cSrcweir substitute_variables($xmlfile, $allvariableshashref); 1816cdf0e10cSrcweir if (( $installer::globals::islinuxrpmbuild ) && ( $#installer::globals::linkrpms > -1 )) { prepare_linkrpm_in_xmlfile($xmlfile,\@installer::globals::linkrpms); } 1817cdf0e10cSrcweir if ( $installer::globals::issolarisx86build || $installer::globals::islinuxbuild ) { remove_w4w_from_xmlfile($xmlfile); } 1818cdf0e10cSrcweir remove_module_if_not_defined($xmlfile, $modulesarrayref, "gid_Module_Optional_Onlineupdate"); 1819cdf0e10cSrcweir replace_component_names($xmlfile, $templatefilename, $modulesarrayref, $javatemplateorigfile, $ulffile); 1820cdf0e10cSrcweir my $xmlfilename4 = $xmlfilename . ".test4"; 1821cdf0e10cSrcweir installer::files::save_file($xmlfilename4, $xmlfile); 1822cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) { put_rpmpath_into_xmlfile($xmlfile, $listofpackages); } 1823cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) { put_filesize_into_xmlfile($xmlfile, $listofpackages); } 1824cdf0e10cSrcweir installer::files::save_file($xmlfilename, $xmlfile); 1825cdf0e10cSrcweir $infoline = "Saving xml file: $xmlfilename\n"; 1826cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1827cdf0e10cSrcweir 1828cdf0e10cSrcweir # Setting the classpath and starting compiler 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir set_classpath_for_install_sdk($javadir); 1831cdf0e10cSrcweir 1832cdf0e10cSrcweir # creating class files: 1833cdf0e10cSrcweir # language class file, dialog class files, installer class file 1834cdf0e10cSrcweir 1835cdf0e10cSrcweir my $jdkpath = ""; 1836cdf0e10cSrcweir if ( $ENV{'JDKPATH'} ) { $jdkpath = $ENV{'JDKPATH'}; } 1837cdf0e10cSrcweir 1838cdf0e10cSrcweir my $javac = "javac"; 1839cdf0e10cSrcweir if ( $jdkpath ) { $javac = $jdkpath . $installer::globals::separator . $javac; } 1840cdf0e10cSrcweir 1841cdf0e10cSrcweir my $systemcall = "$javac locale\/resources\/\*\.java 2\>\&1 |"; 1842cdf0e10cSrcweir make_systemcall($systemcall, 1); 1843cdf0e10cSrcweir 1844cdf0e10cSrcweir $systemcall = "$javac com\/sun\/staroffice\/install\/\*\.java 2\>\&1 |"; 1845cdf0e10cSrcweir make_systemcall($systemcall, 1); 1846cdf0e10cSrcweir 1847cdf0e10cSrcweir # making subdirectory creating empty packages 1848cdf0e10cSrcweir create_empty_packages($xmlfile); 1849cdf0e10cSrcweir 1850cdf0e10cSrcweir # Copy "jresetup" from solver locally to include it into the classfile 1851cdf0e10cSrcweir # Copy "jresetup" from solver to installdir 1852cdf0e10cSrcweir 1853cdf0e10cSrcweir my $setupname = "jresetup"; 1854cdf0e10cSrcweir my $newname = "setup"; 1855cdf0e10cSrcweir copy_setup_locally($includepatharrayref, $setupname, $newname); 1856cdf0e10cSrcweir 1857cdf0e10cSrcweir my $java = "java"; 1858cdf0e10cSrcweir if ( $jdkpath ) { $java = $jdkpath . $installer::globals::separator . $java; } 1859cdf0e10cSrcweir 1860cdf0e10cSrcweir $systemcall = "$java com.sun.setup.builder.InstallBuilder $xmlfilename -novalidate 2\>\&1 |"; 1861cdf0e10cSrcweir make_systemcall($systemcall, 1); 1862cdf0e10cSrcweir 1863cdf0e10cSrcweir # copying the newly created classfile into the installation set 1864cdf0e10cSrcweir 1865cdf0e10cSrcweir my $archivefilename = get_archivefilename($xmlfile); 1866cdf0e10cSrcweir $archivefilename = $archivefilename . ".class"; 1867cdf0e10cSrcweir 1868cdf0e10cSrcweir if ( ! -f $archivefilename ) { installer::exiter::exit_program("ERROR: Could not find Java class file $archivefilename!", "create_java_installer"); } 1869cdf0e10cSrcweir 1870cdf0e10cSrcweir installer::systemactions::copy_one_file($archivefilename, $installdir); 1871cdf0e10cSrcweir 1872cdf0e10cSrcweir # Adding the loader into the installation set. The name of the loader is setup. 1873cdf0e10cSrcweir put_loader_into_installset($installdir, $newname); 1874cdf0e10cSrcweir 1875cdf0e10cSrcweir chdir($from); 1876cdf0e10cSrcweir 1877cdf0e10cSrcweir $infoline = "Changing into directory: $from\n"; 1878cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1879cdf0e10cSrcweir} 1880cdf0e10cSrcweir 1881cdf0e10cSrcweir1; 1882