tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / solenv / bin / modules / installer / strip.pm
blob2074973828efea2ed4f58f3074ae175b62bc57db
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;
21 use strict;
22 use warnings;
24 use base 'Exporter';
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 #####################################################################
37 sub _need_to_strip
39 my ( $filename ) = @_;
41 my $strip = 0;
43 # Check using the "file" command
45 $filename =~ s/'/'\\''/g;
46 open (FILE, "file '$filename' |");
47 my $fileoutput = <FILE>;
48 close (FILE);
50 if (( $fileoutput =~ /not stripped/i ) && ( $fileoutput =~ /\bELF\b/ )) { $strip = 1; }
52 return $strip
55 #####################################################################
56 # Checking whether a file has to be stripped
57 #####################################################################
59 sub _do_strip
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);
70 if ($returnvalue)
72 $infoline = "ERROR: Could not strip $filename!\n";
73 push( @installer::globals::logfileinfo, $infoline);
75 else
77 $infoline = "SUCCESS: Stripped library $filename!\n";
78 push( @installer::globals::logfileinfo, $infoline);
82 #####################################################################
83 # Resolving all variables in the packagename
84 #####################################################################
86 sub strip_libraries
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;
129 # strip file
131 _do_strip($destfilename);