Improved stripping.

master
Luka Vandervelden 2019-09-04 00:53:38 +02:00
parent 33f7ddc263
commit e9bf79964f
1 changed files with 12 additions and 11 deletions

View File

@ -299,21 +299,22 @@ class Package::Recipe
private def do_strip
@context.info "Stripping binaries"
@context.prefixes.each do |prefix|
directory = "#{fake_root_directory}/#{prefix}/lib"
FileUtils.find_files(fake_root_directory) do |path|
file_output = `file #{path}`
strip_opt = nil : String?
unless Dir.exists? directory
next
if file_output.match /ELF.*executable.*not stripped/
strip_opt = "--strip-all"
elsif file_output.match /ELF.*shared object.*not stripped/
strip_opt = "--strip-unneeded"
elsif file_output.match /current ar archive/
strip_opt = "--strip-debug"
end
FileUtils.find_files(directory) do |path|
file_output = `file #{path}`
if strip_opt
@context.detail "stripping #{path}"
if file_output.match /not stripped/
@context.detail "stripping #{path}"
Process.run "strip", [path]
end
Process.run "strip", [strip_opt, path]
end
end
end