Automated stripping.

master
Luka Vandervelden 2019-08-31 02:05:33 +02:00
parent f61055b378
commit 834b609da8
1 changed files with 35 additions and 0 deletions

View File

@ -21,6 +21,20 @@ module FileUtils
end
end
end
def self.find_files(directory, &block : Proc(String, Nil))
Dir.each_child directory do |child|
child_path = directory + "/" + child
if File.file? child_path
yield child_path
end
if File.directory? child_path
self.find child_path, &block
end
end
end
end
class Package::Recipe
@ -272,9 +286,30 @@ class Package::Recipe
raise BuildError.new self, "No file was installed in the fake root."
end
do_strip
do_splits
end
private def do_strip
@context.prefixes.each do |prefix|
directory = "#{fake_root_directory}/#{prefix}/lib"
unless Dir.exists? directory
next
end
FileUtils.find_files(directory) do |path|
file_output = `file #{path}`
if file_output.match /not stripped/
puts "STRIPPING #{path}"
Process.run "strip", [path]
end
end
end
end
private def do_splits
(@packages + auto_splits).each do |package|
next if package == @packages[0]