Skip to content

Commit ee253e4

Browse files
committed
Vendor all Homebrew's gems.
Homebrew's actually ended up using a fair few gems. While we want to avoid Bundler at runtime (and this PR still does that, in fact uses Bundler even less at runtime than it did before) writing our own version to use at build-time seems redundant.
1 parent 6edf938 commit ee253e4

File tree

43 files changed

+315
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+315
-183
lines changed

.bundle/config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
BUNDLE_CLEAN: "true"
3+
BUNDLE_DISABLE_SHARED_GEMS: "true"
4+
BUNDLE_PATH: "Library/Homebrew/vendor"
5+
BUNDLE_JOBS: "3"

.gitignore

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,35 @@
88
!/Library/
99

1010
# Ignore generated files within `Library` (again).
11-
/Library/Homebrew/**/.bundle
12-
/Library/Homebrew/**/vendor/bundle
1311
/Library/Homebrew/doc
1412
/Library/Homebrew/cask/bin
1513
/Library/Homebrew/cask/coverage
1614
/Library/Homebrew/cask/tmp
17-
/Library/Homebrew/test/bin
18-
/Library/Homebrew/test/coverage
19-
/Library/Homebrew/test/fs_leak_log
2015
/Library/Homebrew/tmp
2116
/Library/LinkedKegs
2217
/Library/Locks
2318
/Library/PinnedKegs
2419
/Library/PinnedTaps
2520
/Library/Taps
2621

27-
# Ignore vendored files within `Library`.
22+
# Ignore some vendored files within `Library`.
2823
/Library/Homebrew/vendor/portable-ruby
24+
/Library/Homebrew/vendor/ruby/2.0.0/bin
25+
/Library/Homebrew/vendor/ruby/2.0.0/cache
26+
/Library/Homebrew/vendor/ruby/2.0.0/extensions
27+
/Library/Homebrew/vendor/ruby/2.0.0/gems/*
28+
/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*/*
29+
/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*/*
30+
/Library/Homebrew/vendor/ruby/2.0.0/specifications
31+
/Library/Homebrew/vendor/ruby/2.0.0/tmp
32+
33+
# Unignore our vendored gems
34+
!/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*
35+
!/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*/LICENSE*
36+
!/Library/Homebrew/vendor/ruby/2.0.0/gems/ruby-macho-*/lib
37+
!/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*
38+
!/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*/LICENSE*
39+
!/Library/Homebrew/vendor/ruby/2.0.0/gems/plist-*/lib
2940

3041
# Ignore `bin` contents (again).
3142
/bin
@@ -50,13 +61,13 @@
5061
!/completions
5162

5263
# Unignore our root-level metadata files.
64+
!/.bundle
5365
!/.gitignore
5466
!/.travis.yml
5567
!/.yardopts
5668
!/CODEOFCONDUCT.md
5769
!/CONTRIBUTING.md
70+
!/Gemfile
71+
!/Gemfile.lock
5872
!/LICENSE.txt
5973
!/README.md
60-
61-
# Unignore tests' bundle config
62-
!/Library/Homebrew/test/.bundle

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: ruby
2-
cache:
3-
directories:
4-
- $HOME/.gem/ruby
5-
- Library/Homebrew/vendor/bundle
2+
bundler_args: --path Library/Homebrew/vendor --standalone --jobs 3
3+
cache: bundler
64

75
matrix:
86
include:
@@ -13,6 +11,9 @@ matrix:
1311
rvm: 2.0.0
1412

1513
before_install:
14+
- export GEM_HOME="$PWD/Library/Homebrew/vendor/ruby/2.0.0"
15+
- gem list --installed bundler || gem install bundler
16+
- export PATH="$GEM_HOME/bin:$PATH"
1617
- export HOMEBREW_DEVELOPER=1
1718
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
1819
HOMEBREW_REPOSITORY="$(brew --repo)";

Gemfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
source "https://rubygems.org"
2+
3+
# brew *
4+
gem "ruby-macho"
5+
6+
# brew cask
7+
gem "plist"
8+
9+
# brew cask style
10+
group :cask_style do
11+
gem "rubocop-cask", "~> 0.12.0"
12+
end
13+
14+
# brew man
15+
group :man do
16+
gem "ronn"
17+
end
18+
19+
# brew style
20+
group :style do
21+
gem "rubocop", "~> 0.47.1"
22+
end
23+
24+
# brew tests
25+
group :tests do
26+
gem "parallel_tests"
27+
gem "rspec"
28+
gem "rspec-its", require: false
29+
gem "rspec-wait", require: false
30+
end
31+
32+
# brew tests --coverage
33+
group :coverage do
34+
gem "codecov", require: false
35+
gem "simplecov", require: false
36+
end

