xref: /AOO41X/main/solenv/bin/modules/installer/ziplist.pm (revision 6ab8adf679fd7fbfd27ec2bcc31b5bf76b82f506)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24package installer::ziplist;
25
26use installer::existence;
27use installer::exiter;
28use installer::globals;
29use installer::logger;
30use installer::parameter;
31use installer::remover;
32use installer::systemactions;
33use strict;
34
35=head2 read_openoffice_lst_file (#loggingdir)
36    Read the settings and variables from the settings file (typically 'openoffice.lst').
37=cut
38sub read_openoffice_lst_file ($$;$)
39{
40    my ($filename, $product_name, $loggingdir) = @_;
41
42    # Read all lines from the settings file.
43    my $ziplistref = installer::files::read_file($filename);
44
45    # Extract the lines of the settings block for the current product.
46    my ($productblockref, $parent) = installer::ziplist::getproductblock(
47        $ziplistref, $product_name, 1);
48    my ($settingsblockref, undef) = installer::ziplist::getproductblock($productblockref, "Settings", 0);
49    $settingsblockref = installer::ziplist::analyze_settings_block($settingsblockref);
50
51    # Split into settings and variables.
52    my $allsettingsarrayref = installer::ziplist::get_settings_from_ziplist($settingsblockref);
53    my $allvariablesarrayref = installer::ziplist::get_variables_from_ziplist($settingsblockref);
54
55    # global product block from zip.lst
56    my ($globalproductblockref, undef) = installer::ziplist::getproductblock(
57        $ziplistref, $installer::globals::globalblock, 0);
58
59    if ($installer::globals::globallogging && defined $loggingdir)
60    {
61        installer::files::save_file($loggingdir . "productblock.log", $productblockref);
62        installer::files::save_file($loggingdir . "settingsblock.log", $settingsblockref);
63        installer::files::save_file($loggingdir . "allsettings1.log", $allsettingsarrayref);
64        installer::files::save_file($loggingdir . "allvariables1.log", $allvariablesarrayref);
65        installer::files::save_file($loggingdir . "globalproductblock.log", $globalproductblockref);
66    }
67
68    # Integrate parent values.
69    while (defined $parent)
70    {
71        my $parentproductblockref;
72        ($parentproductblockref, $parent) = installer::ziplist::getproductblock($ziplistref, $parent, 1);
73        my ($parentsettingsblockref, undef) = installer::ziplist::getproductblock(
74            $parentproductblockref, "Settings", 0);
75        $parentsettingsblockref = installer::ziplist::analyze_settings_block($parentsettingsblockref);
76        my $allparentsettingsarrayref = installer::ziplist::get_settings_from_ziplist($parentsettingsblockref);
77        my $allparentvariablesarrayref = installer::ziplist::get_variables_from_ziplist($parentsettingsblockref);
78        if (scalar @$allparentsettingsarrayref > 0)
79        {
80            $allsettingsarrayref = installer::converter::combine_arrays_from_references_first_win(
81                $allsettingsarrayref,
82                $allparentsettingsarrayref)
83        }
84        if (scalar @$allparentvariablesarrayref)
85        {
86            $allvariablesarrayref = installer::converter::combine_arrays_from_references_first_win(
87                $allvariablesarrayref,
88                $allparentvariablesarrayref)
89        }
90    }
91
92    # Integrate global values.
93    if (scalar @$globalproductblockref)
94    {
95        # settings block from zip.lst
96        my ($globalsettingsblockref, undef) = installer::ziplist::getproductblock(
97            $globalproductblockref, "Settings", 0);
98
99        # select data from settings block in zip.lst
100        $globalsettingsblockref = installer::ziplist::analyze_settings_block($globalsettingsblockref);
101
102        my $allglobalsettingsarrayref = installer::ziplist::get_settings_from_ziplist($globalsettingsblockref);
103        my $allglobalvariablesarrayref = installer::ziplist::get_variables_from_ziplist($globalsettingsblockref);
104
105        if ($installer::globals::globallogging && defined $loggingdir)
106        {
107            installer::files::save_file($loggingdir . "globalsettingsblock1.log", $globalsettingsblockref);
108            installer::files::save_file($loggingdir . "globalsettingsblock2.log", $globalsettingsblockref);
109            installer::files::save_file($loggingdir . "allglobalsettings1.log", $allglobalsettingsarrayref);
110            installer::files::save_file($loggingdir . "allglobalvariables1.log", $allglobalvariablesarrayref);
111        }
112
113        if (scalar @$allglobalsettingsarrayref > 0)
114        {
115            $allsettingsarrayref = installer::converter::combine_arrays_from_references_first_win(
116                $allsettingsarrayref, $allglobalsettingsarrayref);
117        }
118        if (scalar @$allglobalvariablesarrayref > 0)
119        {
120            $allvariablesarrayref = installer::converter::combine_arrays_from_references_first_win(
121                $allvariablesarrayref, $allglobalvariablesarrayref);
122        }
123    }
124
125    # Remove multiples (and the trailing ##%##).
126    $allsettingsarrayref = installer::ziplist::remove_multiples_from_ziplist($allsettingsarrayref);
127    $allvariablesarrayref = installer::ziplist::remove_multiples_from_ziplist($allvariablesarrayref);
128    installer::ziplist::replace_variables_in_ziplist_variables($allvariablesarrayref);
129
130    # Transform array into hash.
131    my $allvariableshashref = installer::converter::convert_array_to_hash($allvariablesarrayref);
132
133    # Postprocess the variables.
134    installer::ziplist::set_default_productversion_if_required($allvariableshashref);
135    installer::ziplist::add_variables_to_allvariableshashref($allvariableshashref);
136    installer::ziplist::overwrite_ooovendor($allvariableshashref);
137
138    if ($installer::globals::globallogging && defined $loggingdir)
139    {
140        installer::files::save_file($loggingdir . "allsettings2.log" ,$allsettingsarrayref);
141        installer::files::save_file($loggingdir . "allvariables2.log" ,$allvariablesarrayref);
142    }
143
144    # Eventually we should fix this so that we don't have to return the raw arrays, only the resulting hashes.
145    return ($allvariableshashref, $allsettingsarrayref);
146}
147
148
149#################################################
150# Getting data from path file and zip list file
151#################################################
152
153sub getproductblock
154{
155    my ($fileref, $search, $inheritance) = @_;
156
157    my @searchblock = ();
158    my $searchexists = 0;
159    my $record = 0;
160    my $count = 0;
161    my $line;
162    my $inh = $inheritance ? '(?::\s*(\S+)\s*)?' : "";
163    my $parent;
164
165    for ( my $i = 0; $i <= $#{$fileref}; $i++ )
166    {
167        $line = ${$fileref}[$i];
168
169        if ( $line =~ /^\s*\Q$search\E\s*$inh$/i )      # case insensitive
170        {
171            $record = 1;
172            $searchexists = 1;
173            $parent = $1 if $inheritance;
174        }
175
176        if ($record)
177        {
178            push(@searchblock, $line);
179        }
180
181        if ( ($record) && ($line =~ /\{/) )
182        {
183            $count++;
184        }
185
186        if ( ($record) && ($line =~ /\}/) )
187        {
188            $count--;
189        }
190
191        if ( ($record) && ($line =~ /\}/) && ( $count == 0 ) )
192        {
193            $record = 0;
194        }
195    }
196
197    if (( ! $searchexists ) && ( $search ne $installer::globals::globalblock ))
198    {
199        if ($search eq $installer::globals::product )
200        {
201            installer::exiter::exit_program("ERROR: Product $installer::globals::product not defined in $installer::globals::ziplistname", "getproductblock");
202        }
203        elsif ($search eq $installer::globals::compiler )
204        {
205            installer::exiter::exit_program("ERROR: Compiler $installer::globals::compiler not defined in $installer::globals::pathfilename", "getproductblock");
206        }
207        else    # this is not possible
208        {
209            installer::exiter::exit_program("ERROR: Unknown value for $search in getproductblock()", "getproductblock");
210        }
211    }
212
213    return (\@searchblock, $parent);
214}
215
216###############################################
217# Analyzing the settings in the zip list file
218###############################################
219
220sub analyze_settings_block
221{
222    my ($blockref) = @_;
223
224    my @newsettingsblock = ();
225    my $compilerstring = "";
226    my $record = 1;
227    my $counter = 0;
228
229    # Allowed values in settings block:
230    # "Settings", "Variables", "unix" (for destination path and logfile)
231    # Furthermore allowed values are $installer::globals::build (srx645) and $installer::globals::compiler (pro and nonpro (unxsols4.pro))
232
233    # Comment line in settings block begin with "#" or ";"
234
235    if ( $installer::globals::pro )
236    {
237        $compilerstring = $installer::globals::compiler . ".pro";
238    }
239    else
240    {
241        $compilerstring = $installer::globals::compiler;
242    }
243
244    for ( my $i = 0; $i <= $#{$blockref}; $i++ )
245    {
246        my $line = ${$blockref}[$i];
247        my $nextline = "";
248
249        if ( ${$blockref}[$i+1] ) { $nextline = ${$blockref}[$i+1]; }
250
251        # removing comment lines
252
253        if (($line =~ /^\s*\#/) || ($line =~ /^\s*\;/))
254        {
255            next;
256        }
257
258        # complete blocks of unknows strings are not recorded
259
260        if ((!($line =~ /^\s*\Q$compilerstring\E\s*$/i)) &&
261            (!($line =~ /^\s*\Q$installer::globals::build\E\s*$/i)) &&
262            (!($line =~ /^\s*\bSettings\b\s*$/i)) &&
263            (!($line =~ /^\s*\bVariables\b\s*$/i)) &&
264            (!($line =~ /^\s*\bunix\b\s*$/i)) &&
265            ($nextline =~ /^\s*\{\s*$/i))
266        {
267            $record = 0;
268            next;           # continue with next $i
269        }
270
271        if (!( $record ))
272        {
273            if ($line =~ /^\s*\{\s*$/i)
274            {
275                $counter++;
276            }
277
278            if ($line =~ /^\s*\}\s*$/i)
279            {
280                $counter--;
281            }
282
283            if ($counter == 0)
284            {
285                $record = 1;
286                next;   # continue with next $i
287            }
288        }
289
290        if ($record)
291        {
292            push(@newsettingsblock, $line);
293        }
294    }
295
296    return \@newsettingsblock;
297}
298
299########################################
300# Settings in zip list file
301########################################
302
303sub get_settings_from_ziplist
304{
305    my ($blockref) = @_;
306
307    my @allsettings = ();
308    my $isvariables = 0;
309    my $counter = 0;
310    my $variablescounter = 0;
311
312    # Take all settings from the settings block
313    # Do not take the variables from the settings block
314    # If a setting is defined more than once, take the
315    # setting with the largest counter (open brackets)
316
317    for ( my $i = 0; $i <= $#{$blockref}; $i++ )
318    {
319        my $line = ${$blockref}[$i];
320        my $nextline = "";
321
322        if ( ${$blockref}[$i+1] ) { $nextline = ${$blockref}[$i+1]; }
323
324        if (($line =~ /^\s*\S+\s*$/i) &&
325            ($nextline =~ /^\s*\{\s*$/i) &&
326            (!($line =~ /^\s*Variables\s*$/i)))
327        {
328            next;
329        }
330
331        if ($line =~ /^\s*Variables\s*$/i)
332        {
333            # This is a block of variables
334
335            $isvariables = 1;
336            next;
337        }
338
339        if ($line =~ /^\s*\{\s*$/i)
340        {
341            if ($isvariables)
342            {
343                $variablescounter++;
344            }
345            else
346            {
347                $counter++;
348            }
349
350            next;
351        }
352
353        if ($line =~ /^\s*\}\s*$/i)
354        {
355            if ($isvariables)
356            {
357                $variablescounter--;
358
359                if ($variablescounter == 0)
360                {
361                    $isvariables = 0;
362                }
363            }
364            else
365            {
366                $counter--;
367            }
368
369            next;
370        }
371
372        if ($isvariables)
373        {
374            next;
375        }
376
377        installer::remover::remove_leading_and_ending_whitespaces(\$line);
378
379        $line .= "\t##$counter##\n";
380
381        push(@allsettings, $line);
382    }
383
384    return \@allsettings;
385}
386
387#######################################
388# Variables from zip list file
389#######################################
390
391sub get_variables_from_ziplist
392{
393    my ($blockref) = @_;
394
395    my @allvariables = ();
396    my $isvariables = 0;
397    my $counter = 0;
398    my $variablescounter = 0;
399    my $countersum = 0;
400
401    # Take all variables from the settings block
402    # Do not take the other settings from the settings block
403    # If a variable is defined more than once, take the
404    # variable with the largest counter (open brackets)
405
406    for ( my $i = 0; $i <= $#{$blockref}; $i++ )
407    {
408        my $line = ${$blockref}[$i];
409        my $nextline = ${$blockref}[$i+1];
410
411        if ($line =~ /^\s*Variables\s*$/i)
412        {
413            # This is a block of variables
414
415            $isvariables = 1;
416            next;
417        }
418
419        if ($line =~ /^\s*\{\s*$/i)
420        {
421            if ($isvariables)
422            {
423                $variablescounter++;
424            }
425            else
426            {
427                $counter++;
428            }
429
430            next;
431        }
432
433        if ($line =~ /^\s*\}\s*$/i)
434        {
435            if ($isvariables)
436            {
437                $variablescounter--;
438
439                if ($variablescounter == 0)
440                {
441                    $isvariables = 0;
442                }
443            }
444            else
445            {
446                $counter--;
447            }
448
449            next;
450        }
451
452        if (!($isvariables))
453        {
454            next;
455        }
456
457        $countersum = $counter + $variablescounter;
458
459        installer::remover::remove_leading_and_ending_whitespaces(\$line);
460
461        $line .= "\t##$countersum##\n";
462
463        push(@allvariables, $line);
464    }
465
466    return \@allvariables;
467}
468
469#######################################################################
470# Removing multiple variables and settings, defined in zip list file
471#######################################################################
472
473sub remove_multiples_from_ziplist
474{
475    my ($blockref) = @_;
476
477    # remove all definitions of settings and variables
478    # that occur more than once in the zip list file.
479    # Take the one with the most open brackets. This
480    # number is stored at the end of the string.
481
482    my @newarray = ();
483    my @itemarray = ();
484    my ($line, $itemname, $itemnumber);
485
486    # first collecting all variables and settings names
487
488    for ( my $i = 0; $i <= $#{$blockref}; $i++ )
489    {
490        $line = ${$blockref}[$i];
491
492        if ($line =~ /^\s*\b(\S*)\b\s+.*\#\#\d+\#\#\s*$/i)
493        {
494            $itemname = $1;
495        }
496
497        if (! installer::existence::exists_in_array($itemname, \@itemarray))
498        {
499            push(@itemarray, $itemname);
500        }
501    }
502
503    # and now all $items can be selected with the highest number
504
505    for ( my $i = 0; $i <= $#itemarray; $i++ )
506    {
507        $itemname = $itemarray[$i];
508
509        my $itemnumbermax = 0;
510        my $printline = "";
511
512        for ( my $j = 0; $j <= $#{$blockref}; $j++ )
513        {
514            $line = ${$blockref}[$j];
515
516            if ($line =~ /^\s*\Q$itemname\E\s+.*\#\#(\d+)\#\#\s*$/)
517            {
518                $itemnumber = $1;
519
520                if ($itemnumber >= $itemnumbermax)
521                {
522                    $printline = $line;
523                    $itemnumbermax = $itemnumber;
524                }
525            }
526        }
527
528        # removing the ending number from the printline
529        # and putting it into the array
530
531        $printline =~ s/\#\#\d+\#\#//;
532        installer::remover::remove_leading_and_ending_whitespaces(\$line);
533        push(@newarray, $printline);
534    }
535
536    return \@newarray;
537}
538
539#########################################################
540# Reading one variable defined in the zip list file
541#########################################################
542
543sub getinfofromziplist
544{
545    my ($blockref, $variable) = @_;
546
547    my $searchstring = "";
548    my $line;
549
550    for ( my $i = 0; $i <= $#{$blockref}; $i++ )
551    {
552        $line = ${$blockref}[$i];
553
554        if ( $line =~ /^\s*\Q$variable\E\s+(.+?)\s*$/ ) # "?" for minimal matching
555        {
556            $searchstring = $1;
557            last;
558        }
559    }
560
561    return \$searchstring;
562}
563
564####################################################
565# Replacing variables in include path
566####################################################
567
568sub replace_all_variables_in_pathes
569{
570    my ( $patharrayref, $variableshashref ) = @_;
571
572    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
573    {
574        my $line = ${$patharrayref}[$i];
575
576        my $key;
577
578        foreach $key (keys %{$variableshashref})
579        {
580            my $value = $variableshashref->{$key};
581
582            if (( $line =~ /\{$key\}/ ) && ( $value eq "" )) { $line = ".\n"; }
583
584            $line =~ s/\{\Q$key\E\}/$value/g;
585        }
586
587        ${$patharrayref}[$i] = $line;
588    }
589}
590
591####################################################
592# Replacing minor in include path
593####################################################
594
595sub replace_minor_in_pathes
596{
597    my ( $patharrayref ) = @_;
598
599    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
600    {
601        my $line = ${$patharrayref}[$i];
602
603        if ( ! defined $ENV{CWS_WORK_STAMP} and defined $ENV{UPDMINOR} )
604#       if ( $installer::globals::minor )
605        {
606            $line =~ s/\{minor\}/$installer::globals::minor/g;
607            # no difference for minor and minornonpre (ToDo ?)
608            $line =~ s/\{minornonpre\}/$installer::globals::minor/g;
609        }
610        else    # building without a minor
611        {
612            $line =~ s/\.\{minor\}//g;
613            $line =~ s/\.\{minornonpre\}//g;
614        }
615
616        ${$patharrayref}[$i] = $line;
617    }
618}
619
620####################################################
621# Replacing packagetype in include path
622####################################################
623
624sub replace_packagetype_in_pathes
625{
626    my ( $patharrayref ) = @_;
627
628    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
629    {
630        my $line = ${$patharrayref}[$i];
631
632        if (( $installer::globals::installertypedir ) && ( $line =~ /\{pkgtype\}/ ))
633        {
634            $line =~ s/\{pkgtype\}/$installer::globals::installertypedir/g;
635        }
636
637        ${$patharrayref}[$i] = $line;
638    }
639}
640
641####################################################
642# Removing ending separators in pathes
643####################################################
644
645sub remove_ending_separator
646{
647    my ( $patharrayref ) = @_;
648
649    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
650    {
651        my $line = ${$patharrayref}[$i];
652
653        installer::remover::remove_ending_pathseparator(\$line);
654
655        $line =~ s/\s*$//;
656        $line = $line . "\n";
657
658        ${$patharrayref}[$i] = $line;
659    }
660}
661
662####################################################
663# Replacing languages in include path
664####################################################
665
666sub replace_languages_in_pathes
667{
668    my ( $patharrayref, $languagesref ) = @_;
669
670    installer::logger::include_header_into_logfile("Replacing languages in include pathes:");
671
672    my @patharray = ();
673    my $infoline = "";
674
675    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
676    {
677        my $line = ${$patharrayref}[$i];
678
679        if ( $line =~ /\$\(LANG\)/ )
680        {
681            my $originalline = $line;
682            my $newline = "";
683
684            for ( my $j = 0; $j <= $#{$languagesref}; $j++ )
685            {
686                my $language = ${$languagesref}[$j];
687                $line =~ s/\$\(LANG\)/$language/g;
688                push(@patharray ,$line);
689                my $newdir = $line;
690                $line = $originalline;
691
692                installer::remover::remove_leading_and_ending_whitespaces(\$newline);
693
694                # Is it necessary to refresh the global array, containing all files of all include pathes?
695                if ( -d $newdir )
696                {
697                    # Checking if $newdir is empty
698                    if ( ! installer::systemactions::is_empty_dir($newdir) )
699                    {
700                        $installer::globals::refresh_includepathes = 1;
701                        $infoline = "Directory $newdir exists and is not empty. Refreshing global file array is required.\n";
702                        $installer::logger::Lang->print($infoline);
703                    }
704                    else
705                    {
706                        $infoline = "Directory $newdir is empty. No refresh of global file array required.\n";
707                        $installer::logger::Lang->print($infoline);
708                    }
709                }
710                else
711                {
712                    $infoline = "Directory $newdir does not exist. No refresh of global file array required.\n";
713                    $installer::logger::Lang->print($infoline);
714                }
715            }
716        }
717        else        # not language dependent include path
718        {
719            push(@patharray ,$line);
720        }
721    }
722
723    return \@patharray;
724}
725
726#####################################################
727# Collecting all files from all include paths
728#####################################################
729
730sub list_all_files_from_include_path
731{
732    my ( $patharrayref) = @_;
733
734    installer::logger::include_header_into_logfile("Include pathes:");
735
736    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
737    {
738        my $path = ${$patharrayref}[$i];
739        installer::remover::remove_leading_and_ending_whitespaces(\$path);
740        my $infoline = "$path\n";
741        $installer::logger::Lang->print($infoline);
742    }
743
744    $installer::logger::Lang->print("\n");
745}
746
747#####################################################
748# Collecting all files from all include paths
749#####################################################
750
751sub set_manufacturer
752{
753    my ($allvariables) = @_;
754
755    my $openofficeproductname = "OpenOffice";
756    my $sunname = "";
757
758
759    if ( $allvariables->{'OPENSOURCE'} && $allvariables->{'OPENSOURCE'} == 1 )
760    {
761        $installer::globals::isopensourceproduct = 1;
762        $installer::globals::manufacturer = $openofficeproductname;
763        $installer::globals::longmanufacturer = $openofficeproductname;
764    }
765    else
766    {
767        $installer::globals::isopensourceproduct = 0;
768        if (( $allvariables->{'DEFINEDMANUFACTURER'} ) && ( $allvariables->{'DEFINEDMANUFACTURER'} ne "" )) { $sunname = $allvariables->{'DEFINEDMANUFACTURER'}; }
769        else { installer::exiter::exit_program("ERROR: Property DEFINEDMANUFACTURER has to be set for this product!", "set_manufacturer"); }
770        $installer::globals::manufacturer = $sunname;
771        $installer::globals::longmanufacturer = $sunname;
772    }
773
774    $allvariables->{'MANUFACTURER'} = $installer::globals::manufacturer;
775}
776
777##############################################################
778# A ProductVersion has to be defined. If it is not set in
779# zip.lst, it is set now to "1"
780##############################################################
781
782sub set_default_productversion_if_required
783{
784    my ($allvariables) = @_;
785
786    if (!($allvariables->{'PRODUCTVERSION'}))
787    {
788        $allvariables->{'PRODUCTVERSION'} = 1;  # FAKE
789    }
790}
791
792####################################################
793# Removing .. in pathes
794####################################################
795
796sub simplify_path
797{
798    my ( $pathref ) = @_;
799
800    my $oldpath = $$pathref;
801
802    my $change = 0;
803
804    while ( $oldpath =~ /(^.*)(\Q$installer::globals::separator\E.*\w+?)(\Q$installer::globals::separator\E\.\.)(\Q$installer::globals::separator\E.*$)/ )
805    {
806        my $part1 = $1;
807        my $part2 = $4;
808        $oldpath = $part1 . $part2;
809        $change = 1;
810    }
811
812    if ( $change ) { $$pathref = $oldpath . "\n"; }
813}
814
815####################################################
816# Removing ending separators in pathes
817####################################################
818
819sub resolve_relative_pathes
820{
821    my ( $patharrayref ) = @_;
822
823    for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
824    {
825        installer::parameter::make_path_absolute(\${$patharrayref}[$i]);
826        simplify_path(\${$patharrayref}[$i]);
827    }
828}
829
830####################################################
831# Replacing variables inside zip list variables
832# Example: {milestone} to be replaced by
833# $installer::globals::lastminor
834####################################################
835
836sub replace_variables_in_ziplist_variables
837{
838    my ($blockref) = @_;
839
840    my $milestonevariable = $installer::globals::lastminor;
841    $milestonevariable =~ s/m//;
842    $milestonevariable =~ s/s/\./;
843
844    my $localminor = $installer::globals::lastminor;
845    if ( $installer::globals::minor ) { $localminor = $installer::globals::minor; }
846
847    my $buildidstringcws = $installer::globals::build . $localminor . "(Build:" . $installer::globals::buildid . ")";
848
849    # the environment variable CWS_WORK_STAMP is set only in CWS
850    if ( $ENV{'CWS_WORK_STAMP'} ) { $buildidstringcws = $buildidstringcws . "\[CWS\:" . $ENV{'CWS_WORK_STAMP'} . "\]"; }
851
852    for ( my $i = 0; $i <= $#{$blockref}; $i++ )
853    {
854        if ($installer::globals::lastminor) { ${$blockref}[$i] =~ s/\{milestone\}/$milestonevariable/; }
855        else { ${$blockref}[$i] =~ s/\{milestone\}//; }
856        if ( $localminor ) { ${$blockref}[$i] =~ s/\{minor\}/$localminor/; }
857        else { ${$blockref}[$i] =~ s/\{minor\}//; }
858        if ( $installer::globals::buildid ) { ${$blockref}[$i] =~ s/\{buildid\}/$installer::globals::buildid/; }
859        else { ${$blockref}[$i] =~ s/\{buildid\}//; }
860        if ( $installer::globals::build ) { ${$blockref}[$i] =~ s/\{buildsource\}/$installer::globals::build/; }
861        else { ${$blockref}[$i] =~ s/\{build\}//; }
862        ${$blockref}[$i] =~ s/\{buildidcws\}/$buildidstringcws/;
863    }
864}
865
866###########################################################
867# Overwrite the vendor string in openoffice.lst that is defined in configure
868###########################################################
869
870sub overwrite_ooovendor
871{
872    my ($variableshashref) = @_;
873    $variableshashref->{'OOOVENDOR'} = $ENV{'OOO_VENDOR'} , if( defined $ENV{'OOO_VENDOR'}  && $ENV{'OOO_VENDOR'} ne "" );
874}
875
876###########################################################
877# Adding the lowercase variables into the variableshashref
878###########################################################
879
880sub add_variables_to_allvariableshashref
881{
882    my ($variableshashref) = @_;
883
884    my $lcvariable = lc($variableshashref->{'PRODUCTNAME'});
885    $variableshashref->{'LCPRODUCTNAME'} = $lcvariable;
886
887    if ($variableshashref->{'SHORT_PRODUCTEXTENSION'})
888    {
889        $variableshashref->{'LCPRODUCTEXTENSION'} = "\-" . lc($variableshashref->{'SHORT_PRODUCTEXTENSION'}); # including the "-" !
890    }
891    else
892    {
893        $variableshashref->{'LCPRODUCTEXTENSION'} = "";
894    }
895
896    if ($installer::globals::patch)
897    {
898        $variableshashref->{'PRODUCTADDON'} = $installer::globals::patchaddon;
899    }
900    elsif ($installer::globals::languagepack)
901    {
902        $variableshashref->{'PRODUCTADDON'} = $installer::globals::languagepackaddon;
903    }
904    else
905    {
906        $variableshashref->{'PRODUCTADDON'} = "";
907    }
908
909    my $localbuild = $installer::globals::build;
910    if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; }   # using "680" instead of "src680"
911    $variableshashref->{'PRODUCTMAJOR'} = $localbuild;
912
913    my $localminor = "";
914    if ( $installer::globals::minor ne "" ) { $localminor = $installer::globals::minor; }
915    else { $localminor = $installer::globals::lastminor; }
916    if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; }
917    $variableshashref->{'PRODUCTMINOR'} = $localminor;
918
919    $variableshashref->{'PRODUCTBUILDID'} = $installer::globals::buildid;
920    $variableshashref->{'SYSTEM_LIBTEXTCAT_DATA'} = $ENV{'SYSTEM_LIBTEXTCAT_DATA'} , if( defined $ENV{'SYSTEM_LIBTEXTCAT_DATA'} && $ENV{'SYSTEM_LIBTEXTCAT_DATA'} ne "" );
921}
922
9231;
924