1*cdf0e10cSrcweir#************************************************************************* 2*cdf0e10cSrcweir# 3*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir# 5*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir# 7*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir# 9*cdf0e10cSrcweir# This file is part of OpenOffice.org. 10*cdf0e10cSrcweir# 11*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir# 15*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir# 21*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir# 26*cdf0e10cSrcweir#************************************************************************* 27*cdf0e10cSrcweir 28*cdf0e10cSrcweirpackage installer::ziplist; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse installer::existence; 31*cdf0e10cSrcweiruse installer::exiter; 32*cdf0e10cSrcweiruse installer::globals; 33*cdf0e10cSrcweiruse installer::logger; 34*cdf0e10cSrcweiruse installer::parameter; 35*cdf0e10cSrcweiruse installer::remover; 36*cdf0e10cSrcweiruse installer::systemactions; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir################################################# 39*cdf0e10cSrcweir# Getting data from path file and zip list file 40*cdf0e10cSrcweir################################################# 41*cdf0e10cSrcweir 42*cdf0e10cSrcweirsub getproductblock 43*cdf0e10cSrcweir{ 44*cdf0e10cSrcweir my ($fileref, $search, $inheritance) = @_; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir my @searchblock = (); 47*cdf0e10cSrcweir my $searchexists = 0; 48*cdf0e10cSrcweir my $record = 0; 49*cdf0e10cSrcweir my $count = 0; 50*cdf0e10cSrcweir my $line; 51*cdf0e10cSrcweir my $inh = $inheritance ? '(?::\s*(\S+)\s*)?' : ""; 52*cdf0e10cSrcweir my $parent; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$fileref}; $i++ ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir $line = ${$fileref}[$i]; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir if ( $line =~ /^\s*\Q$search\E\s*$inh$/i ) # case insensitive 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir $record = 1; 61*cdf0e10cSrcweir $searchexists = 1; 62*cdf0e10cSrcweir $parent = $1 if $inheritance; 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir if ($record) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir push(@searchblock, $line); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir if ( ($record) && ($line =~ /\{/) ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir $count++; 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir if ( ($record) && ($line =~ /\}/) ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir $count--; 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir if ( ($record) && ($line =~ /\}/) && ( $count == 0 ) ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir $record = 0; 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir if (( ! $searchexists ) && ( $search ne $installer::globals::globalblock )) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir if ($search eq $installer::globals::product ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Product $installer::globals::product not defined in $installer::globals::ziplistname", "getproductblock"); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir elsif ($search eq $installer::globals::compiler ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Compiler $installer::globals::compiler not defined in $installer::globals::pathfilename", "getproductblock"); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir else # this is not possible 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Unknown value for $search in getproductblock()", "getproductblock"); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir return (\@searchblock, $parent); 103*cdf0e10cSrcweir} 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir############################################### 106*cdf0e10cSrcweir# Analyzing the settings in the zip list file 107*cdf0e10cSrcweir############################################### 108*cdf0e10cSrcweir 109*cdf0e10cSrcweirsub analyze_settings_block 110*cdf0e10cSrcweir{ 111*cdf0e10cSrcweir my ($blockref) = @_; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir my @newsettingsblock = (); 114*cdf0e10cSrcweir my $compilerstring = ""; 115*cdf0e10cSrcweir my $record = 1; 116*cdf0e10cSrcweir my $counter = 0; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir # Allowed values in settings block: 119*cdf0e10cSrcweir # "Settings", "Variables", "unix" (for destination path and logfile) 120*cdf0e10cSrcweir # Furthermore allowed values are $installer::globals::build (srx645) and $installer::globals::compiler (pro and nonpro (unxsols4.pro)) 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir # Comment line in settings block begin with "#" or ";" 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if ( $installer::globals::pro ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir $compilerstring = $installer::globals::compiler . ".pro"; 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir else 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir $compilerstring = $installer::globals::compiler; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$blockref}; $i++ ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir my $line = ${$blockref}[$i]; 136*cdf0e10cSrcweir my $nextline = ""; 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir if ( ${$blockref}[$i+1] ) { $nextline = ${$blockref}[$i+1]; } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir # removing comment lines 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if (($line =~ /^\s*\#/) || ($line =~ /^\s*\;/)) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir next; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir # complete blocks of unknows strings are not recorded 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir if ((!($line =~ /^\s*\Q$compilerstring\E\s*$/i)) && 150*cdf0e10cSrcweir (!($line =~ /^\s*\Q$installer::globals::build\E\s*$/i)) && 151*cdf0e10cSrcweir (!($line =~ /^\s*\bSettings\b\s*$/i)) && 152*cdf0e10cSrcweir (!($line =~ /^\s*\bVariables\b\s*$/i)) && 153*cdf0e10cSrcweir (!($line =~ /^\s*\bunix\b\s*$/i)) && 154*cdf0e10cSrcweir ($nextline =~ /^\s*\{\s*$/i)) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir $record = 0; 157*cdf0e10cSrcweir next; # continue with next $i 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir if (!( $record )) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir if ($line =~ /^\s*\{\s*$/i) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir $counter++; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if ($line =~ /^\s*\}\s*$/i) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir $counter--; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if ($counter == 0) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir $record = 1; 175*cdf0e10cSrcweir next; # continue with next $i 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir if ($record) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir push(@newsettingsblock, $line); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir return \@newsettingsblock; 186*cdf0e10cSrcweir} 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir######################################## 189*cdf0e10cSrcweir# Settings in zip list file 190*cdf0e10cSrcweir######################################## 191*cdf0e10cSrcweir 192*cdf0e10cSrcweirsub get_settings_from_ziplist 193*cdf0e10cSrcweir{ 194*cdf0e10cSrcweir my ($blockref) = @_; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir my @allsettings = (); 197*cdf0e10cSrcweir my $isvariables = 0; 198*cdf0e10cSrcweir my $counter = 0; 199*cdf0e10cSrcweir my $variablescounter = 0; 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir # Take all settings from the settings block 202*cdf0e10cSrcweir # Do not take the variables from the settings block 203*cdf0e10cSrcweir # If a setting is defined more than once, take the 204*cdf0e10cSrcweir # setting with the largest counter (open brackets) 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$blockref}; $i++ ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir my $line = ${$blockref}[$i]; 209*cdf0e10cSrcweir my $nextline = ""; 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir if ( ${$blockref}[$i+1] ) { $nextline = ${$blockref}[$i+1]; } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir if (($line =~ /^\s*\S+\s*$/i) && 214*cdf0e10cSrcweir ($nextline =~ /^\s*\{\s*$/i) && 215*cdf0e10cSrcweir (!($line =~ /^\s*Variables\s*$/i))) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir next; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir if ($line =~ /^\s*Variables\s*$/i) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir # This is a block of variables 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir $isvariables = 1; 225*cdf0e10cSrcweir next; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir if ($line =~ /^\s*\{\s*$/i) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir if ($isvariables) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir $variablescounter++; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir else 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir $counter++; 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir next; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir if ($line =~ /^\s*\}\s*$/i) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir if ($isvariables) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir $variablescounter--; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if ($variablescounter == 0) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir $isvariables = 0; 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir $counter--; 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir next; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir if ($isvariables) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir next; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$line); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir $line .= "\t##$counter##\n"; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir push(@allsettings, $line); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir return \@allsettings; 274*cdf0e10cSrcweir} 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir####################################### 277*cdf0e10cSrcweir# Variables from zip list file 278*cdf0e10cSrcweir####################################### 279*cdf0e10cSrcweir 280*cdf0e10cSrcweirsub get_variables_from_ziplist 281*cdf0e10cSrcweir{ 282*cdf0e10cSrcweir my ($blockref) = @_; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir my @allvariables = (); 285*cdf0e10cSrcweir my $isvariables = 0; 286*cdf0e10cSrcweir my $counter = 0; 287*cdf0e10cSrcweir my $variablescounter = 0; 288*cdf0e10cSrcweir my $countersum = 0; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir # Take all variables from the settings block 291*cdf0e10cSrcweir # Do not take the other settings from the settings block 292*cdf0e10cSrcweir # If a variable is defined more than once, take the 293*cdf0e10cSrcweir # variable with the largest counter (open brackets) 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$blockref}; $i++ ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir my $line = ${$blockref}[$i]; 298*cdf0e10cSrcweir my $nextline = ${$blockref}[$i+1]; 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if ($line =~ /^\s*Variables\s*$/i) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir # This is a block of variables 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir $isvariables = 1; 305*cdf0e10cSrcweir next; 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir if ($line =~ /^\s*\{\s*$/i) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir if ($isvariables) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir $variablescounter++; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir else 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir $counter++; 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir next; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir if ($line =~ /^\s*\}\s*$/i) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir if ($isvariables) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir $variablescounter--; 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir if ($variablescounter == 0) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir $isvariables = 0; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir else 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir $counter--; 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir next; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir if (!($isvariables)) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir next; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir $countersum = $counter + $variablescounter; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$line); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir $line .= "\t##$countersum##\n"; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir push(@allvariables, $line); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir return \@allvariables; 356*cdf0e10cSrcweir} 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir####################################################################### 359*cdf0e10cSrcweir# Removing multiple variables and settings, defined in zip list file 360*cdf0e10cSrcweir####################################################################### 361*cdf0e10cSrcweir 362*cdf0e10cSrcweirsub remove_multiples_from_ziplist 363*cdf0e10cSrcweir{ 364*cdf0e10cSrcweir my ($blockref) = @_; 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir # remove all definitions of settings and variables 367*cdf0e10cSrcweir # that occur more than once in the zip list file. 368*cdf0e10cSrcweir # Take the one with the most open brackets. This 369*cdf0e10cSrcweir # number is stored at the end of the string. 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir my @newarray = (); 372*cdf0e10cSrcweir my @itemarray = (); 373*cdf0e10cSrcweir my ($line, $itemname, $itemnumber); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir # first collecting all variables and settings names 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$blockref}; $i++ ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir $line = ${$blockref}[$i]; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir if ($line =~ /^\s*\b(\S*)\b\s+.*\#\#\d+\#\#\s*$/i) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir $itemname = $1; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir if (! installer::existence::exists_in_array($itemname, \@itemarray)) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir push(@itemarray, $itemname); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir # and now all $items can be selected with the highest number 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir for ( my $i = 0; $i <= $#itemarray; $i++ ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir $itemname = $itemarray[$i]; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir my $itemnumbermax = 0; 399*cdf0e10cSrcweir my $printline = ""; 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$blockref}; $j++ ) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir $line = ${$blockref}[$j]; 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir if ($line =~ /^\s*\Q$itemname\E\s+.*\#\#(\d+)\#\#\s*$/) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir $itemnumber = $1; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir if ($itemnumber >= $itemnumbermax) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir $printline = $line; 412*cdf0e10cSrcweir $itemnumbermax = $itemnumber; 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir # removing the ending number from the printline 418*cdf0e10cSrcweir # and putting it into the array 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir $printline =~ s/\#\#\d+\#\#//; 421*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$line); 422*cdf0e10cSrcweir push(@newarray, $printline); 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir return \@newarray; 426*cdf0e10cSrcweir} 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir######################################################### 429*cdf0e10cSrcweir# Reading one variable defined in the zip list file 430*cdf0e10cSrcweir######################################################### 431*cdf0e10cSrcweir 432*cdf0e10cSrcweirsub getinfofromziplist 433*cdf0e10cSrcweir{ 434*cdf0e10cSrcweir my ($blockref, $variable) = @_; 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir my $searchstring = ""; 437*cdf0e10cSrcweir my $line; 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$blockref}; $i++ ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir $line = ${$blockref}[$i]; 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if ( $line =~ /^\s*\Q$variable\E\s+(.+?)\s*$/ ) # "?" for minimal matching 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir $searchstring = $1; 446*cdf0e10cSrcweir last; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir return \$searchstring; 451*cdf0e10cSrcweir} 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir#################################################### 454*cdf0e10cSrcweir# Replacing variables in include path 455*cdf0e10cSrcweir#################################################### 456*cdf0e10cSrcweir 457*cdf0e10cSrcweirsub replace_all_variables_in_pathes 458*cdf0e10cSrcweir{ 459*cdf0e10cSrcweir my ( $patharrayref, $variableshashref ) = @_; 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir my $line = ${$patharrayref}[$i]; 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir my $key; 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir foreach $key (keys %{$variableshashref}) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir my $value = $variableshashref->{$key}; 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir if (( $line =~ /\{$key\}/ ) && ( $value eq "" )) { $line = ".\n"; } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir $line =~ s/\{\Q$key\E\}/$value/g; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir ${$patharrayref}[$i] = $line; 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir} 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir#################################################### 481*cdf0e10cSrcweir# Replacing minor in include path 482*cdf0e10cSrcweir#################################################### 483*cdf0e10cSrcweir 484*cdf0e10cSrcweirsub replace_minor_in_pathes 485*cdf0e10cSrcweir{ 486*cdf0e10cSrcweir my ( $patharrayref ) = @_; 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir my $line = ${$patharrayref}[$i]; 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir if ( ! defined $ENV{CWS_WORK_STAMP} and defined $ENV{UPDMINOR} ) 493*cdf0e10cSrcweir# if ( $installer::globals::minor ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir $line =~ s/\{minor\}/$installer::globals::minor/g; 496*cdf0e10cSrcweir # no difference for minor and minornonpre (ToDo ?) 497*cdf0e10cSrcweir $line =~ s/\{minornonpre\}/$installer::globals::minor/g; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir else # building without a minor 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir $line =~ s/\.\{minor\}//g; 502*cdf0e10cSrcweir $line =~ s/\.\{minornonpre\}//g; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir ${$patharrayref}[$i] = $line; 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir} 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir#################################################### 510*cdf0e10cSrcweir# Replacing packagetype in include path 511*cdf0e10cSrcweir#################################################### 512*cdf0e10cSrcweir 513*cdf0e10cSrcweirsub replace_packagetype_in_pathes 514*cdf0e10cSrcweir{ 515*cdf0e10cSrcweir my ( $patharrayref ) = @_; 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir my $line = ${$patharrayref}[$i]; 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir if (( $installer::globals::installertypedir ) && ( $line =~ /\{pkgtype\}/ )) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir $line =~ s/\{pkgtype\}/$installer::globals::installertypedir/g; 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir ${$patharrayref}[$i] = $line; 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir} 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir#################################################### 531*cdf0e10cSrcweir# Removing ending separators in pathes 532*cdf0e10cSrcweir#################################################### 533*cdf0e10cSrcweir 534*cdf0e10cSrcweirsub remove_ending_separator 535*cdf0e10cSrcweir{ 536*cdf0e10cSrcweir my ( $patharrayref ) = @_; 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir my $line = ${$patharrayref}[$i]; 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir installer::remover::remove_ending_pathseparator(\$line); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir $line =~ s/\s*$//; 545*cdf0e10cSrcweir $line = $line . "\n"; 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir ${$patharrayref}[$i] = $line; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir} 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir#################################################### 552*cdf0e10cSrcweir# Replacing languages in include path 553*cdf0e10cSrcweir#################################################### 554*cdf0e10cSrcweir 555*cdf0e10cSrcweirsub replace_languages_in_pathes 556*cdf0e10cSrcweir{ 557*cdf0e10cSrcweir my ( $patharrayref, $languagesref ) = @_; 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir installer::logger::include_header_into_logfile("Replacing languages in include pathes:"); 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir my @patharray = (); 562*cdf0e10cSrcweir my $infoline = ""; 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir my $line = ${$patharrayref}[$i]; 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir if ( $line =~ /\$\(LANG\)/ ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir my $originalline = $line; 571*cdf0e10cSrcweir my $newline = ""; 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$languagesref}; $j++ ) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir my $language = ${$languagesref}[$j]; 576*cdf0e10cSrcweir $line =~ s/\$\(LANG\)/$language/g; 577*cdf0e10cSrcweir push(@patharray ,$line); 578*cdf0e10cSrcweir $newdir = $line; 579*cdf0e10cSrcweir $line = $originalline; 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$newline); 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir # Is it necessary to refresh the global array, containing all files of all include pathes? 584*cdf0e10cSrcweir if ( -d $newdir ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir # Checking if $newdir is empty 587*cdf0e10cSrcweir if ( ! installer::systemactions::is_empty_dir($newdir) ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir $installer::globals::refresh_includepathes = 1; 590*cdf0e10cSrcweir $infoline = "Directory $newdir exists and is not empty. Refreshing global file array is required.\n"; 591*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir else 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir $infoline = "Directory $newdir is empty. No refresh of global file array required.\n"; 596*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir else 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir $infoline = "Directory $newdir does not exist. No refresh of global file array required.\n"; 602*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir else # not language dependent include path 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir push(@patharray ,$line); 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir return \@patharray; 613*cdf0e10cSrcweir} 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir##################################################### 616*cdf0e10cSrcweir# Collecting all files from all include paths 617*cdf0e10cSrcweir##################################################### 618*cdf0e10cSrcweir 619*cdf0e10cSrcweirsub list_all_files_from_include_path 620*cdf0e10cSrcweir{ 621*cdf0e10cSrcweir my ( $patharrayref) = @_; 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir installer::logger::include_header_into_logfile("Include pathes:"); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir my $path = ${$patharrayref}[$i]; 628*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$path); 629*cdf0e10cSrcweir my $infoline = "$path\n"; 630*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir push( @installer::globals::logfileinfo, "\n"); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir return \@filesarray; 636*cdf0e10cSrcweir} 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir##################################################### 639*cdf0e10cSrcweir# Collecting all files from all include paths 640*cdf0e10cSrcweir##################################################### 641*cdf0e10cSrcweir 642*cdf0e10cSrcweirsub set_manufacturer 643*cdf0e10cSrcweir{ 644*cdf0e10cSrcweir my ($allvariables) = @_; 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir my $openofficeproductname = "OpenOffice.org"; 647*cdf0e10cSrcweir my $sunname = ""; 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir if ( $allvariables->{'OPENSOURCE'} && $allvariables->{'OPENSOURCE'} == 1 ) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir $installer::globals::isopensourceproduct = 1; 653*cdf0e10cSrcweir $installer::globals::manufacturer = $openofficeproductname; 654*cdf0e10cSrcweir $installer::globals::longmanufacturer = $openofficeproductname; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir else 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir $installer::globals::isopensourceproduct = 0; 659*cdf0e10cSrcweir if (( $allvariables->{'DEFINEDMANUFACTURER'} ) && ( $allvariables->{'DEFINEDMANUFACTURER'} ne "" )) { $sunname = $allvariables->{'DEFINEDMANUFACTURER'}; } 660*cdf0e10cSrcweir else { installer::exiter::exit_program("ERROR: Property DEFINEDMANUFACTURER has to be set for this product!", "set_manufacturer"); } 661*cdf0e10cSrcweir $installer::globals::manufacturer = $sunname; 662*cdf0e10cSrcweir $installer::globals::longmanufacturer = $sunname; 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir $allvariables->{'MANUFACTURER'} = $installer::globals::manufacturer; 666*cdf0e10cSrcweir} 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir############################################################## 669*cdf0e10cSrcweir# A ProductVersion has to be defined. If it is not set in 670*cdf0e10cSrcweir# zip.lst, it is set now to "1" 671*cdf0e10cSrcweir############################################################## 672*cdf0e10cSrcweir 673*cdf0e10cSrcweirsub set_default_productversion_if_required 674*cdf0e10cSrcweir{ 675*cdf0e10cSrcweir my ($allvariables) = @_; 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir if (!($allvariables->{'PRODUCTVERSION'})) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir $allvariables->{'PRODUCTVERSION'} = 1; # FAKE 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir # Creating differentiators for BUILD_SPECIAL in layering 683*cdf0e10cSrcweir if ( ! $ENV{'BUILD_SPECIAL'} ) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir if ( $allvariables->{'REGISTRYLAYERNAME'} ) { $allvariables->{'REGISTRYLAYERNAME'} = $allvariables->{'REGISTRYLAYERNAME'} . "_"; } 686*cdf0e10cSrcweir if (( $installer::globals::iswindowsbuild ) && ( $allvariables->{'BASISROOTNAME'} )) { $allvariables->{'BASISROOTNAME'} = $allvariables->{'BASISROOTNAME'} . "_"; } 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir} 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir#################################################### 691*cdf0e10cSrcweir# Removing .. in pathes 692*cdf0e10cSrcweir#################################################### 693*cdf0e10cSrcweir 694*cdf0e10cSrcweirsub simplify_path 695*cdf0e10cSrcweir{ 696*cdf0e10cSrcweir my ( $pathref ) = @_; 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir my $oldpath = $$pathref; 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir my $change = 0; 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir while ( $oldpath =~ /(^.*)(\Q$installer::globals::separator\E.*\w+?)(\Q$installer::globals::separator\E\.\.)(\Q$installer::globals::separator\E.*$)/ ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir my $part1 = $1; 705*cdf0e10cSrcweir my $part2 = $4; 706*cdf0e10cSrcweir $oldpath = $part1 . $part2; 707*cdf0e10cSrcweir $change = 1; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir if ( $change ) { $$pathref = $oldpath . "\n"; } 711*cdf0e10cSrcweir} 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir#################################################### 714*cdf0e10cSrcweir# Removing ending separators in pathes 715*cdf0e10cSrcweir#################################################### 716*cdf0e10cSrcweir 717*cdf0e10cSrcweirsub resolve_relative_pathes 718*cdf0e10cSrcweir{ 719*cdf0e10cSrcweir my ( $patharrayref ) = @_; 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir installer::parameter::make_path_absolute(\${$patharrayref}[$i]); 724*cdf0e10cSrcweir simplify_path(\${$patharrayref}[$i]); 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir} 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir#################################################### 729*cdf0e10cSrcweir# Replacing variables inside zip list variables 730*cdf0e10cSrcweir# Example: {milestone} to be replaced by 731*cdf0e10cSrcweir# $installer::globals::lastminor 732*cdf0e10cSrcweir#################################################### 733*cdf0e10cSrcweir 734*cdf0e10cSrcweirsub replace_variables_in_ziplist_variables 735*cdf0e10cSrcweir{ 736*cdf0e10cSrcweir my ($blockref) = @_; 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir my $milestonevariable = $installer::globals::lastminor; 739*cdf0e10cSrcweir $milestonevariable =~ s/m//; 740*cdf0e10cSrcweir $milestonevariable =~ s/s/\./; 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir my $localminor = $installer::globals::lastminor; 743*cdf0e10cSrcweir if ( $installer::globals::minor ) { $localminor = $installer::globals::minor; } 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir my $buildidstringcws = $installer::globals::build . $localminor . "(Build:" . $installer::globals::buildid . ")"; 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir # the environment variable CWS_WORK_STAMP is set only in CWS 748*cdf0e10cSrcweir if ( $ENV{'CWS_WORK_STAMP'} ) { $buildidstringcws = $buildidstringcws . "\[CWS\:" . $ENV{'CWS_WORK_STAMP'} . "\]"; } 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$blockref}; $i++ ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir if ($installer::globals::lastminor) { ${$blockref}[$i] =~ s/\{milestone\}/$milestonevariable/; } 753*cdf0e10cSrcweir else { ${$blockref}[$i] =~ s/\{milestone\}//; } 754*cdf0e10cSrcweir if ( $localminor ) { ${$blockref}[$i] =~ s/\{minor\}/$localminor/; } 755*cdf0e10cSrcweir else { ${$blockref}[$i] =~ s/\{minor\}//; } 756*cdf0e10cSrcweir if ( $installer::globals::buildid ) { ${$blockref}[$i] =~ s/\{buildid\}/$installer::globals::buildid/; } 757*cdf0e10cSrcweir else { ${$blockref}[$i] =~ s/\{buildid\}//; } 758*cdf0e10cSrcweir if ( $installer::globals::build ) { ${$blockref}[$i] =~ s/\{buildsource\}/$installer::globals::build/; } 759*cdf0e10cSrcweir else { ${$blockref}[$i] =~ s/\{build\}//; } 760*cdf0e10cSrcweir ${$blockref}[$i] =~ s/\{buildidcws\}/$buildidstringcws/; 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir} 763*cdf0e10cSrcweir 764*cdf0e10cSrcweir########################################################### 765*cdf0e10cSrcweir# Overwrite the vendor string in openoffice.lst that is defined in configure 766*cdf0e10cSrcweir########################################################### 767*cdf0e10cSrcweir 768*cdf0e10cSrcweirsub overwrite_ooovendor 769*cdf0e10cSrcweir{ 770*cdf0e10cSrcweir my ($variableshashref) = @_; 771*cdf0e10cSrcweir $variableshashref->{'OOOVENDOR'} = $ENV{'OOO_VENDOR'} , if( defined $ENV{'OOO_VENDOR'} && $ENV{'OOO_VENDOR'} ne "" ); 772*cdf0e10cSrcweir} 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir########################################################### 775*cdf0e10cSrcweir# Adding the lowercase variables into the variableshashref 776*cdf0e10cSrcweir########################################################### 777*cdf0e10cSrcweir 778*cdf0e10cSrcweirsub add_variables_to_allvariableshashref 779*cdf0e10cSrcweir{ 780*cdf0e10cSrcweir my ($variableshashref) = @_; 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir my $lcvariable = lc($variableshashref->{'PRODUCTNAME'}); 783*cdf0e10cSrcweir $variableshashref->{'LCPRODUCTNAME'} = $lcvariable; 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir if ($variableshashref->{'SHORT_PRODUCTEXTENSION'}) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir $variableshashref->{'LCPRODUCTEXTENSION'} = "\-" . lc($variableshashref->{'SHORT_PRODUCTEXTENSION'}); # including the "-" ! 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir else 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir $variableshashref->{'LCPRODUCTEXTENSION'} = ""; 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir if ( $installer::globals::patch ) { $variableshashref->{'PRODUCTADDON'} = $installer::globals::patchaddon; } 795*cdf0e10cSrcweir elsif ( $installer::globals::languagepack ) { $variableshashref->{'PRODUCTADDON'} = $installer::globals::languagepackaddon; } 796*cdf0e10cSrcweir else { $variableshashref->{'PRODUCTADDON'} = ""; } 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir my $localbuild = $installer::globals::build; 799*cdf0e10cSrcweir if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; } # using "680" instead of "src680" 800*cdf0e10cSrcweir $variableshashref->{'PRODUCTMAJOR'} = $localbuild; 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir my $localminor = ""; 803*cdf0e10cSrcweir if ( $installer::globals::minor ne "" ) { $localminor = $installer::globals::minor; } 804*cdf0e10cSrcweir else { $localminor = $installer::globals::lastminor; } 805*cdf0e10cSrcweir if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; } 806*cdf0e10cSrcweir $variableshashref->{'PRODUCTMINOR'} = $localminor; 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir $variableshashref->{'PRODUCTBUILDID'} = $installer::globals::buildid; 809*cdf0e10cSrcweir $variableshashref->{'SYSTEM_LIBTEXTCAT_DATA'} = $ENV{'SYSTEM_LIBTEXTCAT_DATA'} , if( defined $ENV{'SYSTEM_LIBTEXTCAT_DATA'} && $ENV{'SYSTEM_LIBTEXTCAT_DATA'} ne "" ); 810*cdf0e10cSrcweir} 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir1; 813