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::setupscript; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse installer::existence; 31*cdf0e10cSrcweiruse installer::exiter; 32*cdf0e10cSrcweiruse installer::globals; 33*cdf0e10cSrcweiruse installer::logger; 34*cdf0e10cSrcweiruse installer::remover; 35*cdf0e10cSrcweiruse installer::scriptitems; 36*cdf0e10cSrcweiruse installer::ziplist; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir####################################################### 39*cdf0e10cSrcweir# Set setup script name, if not defined as parameter 40*cdf0e10cSrcweir####################################################### 41*cdf0e10cSrcweir 42*cdf0e10cSrcweirsub set_setupscript_name 43*cdf0e10cSrcweir{ 44*cdf0e10cSrcweir my ( $allsettingsarrayref, $includepatharrayref ) = @_; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir my $scriptnameref = installer::ziplist::getinfofromziplist($allsettingsarrayref, "script"); 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir my $scriptname = $$scriptnameref; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir if ( $scriptname eq "" ) # not defined on command line and not in product list 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Setup script not defined on command line (-l) and not in product list!", "set_setupscript_name"); 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir if ( $installer::globals::compiler =~ /wnt/ ) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir $scriptname .= ".inf"; 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir else 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir $scriptname .= ".ins"; 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir # and now the complete path for the setup script is needed 65*cdf0e10cSrcweir # The log file cannot be used, because this is the language independent section 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir $scriptnameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptname, $includepatharrayref, 1); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir $installer::globals::setupscriptname = $$scriptnameref; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir if ( $installer::globals::setupscriptname eq "" ) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Script $scriptname not found!", "set_setupscript_name"); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir} 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir##################################################################### 78*cdf0e10cSrcweir# Reading script variables from installation object of script file 79*cdf0e10cSrcweir##################################################################### 80*cdf0e10cSrcweir 81*cdf0e10cSrcweirsub get_all_scriptvariables_from_installation_object 82*cdf0e10cSrcweir{ 83*cdf0e10cSrcweir my ($scriptref) = @_; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir my @installobjectvariables; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptref}; $i++ ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir my $line = ${$scriptref}[$i]; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir if ( $line =~ /^\s*Installation\s+\w+\s*$/ ) # should be the first line 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir my $counter = $i+1; 94*cdf0e10cSrcweir my $installline = ${$scriptref}[$counter]; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir while (!($installline =~ /^\s*End\s*$/ )) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir if ( $installline =~ /^\s*(\w+)\s+\=\s*(.*?)\s*\;\s*$/ ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir my $key = $1; 101*cdf0e10cSrcweir my $value = $2; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir # removing leading and ending " in $value 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir if ( $value =~ /^\s*\"(.*)\"\s*$/ ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir $value = $1; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir $key = "\%" . uc($key); # $key is %PRODUCTNAME 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir my $input = $key . " " . $value . "\n"; # $key can only be the first word 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir push(@installobjectvariables ,$input); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir $counter++; 118*cdf0e10cSrcweir $installline = ${$scriptref}[$counter]; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir last; # not interesting after installation object 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir return \@installobjectvariables; 126*cdf0e10cSrcweir} 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir###################################################################### 129*cdf0e10cSrcweir# Including LCPRODUCTNAME into the array 130*cdf0e10cSrcweir###################################################################### 131*cdf0e10cSrcweir 132*cdf0e10cSrcweirsub add_lowercase_productname_setupscriptvariable 133*cdf0e10cSrcweir{ 134*cdf0e10cSrcweir my ( $variablesref ) = @_; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$variablesref}; $j++ ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir my $variableline = ${$variablesref}[$j]; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir my ($key, $value); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if ( $variableline =~ /^\s*\%(\w+?)\s+(.*?)\s*$/ ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir $key = $1; 145*cdf0e10cSrcweir $value = $2; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir if ( $key eq "PRODUCTNAME" ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir my $newline = "\%LCPRODUCTNAME " . lc($value) . "\n"; 150*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 151*cdf0e10cSrcweir my $original = $value; 152*cdf0e10cSrcweir $value =~ s/\s*//g; 153*cdf0e10cSrcweir $newline = "\%ONEWORDPRODUCTNAME " . $value . "\n"; 154*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 155*cdf0e10cSrcweir $newline = "\%LCONEWORDPRODUCTNAME " . lc($value) . "\n"; 156*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 157*cdf0e10cSrcweir $value = $original; 158*cdf0e10cSrcweir $value =~ s/\s*$//g; 159*cdf0e10cSrcweir $value =~ s/^\s*//g; 160*cdf0e10cSrcweir $value =~ s/ /\%20/g; 161*cdf0e10cSrcweir $newline = "\%MASKEDPRODUCTNAME " . $value . "\n"; 162*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 163*cdf0e10cSrcweir $value = $original; 164*cdf0e10cSrcweir $value =~ s/\s/\_/g; 165*cdf0e10cSrcweir # if ( $value =~ /^\s*(.*?)\_(\w)(.*?)\_(\w)(.*)\s*$/ ) { $value = $1 . $2 . $4; } 166*cdf0e10cSrcweir $newline = "\%UNIXPRODUCTNAME " . lc($value) . "\n"; 167*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 168*cdf0e10cSrcweir $newline = "\%SYSTEMINTUNIXPACKAGENAME " . lc($value) . "\n"; 169*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 170*cdf0e10cSrcweir # if ( $value =~ /^\s*(.*?)\_(\w)(.*?)\_(\w)(.*)\s*$/ ) { $value = $1 . $2 . $4; } 171*cdf0e10cSrcweir # if ( $value =~ /^\s*(.*?)\_(\w)(.*?)\_(\w)(.*)\s*$/ ) { $value = $2 . $4; } 172*cdf0e10cSrcweir $newline = "\%UNIXPACKAGENAME " . lc($value) . "\n"; 173*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 174*cdf0e10cSrcweir $value = $original; 175*cdf0e10cSrcweir $value =~ s/\s/\_/g; 176*cdf0e10cSrcweir $value =~ s/\.//g; 177*cdf0e10cSrcweir # if ( $value =~ /^\s*(.*?)\_(\w)(.*?)\_(\w)(.*)\s*$/ ) { $value = $1 . $2 . $4; } 178*cdf0e10cSrcweir $newline = "\%WITHOUTDOTUNIXPRODUCTNAME " . lc($value) . "\n"; 179*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 180*cdf0e10cSrcweir # if ( $value =~ /^\s*(.*?)\_(\w)(.*?)\_(\w)(.*)\s*$/ ) { $value = $1 . $2 . $4; } 181*cdf0e10cSrcweir # if ( $value =~ /^\s*(.*?)\_(\w)(.*?)\_(\w)(.*)\s*$/ ) { $value = $2 . $4; } 182*cdf0e10cSrcweir $newline = "\%WITHOUTDOTUNIXPACKAGENAME " . lc($value) . "\n"; 183*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 184*cdf0e10cSrcweir $newline = "\%SOLARISBRANDPACKAGENAME " . lc($value) . "\n"; 185*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 186*cdf0e10cSrcweir $value = $original; 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir elsif ( $key eq "PRODUCTEXTENSION" ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir my $newline = "\%LCPRODUCTEXTENSION " . lc($value) . "\n"; 191*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir elsif ( $key eq "PRODUCTVERSION" ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir $value =~ s/\.//g; 196*cdf0e10cSrcweir my $newline = "\%WITHOUTDOTPRODUCTVERSION " . $value . "\n"; 197*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir elsif ( $key eq "OOOBASEVERSION" ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir $value =~ s/\.//g; 202*cdf0e10cSrcweir my $newline = "\%WITHOUTDOTOOOBASEVERSION " . $value . "\n"; 203*cdf0e10cSrcweir push(@{$variablesref} ,$newline); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir} 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir###################################################################### 211*cdf0e10cSrcweir# Resolving the new introduced lowercase script variables 212*cdf0e10cSrcweir###################################################################### 213*cdf0e10cSrcweir 214*cdf0e10cSrcweirsub resolve_lowercase_productname_setupscriptvariable 215*cdf0e10cSrcweir{ 216*cdf0e10cSrcweir my ( $variablesref ) = @_; 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir my %variables = (); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir # First step: Collecting variables 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$variablesref}; $j++ ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir my $variableline = ${$variablesref}[$j]; 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir my ($key, $value); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir if ( $variableline =~ /^\s*\%(\w+?)\s+(.*?)\s*$/ ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir $key = $1; 231*cdf0e10cSrcweir $value = $2; 232*cdf0e10cSrcweir $variables{$key} = $value; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir # Second step: Resolving variables 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$variablesref}; $j++ ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir if ( ${$variablesref}[$j] =~ /\$\{(.*?)\}/ ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir my $key = $1; 243*cdf0e10cSrcweir ${$variablesref}[$j] =~ s/\$\{\Q$key\E\}/$variables{$key}/g; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir} 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir###################################################################### 250*cdf0e10cSrcweir# Replacing all setup script variables inside the setup script file 251*cdf0e10cSrcweir###################################################################### 252*cdf0e10cSrcweir 253*cdf0e10cSrcweirsub replace_all_setupscriptvariables_in_script 254*cdf0e10cSrcweir{ 255*cdf0e10cSrcweir my ( $scriptref, $variablesref ) = @_; 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir installer::logger::include_header_into_globallogfile("Replacing variables in setup script (start)"); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir # make hash of variables to be substituted if they appear in the script 260*cdf0e10cSrcweir my %subs; 261*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$variablesref}; $j++ ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir my $variableline = ${$variablesref}[$j]; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if ( $variableline =~ /^\s*(\%\w+?)\s+(.*?)\s*$/ ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir $subs{$1}= $2; 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir # This is far faster than running a regexp for each line 272*cdf0e10cSrcweir my $bigstring = ''; 273*cdf0e10cSrcweir for my $line (@{$scriptref}) { $bigstring = $bigstring . $line; } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir foreach my $key ( keys %subs ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir # Attention: It must be possible to substitute "%PRODUCTNAMEn", "%PRODUCTNAME%PRODUCTVERSIONabc" 278*cdf0e10cSrcweir my $value = $subs{$key}; 279*cdf0e10cSrcweir $bigstring =~ s/$key/$value/g; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir my @newlines = split /\n/, $bigstring; 283*cdf0e10cSrcweir $scriptref = \@newlines; 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir # now check for any mis-named '%' variables that we have left 286*cdf0e10cSrcweir my $num = 0; 287*cdf0e10cSrcweir for my $check (@newlines) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir $num++; 290*cdf0e10cSrcweir if ( $check =~ /^.*\%\w+.*$/ ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir if (( $check =~ /%1/ ) || ( $check =~ /%2/ ) || ( $check =~ /%verify/ )) { next; } 293*cdf0e10cSrcweir my $infoline = "WARNING: mis-named or un-known '%' variable in setup script at line $num:\n$check\n"; 294*cdf0e10cSrcweir push( @installer::globals::globallogfileinfo, $infoline); 295*cdf0e10cSrcweir # print STDERR "Warning: mis-named or un-known '%' variable at line $num:\n$check\n"; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir installer::logger::include_header_into_globallogfile("Replacing variables in setup script (end)"); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir return $scriptref; 302*cdf0e10cSrcweir} 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir####################################################################### 305*cdf0e10cSrcweir# Collecting all items of the type "searchitem" from the setup script 306*cdf0e10cSrcweir####################################################################### 307*cdf0e10cSrcweir 308*cdf0e10cSrcweirsub get_all_items_from_script 309*cdf0e10cSrcweir{ 310*cdf0e10cSrcweir my ($scriptref, $searchitem) = @_; 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir my @allitemarray = (); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir my ($itemkey, $itemvalue, $valuecounter); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptref}; $i++ ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir my $line = ${$scriptref}[$i]; 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir if ( $line =~ /^\s*\Q$searchitem\E\s+(\S+)\s*$/ ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir my $gid = $1; 323*cdf0e10cSrcweir my $counter = $i + 1; 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir my %oneitemhash = (); 326*cdf0e10cSrcweir my $ismultilang = 0; 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir $oneitemhash{'gid'} = $gid; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir while (!( $line =~ /^\s*End\s*$/ )) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir if ( $counter > $#{$scriptref} ) { 333*cdf0e10cSrcweir installer::exiter::exit_program("Invalid setup script file. End of file reached before 'End' line of '$searchitem' section.", "get_all_items_from_script"); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir $line = ${$scriptref}[$counter]; 336*cdf0e10cSrcweir $counter++; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if ( $line =~ /^\s*(.+?)\s*\=\s*(.+?)\s*\;\s*$/ ) # only oneliner! 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir $itemkey = $1; 341*cdf0e10cSrcweir $itemvalue = $2; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_quotationmarks(\$itemvalue); 344*cdf0e10cSrcweir $itemvalue =~ s/\s*$//; # removing ending whitespaces. Could be introduced by empty variables. 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir $oneitemhash{$itemkey} = $itemvalue; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if ( $itemkey =~ /^\s*\S+\s+\(\S+\)\s*$/ ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir $ismultilang = 1; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir else 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir if ( $searchitem eq "Module" ) # more than one line, for instance files at modules! 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir if (( $line =~ /^\s*(.+?)\s*\=\s*\(/ ) && (!($line =~ /\)\;\s*$ / ))) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir if ( $line =~ /^\s*(.+?)\s*\=\s*(.+)/ ) # the first line 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir $itemkey = $1; 362*cdf0e10cSrcweir $itemvalue = $2; 363*cdf0e10cSrcweir $itemvalue =~ s/\s*$//; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir # collecting the complete itemvalue 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir $valuecounter = $counter; 369*cdf0e10cSrcweir $line = ${$scriptref}[$valuecounter]; 370*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$line); 371*cdf0e10cSrcweir $itemvalue = $itemvalue . $line; 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir while (!( $line =~ /\)\;\s*$/ )) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir $valuecounter++; 376*cdf0e10cSrcweir $line = ${$scriptref}[$valuecounter]; 377*cdf0e10cSrcweir installer::remover::remove_leading_and_ending_whitespaces(\$line); 378*cdf0e10cSrcweir $itemvalue = $itemvalue . $line; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir # removing ending ";" 382*cdf0e10cSrcweir $itemvalue =~ s/\;\s*$//; 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir $oneitemhash{$itemkey} = $itemvalue; 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir if ( $itemkey =~ /^\s*\S+\s+\(\S+\)\s*$/ ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir $ismultilang = 1; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir $oneitemhash{'ismultilingual'} = $ismultilang; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir push(@allitemarray, \%oneitemhash); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir return \@allitemarray; 402*cdf0e10cSrcweir} 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir###################################################################### 405*cdf0e10cSrcweir# Collecting all folder at folderitems, that are predefined values 406*cdf0e10cSrcweir# For example: PREDEFINED_AUTOSTART 407*cdf0e10cSrcweir###################################################################### 408*cdf0e10cSrcweir 409*cdf0e10cSrcweirsub add_predefined_folder 410*cdf0e10cSrcweir{ 411*cdf0e10cSrcweir my ( $folderitemref, $folderref ) = @_; 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$folderitemref}; $i++ ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir my $folderitem = ${$folderitemref}[$i]; 416*cdf0e10cSrcweir my $folderid = $folderitem->{'FolderID'}; 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir if ( $folderid =~ /PREDEFINED_/ ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir if (! installer::existence::exists_in_array_of_hashes("gid", $folderid, $folderref)) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir my %folder = (); 423*cdf0e10cSrcweir $folder{'ismultilingual'} = "0"; 424*cdf0e10cSrcweir $folder{'Name'} = ""; 425*cdf0e10cSrcweir $folder{'gid'} = $folderid; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir push(@{$folderref}, \%folder); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir} 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir##################################################################################### 434*cdf0e10cSrcweir# If folderitems are non-advertised, the component needs to have a registry key 435*cdf0e10cSrcweir# below HKCU as key path. Therefore it is required, to mark the file belonging 436*cdf0e10cSrcweir# to a non-advertised shortcut, that a special userreg_xxx registry key can be 437*cdf0e10cSrcweir# created during packing process. 438*cdf0e10cSrcweir##################################################################################### 439*cdf0e10cSrcweir 440*cdf0e10cSrcweirsub prepare_non_advertised_files 441*cdf0e10cSrcweir{ 442*cdf0e10cSrcweir my ( $folderitemref, $filesref ) = @_; 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$folderitemref}; $i++ ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir my $folderitem = ${$folderitemref}[$i]; 447*cdf0e10cSrcweir my $styles = ""; 448*cdf0e10cSrcweir if ( $folderitem->{'Styles'} ) { $styles = $folderitem->{'Styles'}; } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir if ( $styles =~ /\bNON_ADVERTISED\b/ ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir my $fileid = $folderitem->{'FileID'}; 453*cdf0e10cSrcweir if ( $folderitem->{'ComponentIDFile'} ) { $fileid = $folderitem->{'ComponentIDFile'}; } 454*cdf0e10cSrcweir my $onefile = installer::worker::find_file_by_id($filesref, $fileid); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir # Attention: If $onefile with "FileID" is not found, this is not always an error. 457*cdf0e10cSrcweir # FileID can also contain an executable file, for example msiexec.exe. 458*cdf0e10cSrcweir if ( $onefile ne "" ) { $onefile->{'needs_user_registry_key'} = 1; } 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir} 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir##################################################################################### 464*cdf0e10cSrcweir# Adding all variables defined in the installation object into the hash 465*cdf0e10cSrcweir# of all variables from the zip list file. 466*cdf0e10cSrcweir# This is needed if variables are defined in the installation object, 467*cdf0e10cSrcweir# but not in the zip list file. 468*cdf0e10cSrcweir# If there is a definition in the zip list file and in the installation 469*cdf0e10cSrcweir# object, the installation object is more important 470*cdf0e10cSrcweir##################################################################################### 471*cdf0e10cSrcweir 472*cdf0e10cSrcweirsub add_installationobject_to_variables 473*cdf0e10cSrcweir{ 474*cdf0e10cSrcweir my ($allvariables, $allscriptvariablesref) = @_; 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allscriptvariablesref}; $i++ ) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir my $line = ${$allscriptvariablesref}[$i]; 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir if ( $line =~ /^\s*\%(\w+)\s+(.*?)\s*$/ ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir my $key = $1; 483*cdf0e10cSrcweir my $value = $2; 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir $allvariables->{$key} = $value; # overwrite existing values from zip.lst 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir} 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir##################################################################################### 491*cdf0e10cSrcweir# Adding all variables, that must be defined, but are not defined until now. 492*cdf0e10cSrcweir# List of this varibles: @installer::globals::forced_properties 493*cdf0e10cSrcweir##################################################################################### 494*cdf0e10cSrcweir 495*cdf0e10cSrcweirsub add_forced_properties 496*cdf0e10cSrcweir{ 497*cdf0e10cSrcweir my ($allvariables) = @_; 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir my $property; 500*cdf0e10cSrcweir foreach $property ( @installer::globals::forced_properties ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir if ( ! exists($allvariables->{$property}) ) { $allvariables->{$property} = ""; } 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir} 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir##################################################################################### 507*cdf0e10cSrcweir# Some properties are created automatically. It should be possible to 508*cdf0e10cSrcweir# overwrite them, with PRESET properties. For example UNIXPRODUCTNAME 509*cdf0e10cSrcweir# with PRESETUNIXPRODUCTNAME, if this is defined and the automatic process 510*cdf0e10cSrcweir# does not deliver the desired results. 511*cdf0e10cSrcweir##################################################################################### 512*cdf0e10cSrcweir 513*cdf0e10cSrcweirsub replace_preset_properties 514*cdf0e10cSrcweir{ 515*cdf0e10cSrcweir my ($allvariables) = @_; 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir # SOLARISBRANDPACKAGENAME 518*cdf0e10cSrcweir # needs to be replaced by 519*cdf0e10cSrcweir # PRESETSOLARISBRANDPACKAGENAME 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir my @presetproperties = (); 522*cdf0e10cSrcweir push(@presetproperties, "SOLARISBRANDPACKAGENAME"); 523*cdf0e10cSrcweir push(@presetproperties, "SYSTEMINTUNIXPACKAGENAME"); 524*cdf0e10cSrcweir # push(@presetproperties, "UNIXPACKAGENAME"); 525*cdf0e10cSrcweir # push(@presetproperties, "WITHOUTDOTUNIXPACKAGENAME"); 526*cdf0e10cSrcweir # push(@presetproperties, "UNIXPRODUCTNAME"); 527*cdf0e10cSrcweir # push(@presetproperties, "WITHOUTDOTUNIXPRODUCTNAME"); 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir foreach $property ( @presetproperties ) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir my $presetproperty = "PRESET" . $property; 533*cdf0e10cSrcweir if (( exists($allvariables->{$presetproperty}) ) && ( $allvariables->{$presetproperty} ne "" )) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir $allvariables->{$property} = $allvariables->{$presetproperty}; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir} 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir1; 541