1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: strip.pm,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer
::strip
;
34 use installer
::converter
;
35 use installer
::existence
;
36 use installer
::globals
;
37 use installer
::logger
;
38 use installer
::pathanalyzer
;
39 use installer
::systemactions
;
41 #####################################################################
42 # Checking whether a file has to be stripped
43 #####################################################################
47 my ( $filename ) = @_;
51 # Check using the "file" command
53 open (FILE
, "file $filename |");
54 my $fileoutput = <FILE
>;
57 if (( $fileoutput =~ /not stripped/i ) && ( $fileoutput =~ /\bELF\b/ )) { $strip = 1; }
62 #####################################################################
63 # Checking whether a file has to be stripped
64 #####################################################################
68 my ( $filename ) = @_;
70 my $systemcall = "strip" . " " . $filename;
72 my $returnvalue = system($systemcall);
74 my $infoline = "Systemcall: $systemcall\n";
75 push( @installer::globals
::logfileinfo
, $infoline);
79 $infoline = "ERROR: Could not strip $filename!\n";
80 push( @installer::globals
::logfileinfo
, $infoline);
84 $infoline = "SUCCESS: Stripped library $filename!\n";
85 push( @installer::globals
::logfileinfo
, $infoline);
89 #####################################################################
90 # Resolving all variables in the packagename.
91 #####################################################################
95 my ( $filelist, $languagestringref ) = @_;
97 installer
::logger
::include_header_into_logfile
("Stripping files:");
99 my $strippeddirbase = installer
::systemactions
::create_directories
("stripped", $languagestringref);
101 if (! installer
::existence
::exists_in_array
($strippeddirbase, \
@installer::globals
::removedirs
))
103 push(@installer::globals
::removedirs
, $strippeddirbase);
106 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
108 my $sourcefilename = ${$filelist}[$i]->{'sourcepath'};
110 if ( need_to_strip
($sourcefilename) )
112 my $shortfilename = $sourcefilename;
113 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$shortfilename);
115 $infoline = "Strip: $shortfilename\n";
116 push( @installer::globals
::logfileinfo
, $infoline);
118 # copy file into directory for stripped libraries
120 my $onelanguage = ${$filelist}[$i]->{'specificlanguage'};
122 # files without language into directory "00"
124 if ($onelanguage eq "") { $onelanguage = "00"; }
126 my $strippeddir = $strippeddirbase . $installer::globals
::separator
. $onelanguage;
127 installer
::systemactions
::create_directory
($strippeddir); # creating language specific subdirectories
129 my $destfilename = $strippeddir . $installer::globals
::separator
. $shortfilename;
130 installer
::systemactions
::copy_one_file
($sourcefilename, $destfilename);
132 # change sourcepath in files collector
134 ${$filelist}[$i]->{'sourcepath'} = $destfilename;
138 do_strip
($destfilename);