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