2 # This file is part of the LibreOffice project.
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/.
9 package installer
::filelists
;
17 use installer
::globals
;
18 use installer
::logger
;
19 use installer
::pathanalyzer
;
21 sub resolve_filelist_flag
23 my ($files, $links, $outdir) = @_;
27 foreach my $file (@
{$files})
30 my $use_internal_rights = 0;
31 if ($file->{'Styles'})
33 if ($file->{'Styles'} =~ /\bFILELIST\b/)
37 if ($file->{'Styles'} =~ /\bUSE_INTERNAL_RIGHTS\b/ && !$installer::globals
::iswin
)
39 $use_internal_rights = 1;
45 my $filelist_path = $file->{'sourcepath'};
46 my $filelist = read_filelist
($filelist_path);
49 my $destination = $file->{'destination'};
50 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destination);
52 foreach my $path (@
{$filelist})
56 if ((index $path, $outdir) != 0)
58 installer
::logger
::print_error
("file '$path' is not in '$outdir'");
63 installer
::logger
::print_error
("file '$path' contains 2 consecutive '/' which breaks MSIs");
74 installer
::logger
::print_error
("file '$path' does not exist");
79 my $subpath = substr $path, ((length $outdir) + 1); # drop separator too
83 $newfile{'Name'} = $subpath;
84 $newfile{'sourcepath'} = $path;
85 $newfile{'destination'} = $destination . $subpath;
86 $newfile{'filelistname'} = $file->{'Name'};
87 $newfile{'filelistpath'} = $file->{'sourcepath'};
91 # FIXME: for symlinks destination is mangled later in
92 # get_Destination_Directory_For_Item_From_Directorylist
93 $newfile{'DoNotMessWithSymlinks'} = 1;
94 $newfile{'Target'} = readlink($path);
95 push ( @
{$links}, \
%newfile );
99 if ($use_internal_rights)
101 my $st = stat($path);
102 $newfile{'UnixRights'} = sprintf("%o", $st->mode & 0777);
105 push @newfiles, \
%newfile;
111 installer
::logger
::print_message
("filelist $filelist_path is empty\n");
114 else # not a filelist, just pass the current file over
116 push @newfiles, $file;
122 installer
::exiter
::exit_program
("ERROR: error(s) in resolve_filelist_flag");
125 return (\
@newfiles, $links);
131 my $content = installer
::files
::read_file
($path);
134 # split on space, but only if followed by / (don't split within a filename)
135 my $splitRE = qr!\s+(?=/)!;
136 # filelist on win have C:/cygwin style however - also reading dos-file under
137 # cygwin retains \r\n - so chomp below still leaves \r to strip in the RE
138 $splitRE = qr!\s+(?:$|(?=[A-Z]:/))! if ($installer::globals
::os
eq "WNT");
140 foreach my $line (@
{$content})
143 foreach my $file (split $splitRE, $line)
147 push @filelist, $file;
157 # vim: set expandtab shiftwidth=4 tabstop=4: