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