Gemfile.lock

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
ast (2.3.0)
5+
codecov (0.1.10)
6+
json
7+
simplecov
8+
url
9+
diff-lcs (1.3)
10+
docile (1.1.5)
11+
hpricot (0.8.6)
12+
json (2.1.0)
13+
mustache (1.0.5)
14+
parallel (1.11.1)
15+
parallel_tests (2.14.1)
16+
parallel
17+
parser (2.4.0.0)
18+
ast (~> 2.2)
19+
plist (3.3.0)
20+
powerpack (0.1.1)
21+
public_suffix (2.0.5)
22+
rainbow (2.2.2)
23+
rake
24+
rake (12.0.0)
25+
rdiscount (2.2.0.1)
26+
ronn (0.7.3)
27+
hpricot (>= 0.8.2)
28+
mustache (>= 0.7.0)
29+
rdiscount (>= 1.5.8)
30+
rspec (3.6.0)
31+
rspec-core (~> 3.6.0)
32+
rspec-expectations (~> 3.6.0)
33+
rspec-mocks (~> 3.6.0)
34+
rspec-core (3.6.0)
35+
rspec-support (~> 3.6.0)
36+
rspec-expectations (3.6.0)
37+
diff-lcs (>= 1.2.0, < 2.0)
38+
rspec-support (~> 3.6.0)
39+
rspec-its (1.2.0)
40+
rspec-core (>= 3.0.0)
41+
rspec-expectations (>= 3.0.0)
42+
rspec-mocks (3.6.0)
43+
diff-lcs (>= 1.2.0, < 2.0)
44+
rspec-support (~> 3.6.0)
45+
rspec-support (3.6.0)
46+
rspec-wait (0.0.9)
47+
rspec (>= 3, < 4)
48+
rubocop (0.47.1)
49+
parser (>= 2.3.3.1, < 3.0)
50+
powerpack (~> 0.1)
51+
rainbow (>= 1.99.1, < 3.0)
52+
ruby-progressbar (~> 1.7)
53+
unicode-display_width (~> 1.0, >= 1.0.1)
54+
rubocop-cask (0.12.0)
55+
public_suffix (~> 2.0)
56+
rubocop (~> 0.47.1)
57+
ruby-macho (1.1.0)
58+
ruby-progressbar (1.8.1)
59+
simplecov (0.14.1)
60+
docile (~> 1.1.0)
61+
json (>= 1.8, < 3)
62+
simplecov-html (~> 0.10.0)
63+
simplecov-html (0.10.0)
64+
unicode-display_width (1.2.1)
65+
url (0.3.2)
66+
67+
PLATFORMS
68+
ruby
69+
70+
DEPENDENCIES
71+
codecov
72+
parallel_tests
73+
plist
74+
ronn
75+
rspec
76+
rspec-its
77+
rspec-wait
78+
rubocop (~> 0.47.1)
79+
rubocop-cask (~> 0.12.0)
80+
ruby-macho
81+
simplecov
82+
83+
BUNDLED WITH
84+
1.14.6

Library/Homebrew/brew.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
RUBY_TWO = RUBY_VERSION.split(".").first.to_i >= 2
99
raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO
1010

11+
homebrew_library_path = File.dirname(File.realpath(__FILE__))
12+
$:.unshift(homebrew_library_path)
13+
14+
require_relative "#{homebrew_library_path}/vendor/bundler/setup"
15+
1116
require "pathname"
12-
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
13-
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
17+
HOMEBREW_LIBRARY_PATH = Pathname.new(homebrew_library_path)
18+
1419
require "global"
1520
require "tap"
1621

@@ -20,6 +25,8 @@
2025
exit 0
2126
end
2227

28+
HOMEBREW_GEM_HOME = HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}"
29+
2330
def require?(path)
2431
require path
2532
rescue LoadError => e
@@ -52,6 +59,14 @@ def require?(path)
5259
# Add contributed commands to PATH before checking.
5360
path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd"))
5461

62+
# Add RubyGems.
63+
ENV["GEM_HOME"] = ENV["GEM_PATH"] = HOMEBREW_GEM_HOME
64+
path.append(HOMEBREW_GEM_HOME/"bin")
65+
66+
# Make RubyGems notice environment changes.
67+
Gem.clear_paths
68+
Gem::Specification.reset
69+
5570
# Add SCM wrappers.
5671
path.append(HOMEBREW_SHIMS_PATH/"scm")
5772

Library/Homebrew/cask/lib/hbc/artifact/pkg.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "hbc/utils/hash_validator"
44

5-
require "vendor/plist/plist"
5+
require "plist"
66

77
module Hbc
88
module Artifact

Library/Homebrew/cask/lib/hbc/cli/style.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def run
2626
def install_rubocop
2727
capture_stderr do
2828
begin
29-
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
29+
Homebrew.run_bundler_if_needed!
3030
rescue SystemExit
3131
raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "")
3232
end

Library/Homebrew/cask/lib/hbc/container/executable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "hbc/container/naked"
2-
require "vendor/macho/macho"
2+
require "macho"
33

44
module Hbc
55
class Container

Library/Homebrew/cask/lib/hbc/system_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "open3"
22
require "shellwords"
3-
require "vendor/plist/plist"
3+
require "plist"
44

55
require "extend/io"
66

0 commit comments

Comments
 (0)