summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-04-03 19:51:07 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-04-03 19:51:07 -0700
commitf37a24ad046bbe6627fc34d3b13718420d81a25a (patch)
tree7206404a07bddf43e1fcdfdaacf9ac1784177e9a
parent361f5a54b02e455c059dfabe3e18620857827f2d (diff)
downloadchef-f37a24ad046bbe6627fc34d3b13718420d81a25a.tar.gz
fix and simplify rake bundle:* commands
applies the same kinds of fixes that i applied to rake dependencies:* and mostly reverts to mainline usage of bundler. abandons all the trampolining, and uses the platforms that are already locked in the Gemfile.lock and unwinds the multi-platform stuff that bundler does natively now. removes the BundleUtil module entirely since it is no longer used. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--Gemfile.lock10
-rw-r--r--tasks/bundle.rb50
-rw-r--r--tasks/bundle_util.rb110
-rw-r--r--tasks/dependencies.rb1
4 files changed, 20 insertions, 151 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index c366f406f8..4a5b975316 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -205,13 +205,13 @@ GEM
mixlib-cli (~> 1.4)
artifactory (2.8.1)
ast (2.3.0)
- aws-sdk (2.9.1)
- aws-sdk-resources (= 2.9.1)
- aws-sdk-core (2.9.1)
+ aws-sdk (2.9.2)
+ aws-sdk-resources (= 2.9.2)
+ aws-sdk-core (2.9.2)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.9.1)
- aws-sdk-core (= 2.9.1)
+ aws-sdk-resources (2.9.2)
+ aws-sdk-core (= 2.9.2)
aws-sigv4 (1.0.0)
backports (3.7.0)
binding_of_caller (0.7.2)
diff --git a/tasks/bundle.rb b/tasks/bundle.rb
index f530515786..0e9b207932 100644
--- a/tasks/bundle.rb
+++ b/tasks/bundle.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-require_relative "bundle_util"
require_relative "../version_policy"
require "fileutils"
@@ -23,33 +22,22 @@ desc "Tasks to work with the main Gemfile and Gemfile.<platform>"
namespace :bundle do
desc "Update Gemfile.lock and all Gemfile.<platform>.locks (or one or more gems via bundle:update gem1 gem2 ...)."
task :update, [:args] do |t, rake_args|
- extend BundleUtil
args = rake_args[:args] || ""
- with_bundle_unfrozen do
- puts ""
- puts "-------------------------------------------------------------------"
- puts "Updating Gemfile.lock ..."
- puts "-------------------------------------------------------------------"
- bundle "update #{args}"
- platforms.each do |platform|
- bundle "update #{args}", platform: platform
- end
+ Bundler.with_clean_env do
+ sh "bundle config --local frozen '0'"
+ sh "bundle update #{args}"
+ sh "bundle config --local frozen '1'"
end
end
desc "Conservatively update Gemfile.lock and all Gemfile.<platform>.locks"
task :install, [:args] do |t, rake_args|
- extend BundleUtil
args = rake_args[:args] || ""
- with_bundle_unfrozen do
- puts ""
- puts "-------------------------------------------------------------------"
- puts "Updating Gemfile.lock ..."
- puts "-------------------------------------------------------------------"
- bundle "install #{args}"
- platforms.each do |platform|
- bundle "lock", platform: platform
- end
+ args = rake_args[:args] || ""
+ Bundler.with_clean_env do
+ sh "bundle config --local frozen '0'"
+ sh "bundle install #{args}"
+ sh "bundle config --local frozen '1'"
end
end
@@ -82,20 +70,12 @@ namespace :bundle do
end
end
-desc "Run bundle with arbitrary args against the given platform; e.g. rake bundle[show]. No platform to run against the main bundle; bundle[show,windows] to run the windows one; bundle[show,*] to run against all non-default platforms."
-task :bundle, [:args, :platform] do |t, rake_args|
- extend BundleUtil
+desc "Run bundle with arbitrary args"
+task :bundle, [:args] do |t, rake_args|
args = rake_args[:args] || ""
- platform = rake_args[:platform]
- with_bundle_unfrozen do
- if platform == "*"
- platforms.each do |platform|
- bundle args, platform: platform
- end
- elsif platform
- bundle args, platform: platform
- else
- bundle args
- end
+ Bundler.with_clean_env do
+ sh "bundle config --local frozen '0'"
+ sh "bundle #{args}"
+ sh "bundle config --local frozen '1'"
end
end
diff --git a/tasks/bundle_util.rb b/tasks/bundle_util.rb
deleted file mode 100644
index 67647dd4f0..0000000000
--- a/tasks/bundle_util.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-require "bundler"
-require "shellwords"
-
-module BundleUtil
- PLATFORMS = { "windows" => %w{ruby x86-mingw32} }
-
- def project_root
- File.expand_path("../..", __FILE__)
- end
-
- def bundle_platform
- File.join(project_root, "tasks", "bin", "bundle-platform")
- end
-
- # Parse the output of "bundle outdated" and get the list of gems that
- # were outdated
- def parse_bundle_outdated(bundle_outdated_output)
- result = []
- bundle_outdated_output.each_line do |line|
- if line =~ /^\s*\* (.+) \(newest ([^,]+), installed ([^,)])*/
- gem_name, newest_version, installed_version = $1, $2, $3
- result << [ line, gem_name ]
- end
- end
- result
- end
-
- def with_bundle_unfrozen(cwd: nil, leave_frozen: false)
- bundle "config --delete frozen", cwd: cwd
- begin
- yield
- ensure
- bundle "config --local frozen 1", cwd: cwd unless leave_frozen
- end
- end
-
- # Run bundle-platform with the given ruby platform(s)
- def bundle(args, gemfile: nil, platform: nil, cwd: nil, extract_output: false, delete_gemfile_lock: false)
- args = args.split(/\s+/)
- if cwd
- prefix = "[#{cwd}] "
- end
- cwd = File.expand_path(cwd || ".", project_root)
- Bundler.with_clean_env do
- Dir.chdir(cwd) do
- gemfile ||= "Gemfile"
- gemfile = File.expand_path(gemfile, cwd)
- raise "No platform #{platform} (supported: #{PLATFORMS.keys.join(", ")})" if platform && !PLATFORMS[platform]
-
- # First delete the gemfile.lock
- if delete_gemfile_lock
- if File.exist?("#{gemfile}.lock")
- puts "Deleting #{gemfile}.lock ..."
- File.delete("#{gemfile}.lock")
- end
- end
-
- # Run the bundle command
- ruby_platforms = platform ? PLATFORMS[platform].join(" ") : "ruby"
- cmd = Shellwords.join([
- Gem.ruby,
- "-S",
- bundle_platform,
- ruby_platforms,
- "_#{desired_bundler_version}_",
- *args,
- ])
- puts "#{prefix}#{Shellwords.join(["bundle", *args])}#{platform ? " for #{platform} platform" : ""}:"
- with_gemfile(gemfile) do
- puts "#{prefix}BUNDLE_GEMFILE=#{gemfile}"
- puts "#{prefix}> #{cmd}"
- if extract_output
- `#{cmd}`
- else
- unless system(bundle_platform, ruby_platforms, "_#{desired_bundler_version}_", *args)
- raise "#{bundle_platform} failed: exit code #{$?}"
- end
- end
- end
- end
- end
- end
-
- def with_gemfile(gemfile)
- old_gemfile = ENV["BUNDLE_GEMFILE"]
- ENV["BUNDLE_GEMFILE"] = gemfile
- begin
- yield
- ensure
- if old_gemfile
- ENV["BUNDLE_GEMFILE"] = old_gemfile
- else
- ENV.delete("BUNDLE_GEMFILE")
- end
- end
- end
-
- def platforms
- PLATFORMS.keys
- end
-
- def desired_bundler_version
- @desired_bundler_version ||= begin
- omnibus_overrides = File.join(project_root, "omnibus_overrides.rb")
- File.readlines(omnibus_overrides).each do |line|
- return $1 if line =~ /^override :bundler, version: "(.+)"$/
- end
- end
- end
-end
diff --git a/tasks/dependencies.rb b/tasks/dependencies.rb
index 6b836b747e..2118644b12 100644
--- a/tasks/dependencies.rb
+++ b/tasks/dependencies.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-require_relative "bundle_util"
require_relative "bundle"
require_relative "../version_policy"