summaryrefslogtreecommitdiff
path: root/solenv/bin/modules/installer/windows/strip.pm
diff options
context:
space:
mode:
Diffstat (limited to 'solenv/bin/modules/installer/windows/strip.pm')
-rw-r--r--solenv/bin/modules/installer/windows/strip.pm159
1 files changed, 159 insertions, 0 deletions
diff --git a/solenv/bin/modules/installer/windows/strip.pm b/solenv/bin/modules/installer/windows/strip.pm
new file mode 100644
index 000000000000..79b1046c1e8f
--- /dev/null
+++ b/solenv/bin/modules/installer/windows/strip.pm
@@ -0,0 +1,159 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+package installer::windows::strip;
+
+use File::Temp qw(tmpnam);
+use installer::converter;
+use installer::existence;
+use installer::globals;
+use installer::logger;
+use installer::pathanalyzer;
+use installer::systemactions;
+
+#####################################################################
+# Checking whether a file has to be stripped
+#####################################################################
+
+sub need_to_strip
+{
+ my ( $filename ) = @_;
+
+ my $strip = 0;
+
+ # Check using the "nm" command
+
+ $filename =~ s/\\/\\\\/g;
+
+ open (FILE, "nm $filename 2>&1 |");
+ my $nmoutput = <FILE>;
+ close (FILE);
+
+ if ( $nmoutput && !( $nmoutput =~ /no symbols/i || $nmoutput =~ /not recognized/i )) { $strip = 1; }
+
+ return $strip
+}
+
+#####################################################################
+# Checking whether a file has to be stripped
+#####################################################################
+
+sub do_strip
+{
+ my ( $filename ) = @_;
+
+ my $systemcall = "strip" . " " . $filename;
+
+ my $returnvalue = system($systemcall);
+
+ my $infoline = "Systemcall: $systemcall\n";
+ push( @installer::globals::logfileinfo, $infoline);
+
+ if ($returnvalue)
+ {
+ $infoline = "ERROR: Could not strip $filename!\n";
+ push( @installer::globals::logfileinfo, $infoline);
+ }
+ else
+ {
+ $infoline = "SUCCESS: Stripped library $filename!\n";
+ push( @installer::globals::logfileinfo, $infoline);
+ }
+}
+
+#####################################################################
+# Resolving all variables in the packagename.
+#####################################################################
+
+sub strip_binaries
+{
+ my ( $filelist, $languagestringref ) = @_;
+
+ installer::logger::include_header_into_logfile("Stripping files:");
+
+ my $strippeddirbase = installer::systemactions::create_directories("stripped", $languagestringref);
+
+ if (! installer::existence::exists_in_array($strippeddirbase, \@installer::globals::removedirs))
+ {
+ push(@installer::globals::removedirs, $strippeddirbase);
+ }
+
+ my ($tmpfilehandle, $tmpfilename) = tmpnam();
+ open SOURCEPATHLIST, ">$tmpfilename" or die "oops...\n";
+ for ( my $i = 0; $i <= $#{$filelist}; $i++ )
+ {
+ print SOURCEPATHLIST "${$filelist}[$i]->{'sourcepath'}\n";
+ }
+ close SOURCEPATHLIST;
+ my @filetypelist = qx{file -f "$tmpfilename"};
+ chomp @filetypelist;
+ unlink "$tmpfilename" or die "oops\n";
+ for ( my $i = 0; $i <= $#{$filelist}; $i++ )
+ {
+ ${$filelist}[$i]->{'is_executable'} = ( $filetypelist[$i] =~ /:.*PE executable/ );
+ }
+
+ if ( $^O =~ /cygwin/i ) { installer::worker::generate_cygwin_pathes($filelist); }
+
+ for ( my $i = 0; $i <= $#{$filelist}; $i++ )
+ {
+ my $sourcefilename = ${$filelist}[$i]->{'cyg_sourcepath'};
+
+ if ( ${$filelist}[$i]->{'is_executable'} && need_to_strip($sourcefilename) )
+ {
+ my $shortfilename = $sourcefilename;
+ installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$shortfilename);
+
+ $infoline = "Strip: $shortfilename\n";
+ push( @installer::globals::logfileinfo, $infoline);
+
+ # copy file into directory for stripped libraries
+
+ my $onelanguage = ${$filelist}[$i]->{'specificlanguage'};
+
+ # files without language into directory "00"
+
+ if ($onelanguage eq "") { $onelanguage = "00"; }
+
+ my $strippeddir = $strippeddirbase . $installer::globals::separator . $onelanguage;
+ installer::systemactions::create_directory($strippeddir); # creating language specific subdirectories
+
+ my $destfilename = $strippeddir . $installer::globals::separator . $shortfilename;
+ installer::systemactions::copy_one_file($sourcefilename, $destfilename);
+
+ # change sourcepath in files collector
+
+ ${$filelist}[$i]->{'sourcepath'} = $destfilename;
+
+ # strip file
+
+ do_strip($destfilename);
+ }
+ }
+}
+
+1;