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