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
::strip
;
26 use installer
::globals
;
27 use installer
::logger
;
28 use installer
::pathanalyzer
;
29 use installer
::systemactions
;
31 our @EXPORT_OK = qw(strip_libraries);
33 #####################################################################
34 # Checking whether a file has to be stripped
35 #####################################################################
39 my ( $filename ) = @_;
43 # Check using the "file" command
45 $filename =~ s/'/'\\''/g;
46 open (FILE
, "file '$filename' |");
47 my $fileoutput = <FILE
>;
50 if (( $fileoutput =~ /not stripped/i ) && ( $fileoutput =~ /\bELF\b/ )) { $strip = 1; }
55 #####################################################################
56 # Checking whether a file has to be stripped
57 #####################################################################
61 my ( $filename ) = @_;
63 my $systemcall = "strip" . " " . $filename;
65 my $returnvalue = system($systemcall);
67 my $infoline = "Systemcall: $systemcall\n";
68 push( @installer::globals
::logfileinfo
, $infoline);
72 $infoline = "ERROR: Could not strip $filename!\n";
73 push( @installer::globals
::logfileinfo
, $infoline);
77 $infoline = "SUCCESS: Stripped library $filename!\n";
78 push( @installer::globals
::logfileinfo
, $infoline);
82 #####################################################################
83 # Resolving all variables in the packagename
84 #####################################################################
88 my ( $filelist, $languagestringref ) = @_;
90 installer
::logger
::include_header_into_logfile
("Stripping files:");
92 my $strippeddirbase = installer
::systemactions
::create_directories
("stripped", $languagestringref);
94 if (! grep {$_ eq $strippeddirbase} @installer::globals
::removedirs
)
96 push(@installer::globals
::removedirs
, $strippeddirbase);
99 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
101 my $sourcefilename = ${$filelist}[$i]->{'sourcepath'};
103 if ( _need_to_strip
($sourcefilename) )
105 my $shortfilename = $sourcefilename;
106 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$shortfilename);
108 my $infoline = "Strip: $shortfilename\n";
109 push( @installer::globals
::logfileinfo
, $infoline);
111 # copy file into directory for stripped libraries
113 my $onelanguage = ${$filelist}[$i]->{'specificlanguage'};
115 # files without language into directory "00"
117 if ($onelanguage eq "") { $onelanguage = "00"; }
119 my $strippeddir = $strippeddirbase . $installer::globals
::separator
. $onelanguage;
120 installer
::systemactions
::create_directory
($strippeddir); # creating language specific subdirectories
122 my $destfilename = $strippeddir . $installer::globals
::separator
. $shortfilename;
123 installer
::systemactions
::copy_one_file
($sourcefilename, $destfilename);
125 # change sourcepath in files collector
127 ${$filelist}[$i]->{'sourcepath'} = $destfilename;
131 _do_strip
($destfilename);