From d7eca0b57ca016c006110b6a644f683ebc91f3ed Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 13 Sep 2018 15:24:18 +0100 Subject: [PATCH] Use Bundler to manage vendor directory Rather than having to manually keep track of what version each thing in here is and copy files around by hand on update let's use Bundler's standalone mode and careful use of `.gitignore` to help us do it. This means a `bundle update --standalone` will allow us to update all gems in vendor. We could consider vendoring other gems this way in future but I'd suggest only doing this for gems with no dependencies or at least gems with no native extensions. The only gem this applies to that we currently use is `ruby-prof` and I'm not convinced it's widely used enough to warrant vendoring for everyone. Perhaps that's another criteria: it should be functionality that's used by non-developer commands and/or normal Homebrew usage. --- .gitignore | 9 +++++++++ Library/Homebrew/cask/artifact/pkg.rb | 2 +- Library/Homebrew/extend/string.rb | 2 +- Library/Homebrew/load_path.rb | 2 ++ Library/Homebrew/os/mac/mach.rb | 2 +- Library/Homebrew/system_command.rb | 2 +- Library/Homebrew/vendor/.bundle/config | 4 ++++ Library/Homebrew/vendor/Gemfile | 5 +++++ Library/Homebrew/vendor/Gemfile.lock | 17 +++++++++++++++++ .../vendor/bundle-standalone/bundler/setup.rb | 9 +++++++++ .../lib/backports/2.4.0/string/match.rb} | 1 - .../ruby/2.3.0/gems/plist-3.3.0/lib}/plist.rb | 6 +++--- .../gems/plist-3.3.0/lib}/plist/generator.rb | 0 .../2.3.0/gems/plist-3.3.0/lib}/plist/parser.rb | 0 .../gems/plist-3.3.0/lib}/plist/version.rb | 0 .../2.3.0/gems/ruby-macho-2.0.0/lib}/macho.rb | 0 .../ruby-macho-2.0.0/lib}/macho/exceptions.rb | 0 .../ruby-macho-2.0.0/lib}/macho/fat_file.rb | 0 .../gems/ruby-macho-2.0.0/lib}/macho/headers.rb | 0 .../lib}/macho/load_commands.rb | 0 .../ruby-macho-2.0.0/lib}/macho/macho_file.rb | 0 .../ruby-macho-2.0.0/lib}/macho/sections.rb | 0 .../ruby-macho-2.0.0/lib}/macho/structure.rb | 0 .../gems/ruby-macho-2.0.0/lib}/macho/tools.rb | 0 .../gems/ruby-macho-2.0.0/lib}/macho/utils.rb | 0 .../gems/ruby-macho-2.0.0/lib}/macho/view.rb | 0 26 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 Library/Homebrew/vendor/.bundle/config create mode 100644 Library/Homebrew/vendor/Gemfile create mode 100644 Library/Homebrew/vendor/Gemfile.lock create mode 100644 Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb rename Library/Homebrew/vendor/{backports/string.rb => bundle-standalone/ruby/2.3.0/gems/backports-3.8.0/lib/backports/2.4.0/string/match.rb} (66%) rename Library/Homebrew/vendor/{plist => bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib}/plist.rb (74%) mode change 100755 => 100644 rename Library/Homebrew/vendor/{plist => bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib}/plist/generator.rb (100%) mode change 100755 => 100644 rename Library/Homebrew/vendor/{plist => bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib}/plist/parser.rb (100%) rename Library/Homebrew/vendor/{plist => bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib}/plist/version.rb (100%) mode change 100755 => 100644 rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/exceptions.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/fat_file.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/headers.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/load_commands.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/macho_file.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/sections.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/structure.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/tools.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/utils.rb (100%) rename Library/Homebrew/vendor/{macho => bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib}/macho/view.rb (100%) diff --git a/.gitignore b/.gitignore index 96ec003b86..df5ca018c1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,15 @@ **/.bundle/cache **/vendor/bundle **/vendor/ruby +**/vendor/bundle-standalone/ruby/*/cache +**/vendor/bundle-standalone/ruby/*/gems/*/* +**/vendor/bundle-standalone/ruby/*/specifications + +# Unignore vendored gems +!**/vendor/bundle-standalone/ruby/*/gems/*/lib + +# Ignore backports gem (we don't need all files) +**/vendor/bundle-standalone/ruby/*/gems/backports-*/lib # Ignore `bin` contents (again). /bin diff --git a/Library/Homebrew/cask/artifact/pkg.rb b/Library/Homebrew/cask/artifact/pkg.rb index 45e3bba128..bade72ab9f 100644 --- a/Library/Homebrew/cask/artifact/pkg.rb +++ b/Library/Homebrew/cask/artifact/pkg.rb @@ -1,4 +1,4 @@ -require "vendor/plist/plist" +require "plist" require "cask/artifact/abstract_artifact" diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb index c94bfc8345..54c1663307 100644 --- a/Library/Homebrew/extend/string.rb +++ b/Library/Homebrew/extend/string.rb @@ -1,5 +1,5 @@ # Contains backports from newer versions of Ruby -require_relative "../vendor/backports/string" +require "backports/2.4.0/string/match" class String # String.chomp, but if result is empty: returns nil instead. diff --git a/Library/Homebrew/load_path.rb b/Library/Homebrew/load_path.rb index bab8941a97..678263d322 100644 --- a/Library/Homebrew/load_path.rb +++ b/Library/Homebrew/load_path.rb @@ -5,3 +5,5 @@ HOMEBREW_LIBRARY_PATH = Pathname(__dir__).realpath unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.to_s) end + +require "vendor/bundle-standalone/bundler/setup" diff --git a/Library/Homebrew/os/mac/mach.rb b/Library/Homebrew/os/mac/mach.rb index 7ec65439db..0ab7a0d3a7 100644 --- a/Library/Homebrew/os/mac/mach.rb +++ b/Library/Homebrew/os/mac/mach.rb @@ -1,4 +1,4 @@ -require "vendor/macho/macho" +require "macho" require "os/mac/architecture_list" module MachOShim diff --git a/Library/Homebrew/system_command.rb b/Library/Homebrew/system_command.rb index 571b3540be..c1614cc95d 100644 --- a/Library/Homebrew/system_command.rb +++ b/Library/Homebrew/system_command.rb @@ -1,6 +1,6 @@ require "open3" require "ostruct" -require "vendor/plist/plist" +require "plist" require "shellwords" require "extend/io" diff --git a/Library/Homebrew/vendor/.bundle/config b/Library/Homebrew/vendor/.bundle/config new file mode 100644 index 0000000000..9b31762860 --- /dev/null +++ b/Library/Homebrew/vendor/.bundle/config @@ -0,0 +1,4 @@ +--- +BUNDLE_PATH: "bundle-standalone" +BUNDLE_DISABLE_SHARED_GEMS: "true" +BUNDLE_BIN: "false" diff --git a/Library/Homebrew/vendor/Gemfile b/Library/Homebrew/vendor/Gemfile new file mode 100644 index 0000000000..70cbcaa226 --- /dev/null +++ b/Library/Homebrew/vendor/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "backports" +gem "plist" +gem "ruby-macho" diff --git a/Library/Homebrew/vendor/Gemfile.lock b/Library/Homebrew/vendor/Gemfile.lock new file mode 100644 index 0000000000..e03f3113bf --- /dev/null +++ b/Library/Homebrew/vendor/Gemfile.lock @@ -0,0 +1,17 @@ +GEM + remote: https://rubygems.org/ + specs: + backports (3.8.0) + plist (3.3.0) + ruby-macho (2.0.0) + +PLATFORMS + ruby + +DEPENDENCIES + backports + plist + ruby-macho + +BUNDLED WITH + 1.16.4 diff --git a/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb b/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb new file mode 100644 index 0000000000..34e086a93c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb @@ -0,0 +1,9 @@ +require 'rbconfig' +# ruby 1.8.7 doesn't define RUBY_ENGINE +ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' +ruby_version = RbConfig::CONFIG["ruby_version"] +path = File.expand_path('..', __FILE__) +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.8.0/lib" +$:.unshift "#{path}/" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.3.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.0.0/lib" diff --git a/Library/Homebrew/vendor/backports/string.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/backports-3.8.0/lib/backports/2.4.0/string/match.rb similarity index 66% rename from Library/Homebrew/vendor/backports/string.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/backports-3.8.0/lib/backports/2.4.0/string/match.rb index 6299a3fb48..9f9f49dd18 100644 --- a/Library/Homebrew/vendor/backports/string.rb +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/backports-3.8.0/lib/backports/2.4.0/string/match.rb @@ -1,4 +1,3 @@ -# Taken from https://github.com/marcandre/backports/blob/v3.8.0/lib/backports/2.4.0/string/match.rb unless String.method_defined? :match? class String def match?(*args) diff --git a/Library/Homebrew/vendor/plist/plist.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist.rb old mode 100755 new mode 100644 similarity index 74% rename from Library/Homebrew/vendor/plist/plist.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist.rb index 82ecb27d28..986dad4617 --- a/Library/Homebrew/vendor/plist/plist.rb +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist.rb @@ -13,9 +13,9 @@ require 'base64' require 'cgi' require 'stringio' -require_relative 'plist/generator' -require_relative 'plist/parser' -require_relative 'plist/version' +require 'plist/generator' +require 'plist/parser' +require 'plist/version' module Plist end diff --git a/Library/Homebrew/vendor/plist/plist/generator.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/generator.rb old mode 100755 new mode 100644 similarity index 100% rename from Library/Homebrew/vendor/plist/plist/generator.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/generator.rb diff --git a/Library/Homebrew/vendor/plist/plist/parser.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/parser.rb similarity index 100% rename from Library/Homebrew/vendor/plist/plist/parser.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/parser.rb diff --git a/Library/Homebrew/vendor/plist/plist/version.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/version.rb old mode 100755 new mode 100644 similarity index 100% rename from Library/Homebrew/vendor/plist/plist/version.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/version.rb diff --git a/Library/Homebrew/vendor/macho/macho.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho.rb diff --git a/Library/Homebrew/vendor/macho/macho/exceptions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/exceptions.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/exceptions.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/exceptions.rb diff --git a/Library/Homebrew/vendor/macho/macho/fat_file.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/fat_file.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/fat_file.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/fat_file.rb diff --git a/Library/Homebrew/vendor/macho/macho/headers.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/headers.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/headers.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/headers.rb diff --git a/Library/Homebrew/vendor/macho/macho/load_commands.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/load_commands.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/load_commands.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/load_commands.rb diff --git a/Library/Homebrew/vendor/macho/macho/macho_file.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/macho_file.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/macho_file.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/macho_file.rb diff --git a/Library/Homebrew/vendor/macho/macho/sections.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/sections.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/sections.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/sections.rb diff --git a/Library/Homebrew/vendor/macho/macho/structure.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/structure.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/structure.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/structure.rb diff --git a/Library/Homebrew/vendor/macho/macho/tools.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/tools.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/tools.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/tools.rb diff --git a/Library/Homebrew/vendor/macho/macho/utils.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/utils.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/utils.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/utils.rb diff --git a/Library/Homebrew/vendor/macho/macho/view.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/view.rb similarity index 100% rename from Library/Homebrew/vendor/macho/macho/view.rb rename to Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/ruby-macho-2.0.0/lib/macho/view.rb