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 open (FILE
, "file $filename |");
46 my $fileoutput = <FILE
>;
49 if (( $fileoutput =~ /not stripped/i ) && ( $fileoutput =~ /\bELF\b/ )) { $strip = 1; }
54 #####################################################################
55 # Checking whether a file has to be stripped
56 #####################################################################
60 my ( $filename ) = @_;
62 my $systemcall = "strip" . " " . $filename;
64 my $returnvalue = system($systemcall);
66 my $infoline = "Systemcall: $systemcall\n";
67 push( @installer::globals
::logfileinfo
, $infoline);
71 $infoline = "ERROR: Could not strip $filename!\n";
72 push( @installer::globals
::logfileinfo
, $infoline);
76 $infoline = "SUCCESS: Stripped library $filename!\n";
77 push( @installer::globals
::logfileinfo
, $infoline);
81 #####################################################################
82 # Resolving all variables in the packagename.
83 #####################################################################
87 my ( $filelist, $languagestringref ) = @_;
89 installer
::logger
::include_header_into_logfile
("Stripping files:");
91 my $strippeddirbase = installer
::systemactions
::create_directories
("stripped", $languagestringref);
93 if (! grep {$_ eq $strippeddirbase} @installer::globals
::removedirs
)
95 push(@installer::globals
::removedirs
, $strippeddirbase);
98 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
100 my $sourcefilename = ${$filelist}[$i]->{'sourcepath'};
102 if ( _need_to_strip
($sourcefilename) )
104 my $shortfilename = $sourcefilename;
105 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$shortfilename);
107 my $infoline = "Strip: $shortfilename\n";
108 push( @installer::globals
::logfileinfo
, $infoline);
110 # copy file into directory for stripped libraries
112 my $onelanguage = ${$filelist}[$i]->{'specificlanguage'};
114 # files without language into directory "00"
116 if ($onelanguage eq "") { $onelanguage = "00"; }
118 my $strippeddir = $strippeddirbase . $installer::globals
::separator
. $onelanguage;
119 installer
::systemactions
::create_directory
($strippeddir); # creating language specific subdirectories
121 my $destfilename = $strippeddir . $installer::globals
::separator
. $shortfilename;
122 installer
::systemactions
::copy_one_file
($sourcefilename, $destfilename);
124 # change sourcepath in files collector
126 ${$filelist}[$i]->{'sourcepath'} = $destfilename;
130 _do_strip
($destfilename);