diff options
author | Lamont Granquist <lamont@chef.io> | 2020-03-11 16:06:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-11 16:06:28 -0700 |
commit | 3f67665d521a7d42e389680b2c7a7883314bfad4 (patch) | |
tree | 2a68dad3b68539ed9f397503b345dfc1553097dd | |
parent | dfd018cb04a2eae78e5cd8f7569dff4919e3769a (diff) | |
parent | b858fe34ff8109893580d4fd74e70932d4e67545 (diff) | |
download | chef-3f67665d521a7d42e389680b2c7a7883314bfad4.tar.gz |
Merge pull request #9478 from chef/slim_the_install
Bring in the extended Ruby cleanup used in chef-workstation
-rw-r--r-- | omnibus/config/projects/chef.rb | 3 | ||||
-rw-r--r-- | omnibus/config/software/more-ruby-cleanup.rb | 98 |
2 files changed, 101 insertions, 0 deletions
diff --git a/omnibus/config/projects/chef.rb b/omnibus/config/projects/chef.rb index 115dc11490..150dccb60e 100644 --- a/omnibus/config/projects/chef.rb +++ b/omnibus/config/projects/chef.rb @@ -70,6 +70,9 @@ end dependency "ruby-cleanup" +# further gem cleanup other projects might not yet want to use +dependency "more-ruby-cleanup" + package :rpm do signing_passphrase ENV["OMNIBUS_RPM_SIGNING_PASSPHRASE"] compression_level 1 diff --git a/omnibus/config/software/more-ruby-cleanup.rb b/omnibus/config/software/more-ruby-cleanup.rb new file mode 100644 index 0000000000..6cfb526def --- /dev/null +++ b/omnibus/config/software/more-ruby-cleanup.rb @@ -0,0 +1,98 @@ +# +# Copyright:: 2019-2020 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require "fileutils" + +name "more-ruby-cleanup" + +skip_transitive_dependency_licensing true +license :project_license + +source path: "#{project.files_path}/#{name}" + +dependency "ruby" +dependency "rubygems" + +build do + block "Removing additional non-code files from installed gems" do + # find the embedded ruby gems dir and clean it up for globbing + target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr('\\', "/") + files = %w{ + .appveyor.yml + .autotest + .github + .kokoro + Appraisals + autotest/* + bench + benchmark + benchmarks + doc + doc-api + docs + donate.png + ed25519.png + example + examples + ext + frozen_old_spec + Gemfile.devtools + Gemfile.lock + Gemfile.travis + logo.png + man + rakelib + release-script.txt + sample + samples + site + test + tests + travis_build_script.sh + warning.txt + website + yard-template + } + + Dir.glob(Dir.glob("#{target_dir}/*/{#{files.join(",")}}")).each do |f| + # chef stores the powershell dlls in the ext dir + next if File.basename(File.expand_path("..", f)).start_with?("chef-") + + puts "Deleting #{f}" + FileUtils.rm_rf(f) + end + end + + block "Removing Gemspec / Rakefile / Gemfile unless there's a bin dir" do + # find the embedded ruby gems dir and clean it up for globbing + target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr('\\', "/") + files = %w{ + *.gemspec + Gemfile + Rakefile + tasks/*.rake + } + + Dir.glob(Dir.glob("#{target_dir}/*/{#{files.join(",")}}")).each do |f| + # don't delete these files if there's a bin dir in the same dir + unless Dir.exist?(File.join(File.dirname(f), "bin")) + puts "Deleting #{f}" + File.delete(f) + end + end + end +end
\ No newline at end of file |