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
::windows
::strip
;
34 use File
::Temp
qw(tmpnam);
35 use installer
::converter
;
36 use installer
::existence
;
37 use installer
::globals
;
38 use installer
::logger
;
39 use installer
::pathanalyzer
;
40 use installer
::systemactions
;
42 #####################################################################
43 # Checking whether a file has to be stripped
44 #####################################################################
48 my ( $filename ) = @_;
52 # Check using the "nm" command
54 $filename =~ s/\\/\\\\/g;
56 open (FILE
, "nm $filename 2>&1 |");
57 my $nmoutput = <FILE
>;
60 if ( $nmoutput && !( $nmoutput =~ /no symbols/i || $nmoutput =~ /not recognized/i )) { $strip = 1; }
65 #####################################################################
66 # Checking whether a file has to be stripped
67 #####################################################################
71 my ( $filename ) = @_;
73 my $systemcall = "strip" . " " . $filename;
75 my $returnvalue = system($systemcall);
77 my $infoline = "Systemcall: $systemcall\n";
78 push( @installer::globals
::logfileinfo
, $infoline);
82 $infoline = "ERROR: Could not strip $filename!\n";
83 push( @installer::globals
::logfileinfo
, $infoline);
87 $infoline = "SUCCESS: Stripped library $filename!\n";
88 push( @installer::globals
::logfileinfo
, $infoline);
92 #####################################################################
93 # Resolving all variables in the packagename.
94 #####################################################################
98 my ( $filelist, $languagestringref ) = @_;
100 installer
::logger
::include_header_into_logfile
("Stripping files:");
102 my $strippeddirbase = installer
::systemactions
::create_directories
("stripped", $languagestringref);
104 if (! installer
::existence
::exists_in_array
($strippeddirbase, \
@installer::globals
::removedirs
))
106 push(@installer::globals
::removedirs
, $strippeddirbase);
109 my ($tmpfilehandle, $tmpfilename) = tmpnam
();
110 open SOURCEPATHLIST
, ">$tmpfilename" or die "oops...\n";
111 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
113 print SOURCEPATHLIST
"${$filelist}[$i]->{'sourcepath'}\n";
115 close SOURCEPATHLIST
;
116 my @filetypelist = qx{file
-f
"$tmpfilename"};
118 unlink "$tmpfilename" or die "oops\n";
119 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
121 ${$filelist}[$i]->{'is_executable'} = ( $filetypelist[$i] =~ /:.*PE executable/ );
124 if ( $^O
=~ /cygwin/i ) { installer
::worker
::generate_cygwin_pathes
($filelist); }
126 for ( my $i = 0; $i <= $#{$filelist}; $i++ )
128 my $sourcefilename = ${$filelist}[$i]->{'cyg_sourcepath'};
130 if ( ${$filelist}[$i]->{'is_executable'} && need_to_strip
($sourcefilename) )
132 my $shortfilename = $sourcefilename;
133 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$shortfilename);
135 $infoline = "Strip: $shortfilename\n";
136 push( @installer::globals
::logfileinfo
, $infoline);
138 # copy file into directory for stripped libraries
140 my $onelanguage = ${$filelist}[$i]->{'specificlanguage'};
142 # files without language into directory "00"
144 if ($onelanguage eq "") { $onelanguage = "00"; }
146 my $strippeddir = $strippeddirbase . $installer::globals
::separator
. $onelanguage;
147 installer
::systemactions
::create_directory
($strippeddir); # creating language specific subdirectories
149 my $destfilename = $strippeddir . $installer::globals
::separator
. $shortfilename;
150 installer
::systemactions
::copy_one_file
($sourcefilename, $destfilename);
152 # change sourcepath in files collector
154 ${$filelist}[$i]->{'sourcepath'} = $destfilename;
158 do_strip
($destfilename);