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/.
8 # This file incorporates work covered by the following license notice:
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 .
19 package installer
::windows
::strip
;
21 use File
::Temp
qw(tmpnam);
22 use installer
::converter
;
23 use installer
::globals
;
24 use installer
::logger
;
25 use installer
::pathanalyzer
;
26 use installer
::systemactions
;
28 #####################################################################
29 # Checking whether a file has to be stripped
30 #####################################################################
34 my ( $filename ) = @_;
38 # Check using the "nm" command
40 $filename =~ s/\\/\\\\/g;
42 open (FILE
, "nm $filename 2>&1 |");
43 my $nmoutput = <FILE
>;
46 if ( $nmoutput && !( $nmoutput =~ /no symbols/i || $nmoutput =~ /not recognized/i )) { $strip = 1; }
51 #####################################################################
52 # Checking whether a file has to be stripped
53 #####################################################################
57 my ( $filename ) = @_;
59 my $systemcall = "strip" . " " . $filename;
61 my $returnvalue = system($systemcall);
63 my $infoline = "Systemcall: $systemcall\n";
64 push( @installer::globals
::logfileinfo
, $infoline);
68 $infoline = "ERROR: Could not strip $filename!\n";
69 push( @installer::globals
::logfileinfo
, $infoline);
73 $infoline = "SUCCESS: Stripped library $filename!\n";
74 push( @installer::globals
::logfileinfo
, $infoline);
78 #####################################################################
79 # Resolving all variables in the packagename.
80 #####################################################################
84 my ( $filelist, $languagestringref ) = @_;
86 installer
::logger
::include_header_into_logfile
("Stripping files:");
88 my $strippeddirbase = installer
::systemactions
::create_directories
("stripped", $languagestringref);
90 if (! grep {$_ eq $strippeddirbase} @installer::globals
::removedirs
)
92 push(@installer::globals
::removedirs
, $strippeddirbase);
95 my ($tmpfilehandle, $tmpfilename) = tmpnam
();
96 open SOURCEPATHLIST
, ">$tmpfilename" or die "oops...\n";
97 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
99 print SOURCEPATHLIST
"${$filelist}[$i]->{'sourcepath'}\n";
101 close SOURCEPATHLIST
;
102 my @filetypelist = qx{file
-f
"$tmpfilename"};
104 unlink "$tmpfilename" or die "oops\n";
105 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
107 ${$filelist}[$i]->{'is_executable'} = ( $filetypelist[$i] =~ /:.*PE executable/ );
110 if ( $^O
=~ /cygwin/i ) { installer
::worker
::generate_cygwin_paths
($filelist); }
112 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
114 my $sourcefilename = ${$filelist}[$i]->{'cyg_sourcepath'};
116 if ( ${$filelist}[$i]->{'is_executable'} && need_to_strip
($sourcefilename) )
118 my $shortfilename = $sourcefilename;
119 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$shortfilename);
121 $infoline = "Strip: $shortfilename\n";
122 push( @installer::globals
::logfileinfo
, $infoline);
124 # copy file into directory for stripped libraries
126 my $onelanguage = ${$filelist}[$i]->{'specificlanguage'};
128 # files without language into directory "00"
130 if ($onelanguage eq "") { $onelanguage = "00"; }
132 my $strippeddir = $strippeddirbase . $installer::globals
::separator
. $onelanguage;
133 installer
::systemactions
::create_directory
($strippeddir); # creating language specific subdirectories
135 my $destfilename = $strippeddir . $installer::globals
::separator
. $shortfilename;
136 installer
::systemactions
::copy_one_file
($sourcefilename, $destfilename);
138 # change sourcepath in files collector
140 ${$filelist}[$i]->{'sourcepath'} = $destfilename;
144 do_strip
($destfilename);