From 834b609da84021db2ab627a1185a05518bb94167 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sat, 31 Aug 2019 02:05:33 +0200 Subject: [PATCH] Automated stripping. --- src/recipe.cr | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/recipe.cr b/src/recipe.cr index 62eb7a6..b660391 100644 --- a/src/recipe.cr +++ b/src/recipe.cr @@ -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]