Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggressively prune files from the gems we install #672

Merged
merged 2 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions omnibus/config/projects/chef-workstation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
dependency "uninstall-scripts"
dependency "ruby-cleanup"

# further gem cleanup other projects might not yet want to use
dependency "more-ruby-cleanup"

dependency "go"
dependency "main-chef-wrapper"
dependency "chef-analyze"
Expand Down
102 changes: 102 additions & 0 deletions omnibus/config/software/more-ruby-cleanup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#
# Copyright:: 2019 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{
.github
examples
example
docs
doc
doc-api
sample
samples
test
tests
benchmark
benchmarks
rakelib
CHANGELOG.md
CONTRIBUTORS.md
README.md
README.markdown
HISTORY.md
TODO.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
UPGRADING.md
CODE_OF_CONDUCT.md
Code-of-Conduct.md
ARCHITECTURE.md
CHANGES.md
README.YARD.md
GUIDE.md
MIGRATING.md
README.txt
HISTORY.txt
Manifest.txt
Manifest
CHANGES.txt
CHANGELOG.txt
warning.txt
FAQ.txt
release-script.txt
TODO
HISTORY
CHANGES
CHANGELOG
README
Gemfile.travis
Gemfile.lock
Gemfile.devtools
README.rdoc
CHANGELOG.rdoc
History.rdoc
CONTRIBUTING.rdoc
README_INDEX.rdoc
logo.png
donate.png
Appraisals
website
}

Dir.glob(Dir.glob("#{target_dir}/*/{#{files.join(",")}}")).each do |f|
puts "Deleting #{f}"
if File.directory?(f)
# recursively removes files and the dir
FileUtils.remove_dir(f)
else
File.delete(f)
end
end
end
end