| 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::removefile; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use installer::files; |
| 25 |
use installer::globals; |
| 26 |
use installer::windows::idtglobal; |
| 27 |
|
| 28 |
######################################################################## |
| 29 |
# Returning the FileKey for a folderitem for removefile table. |
| 30 |
######################################################################## |
| 31 |
|
| 32 |
sub get_removefile_filekey |
| 33 |
{ |
| 34 |
my ($folderitem) = @_; |
| 35 |
|
| 36 |
# returning the unique identifier |
| 37 |
|
| 38 |
my $identifier = "remove_" . $folderitem->{'directory'}; |
| 39 |
|
| 40 |
$identifier = lc($identifier); |
| 41 |
|
| 42 |
return $identifier; |
| 43 |
} |
| 44 |
|
| 45 |
######################################################################## |
| 46 |
# Returning the Component for a folderitem for removefile table. |
| 47 |
######################################################################## |
| 48 |
|
| 49 |
sub get_removefile_component |
| 50 |
{ |
| 51 |
my ($folderitem) = @_; |
| 52 |
|
| 53 |
return $folderitem->{'component'}; |
| 54 |
} |
| 55 |
|
| 56 |
######################################################################## |
| 57 |
# Returning the FileName for a folderitem for removefile table. |
| 58 |
######################################################################## |
| 59 |
|
| 60 |
sub get_removefile_filename |
| 61 |
{ |
| 62 |
my ($folderitem) = @_; |
| 63 |
|
| 64 |
# return nothing: The assigned directory will be removed |
| 65 |
|
| 66 |
return ""; |
| 67 |
} |
| 68 |
|
| 69 |
######################################################################## |
| 70 |
# Returning the DirProperty for a folderitem for removefile table. |
| 71 |
######################################################################## |
| 72 |
|
| 73 |
sub get_removefile_dirproperty |
| 74 |
{ |
| 75 |
my ($folderitem) = @_; |
| 76 |
|
| 77 |
return $folderitem->{'directory'}; |
| 78 |
} |
| 79 |
|
| 80 |
######################################################################## |
| 81 |
# Returning the InstallMode for a folderitem for removefile table. |
| 82 |
######################################################################## |
| 83 |
|
| 84 |
sub get_removefile_installmode |
| 85 |
{ |
| 86 |
my ($folderitem) = @_; |
| 87 |
|
| 88 |
# always returning "2": The file is only removed, if the assigned |
| 89 |
# component is removed. Name: msidbRemoveFileInstallModeOnRemove |
| 90 |
|
| 91 |
return 2; |
| 92 |
} |
| 93 |
|
| 94 |
########################################################################################################### |
| 95 |
# Creating the file RemoveFi.idt dynamically |
| 96 |
# Content: |
| 97 |
# FileKey Component_ FileName DirProperty InstallMode |
| 98 |
########################################################################################################### |
| 99 |
|
| 100 |
sub create_removefile_table |
| 101 |
{ |
| 102 |
my ($folderitemsref, $basedir) = @_; |
| 103 |
|
| 104 |
# Only the directories created for the FolderItems have to be deleted |
| 105 |
# with the information in the table RemoveFile |
| 106 |
|
| 107 |
my @directorycollector = (); |
| 108 |
|
| 109 |
for ( my $i = 0; $i <= $#{$folderitemsref}; $i++ ) |
| 110 |
{ |
| 111 |
my $onelink = ${$folderitemsref}[$i]; |
| 112 |
|
| 113 |
if ( $onelink->{'used'} == 0 ) { next; } |
| 114 |
|
| 115 |
next if grep {$_ eq $onelink->{'directory'}} @directorycollector; |
| 116 |
|
| 117 |
push(@directorycollector, $onelink->{'directory'}); |
| 118 |
|
| 119 |
my %removefile = (); |
| 120 |
|
| 121 |
$removefile{'FileKey'} = get_removefile_filekey($onelink); |
| 122 |
$removefile{'Component_'} = get_removefile_component($onelink); |
| 123 |
$removefile{'FileName'} = get_removefile_filename($onelink); |
| 124 |
$removefile{'DirProperty'} = get_removefile_dirproperty($onelink); |
| 125 |
# fdo#44565 do not remove empty Desktop folder |
| 126 |
if ( $removefile{'DirProperty'} eq $installer::globals::desktopfolder ) { next; } |
| 127 |
$removefile{'InstallMode'} = get_removefile_installmode($onelink); |
| 128 |
|
| 129 |
my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t" |
| 130 |
. $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n"; |
| 131 |
|
| 132 |
push(@installer::globals::removefiletable, $oneline); |
| 133 |
} |
| 134 |
|
| 135 |
# Saving the file |
| 136 |
|
| 137 |
my $removefiletablename = $basedir . $installer::globals::separator . "RemoveFi.idt"; |
| 138 |
installer::files::save_file($removefiletablename ,\@installer::globals::removefiletable); |
| 139 |
my $infoline = "Created idt file: $removefiletablename\n"; |
| 140 |
push(@installer::globals::logfileinfo, $infoline); |
| 141 |
|
| 142 |
} |
| 143 |
|
| 144 |
1; |