| 1 |
# |
| 2 |
# This file is part of the LibreOffice project. |
| 3 |
# |
| 4 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
# |
| 8 |
# This file incorporates work covered by the following license notice: |
| 9 |
# |
| 10 |
# Licensed to the Apache Software Foundation (ASF) under one or more |
| 11 |
# contributor license agreements. See the NOTICE file distributed |
| 12 |
# with this work for additional information regarding copyright |
| 13 |
# ownership. The ASF licenses this file to you under the Apache |
| 14 |
# License, Version 2.0 (the "License"); you may not use this file |
| 15 |
# except in compliance with the License. You may obtain a copy of |
| 16 |
# the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 17 |
# |
| 18 |
|
| 19 |
package installer::windows::createfolder; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use installer::exiter; |
| 25 |
use installer::files; |
| 26 |
use installer::globals; |
| 27 |
use installer::windows::idtglobal; |
| 28 |
|
| 29 |
############################################################## |
| 30 |
# Returning directory for createfolder table. |
| 31 |
############################################################## |
| 32 |
|
| 33 |
sub get_createfolder_directory |
| 34 |
{ |
| 35 |
my ($onedir) = @_; |
| 36 |
|
| 37 |
my $uniquename = $onedir->{'uniquename'}; |
| 38 |
|
| 39 |
return $uniquename; |
| 40 |
} |
| 41 |
|
| 42 |
############################################################## |
| 43 |
# Searching the correct file for language pack directories. |
| 44 |
############################################################## |
| 45 |
|
| 46 |
sub get_languagepack_file |
| 47 |
{ |
| 48 |
my ($filesref, $onedir) = @_; |
| 49 |
|
| 50 |
my $language = $onedir->{'specificlanguage'}; |
| 51 |
my $foundfile = 0; |
| 52 |
my $onefile = ""; |
| 53 |
|
| 54 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 55 |
{ |
| 56 |
$onefile = ${$filesref}[$i]; |
| 57 |
|
| 58 |
if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} ) |
| 59 |
{ |
| 60 |
$foundfile = 1; |
| 61 |
last; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); } |
| 66 |
|
| 67 |
return $onefile; |
| 68 |
} |
| 69 |
|
| 70 |
############################################################## |
| 71 |
# Returning component for createfolder table. |
| 72 |
############################################################## |
| 73 |
|
| 74 |
sub get_createfolder_component |
| 75 |
{ |
| 76 |
my ($onedir, $filesref, $allvariableshashref) = @_; |
| 77 |
|
| 78 |
# Directories do not belong to a module. |
| 79 |
# Therefore they can only belong to the root module and |
| 80 |
# will be added to a component at the root module. |
| 81 |
# All directories will be added to the component |
| 82 |
# $allvariableshashref->{'ROOTMODULEGID'} |
| 83 |
|
| 84 |
if ( ! $allvariableshashref->{'ROOTMODULEGID'} ) { installer::exiter::exit_program("ERROR: ROOTMODULEGID must be defined in list file!", "get_createfolder_component"); } |
| 85 |
|
| 86 |
my $rootmodulegid = $allvariableshashref->{'ROOTMODULEGID'}; |
| 87 |
|
| 88 |
my $onefile; |
| 89 |
if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); } |
| 90 |
elsif ( $installer::globals::helppack ) { ($onefile) = grep {$_->{gid} eq 'gid_File_Help_Common_Zip'} @{$filesref} } |
| 91 |
else { |
| 92 |
foreach my $file (@{$filesref}) { |
| 93 |
if ($file->{'modules'} eq $rootmodulegid) |
| 94 |
{ |
| 95 |
$onefile = $file; |
| 96 |
last; |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if (! defined $onefile) { |
| 102 |
installer::exiter::exit_program("ERROR: Could not find file!", "get_createfolder_component"); |
| 103 |
} |
| 104 |
|
| 105 |
return $onefile->{'componentname'}; |
| 106 |
} |
| 107 |
|
| 108 |
#################################################################################### |
| 109 |
# Creating the file CreateFo.idt dynamically for creation of empty directories |
| 110 |
# Content: |
| 111 |
# Directory_ Component_ |
| 112 |
#################################################################################### |
| 113 |
|
| 114 |
sub create_createfolder_table |
| 115 |
{ |
| 116 |
my ($dirref, $filesref, $basedir, $allvariableshashref) = @_; |
| 117 |
|
| 118 |
my @createfoldertable = (); |
| 119 |
|
| 120 |
my $infoline; |
| 121 |
|
| 122 |
installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder"); |
| 123 |
|
| 124 |
for ( my $i = 0; $i <= $#{$dirref}; $i++ ) |
| 125 |
{ |
| 126 |
my $onedir = ${$dirref}[$i]; |
| 127 |
|
| 128 |
# language packs and help packs get only language dependent directories |
| 129 |
if (( $installer::globals::languagepack ) || ( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next }; |
| 130 |
|
| 131 |
my $styles = ""; |
| 132 |
|
| 133 |
if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } |
| 134 |
|
| 135 |
if ( $styles =~ /\bCREATE\b/ ) |
| 136 |
{ |
| 137 |
my %directory = (); |
| 138 |
|
| 139 |
$directory{'Directory_'} = get_createfolder_directory($onedir); |
| 140 |
$directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref); |
| 141 |
|
| 142 |
my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n"; |
| 143 |
|
| 144 |
push(@createfoldertable, $oneline); |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
# Saving the file |
| 149 |
|
| 150 |
my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt"; |
| 151 |
installer::files::save_file($createfoldertablename ,\@createfoldertable); |
| 152 |
$infoline = "Created idt file: $createfoldertablename\n"; |
| 153 |
push(@installer::globals::logfileinfo, $infoline); |
| 154 |
|
| 155 |
} |
| 156 |
|
| 157 |
1; |