xref: /trunk/main/solenv/bin/modules/installer/windows/createfolder.pm (revision ec6d9e159f5d40bf5d1f27b0b525436f7e942929)
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
22cdf0e10cSrcweirpackage installer::windows::createfolder;
23cdf0e10cSrcweir
24cdf0e10cSrcweiruse installer::existence;
25cdf0e10cSrcweiruse installer::exiter;
26cdf0e10cSrcweiruse installer::files;
27cdf0e10cSrcweiruse installer::globals;
28cdf0e10cSrcweiruse installer::windows::idtglobal;
29cdf0e10cSrcweir
30cdf0e10cSrcweir##############################################################
31cdf0e10cSrcweir# Returning directory for createfolder table.
32cdf0e10cSrcweir##############################################################
33cdf0e10cSrcweir
34cdf0e10cSrcweirsub get_createfolder_directory
35cdf0e10cSrcweir{
36cdf0e10cSrcweir    my ($onedir) = @_;
37cdf0e10cSrcweir
38cdf0e10cSrcweir    my $uniquename = $onedir->{'uniquename'};
39cdf0e10cSrcweir
40cdf0e10cSrcweir    return $uniquename;
41cdf0e10cSrcweir}
42cdf0e10cSrcweir
43cdf0e10cSrcweir##############################################################
44cdf0e10cSrcweir# Searching the correct file for language pack directories.
45cdf0e10cSrcweir##############################################################
46cdf0e10cSrcweir
47cdf0e10cSrcweirsub get_languagepack_file
48cdf0e10cSrcweir{
49cdf0e10cSrcweir    my ($filesref, $onedir) = @_;
50cdf0e10cSrcweir
51cdf0e10cSrcweir    my $language = $onedir->{'specificlanguage'};
52cdf0e10cSrcweir    my $foundfile = 0;
53cdf0e10cSrcweir    my $onefile = "";
54cdf0e10cSrcweir
55cdf0e10cSrcweir    for ( my $i = 0; $i <= $#{$filesref}; $i++ )
56cdf0e10cSrcweir    {
57cdf0e10cSrcweir        $onefile = ${$filesref}[$i];
58cdf0e10cSrcweir
59cdf0e10cSrcweir        if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} )
60cdf0e10cSrcweir        {
61cdf0e10cSrcweir            $foundfile = 1;
62cdf0e10cSrcweir            last;
63cdf0e10cSrcweir        }
64cdf0e10cSrcweir    }
65cdf0e10cSrcweir
66cdf0e10cSrcweir    if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); }
67cdf0e10cSrcweir
68cdf0e10cSrcweir    return $onefile;
69cdf0e10cSrcweir}
70cdf0e10cSrcweir
71cdf0e10cSrcweir##############################################################
72cdf0e10cSrcweir# Returning component for createfolder table.
73cdf0e10cSrcweir##############################################################
74cdf0e10cSrcweir
75cdf0e10cSrcweirsub get_createfolder_component
76cdf0e10cSrcweir{
77cdf0e10cSrcweir    my ($onedir, $filesref, $allvariableshashref) = @_;
78cdf0e10cSrcweir
79cdf0e10cSrcweir    # Directories do not belong to a module.
80cdf0e10cSrcweir    # Therefore they can only belong to the root module and
81cdf0e10cSrcweir    # will be added to a component at the root module.
82cdf0e10cSrcweir    # All directories will be added to the component
83cdf0e10cSrcweir    # containing the file $allvariableshashref->{'GLOBALFILEGID'}
84cdf0e10cSrcweir
85cdf0e10cSrcweir    if ( ! $allvariableshashref->{'GLOBALFILEGID'} ) { installer::exiter::exit_program("ERROR: GLOBALFILEGID must be defined in list file!", "get_createfolder_component"); }
86cdf0e10cSrcweir    if (( $installer::globals::patch ) && ( ! $allvariableshashref->{'GLOBALFILEGID'} )) { installer::exiter::exit_program("ERROR: GLOBALPATCHFILEGID must be defined in list file!", "get_createfolder_component"); }
87cdf0e10cSrcweir
88cdf0e10cSrcweir    my $globalfilegid = $allvariableshashref->{'GLOBALFILEGID'};
89cdf0e10cSrcweir    if ( $installer::globals::patch ) { $globalfilegid = $allvariableshashref->{'GLOBALPATCHFILEGID'}; }
90cdf0e10cSrcweir
91cdf0e10cSrcweir    my $onefile = "";
92cdf0e10cSrcweir    if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); }
93cdf0e10cSrcweir    else { $onefile = installer::existence::get_specified_file($filesref, $globalfilegid); }
94cdf0e10cSrcweir
95cdf0e10cSrcweir    return $onefile->{'componentname'};
96cdf0e10cSrcweir}
97cdf0e10cSrcweir
98cdf0e10cSrcweir####################################################################################
99cdf0e10cSrcweir# Creating the file CreateFo.idt dynamically for creation of empty directories
100cdf0e10cSrcweir# Content:
101cdf0e10cSrcweir# Directory_ Component_
102cdf0e10cSrcweir####################################################################################
103cdf0e10cSrcweir
104cdf0e10cSrcweirsub create_createfolder_table
105cdf0e10cSrcweir{
106cdf0e10cSrcweir    my ($dirref, $filesref, $basedir, $allvariableshashref) = @_;
107cdf0e10cSrcweir
108cdf0e10cSrcweir    my @createfoldertable = ();
109cdf0e10cSrcweir
110cdf0e10cSrcweir    my $infoline;
111cdf0e10cSrcweir
112cdf0e10cSrcweir    installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder");
113cdf0e10cSrcweir
114cdf0e10cSrcweir    for ( my $i = 0; $i <= $#{$dirref}; $i++ )
115cdf0e10cSrcweir    {
116cdf0e10cSrcweir        my $onedir = ${$dirref}[$i];
117cdf0e10cSrcweir
118cdf0e10cSrcweir        # language packs get only language dependent directories
119cdf0e10cSrcweir        if (( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next };
120cdf0e10cSrcweir
121cdf0e10cSrcweir        my $styles = "";
122cdf0e10cSrcweir
123cdf0e10cSrcweir        if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
124cdf0e10cSrcweir
125cdf0e10cSrcweir        if ( $styles =~ /\bCREATE\b/ )
126cdf0e10cSrcweir        {
127cdf0e10cSrcweir            my %directory = ();
128cdf0e10cSrcweir
129cdf0e10cSrcweir            $directory{'Directory_'} = get_createfolder_directory($onedir);
130cdf0e10cSrcweir            $directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref);
131cdf0e10cSrcweir
132cdf0e10cSrcweir            my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n";
133cdf0e10cSrcweir
134cdf0e10cSrcweir            push(@createfoldertable, $oneline);
135cdf0e10cSrcweir        }
136cdf0e10cSrcweir    }
137cdf0e10cSrcweir
138cdf0e10cSrcweir    # Saving the file
139cdf0e10cSrcweir
140cdf0e10cSrcweir    my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt";
141cdf0e10cSrcweir    installer::files::save_file($createfoldertablename ,\@createfoldertable);
142*b274bc22SAndre Fischer    $installer::logger::Lang->printf("Created idt file: %s\n", $createfoldertablename);
143cdf0e10cSrcweir}
144cdf0e10cSrcweir
145cdf0e10cSrcweir1;
146