19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::languagepack; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::converter; 27cdf0e10cSrcweiruse installer::existence; 28cdf0e10cSrcweiruse installer::files; 29cdf0e10cSrcweiruse installer::globals; 30cdf0e10cSrcweiruse installer::logger; 31cdf0e10cSrcweiruse installer::pathanalyzer; 32cdf0e10cSrcweiruse installer::scpzipfiles; 33cdf0e10cSrcweiruse installer::scriptitems; 34cdf0e10cSrcweiruse installer::systemactions; 35cdf0e10cSrcweiruse installer::worker; 36cdf0e10cSrcweir 37cdf0e10cSrcweir#################################################### 38cdf0e10cSrcweir# Selecting all files with the correct language 39cdf0e10cSrcweir#################################################### 40cdf0e10cSrcweir 41cdf0e10cSrcweirsub select_language_items 42cdf0e10cSrcweir{ 43cdf0e10cSrcweir my ( $itemsref, $languagesarrayref, $itemname ) = @_; 44cdf0e10cSrcweir 45cdf0e10cSrcweir installer::logger::include_header_into_logfile("Selecting languages for language pack. Item: $itemname"); 46cdf0e10cSrcweir 47cdf0e10cSrcweir my @itemsarray = (); 48cdf0e10cSrcweir 49cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$itemsref}; $i++ ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir my $oneitem = ${$itemsref}[$i]; 52cdf0e10cSrcweir 53cdf0e10cSrcweir my $ismultilingual = $oneitem->{'ismultilingual'}; 54cdf0e10cSrcweir 55cdf0e10cSrcweir if (!($ismultilingual)) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir # Files with style "LANGUAGEPACK" and "FORCELANGUAGEPACK" also have to be included into the language pack. 58cdf0e10cSrcweir # Files with style "LANGUAGEPACK" are only included into language packs. 59cdf0e10cSrcweir # Files with style "FORCELANGUAGEPACK" are included into language packs and non language packs. They are 60cdf0e10cSrcweir # forced, because otherwise they not not be included into languagepacks. 61cdf0e10cSrcweir 62cdf0e10cSrcweir my $styles = ""; 63cdf0e10cSrcweir if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; } 64cdf0e10cSrcweir 65cdf0e10cSrcweir if (( $styles =~ /\bLANGUAGEPACK\b/ ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ )) { push(@itemsarray, $oneitem); } 66cdf0e10cSrcweir 67cdf0e10cSrcweir next; # single language files are not included into language pack 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir my $specificlanguage = ""; 71cdf0e10cSrcweir if ( $oneitem->{'specificlanguage'} ) { $specificlanguage = $oneitem->{'specificlanguage'}; } 72cdf0e10cSrcweir 73cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) # iterating over all languages 74cdf0e10cSrcweir { 75cdf0e10cSrcweir my $onelanguage = ${$languagesarrayref}[$j]; 76cdf0e10cSrcweir my $locallang = $onelanguage; 77cdf0e10cSrcweir $locallang =~ s/-/_/; 78cdf0e10cSrcweir 79cdf0e10cSrcweir if ( $specificlanguage eq $onelanguage ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir # $oneitem->{'modules'} = $installer::globals::rootmodulegid; # all files in a language pack are root files 82cdf0e10cSrcweir # Using $installer::globals::languagemodulesbase (?) 83cdf0e10cSrcweir 84cdf0e10cSrcweir# # no more automatic change of module assignments 85cdf0e10cSrcweir# $oneitem->{'modules'} = $installer::globals::rootmodulegid . "_$locallang"; # all files in a language pack are root files 86cdf0e10cSrcweir# 87cdf0e10cSrcweir# if (( $installer::globals::islinuxbuild ) || ( $installer::globals::issolarispkgbuild )) 88cdf0e10cSrcweir# { 89cdf0e10cSrcweir# if ( $oneitem->{'Dir'} ) 90cdf0e10cSrcweir# { 91cdf0e10cSrcweir# if ( $oneitem->{'Dir'} eq "gid_Dir_Fonts_Truetype" ) { $oneitem->{'modules'} = "gid_Module_Langpack_Fonts_$locallang"; } 92cdf0e10cSrcweir# if ( $oneitem->{'Dir'} eq "gid_Dir_Resource" ) { $oneitem->{'modules'} = "gid_Module_Langpack_Resource_$locallang"; } 93cdf0e10cSrcweir# if ( $oneitem->{'Dir'} eq "gid_Dir_Help_Isolanguage" ) { $oneitem->{'modules'} = "gid_Module_Langpack_Help_$locallang"; } 94cdf0e10cSrcweir# } 95cdf0e10cSrcweir# } 96cdf0e10cSrcweir 97cdf0e10cSrcweir # preparing different modules for Windows Installer language packs 98cdf0e10cSrcweir # my $underlinelanguage = $specificlanguage; 99cdf0e10cSrcweir # $underlinelanguage =~ s/-/_/; 100cdf0e10cSrcweir # if ( $installer::globals::iswindowsbuild ) { $oneitem->{'modules'} = $installer::globals::languagemodulesbase . $underlinelanguage; } 101cdf0e10cSrcweir 102cdf0e10cSrcweir# # no more collecting of language pack feature 103cdf0e10cSrcweir# if (! installer::existence::exists_in_array($oneitem->{'modules'}, \@installer::globals::languagepackfeature)) 104cdf0e10cSrcweir# { 105cdf0e10cSrcweir# push(@installer::globals::languagepackfeature, $oneitem->{'modules'}); # Collecting all language pack feature 106cdf0e10cSrcweir# } 107cdf0e10cSrcweir 108cdf0e10cSrcweir push(@itemsarray, $oneitem); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir return \@itemsarray; 114cdf0e10cSrcweir} 115cdf0e10cSrcweir 116cdf0e10cSrcweirsub replace_languagestring_variable 117cdf0e10cSrcweir{ 118cdf0e10cSrcweir my ($onepackageref, $languagestringref) = @_; 119cdf0e10cSrcweir 120cdf0e10cSrcweir my $key; 121cdf0e10cSrcweir 122cdf0e10cSrcweir foreach $key (keys %{$onepackageref}) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir my $value = $onepackageref->{$key}; 125cdf0e10cSrcweir $value =~ s/\%LANGUAGESTRING/$$languagestringref/g; 126cdf0e10cSrcweir $onepackageref->{$key} = $value; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir} 129cdf0e10cSrcweir 130cdf0e10cSrcweir######################################################### 131cdf0e10cSrcweir# Including the license text into the script template 132cdf0e10cSrcweir######################################################### 133cdf0e10cSrcweir 134cdf0e10cSrcweirsub put_license_file_into_script 135cdf0e10cSrcweir{ 136cdf0e10cSrcweir my ($scriptfile, $licensefile) = @_; 137cdf0e10cSrcweir 138cdf0e10cSrcweir my $infoline = "Adding licensefile into language pack script\n"; 139*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 140cdf0e10cSrcweir 141cdf0e10cSrcweir my $includestring = ""; 142cdf0e10cSrcweir 143cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$licensefile}; $i++ ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir $includestring = $includestring . ${$licensefile}[$i]; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/LICENSEFILEPLACEHOLDER/$includestring/; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir} 153cdf0e10cSrcweir 154cdf0e10cSrcweir######################################################### 155cdf0e10cSrcweir# Creating a tar.gz file from a Solaris package 156cdf0e10cSrcweir######################################################### 157cdf0e10cSrcweir 158cdf0e10cSrcweirsub create_tar_gz_file 159cdf0e10cSrcweir{ 160cdf0e10cSrcweir my ($installdir, $packagename, $packagestring) = @_; 161cdf0e10cSrcweir 162cdf0e10cSrcweir $packagename =~ s/\.rpm\s*$//; 163cdf0e10cSrcweir my $targzname = $packagename . ".tar.gz"; 164cdf0e10cSrcweir $systemcall = "cd $installdir; tar -cf - $packagestring | gzip > $targzname"; 165cdf0e10cSrcweir installer::logger::print_message( "... $systemcall ...\n" ); 166cdf0e10cSrcweir 167cdf0e10cSrcweir my $returnvalue = system($systemcall); 168cdf0e10cSrcweir 169cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 170*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 171cdf0e10cSrcweir 172cdf0e10cSrcweir if ($returnvalue) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 175*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir else 178cdf0e10cSrcweir { 179cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 180*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir return $targzname; 184cdf0e10cSrcweir} 185cdf0e10cSrcweir 186cdf0e10cSrcweir######################################################### 187cdf0e10cSrcweir# Determining the name of the package file 188cdf0e10cSrcweir######################################################### 189cdf0e10cSrcweir 190cdf0e10cSrcweirsub get_packagename_from_packagelist 191cdf0e10cSrcweir{ 192cdf0e10cSrcweir my ( $alldirs, $allvariables, $languagestringref ) = @_; 193cdf0e10cSrcweir 194cdf0e10cSrcweir # my $packagename = ""; 195cdf0e10cSrcweir 196cdf0e10cSrcweir # for ( my $i = 0; $i <= $#{$alldirs}; $i++ ) 197cdf0e10cSrcweir # { 198cdf0e10cSrcweir # if ( ${$alldirs}[$i] =~ /-fonts/ ) { next; } 199cdf0e10cSrcweir # if ( ${$alldirs}[$i] =~ /-help/ ) { next; } 200cdf0e10cSrcweir # if ( ${$alldirs}[$i] =~ /-res/ ) { next; } 201cdf0e10cSrcweir # 202cdf0e10cSrcweir # $packagename = ${$alldirs}[$i]; 203cdf0e10cSrcweir # last; 204cdf0e10cSrcweir # } 205cdf0e10cSrcweir 206cdf0e10cSrcweir # if ( $packagename eq "" ) { installer::exiter::exit_program("ERROR: Could not find base package in directory $installdir!", "get_packagename_from_packagelist"); } 207cdf0e10cSrcweir 208cdf0e10cSrcweir my $localproductname = $allvariables->{'PRODUCTNAME'}; 209cdf0e10cSrcweir $localproductname = lc($localproductname); 210cdf0e10cSrcweir $localproductname =~ s/ //g; 211cdf0e10cSrcweir $localproductname =~ s/-/_/g; 212cdf0e10cSrcweir 213cdf0e10cSrcweir my $packagename = $localproductname . "_" . $$languagestringref; 214cdf0e10cSrcweir 215cdf0e10cSrcweir return $packagename; 216cdf0e10cSrcweir} 217cdf0e10cSrcweir 218cdf0e10cSrcweir######################################################### 219cdf0e10cSrcweir# Determining the name of the package file or the rpm 220cdf0e10cSrcweir# in the installation directory. For language packs 221cdf0e10cSrcweir# there is only one file in this directory 222cdf0e10cSrcweir######################################################### 223cdf0e10cSrcweir 224cdf0e10cSrcweirsub determine_packagename 225cdf0e10cSrcweir{ 226cdf0e10cSrcweir my ( $installdir, $allvariables, $languagestringref ) = @_; 227cdf0e10cSrcweir 228cdf0e10cSrcweir my $packagename = ""; 229cdf0e10cSrcweir my $allnames = ""; 230cdf0e10cSrcweir 231cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir # determining the rpm file in directory $installdir 234cdf0e10cSrcweir 235cdf0e10cSrcweir my $fileextension = "rpm"; 236cdf0e10cSrcweir my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $installdir); 237cdf0e10cSrcweir if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find package in directory $installdir!", "determine_packagename"); } 238cdf0e10cSrcweir my $rpmsav = installer::converter::copy_array_from_references($rpmfiles); 239cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); } 240cdf0e10cSrcweir 241cdf0e10cSrcweir $packagename = get_packagename_from_packagelist($rpmfiles, $allvariables, $languagestringref); 242cdf0e10cSrcweir 243cdf0e10cSrcweir my $packagestring = installer::converter::convert_array_to_space_separated_string($rpmfiles); 244cdf0e10cSrcweir $packagename = create_tar_gz_file($installdir, $packagename, $packagestring); # only one file 245cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$rpmsav}; $i++ ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir my $onefile = $installdir . $installer::globals::separator . ${$rpmsav}[$i]; 248cdf0e10cSrcweir unlink($onefile); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir $allnames = $rpmfiles; 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir if ( $installer::globals::issolarisbuild ) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir # determining the Solaris package file in directory $installdir 257cdf0e10cSrcweir my $alldirs = installer::systemactions::get_all_directories($installdir); 258cdf0e10cSrcweir 259cdf0e10cSrcweir if ( ! ( $#{$alldirs} > -1 )) { installer::exiter::exit_program("ERROR: Could not find package in directory $installdir!", "determine_packagename"); } 260cdf0e10cSrcweir my $alldirssav = installer::converter::copy_array_from_references($alldirs); 261cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alldirs}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$alldirs}[$i]); } 262cdf0e10cSrcweir 263cdf0e10cSrcweir $packagename = get_packagename_from_packagelist($alldirs, $allvariables, $languagestringref); 264cdf0e10cSrcweir my $packagestring = installer::converter::convert_array_to_space_separated_string($alldirs); 265cdf0e10cSrcweir $packagename = create_tar_gz_file($installdir, $packagename, $packagestring); # only a file (not a directory) can be included into the shell script 266cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alldirssav}; $i++ ) { installer::systemactions::remove_complete_directory(${$alldirssav}[$i], 1); } 267cdf0e10cSrcweir $allnames = $alldirs; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir my $infoline = "Found package in installation directory $installdir : $packagename\n"; 271*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 272cdf0e10cSrcweir 273cdf0e10cSrcweir return ( $packagename, $allnames); 274cdf0e10cSrcweir} 275cdf0e10cSrcweir 276cdf0e10cSrcweir######################################################### 277cdf0e10cSrcweir# Including the name of the package file or the rpm 278cdf0e10cSrcweir# into the script template 279cdf0e10cSrcweir######################################################### 280cdf0e10cSrcweir 281cdf0e10cSrcweirsub put_packagename_into_script 282cdf0e10cSrcweir{ 283cdf0e10cSrcweir my ($scriptfile, $packagename, $allnames) = @_; 284cdf0e10cSrcweir 285cdf0e10cSrcweir my $localpackagename = $packagename; 286cdf0e10cSrcweir $localpackagename =~ s/\.tar\.gz//; # making "OOOopenoffice-it-ea.tar.gz" to "OOOopenoffice-it-ea" 287cdf0e10cSrcweir my $infoline = "Adding packagename $localpackagename into language pack script\n"; 288*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 289cdf0e10cSrcweir 290cdf0e10cSrcweir my $installline = ""; 291cdf0e10cSrcweir 292cdf0e10cSrcweir if ( $installer::globals::issolarisbuild ) { $installline = " /usr/sbin/pkgadd -d \$outdir -a \$adminfile"; } 293cdf0e10cSrcweir 294cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) { $installline = " rpm --prefix \$PRODUCTINSTALLLOCATION --replacepkgs -i"; } 295cdf0e10cSrcweir 296cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allnames}; $i++ ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir if ( $installer::globals::issolarisbuild ) { $installline = $installline . " ${$allnames}[$i]"; } 299cdf0e10cSrcweir 300cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) { $installline = $installline . " \$outdir/${$allnames}[$i]"; } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir} 308cdf0e10cSrcweir 309cdf0e10cSrcweir################################################################## 310cdf0e10cSrcweir# Including the lowercase product name into the script template 311cdf0e10cSrcweir################################################################## 312cdf0e10cSrcweir 313cdf0e10cSrcweirsub put_productname_into_script 314cdf0e10cSrcweir{ 315cdf0e10cSrcweir my ($scriptfile, $variableshashref) = @_; 316cdf0e10cSrcweir 317cdf0e10cSrcweir my $productname = $variableshashref->{'PRODUCTNAME'}; 318cdf0e10cSrcweir $productname = lc($productname); 319cdf0e10cSrcweir $productname =~ s/\.//g; # openoffice.org -> openofficeorg 320cdf0e10cSrcweir 321cdf0e10cSrcweir my $infoline = "Adding productname $productname into language pack script\n"; 322*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 323cdf0e10cSrcweir 324cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; 327cdf0e10cSrcweir } 328cdf0e10cSrcweir} 329cdf0e10cSrcweir 330cdf0e10cSrcweir################################################################## 331cdf0e10cSrcweir# Including the full product name into the script template 332cdf0e10cSrcweir# (name and version) 333cdf0e10cSrcweir################################################################## 334cdf0e10cSrcweir 335cdf0e10cSrcweirsub put_fullproductname_into_script 336cdf0e10cSrcweir{ 337cdf0e10cSrcweir my ($scriptfile, $variableshashref) = @_; 338cdf0e10cSrcweir 339cdf0e10cSrcweir my $productname = $variableshashref->{'PRODUCTNAME'}; 340cdf0e10cSrcweir my $productversion = ""; 341cdf0e10cSrcweir if ( $variableshashref->{'PRODUCTVERSION'} ) { $productversion = $variableshashref->{'PRODUCTVERSION'}; }; 342cdf0e10cSrcweir my $fullproductname = $productname . " " . $productversion; 343cdf0e10cSrcweir 344cdf0e10cSrcweir my $infoline = "Adding full productname \"$fullproductname\" into language pack script\n"; 345*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 346cdf0e10cSrcweir 347cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/FULLPRODUCTNAMELONGPLACEHOLDER/$fullproductname/; 350cdf0e10cSrcweir } 351cdf0e10cSrcweir} 352cdf0e10cSrcweir 353cdf0e10cSrcweir################################################################## 354cdf0e10cSrcweir# Including the name of the search package (-core01) 355cdf0e10cSrcweir# into the script template 356cdf0e10cSrcweir################################################################## 357cdf0e10cSrcweir 358cdf0e10cSrcweirsub put_searchpackage_into_script 359cdf0e10cSrcweir{ 360cdf0e10cSrcweir my ($scriptfile, $variableshashref) = @_; 361cdf0e10cSrcweir 362cdf0e10cSrcweir my $basispackageprefix = $variableshashref->{'BASISPACKAGEPREFIX'}; 363cdf0e10cSrcweir my $basispackageversion = $variableshashref->{'OOOBASEVERSION'}; 364cdf0e10cSrcweir 365cdf0e10cSrcweir if ( $installer::globals::issolarisbuild ) { $basispackageversion =~ s/\.//g; } # "3.0" -> "30" 366cdf0e10cSrcweir 367cdf0e10cSrcweir my $infoline = "Adding basis package prefix $basispackageprefix into language pack script\n"; 368*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 369cdf0e10cSrcweir 370cdf0e10cSrcweir $infoline = "Adding basis package version $basispackageversion into language pack script\n"; 371*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 372cdf0e10cSrcweir 373cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/BASISPACKAGEPREFIXPLACEHOLDER/$basispackageprefix/; 376cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/OOOBASEVERSIONPLACEHOLDER/$basispackageversion/; 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir} 380cdf0e10cSrcweir 381cdf0e10cSrcweir######################################################### 382cdf0e10cSrcweir# Including the linenumber into the script template 383cdf0e10cSrcweir######################################################### 384cdf0e10cSrcweir 385cdf0e10cSrcweirsub put_linenumber_into_script 386cdf0e10cSrcweir{ 387cdf0e10cSrcweir my ( $scriptfile, $licensefile, $allnames ) = @_; 388cdf0e10cSrcweir 389cdf0e10cSrcweir my $linenumber = $#{$scriptfile} + $#{$licensefile} + 3; # also adding the content of the license file! 390cdf0e10cSrcweir 391cdf0e10cSrcweir my $infoline = "Adding linenumber $linenumber into language pack script\n"; 392*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 393cdf0e10cSrcweir 394cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/LINENUMBERPLACEHOLDER/$linenumber/; 397cdf0e10cSrcweir } 398cdf0e10cSrcweir} 399cdf0e10cSrcweir 400cdf0e10cSrcweir######################################################### 401cdf0e10cSrcweir# Determining the name of the new scriptfile 402cdf0e10cSrcweir######################################################### 403cdf0e10cSrcweir 404cdf0e10cSrcweirsub determine_scriptfile_name 405cdf0e10cSrcweir{ 406cdf0e10cSrcweir my ( $packagename ) = @_; 407cdf0e10cSrcweir 408cdf0e10cSrcweir my $scriptfilename = $packagename; 409cdf0e10cSrcweir 410cdf0e10cSrcweir# if ( $installer::globals::islinuxrpmbuild ) { $scriptfilename =~ s/\.rpm\s*$/\.sh/; } 411cdf0e10cSrcweir# if ( $installer::globals::issolarisbuild ) { $scriptfilename =~ s/\.tar\.gz\s*$/\.sh/; } 412cdf0e10cSrcweir 413cdf0e10cSrcweir $scriptfilename =~ s/\.tar\.gz\s*$/\.sh/; 414cdf0e10cSrcweir 415cdf0e10cSrcweir my $infoline = "Setting language pack script file name to $scriptfilename\n"; 416*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 417cdf0e10cSrcweir 418cdf0e10cSrcweir return $scriptfilename; 419cdf0e10cSrcweir} 420cdf0e10cSrcweir 421cdf0e10cSrcweir######################################################### 422cdf0e10cSrcweir# Saving the script file in the installation directory 423cdf0e10cSrcweir######################################################### 424cdf0e10cSrcweir 425cdf0e10cSrcweirsub save_script_file 426cdf0e10cSrcweir{ 427cdf0e10cSrcweir my ($installdir, $newscriptfilename, $scriptfile) = @_; 428cdf0e10cSrcweir 429cdf0e10cSrcweir $newscriptfilename = $installdir . $installer::globals::separator . $newscriptfilename; 430cdf0e10cSrcweir installer::files::save_file($newscriptfilename, $scriptfile); 431cdf0e10cSrcweir 432cdf0e10cSrcweir my $infoline = "Saving script file $newscriptfilename\n"; 433*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 434cdf0e10cSrcweir 435cdf0e10cSrcweir return $newscriptfilename; 436cdf0e10cSrcweir} 437cdf0e10cSrcweir 438cdf0e10cSrcweir######################################################### 439cdf0e10cSrcweir# Including the binary package into the script 440cdf0e10cSrcweir######################################################### 441cdf0e10cSrcweir 442cdf0e10cSrcweirsub include_package_into_script 443cdf0e10cSrcweir{ 444cdf0e10cSrcweir my ( $scriptfilename, $installdir, $packagename ) = @_; 445cdf0e10cSrcweir 446cdf0e10cSrcweir my $longpackagename = $installdir . $installer::globals::separator . $packagename; 447cdf0e10cSrcweir my $systemcall = "cat $longpackagename >>$scriptfilename"; 448cdf0e10cSrcweir 449cdf0e10cSrcweir my $returnvalue = system($systemcall); 450cdf0e10cSrcweir 451cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 452*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 453cdf0e10cSrcweir 454cdf0e10cSrcweir if ($returnvalue) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 457*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir else 460cdf0e10cSrcweir { 461cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 462*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir my $localcall = "chmod 775 $scriptfilename \>\/dev\/null 2\>\&1"; 466cdf0e10cSrcweir system($localcall); 467cdf0e10cSrcweir 468cdf0e10cSrcweir} 469cdf0e10cSrcweir 470cdf0e10cSrcweir######################################################### 471cdf0e10cSrcweir# Removing the binary package 472cdf0e10cSrcweir######################################################### 473cdf0e10cSrcweir 474cdf0e10cSrcweirsub remove_package 475cdf0e10cSrcweir{ 476cdf0e10cSrcweir my ( $installdir, $packagename ) = @_; 477cdf0e10cSrcweir 478cdf0e10cSrcweir my $remove_package = 1; 479cdf0e10cSrcweir 480cdf0e10cSrcweir if ( $ENV{'DONT_REMOVE_PACKAGE'} ) { $remove_package = 0; } 481cdf0e10cSrcweir 482cdf0e10cSrcweir if ( $remove_package ) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir my $longpackagename = $installdir . $installer::globals::separator . $packagename; 485cdf0e10cSrcweir unlink $longpackagename; 486cdf0e10cSrcweir 487cdf0e10cSrcweir my $infoline = "Removing package: $longpackagename \n"; 488*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir} 491cdf0e10cSrcweir 492cdf0e10cSrcweir#################################################### 493cdf0e10cSrcweir# Unix language packs, that are not part of 494cdf0e10cSrcweir# multilingual installation sets, need a 495cdf0e10cSrcweir# shell script installer 496cdf0e10cSrcweir#################################################### 497cdf0e10cSrcweir 498cdf0e10cSrcweirsub build_installer_for_languagepack 499cdf0e10cSrcweir{ 500cdf0e10cSrcweir my ($installdir, $allvariableshashref, $includepatharrayref, $languagesarrayref, $languagestringref) = @_; 501cdf0e10cSrcweir 502cdf0e10cSrcweir installer::logger::print_message( "... creating shell script installer ...\n" ); 503cdf0e10cSrcweir 504cdf0e10cSrcweir installer::logger::include_header_into_logfile("Creating shell script installer:"); 505cdf0e10cSrcweir 506cdf0e10cSrcweir # find and read setup script template 507cdf0e10cSrcweir 508cdf0e10cSrcweir my $scriptfilename = "langpackscript.sh"; 509cdf0e10cSrcweir my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0); 510cdf0e10cSrcweir if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "build_installer_for_languagepack"); } 511cdf0e10cSrcweir my $scriptfile = installer::files::read_file($$scriptref); 512cdf0e10cSrcweir 513cdf0e10cSrcweir my $infoline = "Found script file $scriptfilename: $$scriptref \n"; 514*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 515cdf0e10cSrcweir 516cdf0e10cSrcweir # find and read english license file 517cdf0e10cSrcweir my $licenselanguage = "en-US"; # always english ! 518b14cb721SHerbert Dürr my $licensefilename = "LICENSE"; 519cdf0e10cSrcweir my $licenseincludepatharrayref = installer::worker::get_language_specific_include_pathes($includepatharrayref, $licenselanguage); 520cdf0e10cSrcweir 521cdf0e10cSrcweir my $licenseref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $licenseincludepatharrayref, 0); 522cdf0e10cSrcweir if ($$licenseref eq "") { installer::exiter::exit_program("ERROR: Could not find License file $licensefilename!", "build_installer_for_languagepack"); } 523cdf0e10cSrcweir my $licensefile = installer::files::read_file($$licenseref); 524cdf0e10cSrcweir 525cdf0e10cSrcweir $infoline = "Found licensefile $licensefilename: $$licenseref \n"; 526*b274bc22SAndre Fischer $installer::logger::Lang->print($infoline); 527cdf0e10cSrcweir 528cdf0e10cSrcweir # including variables into license file 529cdf0e10cSrcweir installer::scpzipfiles::replace_all_ziplistvariables_in_file($licensefile, $allvariableshashref); 530cdf0e10cSrcweir 531cdf0e10cSrcweir # add license text into script template 532cdf0e10cSrcweir put_license_file_into_script($scriptfile, $licensefile); 533cdf0e10cSrcweir 534cdf0e10cSrcweir # add rpm or package file name into script template 535cdf0e10cSrcweir my ( $packagename, $allnames) = determine_packagename($installdir, $allvariableshashref, $languagestringref); 536cdf0e10cSrcweir put_packagename_into_script($scriptfile, $packagename, $allnames); 537cdf0e10cSrcweir 538cdf0e10cSrcweir # add product name into script template 539cdf0e10cSrcweir put_productname_into_script($scriptfile, $allvariableshashref); 540cdf0e10cSrcweir 541cdf0e10cSrcweir # add product name into script template 542cdf0e10cSrcweir put_fullproductname_into_script($scriptfile, $allvariableshashref); 543cdf0e10cSrcweir 544cdf0e10cSrcweir # add product name into script template 545cdf0e10cSrcweir put_searchpackage_into_script($scriptfile, $allvariableshashref); 546cdf0e10cSrcweir 547cdf0e10cSrcweir # replace linenumber in script template 548cdf0e10cSrcweir put_linenumber_into_script($scriptfile, $licensefile, $allnames); 549cdf0e10cSrcweir 550cdf0e10cSrcweir # saving the script file 551cdf0e10cSrcweir my $newscriptfilename = determine_scriptfile_name($packagename); 552cdf0e10cSrcweir $newscriptfilename = save_script_file($installdir, $newscriptfilename, $scriptfile); 553cdf0e10cSrcweir 554cdf0e10cSrcweir # include rpm or package into script 555cdf0e10cSrcweir include_package_into_script($newscriptfilename, $installdir, $packagename); 556cdf0e10cSrcweir 557cdf0e10cSrcweir # remove rpm or package 558cdf0e10cSrcweir remove_package($installdir, $packagename); 559cdf0e10cSrcweir} 560cdf0e10cSrcweir 561cdf0e10cSrcweir1; 562