| Filename | /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer/languagepack.pm |
| Statements | Executed 19 statements in 5.02ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 405µs | 409µs | installer::languagepack::BEGIN@30 |
| 1 | 1 | 1 | 21µs | 23µs | installer::languagepack::BEGIN@32 |
| 1 | 1 | 1 | 19µs | 21µs | installer::languagepack::BEGIN@36 |
| 1 | 1 | 1 | 17µs | 20µs | installer::languagepack::BEGIN@31 |
| 1 | 1 | 1 | 17µs | 20µs | installer::languagepack::BEGIN@34 |
| 1 | 1 | 1 | 16µs | 18µs | installer::languagepack::BEGIN@37 |
| 1 | 1 | 1 | 16µs | 18µs | installer::languagepack::BEGIN@35 |
| 1 | 1 | 1 | 15µs | 18µs | installer::languagepack::BEGIN@38 |
| 1 | 1 | 1 | 15µs | 71µs | installer::languagepack::BEGIN@33 |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::build_installer_for_languagepack |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::create_tar_gz_file |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::determine_packagename |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::determine_scriptfile_name |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::get_packagename_from_packagelist |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::include_package_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::put_fullproductname_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::put_license_file_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::put_linenumber_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::put_packagename_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::put_productname_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::put_searchpackage_into_script |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::remove_package |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::replace_languagestring_variable |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::save_script_file |
| 0 | 0 | 0 | 0s | 0s | installer::languagepack::select_language_items |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | #************************************************************************* | ||||
| 2 | # | ||||
| 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||||
| 4 | # | ||||
| 5 | # Copyright 2000, 2010 Oracle and/or its affiliates. | ||||
| 6 | # | ||||
| 7 | # OpenOffice.org - a multi-platform office productivity suite | ||||
| 8 | # | ||||
| 9 | # This file is part of OpenOffice.org. | ||||
| 10 | # | ||||
| 11 | # OpenOffice.org is free software: you can redistribute it and/or modify | ||||
| 12 | # it under the terms of the GNU Lesser General Public License version 3 | ||||
| 13 | # only, as published by the Free Software Foundation. | ||||
| 14 | # | ||||
| 15 | # OpenOffice.org is distributed in the hope that it will be useful, | ||||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| 18 | # GNU Lesser General Public License version 3 for more details | ||||
| 19 | # (a copy is included in the LICENSE file that accompanied this code). | ||||
| 20 | # | ||||
| 21 | # You should have received a copy of the GNU Lesser General Public License | ||||
| 22 | # version 3 along with OpenOffice.org. If not, see | ||||
| 23 | # <http://www.openoffice.org/license.html> | ||||
| 24 | # for a copy of the LGPLv3 License. | ||||
| 25 | # | ||||
| 26 | #************************************************************************* | ||||
| 27 | |||||
| 28 | package installer::languagepack; | ||||
| 29 | |||||
| 30 | 2 | 67µs | 2 | 414µs | # spent 409µs (405+5) within installer::languagepack::BEGIN@30 which was called:
# once (405µs+5µs) by installer::BEGIN@46 at line 30 # spent 409µs making 1 call to installer::languagepack::BEGIN@30
# spent 5µs making 1 call to UNIVERSAL::import |
| 31 | 2 | 57µs | 2 | 22µs | # spent 20µs (17+3) within installer::languagepack::BEGIN@31 which was called:
# once (17µs+3µs) by installer::BEGIN@46 at line 31 # spent 20µs making 1 call to installer::languagepack::BEGIN@31
# spent 2µs making 1 call to UNIVERSAL::import |
| 32 | 2 | 55µs | 2 | 25µs | # spent 23µs (21+2) within installer::languagepack::BEGIN@32 which was called:
# once (21µs+2µs) by installer::BEGIN@46 at line 32 # spent 23µs making 1 call to installer::languagepack::BEGIN@32
# spent 2µs making 1 call to UNIVERSAL::import |
| 33 | 2 | 60µs | 2 | 127µs | # spent 71µs (15+56) within installer::languagepack::BEGIN@33 which was called:
# once (15µs+56µs) by installer::BEGIN@46 at line 33 # spent 71µs making 1 call to installer::languagepack::BEGIN@33
# spent 56µs making 1 call to Exporter::import |
| 34 | 2 | 54µs | 2 | 22µs | # spent 20µs (17+3) within installer::languagepack::BEGIN@34 which was called:
# once (17µs+3µs) by installer::BEGIN@46 at line 34 # spent 20µs making 1 call to installer::languagepack::BEGIN@34
# spent 3µs making 1 call to UNIVERSAL::import |
| 35 | 2 | 53µs | 2 | 21µs | # spent 18µs (16+3) within installer::languagepack::BEGIN@35 which was called:
# once (16µs+3µs) by installer::BEGIN@46 at line 35 # spent 18µs making 1 call to installer::languagepack::BEGIN@35
# spent 3µs making 1 call to UNIVERSAL::import |
| 36 | 2 | 53µs | 2 | 24µs | # spent 21µs (19+3) within installer::languagepack::BEGIN@36 which was called:
# once (19µs+3µs) by installer::BEGIN@46 at line 36 # spent 21µs making 1 call to installer::languagepack::BEGIN@36
# spent 2µs making 1 call to UNIVERSAL::import |
| 37 | 2 | 53µs | 2 | 19µs | # spent 18µs (16+2) within installer::languagepack::BEGIN@37 which was called:
# once (16µs+2µs) by installer::BEGIN@46 at line 37 # spent 18µs making 1 call to installer::languagepack::BEGIN@37
# spent 2µs making 1 call to UNIVERSAL::import |
| 38 | 2 | 4.56ms | 2 | 20µs | # spent 18µs (15+2) within installer::languagepack::BEGIN@38 which was called:
# once (15µs+2µs) by installer::BEGIN@46 at line 38 # spent 18µs making 1 call to installer::languagepack::BEGIN@38
# spent 2µs making 1 call to UNIVERSAL::import |
| 39 | |||||
| 40 | #################################################### | ||||
| 41 | # Selecting all files with the correct language | ||||
| 42 | #################################################### | ||||
| 43 | |||||
| 44 | sub select_language_items | ||||
| 45 | { | ||||
| 46 | my ( $itemsref, $languagesarrayref, $itemname ) = @_; | ||||
| 47 | |||||
| 48 | installer::logger::include_header_into_logfile("Selecting languages for language pack. Item: $itemname"); | ||||
| 49 | |||||
| 50 | my @itemsarray = (); | ||||
| 51 | |||||
| 52 | for ( my $i = 0; $i <= $#{$itemsref}; $i++ ) | ||||
| 53 | { | ||||
| 54 | my $oneitem = ${$itemsref}[$i]; | ||||
| 55 | |||||
| 56 | my $ismultilingual = $oneitem->{'ismultilingual'}; | ||||
| 57 | |||||
| 58 | if (!($ismultilingual)) | ||||
| 59 | { | ||||
| 60 | # Files with style "LANGUAGEPACK" and "FORCELANGUAGEPACK" also have to be included into the language pack. | ||||
| 61 | # Files with style "LANGUAGEPACK" are only included into language packs. | ||||
| 62 | # Files with style "FORCELANGUAGEPACK" are included into language packs and non language packs. They are | ||||
| 63 | # forced, because otherwise they not not be included into languagepacks. | ||||
| 64 | |||||
| 65 | my $styles = ""; | ||||
| 66 | if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; } | ||||
| 67 | |||||
| 68 | if (( $styles =~ /\bLANGUAGEPACK\b/ ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ )) { push(@itemsarray, $oneitem); } | ||||
| 69 | |||||
| 70 | next; # single language files are not included into language pack | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | my $specificlanguage = ""; | ||||
| 74 | if ( $oneitem->{'specificlanguage'} ) { $specificlanguage = $oneitem->{'specificlanguage'}; } | ||||
| 75 | |||||
| 76 | for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) # iterating over all languages | ||||
| 77 | { | ||||
| 78 | my $onelanguage = ${$languagesarrayref}[$j]; | ||||
| 79 | my $locallang = $onelanguage; | ||||
| 80 | $locallang =~ s/-/_/; | ||||
| 81 | |||||
| 82 | if ( $specificlanguage eq $onelanguage ) | ||||
| 83 | { | ||||
| 84 | push(@itemsarray, $oneitem); | ||||
| 85 | } | ||||
| 86 | } | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | return \@itemsarray; | ||||
| 90 | } | ||||
| 91 | |||||
| 92 | sub replace_languagestring_variable | ||||
| 93 | { | ||||
| 94 | my ($onepackageref, $languagestringref) = @_; | ||||
| 95 | |||||
| 96 | my $key; | ||||
| 97 | |||||
| 98 | foreach $key (keys %{$onepackageref}) | ||||
| 99 | { | ||||
| 100 | my $value = $onepackageref->{$key}; | ||||
| 101 | $value =~ s/\%LANGUAGESTRING/$$languagestringref/g; | ||||
| 102 | $onepackageref->{$key} = $value; | ||||
| 103 | } | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | ######################################################### | ||||
| 107 | # Including the license text into the script template | ||||
| 108 | ######################################################### | ||||
| 109 | |||||
| 110 | sub put_license_file_into_script | ||||
| 111 | { | ||||
| 112 | my ($scriptfile, $licensefile) = @_; | ||||
| 113 | |||||
| 114 | my $infoline = "Adding licensefile into language pack script\n"; | ||||
| 115 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 116 | |||||
| 117 | my $includestring = ""; | ||||
| 118 | |||||
| 119 | for ( my $i = 0; $i <= $#{$licensefile}; $i++ ) | ||||
| 120 | { | ||||
| 121 | $includestring = $includestring . ${$licensefile}[$i]; | ||||
| 122 | } | ||||
| 123 | |||||
| 124 | for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) | ||||
| 125 | { | ||||
| 126 | ${$scriptfile}[$i] =~ s/LICENSEFILEPLACEHOLDER/$includestring/; | ||||
| 127 | } | ||||
| 128 | } | ||||
| 129 | |||||
| 130 | ######################################################### | ||||
| 131 | # Creating a tar.gz file from a Solaris package | ||||
| 132 | ######################################################### | ||||
| 133 | |||||
| 134 | sub create_tar_gz_file | ||||
| 135 | { | ||||
| 136 | my ($installdir, $packagename, $packagestring) = @_; | ||||
| 137 | |||||
| 138 | $packagename =~ s/\.rpm\s*$//; | ||||
| 139 | my $targzname = $packagename . ".tar.gz"; | ||||
| 140 | $systemcall = "cd $installdir; tar -cf - $packagestring | gzip > $targzname"; | ||||
| 141 | installer::logger::print_message( "... $systemcall ...\n" ); | ||||
| 142 | |||||
| 143 | my $returnvalue = system($systemcall); | ||||
| 144 | |||||
| 145 | my $infoline = "Systemcall: $systemcall\n"; | ||||
| 146 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 147 | |||||
| 148 | if ($returnvalue) | ||||
| 149 | { | ||||
| 150 | $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; | ||||
| 151 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 152 | } | ||||
| 153 | else | ||||
| 154 | { | ||||
| 155 | $infoline = "Success: Executed \"$systemcall\" successfully!\n"; | ||||
| 156 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 157 | } | ||||
| 158 | |||||
| 159 | return $targzname; | ||||
| 160 | } | ||||
| 161 | |||||
| 162 | ######################################################### | ||||
| 163 | # Determining the name of the package file | ||||
| 164 | ######################################################### | ||||
| 165 | |||||
| 166 | sub get_packagename_from_packagelist | ||||
| 167 | { | ||||
| 168 | my ( $alldirs, $allvariables, $languagestringref ) = @_; | ||||
| 169 | |||||
| 170 | my $localproductname = $allvariables->{'PRODUCTNAME'}; | ||||
| 171 | $localproductname = lc($localproductname); | ||||
| 172 | $localproductname =~ s/ //g; | ||||
| 173 | $localproductname =~ s/-/_/g; | ||||
| 174 | |||||
| 175 | my $packagename = $localproductname . "_" . $$languagestringref; | ||||
| 176 | |||||
| 177 | return $packagename; | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | ######################################################### | ||||
| 181 | # Determining the name of the package file or the rpm | ||||
| 182 | # in the installation directory. For language packs | ||||
| 183 | # there is only one file in this directory | ||||
| 184 | ######################################################### | ||||
| 185 | |||||
| 186 | sub determine_packagename | ||||
| 187 | { | ||||
| 188 | my ( $installdir, $allvariables, $languagestringref ) = @_; | ||||
| 189 | |||||
| 190 | my $packagename = ""; | ||||
| 191 | my $allnames = ""; | ||||
| 192 | |||||
| 193 | if ( $installer::globals::isrpmbuild ) | ||||
| 194 | { | ||||
| 195 | # determining the rpm file in directory $installdir | ||||
| 196 | |||||
| 197 | my $fileextension = "rpm"; | ||||
| 198 | my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $installdir); | ||||
| 199 | if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find package in directory $installdir!", "determine_packagename"); } | ||||
| 200 | my $rpmsav = [@{$rpmfiles}]; | ||||
| 201 | for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); } | ||||
| 202 | |||||
| 203 | $packagename = get_packagename_from_packagelist($rpmfiles, $allvariables, $languagestringref); | ||||
| 204 | |||||
| 205 | my $packagestring = installer::converter::convert_array_to_space_separated_string($rpmfiles); | ||||
| 206 | $packagename = create_tar_gz_file($installdir, $packagename, $packagestring); # only one file | ||||
| 207 | for ( my $i = 0; $i <= $#{$rpmsav}; $i++ ) | ||||
| 208 | { | ||||
| 209 | my $onefile = $installdir . $installer::globals::separator . ${$rpmsav}[$i]; | ||||
| 210 | unlink($onefile); | ||||
| 211 | } | ||||
| 212 | |||||
| 213 | $allnames = $rpmfiles; | ||||
| 214 | } | ||||
| 215 | |||||
| 216 | if ( $installer::globals::issolarisbuild ) | ||||
| 217 | { | ||||
| 218 | # determining the Solaris package file in directory $installdir | ||||
| 219 | my $alldirs = installer::systemactions::get_all_directories($installdir); | ||||
| 220 | |||||
| 221 | if ( ! ( $#{$alldirs} > -1 )) { installer::exiter::exit_program("ERROR: Could not find package in directory $installdir!", "determine_packagename"); } | ||||
| 222 | my $alldirssav = [@{$alldirs}]; | ||||
| 223 | for ( my $i = 0; $i <= $#{$alldirs}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$alldirs}[$i]); } | ||||
| 224 | |||||
| 225 | $packagename = get_packagename_from_packagelist($alldirs, $allvariables, $languagestringref); | ||||
| 226 | my $packagestring = installer::converter::convert_array_to_space_separated_string($alldirs); | ||||
| 227 | $packagename = create_tar_gz_file($installdir, $packagename, $packagestring); # only a file (not a directory) can be included into the shell script | ||||
| 228 | for ( my $i = 0; $i <= $#{$alldirssav}; $i++ ) { installer::systemactions::remove_complete_directory(${$alldirssav}[$i], 1); } | ||||
| 229 | $allnames = $alldirs; | ||||
| 230 | } | ||||
| 231 | |||||
| 232 | my $infoline = "Found package in installation directory $installdir : $packagename\n"; | ||||
| 233 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 234 | |||||
| 235 | return ( $packagename, $allnames); | ||||
| 236 | } | ||||
| 237 | |||||
| 238 | ######################################################### | ||||
| 239 | # Including the name of the package file or the rpm | ||||
| 240 | # into the script template | ||||
| 241 | ######################################################### | ||||
| 242 | |||||
| 243 | sub put_packagename_into_script | ||||
| 244 | { | ||||
| 245 | my ($scriptfile, $packagename, $allnames) = @_; | ||||
| 246 | |||||
| 247 | my $localpackagename = $packagename; | ||||
| 248 | $localpackagename =~ s/\.tar\.gz//; # making "OOOopenoffice-it-ea.tar.gz" to "OOOopenoffice-it-ea" | ||||
| 249 | my $infoline = "Adding packagename $localpackagename into language pack script\n"; | ||||
| 250 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 251 | |||||
| 252 | my $installline = ""; | ||||
| 253 | |||||
| 254 | if ( $installer::globals::issolarisbuild ) { $installline = " /usr/sbin/pkgadd -d \$outdir -a \$adminfile"; } | ||||
| 255 | |||||
| 256 | if ( $installer::globals::isrpmbuild ) { $installline = " rpm --prefix \$PRODUCTINSTALLLOCATION --replacepkgs -i"; } | ||||
| 257 | |||||
| 258 | for ( my $i = 0; $i <= $#{$allnames}; $i++ ) | ||||
| 259 | { | ||||
| 260 | if ( $installer::globals::issolarisbuild ) { $installline = $installline . " ${$allnames}[$i]"; } | ||||
| 261 | |||||
| 262 | if ( $installer::globals::isrpmbuild ) { $installline = $installline . " \$outdir/${$allnames}[$i]"; } | ||||
| 263 | } | ||||
| 264 | |||||
| 265 | for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) | ||||
| 266 | { | ||||
| 267 | ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/; | ||||
| 268 | } | ||||
| 269 | } | ||||
| 270 | |||||
| 271 | ################################################################## | ||||
| 272 | # Including the lowercase product name into the script template | ||||
| 273 | ################################################################## | ||||
| 274 | |||||
| 275 | sub put_productname_into_script | ||||
| 276 | { | ||||
| 277 | my ($scriptfile, $variableshashref) = @_; | ||||
| 278 | |||||
| 279 | my $productname = $variableshashref->{'PRODUCTNAME'}; | ||||
| 280 | $productname = lc($productname); | ||||
| 281 | $productname =~ s/\.//g; # openoffice.org -> openofficeorg | ||||
| 282 | |||||
| 283 | my $infoline = "Adding productname $productname into language pack script\n"; | ||||
| 284 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 285 | |||||
| 286 | for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) | ||||
| 287 | { | ||||
| 288 | ${$scriptfile}[$i] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; | ||||
| 289 | } | ||||
| 290 | } | ||||
| 291 | |||||
| 292 | ################################################################## | ||||
| 293 | # Including the full product name into the script template | ||||
| 294 | # (name and version) | ||||
| 295 | ################################################################## | ||||
| 296 | |||||
| 297 | sub put_fullproductname_into_script | ||||
| 298 | { | ||||
| 299 | my ($scriptfile, $variableshashref) = @_; | ||||
| 300 | |||||
| 301 | my $productname = $variableshashref->{'PRODUCTNAME'}; | ||||
| 302 | my $productversion = ""; | ||||
| 303 | if ( $variableshashref->{'PRODUCTVERSION'} ) { $productversion = $variableshashref->{'PRODUCTVERSION'}; }; | ||||
| 304 | my $fullproductname = $productname . " " . $productversion; | ||||
| 305 | |||||
| 306 | my $infoline = "Adding full productname \"$fullproductname\" into language pack script\n"; | ||||
| 307 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 308 | |||||
| 309 | for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) | ||||
| 310 | { | ||||
| 311 | ${$scriptfile}[$i] =~ s/FULLPRODUCTNAMELONGPLACEHOLDER/$fullproductname/; | ||||
| 312 | } | ||||
| 313 | } | ||||
| 314 | |||||
| 315 | ################################################################## | ||||
| 316 | # Including the name of the search package (-core01) | ||||
| 317 | # into the script template | ||||
| 318 | ################################################################## | ||||
| 319 | |||||
| 320 | sub put_searchpackage_into_script | ||||
| 321 | { | ||||
| 322 | my ($scriptfile, $variableshashref) = @_; | ||||
| 323 | |||||
| 324 | my $basispackageprefix = $variableshashref->{'BASISPACKAGEPREFIX'}; | ||||
| 325 | my $productversion = $variableshashref->{'PRODUCTVERSION'}; | ||||
| 326 | |||||
| 327 | if ( $installer::globals::issolarisbuild ) { $productversion =~ s/\.//g; } # "3.0" -> "30" | ||||
| 328 | |||||
| 329 | my $infoline = "Adding basis package prefix $basispackageprefix into language pack script\n"; | ||||
| 330 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 331 | |||||
| 332 | $infoline = "Adding basis package version $productversion into language pack script\n"; | ||||
| 333 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 334 | |||||
| 335 | for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) | ||||
| 336 | { | ||||
| 337 | ${$scriptfile}[$i] =~ s/BASISPACKAGEPREFIXPLACEHOLDER/$basispackageprefix/; | ||||
| 338 | ${$scriptfile}[$i] =~ s/PRODUCTVERSIONPLACEHOLDER/$productversion/; | ||||
| 339 | } | ||||
| 340 | |||||
| 341 | } | ||||
| 342 | |||||
| 343 | ######################################################### | ||||
| 344 | # Including the linenumber into the script template | ||||
| 345 | ######################################################### | ||||
| 346 | |||||
| 347 | sub put_linenumber_into_script | ||||
| 348 | { | ||||
| 349 | my ( $scriptfile, $licensefile, $allnames ) = @_; | ||||
| 350 | |||||
| 351 | my $linenumber = $#{$scriptfile} + $#{$licensefile} + 3; # also adding the content of the license file! | ||||
| 352 | |||||
| 353 | my $infoline = "Adding linenumber $linenumber into language pack script\n"; | ||||
| 354 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 355 | |||||
| 356 | for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) | ||||
| 357 | { | ||||
| 358 | ${$scriptfile}[$i] =~ s/LINENUMBERPLACEHOLDER/$linenumber/; | ||||
| 359 | } | ||||
| 360 | } | ||||
| 361 | |||||
| 362 | ######################################################### | ||||
| 363 | # Determining the name of the new scriptfile | ||||
| 364 | ######################################################### | ||||
| 365 | |||||
| 366 | sub determine_scriptfile_name | ||||
| 367 | { | ||||
| 368 | my ( $packagename ) = @_; | ||||
| 369 | |||||
| 370 | my $scriptfilename = $packagename; | ||||
| 371 | |||||
| 372 | $scriptfilename =~ s/\.tar\.gz\s*$/\.sh/; | ||||
| 373 | |||||
| 374 | my $infoline = "Setting language pack script file name to $scriptfilename\n"; | ||||
| 375 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 376 | |||||
| 377 | return $scriptfilename; | ||||
| 378 | } | ||||
| 379 | |||||
| 380 | ######################################################### | ||||
| 381 | # Saving the script file in the installation directory | ||||
| 382 | ######################################################### | ||||
| 383 | |||||
| 384 | sub save_script_file | ||||
| 385 | { | ||||
| 386 | my ($installdir, $newscriptfilename, $scriptfile) = @_; | ||||
| 387 | |||||
| 388 | $newscriptfilename = $installdir . $installer::globals::separator . $newscriptfilename; | ||||
| 389 | installer::files::save_file($newscriptfilename, $scriptfile); | ||||
| 390 | |||||
| 391 | my $infoline = "Saving script file $newscriptfilename\n"; | ||||
| 392 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 393 | |||||
| 394 | return $newscriptfilename; | ||||
| 395 | } | ||||
| 396 | |||||
| 397 | ######################################################### | ||||
| 398 | # Including the binary package into the script | ||||
| 399 | ######################################################### | ||||
| 400 | |||||
| 401 | sub include_package_into_script | ||||
| 402 | { | ||||
| 403 | my ( $scriptfilename, $installdir, $packagename ) = @_; | ||||
| 404 | |||||
| 405 | my $longpackagename = $installdir . $installer::globals::separator . $packagename; | ||||
| 406 | my $systemcall = "cat $longpackagename >>$scriptfilename"; | ||||
| 407 | |||||
| 408 | my $returnvalue = system($systemcall); | ||||
| 409 | |||||
| 410 | my $infoline = "Systemcall: $systemcall\n"; | ||||
| 411 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 412 | |||||
| 413 | if ($returnvalue) | ||||
| 414 | { | ||||
| 415 | $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; | ||||
| 416 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 417 | } | ||||
| 418 | else | ||||
| 419 | { | ||||
| 420 | $infoline = "Success: Executed \"$systemcall\" successfully!\n"; | ||||
| 421 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 422 | } | ||||
| 423 | |||||
| 424 | chmod 0775, $scriptfilename; | ||||
| 425 | |||||
| 426 | } | ||||
| 427 | |||||
| 428 | ######################################################### | ||||
| 429 | # Removing the binary package | ||||
| 430 | ######################################################### | ||||
| 431 | |||||
| 432 | sub remove_package | ||||
| 433 | { | ||||
| 434 | my ( $installdir, $packagename ) = @_; | ||||
| 435 | |||||
| 436 | my $remove_package = 1; | ||||
| 437 | |||||
| 438 | if ( $ENV{'DONT_REMOVE_PACKAGE'} ) { $remove_package = 0; } | ||||
| 439 | |||||
| 440 | if ( $remove_package ) | ||||
| 441 | { | ||||
| 442 | my $longpackagename = $installdir . $installer::globals::separator . $packagename; | ||||
| 443 | unlink $longpackagename; | ||||
| 444 | |||||
| 445 | my $infoline = "Removing package: $longpackagename \n"; | ||||
| 446 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 447 | } | ||||
| 448 | } | ||||
| 449 | |||||
| 450 | #################################################### | ||||
| 451 | # Unix language packs, that are not part of | ||||
| 452 | # multilingual installation sets, need a | ||||
| 453 | # shell script installer | ||||
| 454 | #################################################### | ||||
| 455 | |||||
| 456 | sub build_installer_for_languagepack | ||||
| 457 | { | ||||
| 458 | my ($installdir, $allvariableshashref, $includepatharrayref, $languagesarrayref, $languagestringref) = @_; | ||||
| 459 | |||||
| 460 | installer::logger::print_message( "... creating shell script installer ...\n" ); | ||||
| 461 | |||||
| 462 | installer::logger::include_header_into_logfile("Creating shell script installer:"); | ||||
| 463 | |||||
| 464 | # find and read setup script template | ||||
| 465 | |||||
| 466 | my $scriptfilename = "langpackscript.sh"; | ||||
| 467 | my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0); | ||||
| 468 | if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "build_installer_for_languagepack"); } | ||||
| 469 | my $scriptfile = installer::files::read_file($$scriptref); | ||||
| 470 | |||||
| 471 | my $infoline = "Found script file $scriptfilename: $$scriptref \n"; | ||||
| 472 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 473 | |||||
| 474 | # find and read english license file | ||||
| 475 | my $licenselanguage = "en-US"; # always english ! | ||||
| 476 | my $licensefilename = "LICENSE"; # _" . $licenselanguage; | ||||
| 477 | my $licenseincludepatharrayref = installer::worker::get_language_specific_include_paths($includepatharrayref, $licenselanguage); | ||||
| 478 | |||||
| 479 | my $licenseref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $licenseincludepatharrayref, 0); | ||||
| 480 | if ($$licenseref eq "") { installer::exiter::exit_program("ERROR: Could not find License file $licensefilename!", "build_installer_for_languagepack"); } | ||||
| 481 | my $licensefile = installer::files::read_file($$licenseref); | ||||
| 482 | |||||
| 483 | $infoline = "Found licensefile $licensefilename: $$licenseref \n"; | ||||
| 484 | push( @installer::globals::logfileinfo, $infoline); | ||||
| 485 | |||||
| 486 | # including variables into license file | ||||
| 487 | installer::scpzipfiles::replace_all_ziplistvariables_in_file($licensefile, $allvariableshashref); | ||||
| 488 | |||||
| 489 | # add license text into script template | ||||
| 490 | put_license_file_into_script($scriptfile, $licensefile); | ||||
| 491 | |||||
| 492 | # add rpm or package file name into script template | ||||
| 493 | my ( $packagename, $allnames) = determine_packagename($installdir, $allvariableshashref, $languagestringref); | ||||
| 494 | put_packagename_into_script($scriptfile, $packagename, $allnames); | ||||
| 495 | |||||
| 496 | # add product name into script template | ||||
| 497 | put_productname_into_script($scriptfile, $allvariableshashref); | ||||
| 498 | |||||
| 499 | # add product name into script template | ||||
| 500 | put_fullproductname_into_script($scriptfile, $allvariableshashref); | ||||
| 501 | |||||
| 502 | # add product name into script template | ||||
| 503 | put_searchpackage_into_script($scriptfile, $allvariableshashref); | ||||
| 504 | |||||
| 505 | # replace linenumber in script template | ||||
| 506 | put_linenumber_into_script($scriptfile, $licensefile, $allnames); | ||||
| 507 | |||||
| 508 | # saving the script file | ||||
| 509 | my $newscriptfilename = determine_scriptfile_name($packagename); | ||||
| 510 | $newscriptfilename = save_script_file($installdir, $newscriptfilename, $scriptfile); | ||||
| 511 | |||||
| 512 | # include rpm or package into script | ||||
| 513 | include_package_into_script($newscriptfilename, $installdir, $packagename); | ||||
| 514 | |||||
| 515 | # remove rpm or package | ||||
| 516 | remove_package($installdir, $packagename); | ||||
| 517 | } | ||||
| 518 | |||||
| 519 | 1 | 8µs | 1; |