summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-05-04 16:41:10 -0700
committerGitHub <noreply@github.com>2020-05-04 16:41:10 -0700
commit5aa7e5a2b98684e26b51b29c41b26ce7f5a3746e (patch)
tree6653aa7e7d41fb4933d31e33bda2e52cebce393a
parent7e4ea765ace14dc2e89921577187429d34836a3b (diff)
parentb07a6d088c01d4ff6a186ab89632bf57e758b6b5 (diff)
downloadchef-5aa7e5a2b98684e26b51b29c41b26ce7f5a3746e.tar.gz
Merge pull request #9739 from chef/robb/reorder-gem-installs-in-hab-build
fix Habitat Windows package build
-rw-r--r--Rakefile41
-rw-r--r--habitat/plan.ps123
-rw-r--r--scripts/ci/ensure-minimum-viable-hab.ps15
3 files changed, 46 insertions, 23 deletions
diff --git a/Rakefile b/Rakefile
index a147fc3435..56a2138766 100644
--- a/Rakefile
+++ b/Rakefile
@@ -34,24 +34,32 @@ require "bundler/gem_helper"
ENV["CHEF_LICENSE"] = "accept-no-persist"
-# hack the chef-config install to run before the traditional install task
-task :super_install do
- %w{chef-utils chef-config}.each do |gem|
- path = ::File.join(::File.dirname(__FILE__), gem)
- Dir.chdir(path)
- sh("rake install")
+namespace :pre_install do
+ desc "Runs 'rake install' for the gems that live in subdirectories in this repo"
+ task :install_gems_from_dirs do
+ %w{chef-utils chef-config}.each do |gem|
+ path = ::File.join(::File.dirname(__FILE__), gem)
+ Dir.chdir(path) do
+ sh("rake install")
+ end
+ end
end
-# Templating the powershell extensions so we can inject distro constants
- template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
- psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
- FileUtils.mkdir_p psm1_path
- template = ERB.new(IO.read(template_file))
- chef_psm1 = template.result
- File.open(::File.join(psm1_path, "chef.psm1"), "w") { |f| f.write(chef_psm1) }
+ desc "Renders the powershell extensions with distro flavoring"
+ task :render_powershell_extension do
+ template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
+ psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
+ FileUtils.mkdir_p psm1_path
+ template = ERB.new(IO.read(template_file))
+ chef_psm1 = template.result
+ File.open(::File.join(psm1_path, "chef.psm1"), "w") { |f| f.write(chef_psm1) }
+ end
+
+ task all: ["pre_install:install_gems_from_dirs", "pre_install:render_powershell_extension"]
end
-task install: :super_install
+# hack in all the preinstall tasks to occur before the tradtional install task
+task install: "pre_install:all"
# make sure we build the correct gemspec on windows
gemspec = Gem.win_platform? ? "chef-universal-mingw32" : "chef"
@@ -60,8 +68,9 @@ Bundler::GemHelper.install_tasks name: gemspec
# this gets appended to the normal bundler install helper
task :install do
chef_bin_path = ::File.join(::File.dirname(__FILE__), "chef-bin")
- Dir.chdir(chef_bin_path)
- sh("rake install:force")
+ Dir.chdir(chef_bin_path) do
+ sh("rake install:force")
+ end
end
task :pedant, :chef_zero_spec
diff --git a/habitat/plan.ps1 b/habitat/plan.ps1
index ca40a13bda..704b736048 100644
--- a/habitat/plan.ps1
+++ b/habitat/plan.ps1
@@ -28,6 +28,7 @@ function Invoke-Begin {
function Invoke-SetupEnvironment {
Push-RuntimeEnv -IsPath GEM_PATH "$pkg_prefix/vendor"
+ Push-RuntimeEnv -IsPath RUBY_DLL_PATH "$pkg_prefix/lib"
Set-RuntimeEnv APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH
Set-RuntimeEnv FORCE_FFI_YAJL "ext" # Always use the C-extensions because we use MRI on all the things and C is fast.
@@ -44,6 +45,7 @@ function Invoke-Download() {
try {
Push-Location (Resolve-Path "$PLAN_CONTEXT/../").Path
git archive --format=zip --output="${HAB_CACHE_SRC_PATH}/${pkg_filename}" HEAD
+ if (-not $?) { throw "unable to create archive of source" }
} finally {
Pop-Location
}
@@ -62,6 +64,7 @@ function Invoke-Prepare {
Write-BuildLine " ** Configuring bundler for this build environment"
bundle config --local without server docgen maintenance pry travis integration ci chefstyle
+ if (-not $?) { throw "unable to configure bundler to restrict gems to be installed" }
bundle config --local jobs 4
bundle config --local retry 5
bundle config --local silence_root_warning 1
@@ -74,20 +77,32 @@ function Invoke-Build {
try {
Push-Location "${HAB_CACHE_SRC_PATH}/${pkg_dirname}"
+ Write-BuildLine " ** Copying Chef DLLs"
+ New-Item -ItemType Directory -Force -Path "$pkg_prefix/lib"
+ Get-ChildItem ./distro/ruby_bin_folder -Filter "*.dll" | Copy-Item -Destination "$pkg_prefix/lib"
+ $env:_BUNDER_WINDOWS_DLLS_COPIED = "1"
+
Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies"
bundle install
- Write-BuildLine " ** Running the chef project's 'rake install' to install the path-based gems so they look like any other installed gem."
- bundle exec rake install # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler
- Write-BuildLine " ** Also 'rake install' any gem sourced as a git reference."
+ if (-not $?) { throw "unable to install gem dependencies" }
+ Write-BuildLine " ** 'rake install' any gem sourced as a git reference so they'll look like regular gems."
foreach($git_gem in (Get-ChildItem "$env:GEM_HOME/bundler/gems")) {
try {
Push-Location $git_gem
- Write-BuildLine " -- and $git_gem too"
+ Write-BuildLine " -- installing $git_gem"
rake install # this needs to NOT be 'bundle exec'd else bundler complains about dev deps not being installed
+ if (-not $?) { throw "unable to install $git_gem as a plain old gem" }
} finally {
Pop-Location
}
}
+ Write-BuildLine " ** Running the chef project's 'rake install' to install the path-based gems so they look like any other installed gem."
+ bundle exec rake install # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler
+ if (-not $?) {
+ Write-Warning " -- That didn't work. Let's try again."
+ bundle exec rake install # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler
+ if (-not $?) { throw "unable to install the gems that live in directories within this repo" }
+ }
} finally {
Pop-Location
}
diff --git a/scripts/ci/ensure-minimum-viable-hab.ps1 b/scripts/ci/ensure-minimum-viable-hab.ps1
index 175c7d4890..10bfeb0fa8 100644
--- a/scripts/ci/ensure-minimum-viable-hab.ps1
+++ b/scripts/ci/ensure-minimum-viable-hab.ps1
@@ -1,6 +1,5 @@
-$hab_version = (hab --version)
-$hab_minor_version = $hab_version.split('.')[1]
-if ( -not $? -Or $hab_minor_version -lt 85 ) {
+[Version]$hab_version = (hab --version).split(" ")[1].split("/")[0]
+if ($hab_version -lt [Version]"0.85.0" ) {
Write-Host "--- :habicat: Installing the version of Habitat required"
install-habitat --version 0.85.0.20190916
if (-not $?) { throw "Hab version is older than 0.85 and could not update it." }