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

Vendor all Homebrew's gems. #2597

Merged
merged 1 commit into from
May 7, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .bundle/config
@@ -0,0 +1,5 @@
---
BUNDLE_CLEAN: "true"
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_PATH: "Library/Homebrew/vendor"
BUNDLE_JOBS: "3"
29 changes: 20 additions & 9 deletions .gitignore
Expand Up @@ -8,24 +8,35 @@
!/Library/

# Ignore generated files within `Library` (again).
/Library/Homebrew/**/.bundle
/Library/Homebrew/**/vendor/bundle
/Library/Homebrew/doc
/Library/Homebrew/cask/bin
/Library/Homebrew/cask/coverage
/Library/Homebrew/cask/tmp
/Library/Homebrew/test/bin
/Library/Homebrew/test/coverage
/Library/Homebrew/test/fs_leak_log
/Library/Homebrew/tmp
/Library/LinkedKegs
/Library/Locks
/Library/PinnedKegs
/Library/PinnedTaps
/Library/Taps

# Ignore vendored files within `Library`.
# Ignore some vendored files within `Library`.
/Library/Homebrew/vendor/portable-ruby
/Library/Homebrew/vendor/ruby/2.0.0/bin
/Library/Homebrew/vendor/ruby/2.0.0/cache
/Library/Homebrew/vendor/ruby/2.0.0/extensions
/Library/Homebrew/vendor/ruby/2.0.0/gems/*
/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*/*
/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*/*
/Library/Homebrew/vendor/ruby/2.0.0/specifications
/Library/Homebrew/vendor/ruby/2.0.0/tmp

# Unignore our vendored gems
!/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*
!/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*/LICENSE*
!/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*/lib
!/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*
!/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*/LICENSE*
!/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*/lib

# Ignore `bin` contents (again).
/bin
Expand All @@ -50,13 +61,13 @@
!/completions

# Unignore our root-level metadata files.
!/.bundle
!/.gitignore
!/.travis.yml
!/.yardopts
!/CODEOFCONDUCT.md
!/CONTRIBUTING.md
!/Gemfile
!/Gemfile.lock
!/LICENSE.txt
!/README.md

# Unignore tests' bundle config
!/Library/Homebrew/test/.bundle
9 changes: 5 additions & 4 deletions .travis.yml
@@ -1,8 +1,6 @@
language: ruby
cache:
directories:
- $HOME/.gem/ruby
- Library/Homebrew/vendor/bundle
bundler_args: --path Library/Homebrew/vendor --standalone --jobs 3
cache: bundler

matrix:
include:
Expand All @@ -13,6 +11,9 @@ matrix:
rvm: 2.0.0

before_install:
- export GEM_HOME="$PWD/Library/Homebrew/vendor/ruby/2.0.0"
- gem list --installed bundler || gem install bundler
- export PATH="$GEM_HOME/bin:$PATH"
- export HOMEBREW_DEVELOPER=1
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
HOMEBREW_REPOSITORY="$(brew --repo)";
Expand Down
36 changes: 36 additions & 0 deletions Gemfile
@@ -0,0 +1,36 @@
source "https://rubygems.org"

# brew *
gem "ruby-macho"

# brew cask
gem "plist"

# brew cask style
group :cask_style do
gem "rubocop-cask", "~> 0.12.0"
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what you've done here with the groups.


# brew man
group :man do
gem "ronn"
end

# brew style
group :style do
gem "rubocop", "~> 0.47.1"
end

# brew tests
group :tests do
gem "parallel_tests"
gem "rspec"
gem "rspec-its", require: false
gem "rspec-wait", require: false
end

# brew tests --coverage
group :coverage do
gem "codecov", require: false
gem "simplecov", require: false
end
84 changes: 84 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,84 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.3.0)
codecov (0.1.10)
json
simplecov
url
diff-lcs (1.3)
docile (1.1.5)
hpricot (0.8.6)
json (2.1.0)
mustache (1.0.5)
parallel (1.11.1)
parallel_tests (2.14.1)
parallel
parser (2.4.0.0)
ast (~> 2.2)
plist (3.3.0)
powerpack (0.1.1)
public_suffix (2.0.5)
rainbow (2.2.2)
rake
rake (12.0.0)
rdiscount (2.2.0.1)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (0.47.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-cask (0.12.0)
public_suffix (~> 2.0)
rubocop (~> 0.47.1)
ruby-macho (1.1.0)
ruby-progressbar (1.8.1)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
unicode-display_width (1.2.1)
url (0.3.2)

PLATFORMS
ruby

DEPENDENCIES
codecov
parallel_tests
plist
ronn
rspec
rspec-its
rspec-wait
rubocop (~> 0.47.1)
rubocop-cask (~> 0.12.0)
ruby-macho
simplecov

BUNDLED WITH
1.14.6
19 changes: 17 additions & 2 deletions Library/Homebrew/brew.rb
Expand Up @@ -8,9 +8,14 @@
RUBY_TWO = RUBY_VERSION.split(".").first.to_i >= 2
raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO

homebrew_library_path = File.dirname(File.realpath(__FILE__))
$:.unshift(homebrew_library_path)

require_relative "#{homebrew_library_path}/vendor/bundler/setup"

require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
HOMEBREW_LIBRARY_PATH = Pathname.new(homebrew_library_path)

require "global"
require "tap"

Expand All @@ -20,6 +25,8 @@
exit 0
end

HOMEBREW_GEM_HOME = HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}"

