1
+ $ErrorActionPreference = " Stop"
2
+ $PSDefaultParameterValues [' *:ErrorAction' ]= ' Stop'
3
+
4
+ $pkg_name = " fauxhai"
5
+ $pkg_origin = " core"
6
+ $pkg_version = " 9.3.16"
7
+ $pkg_revision = " 1"
8
+ $pkg_maintainer = " The Chef Maintainers <[email protected] >"
9
+
10
+ $pkg_deps = @ (
11
+ " chef/ruby31-plus-devkit"
12
+ " core/git"
13
+ )
14
+ $pkg_bin_dirs = @ (" bin"
15
+ " vendor/bin" )
16
+ $project_root = (Resolve-Path " $PLAN_CONTEXT /../" ).Path
17
+
18
+ function Invoke-SetupEnvironment {
19
+ Push-RuntimeEnv - IsPath GEM_PATH " $pkg_prefix /vendor"
20
+
21
+ Set-RuntimeEnv APPBUNDLER_ALLOW_RVM " true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH
22
+ Set-RuntimeEnv FORCE_FFI_YAJL " ext"
23
+ Set-RuntimeEnv LANG " en_US.UTF-8"
24
+ Set-RuntimeEnv LC_CTYPE " en_US.UTF-8"
25
+ }
26
+
27
+ function Invoke-Build {
28
+ try {
29
+ $env: Path += " ;c:\\Program Files\\Git\\bin"
30
+ Push-Location $project_root
31
+ $env: GEM_HOME = " $HAB_CACHE_SRC_PATH /$pkg_dirname /vendor"
32
+
33
+ Write-BuildLine " ** Configuring bundler for this build environment"
34
+ bundle config -- local without integration deploy maintenance
35
+ bundle config -- local jobs 4
36
+ bundle config -- local retry 5
37
+ bundle config -- local silence_root_warning 1
38
+ Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies"
39
+ bundle install
40
+
41
+ gem build fauxhai- chef.gemspec
42
+ Write-BuildLine " ** Using gem to install"
43
+ gem install fauxhai- chef-* .gem -- no- document
44
+
45
+
46
+ If ($lastexitcode -ne 0 ) { Exit $lastexitcode }
47
+ } finally {
48
+ Pop-Location
49
+ }
50
+ }
51
+
52
+ function Invoke-Install {
53
+ Write-BuildLine " ** Copy built & cached gems to install directory"
54
+ Copy-Item - Path " $HAB_CACHE_SRC_PATH /$pkg_dirname /*" - Destination $pkg_prefix - Recurse - Force - Exclude @ (" gem_make.out" , " mkmf.log" , " Makefile" ,
55
+ " */latest" , " latest" ,
56
+ " */JSON-Schema-Test-Suite" , " JSON-Schema-Test-Suite" )
57
+
58
+ try {
59
+ Push-Location $pkg_prefix
60
+ bundle config -- local gemfile $project_root / Gemfile
61
+ Write-BuildLine " ** generating binstubs for fauxhai-chef with precise version pins"
62
+ Write-BuildLine " ** generating binstubs for fauxhai-chef with precise version pins $project_root $pkg_prefix /bin "
63
+ Invoke-Expression - Command " appbundler.bat $project_root $pkg_prefix /bin fauxhai-chef"
64
+ If ($lastexitcode -ne 0 ) { Exit $lastexitcode }
65
+ Write-BuildLine " ** Running the fauxhai-chef project's 'rake install' to install the path-based gems so they look like any other installed gem."
66
+
67
+ If ($lastexitcode -ne 0 ) { Exit $lastexitcode }
68
+ } finally {
69
+ Pop-Location
70
+ }
71
+ }
72
+
73
+ function Invoke-After {
74
+ # We don't need the cache of downloaded .gem files ...
75
+ Remove-Item $pkg_prefix / vendor/ cache - Recurse - Force
76
+ # We don't need the gem docs.
77
+ Remove-Item $pkg_prefix / vendor/ doc - Recurse - Force
78
+ # We don't need to ship the test suites for every gem dependency,
79
+ # only inspec's for package verification.
80
+ Get-ChildItem $pkg_prefix / vendor/ gems - Filter " spec" - Directory - Recurse - Depth 1 `
81
+ | Where-Object - FilterScript { $_.FullName -notlike " *fauxhai-chef*" } `
82
+ | Remove-Item - Recurse - Force
83
+ # Remove the byproducts of compiling gems with extensions
84
+ Get-ChildItem $pkg_prefix / vendor/ gems - Include @ (" gem_make.out" , " mkmf.log" , " Makefile" ) - File - Recurse `
85
+ | Remove-Item - Force
86
+ }
0 commit comments