def require?(path)
require path
rescue LoadError => e
Expand Down Expand Up @@ -52,6 +59,14 @@ def require?(path)
# Add contributed commands to PATH before checking.
path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd"))

# Add RubyGems.
ENV["GEM_HOME"] = ENV["GEM_PATH"] = HOMEBREW_GEM_HOME
path.append(HOMEBREW_GEM_HOME/"bin")

# Make RubyGems notice environment changes.
Gem.clear_paths
Gem::Specification.reset

# Add SCM wrappers.
path.append(HOMEBREW_SHIMS_PATH/"scm")

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
Expand Up @@ -2,7 +2,7 @@

require "hbc/utils/hash_validator"

require "vendor/plist/plist"
require "plist"

module Hbc
module Artifact
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/lib/hbc/cli/style.rb
Expand Up @@ -26,7 +26,7 @@ def run
def install_rubocop
capture_stderr do
begin
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
Homebrew.run_bundler_if_needed!
rescue SystemExit
raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "")
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/lib/hbc/container/executable.rb
@@ -1,5 +1,5 @@
require "hbc/container/naked"
require "vendor/macho/macho"
require "macho"

module Hbc
class Container
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/lib/hbc/system_command.rb
@@ -1,6 +1,6 @@
require "open3"
require "shellwords"
require "vendor/plist/plist"
require "plist"

require "extend/io"

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/style.rb
Expand Up @@ -65,7 +65,7 @@ def check_style_json(files, options = {})
def check_style_impl(files, output_type, options = {})
fix = options[:fix]

Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION
Homebrew.run_bundler_if_needed!
require "rubocop"
require_relative "../rubocops"

Expand Down
2 changes: 0 additions & 2 deletions Library/Homebrew/config.rb
Expand Up @@ -2,8 +2,6 @@
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
end

require "constants"

# Path to `bin/brew` main executable in HOMEBREW_PREFIX
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])

Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/constants.rb

This file was deleted.

3 changes: 3 additions & 0 deletions Library/Homebrew/dev-cmd/audit.rb
Expand Up @@ -65,6 +65,9 @@ def audit
ENV.activate_extensions!
ENV.setup_build_environment

# Add RubyGems (for RuboCop).
ENV["PATH"] = PATH.new(ENV["PATH"]).append(HOMEBREW_GEM_HOME/"bin")

if ARGV.named.empty?
ff = Formula
files = Tap.map(&:formula_dir)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/man.rb
Expand Up @@ -35,7 +35,7 @@ def man
end

def regenerate_man_pages
Homebrew.install_gem_setup_path! "ronn"
Homebrew.run_bundler_if_needed!

markup = build_man_page
convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md")
Expand Down
20 changes: 10 additions & 10 deletions Library/Homebrew/dev-cmd/tests.rb
Expand Up @@ -49,8 +49,6 @@ def tests
FileUtils.rm_f "test/coverage/.resultset.json"
end

ENV["BUNDLE_GEMFILE"] = "#{HOMEBREW_LIBRARY_PATH}/test/Gemfile"

# Override author/committer as global settings might be invalid and thus
# will cause silent failure during the setup of dummy Git repositories.
%w[AUTHOR COMMITTER].each do |role|
Expand All @@ -59,10 +57,7 @@ def tests
ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
end

Homebrew.install_gem_setup_path! "bundler"
unless quiet_system("bundle", "check")
system "bundle", "install"
end
Homebrew.run_bundler_if_needed!

parallel = true

Expand Down Expand Up @@ -106,10 +101,15 @@ def tests
files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} }
end

if parallel
system "bundle", "exec", "parallel_rspec", *opts, "--", *args, "--", *files
else
system "bundle", "exec", "rspec", *args, "--", *files
files.map! { |p| HOMEBREW_LIBRARY_PATH/p }

(HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}").cd do
if parallel
system "parallel_rspec", *opts, "--", *args, "--", *files
else
system "rspec", *args, "--", *files
end
FileUtils.rm_rf "tmp"
end

return if $?.success?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/os/mac/mach.rb
@@ -1,4 +1,4 @@
require "vendor/macho/macho"
require "macho"
require "os/mac/architecture_list"

module MachOShim
Expand Down
12 changes: 0 additions & 12 deletions Library/Homebrew/test/Gemfile

This file was deleted.