appbundle-updater 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 993c81b1b3816818571de18733857471df1569e4
4
+ data.tar.gz: 82ec4a5dca4c3a14320e2d7bc08c32ee05761894
5
+ SHA512:
6
+ metadata.gz: 494ece937ae9456b48064edde51b7fe0d724aee1d95ca39a4ae7a35706d36df26b2b886aa646ad0793926421099be5e9611c7a3e877bd64c42637fad5f67ef69
7
+ data.tar.gz: 5cca9976ebd9845da42b8914afe447a81543315e2fcd9d06a8978188e6543e5387966404a37e0d914c85d888c4e762c45df49c42e489f12689f5a6e4b042eb57
@@ -0,0 +1,12 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ Gemfile
5
+ Gemfile.lock
6
+ tmp
7
+ .rvmrc
8
+ .rbenv-version
9
+ .ruby-version
10
+ .DS_Store
11
+ .kitchen/
12
+ .kitchen.local.yml
@@ -0,0 +1,14 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+
5
+ provisioner:
6
+ name: shell
7
+ data_path: bin
8
+
9
+ platforms:
10
+ - name: ubuntu-14.04
11
+ - name: windows-2012r2-core
12
+
13
+ suites:
14
+ - name: default
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,77 @@
1
+ # appbundle-updater
2
+
3
+ Helper to update Chef and Chef-DK appbundle'd apps inside of an omnibus bundle.
4
+
5
+ ## Requirements
6
+
7
+ * A ChefDK or Chef Client installation in the standard location.
8
+ * You need to have the `git` command in your PATH.
9
+
10
+ ## Usage Examples
11
+
12
+ Updating chef in the /opt/chefdk bundle to master:
13
+
14
+ ```
15
+ sudo appbundle-updater chefdk chef master
16
+ ```
17
+
18
+ Updating chef-dk in the /opt/chefdk bundle to master (sorry about the inconsistent dashes here
19
+ but the project/gem is called "chef-dk" while the path on the filesystem is /opt/chefdk, the
20
+ path on the filesystem comes first):
21
+
22
+ ```
23
+ sudo appbundle-updater chefdk chef-dk master
24
+ ```
25
+
26
+ Updating various other softwares in /opt/chefdk bundle to master:
27
+
28
+ ```
29
+ sudo appbundle-updater chefdk berkshelf master
30
+ sudo appbundle-updater chefdk chef-vault master
31
+ sudo appbundle-updater chefdk ohai master
32
+ sudo appbundle-updater chefdk foodcritic master
33
+ sudo appbundle-updater chefdk test-kitchen master
34
+ ```
35
+
36
+ Updating chef and ohai in the /opt/chef bundle to master:
37
+
38
+ ```
39
+ sudo appbundle-updater chef chef master
40
+ sudo appbundle-updater chef ohai master
41
+ ```
42
+
43
+ Windows users from PowerShell use the bat file:
44
+
45
+ ```powershell
46
+ & appbundle-updater chefdk test-kitchen master
47
+ ```
48
+
49
+ If you don't want "master" you can use any other git tag/branch/sha/etc that git understands.
50
+
51
+ ## <a name="development"></a> Development
52
+
53
+ * Source hosted at [GitHub][repo]
54
+ * Report issues/questions/feature requests on [GitHub Issues][issues]
55
+
56
+ Pull requests are very welcome! Make sure your patches are well tested.
57
+ Ideally create a topic branch for every separate change you make. For
58
+ example:
59
+
60
+ 1. Fork the repo
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create new Pull Request
65
+
66
+ ## <a name="authors"></a> Authors
67
+
68
+ Created and maintained by [Fletcher Nichol][fnichol] (<fnichol@nichol.ca>)
69
+
70
+ ## <a name="license"></a> License
71
+
72
+ Apache 2.0 (see [LICENSE.txt][license])
73
+
74
+ [license]: https://github.com/fnichol/chefdk-update-app/blob/master/LICENSE.txt
75
+ [fnichol]: https://github.com/fnichol
76
+ [repo]: https://github.com/fnichol/chefdk-update-app
77
+ [issues]: https://github.com/fnichol/chefdk-update-app/issues
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'appbundle_updater/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "appbundle-updater"
8
+ spec.version = AppbundleUpdater::VERSION
9
+ spec.authors = ["lamont-granquist"]
10
+ spec.email = ["lamont@chef.io"]
11
+ spec.description = %q{Updates appbundled apps in Chef's omnibus packages}
12
+ spec.summary = spec.description
13
+ spec.homepage = ""
14
+ spec.license = "Apache2"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ #
4
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
5
+ #
6
+ # Copyright (C) 2015 Fletcher Nichol
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require "pathname"
21
+ require "optparse"
22
+
23
+ # FIXME: move to helpers mixin
24
+
25
+ def windows?
26
+ @windows ||= RUBY_PLATFORM =~ /mswin|mingw|windows/
27
+ end
28
+
29
+ def chefdk
30
+ if windows?
31
+ Pathname.new(File.join(ENV["SYSTEMDRIVE"], "opscode", ARGV[0]))
32
+ else
33
+ Pathname.new(File.join("/opt", ARGV[0]))
34
+ end
35
+ end
36
+
37
+ def bin_dir
38
+ chefdk.join("embedded/bin")
39
+ end
40
+
41
+ App = Struct.new(:name, :url, :bundle_without, :install_command) do
42
+ def to_s
43
+ name
44
+ end
45
+ end
46
+
47
+ CHEFDK_APPS = [
48
+ App.new(
49
+ "berkshelf",
50
+ "https://github.com/berkshelf/berkshelf.git",
51
+ "guard test",
52
+ "#{bin_dir.join("rake")} install",
53
+ ),
54
+ App.new(
55
+ "chef",
56
+ "https://github.com/chef/chef.git",
57
+ "server docgen test development",
58
+ "#{bin_dir.join("rake")} install",
59
+ ),
60
+ App.new(
61
+ "chef-dk",
62
+ "https://github.com/chef/chef-dk.git",
63
+ "dev test development",
64
+ "#{bin_dir.join("rake")} install",
65
+ ),
66
+ App.new(
67
+ "chef-vault",
68
+ "https://github.com/Nordstrom/chef-vault.git",
69
+ "test",
70
+ "#{bin_dir.join("rake")} install",
71
+ ),
72
+ App.new(
73
+ "foodcritic",
74
+ "https://github.com/acrmp/foodcritic.git",
75
+ nil,
76
+ "#{bin_dir.join("rake")} install",
77
+ ),
78
+ App.new(
79
+ "ohai",
80
+ "https://github.com/chef/ohai.git",
81
+ "test development",
82
+ "#{bin_dir.join("rake")} install",
83
+ ),
84
+ App.new(
85
+ "test-kitchen",
86
+ "https://github.com/test-kitchen/test-kitchen.git",
87
+ "guard test",
88
+ "#{bin_dir.join("rake")} install",
89
+ )
90
+ ].freeze
91
+
92
+ class Updater
93
+ attr_reader :app, :ref
94
+
95
+ def initialize(options)
96
+ @app = options[:app]
97
+ @ref = options[:ref]
98
+ end
99
+
100
+ def start
101
+ if !windows? && Process.uid != 0
102
+ abort "#{$0} needs to be run as root user or with sudo"
103
+ end
104
+
105
+ ruby("-rpp -e 'pp ENV'")
106
+ banner("Cleaning #{app} checkout")
107
+ app_dir.rmtree if app_dir.directory?
108
+
109
+ banner("Cloning #{app} from #{app.url}")
110
+ run("git clone #{app.url} #{app_dir}")
111
+
112
+ banner("Checking out #{app} to #{ref}")
113
+ Dir.chdir(app_dir) do
114
+ run("git checkout #{ref}")
115
+ end
116
+
117
+ banner("Installing dependencies")
118
+ Dir.chdir(app_dir) do
119
+ cmd = "#{bin_dir.join("bundle")} install"
120
+ cmd += " --without #{app.bundle_without}" if app.bundle_without
121
+ ruby(cmd)
122
+ end
123
+
124
+ banner("Installing gem")
125
+ Dir.chdir(app_dir) do
126
+ ruby("#{bin_dir.join("bundle")} exec #{app.install_command}")
127
+ end
128
+
129
+ banner("Updating appbundler binstubs for #{app}")
130
+ Dir.chdir(app_dir) do
131
+ ruby("#{bin_dir.join("appbundler")} #{app_dir} #{chefdk.join("bin")}")
132
+ end
133
+
134
+ banner("Finished!")
135
+ end
136
+
137
+ private
138
+ ENV_KEYS = %w[
139
+ BUNDLE_BIN_PATH BUNDLE_GEMFILE GEM_HOME GEM_PATH GEM_ROOT IRBRC MY_RUBY_HOME RUBYLIB RUBYOPT RUBY_ENGINE RUBY_ROOT RUBY_VERSION _ORIGINAL_GEM_PATH PATH
140
+ ].freeze
141
+
142
+ def app_dir
143
+ chefdk.join("embedded/apps/#{app}")
144
+ end
145
+
146
+ def banner(msg)
147
+ puts "-----> #{msg}"
148
+ end
149
+
150
+ def ruby(script)
151
+ ruby = bin_dir.join("ruby").to_s.tap { |p| p.concat(".exe") if windows? }
152
+
153
+ run([ruby, script].join(" "))
154
+ end
155
+
156
+ def run(cmd)
157
+ ENV_KEYS.each { |key| ENV["_YOLO_#{key}"] = ENV[key]; ENV.delete(key) }
158
+ ENV['PATH'] = "#{bin_dir}:#{ENV['_YOLO_PATH']}"
159
+ puts " running: #{cmd}"
160
+ system(cmd) or raise("Command [#{cmd}] failed!")
161
+ ENV_KEYS.each { |key| ENV[key] = ENV.delete("_YOLO_#{key}") }
162
+ end
163
+
164
+ end
165
+
166
+ class CLI
167
+ def self.options
168
+ new.options
169
+ end
170
+
171
+ attr_reader :options, :parser
172
+
173
+ def initialize
174
+ @options = Hash.new
175
+ @parser = OptionParser.new { |opts|
176
+ opts.banner = "Usage: #{$0} PROJECT APP_NAME GIT_REF"
177
+ opts.on("-h", "--help", "Prints this help") do
178
+ puts opts
179
+ exit
180
+ end
181
+ opts.separator("")
182
+ opts.separator("App names:")
183
+ CHEFDK_APPS.each { |a| opts.separator(" * #{a.name}") }
184
+ }
185
+ @parser.parse!
186
+ validate!
187
+ end
188
+
189
+ def validate!
190
+ die("PROJECT APP_NAME GIT_REF options are all required") if ARGV.length < 3
191
+ options[:app] = CHEFDK_APPS.find { |a| a.name == ARGV[1] }
192
+ die("Invalid APP_NAME: #{ARGV[1]}") if options[:app].nil?
193
+ options[:ref] = ARGV[2]
194
+ end
195
+
196
+ def die(msg)
197
+ $stderr.puts msg
198
+ $stderr.puts parser
199
+ exit 1
200
+ end
201
+ end
202
+
203
+ Updater.new(CLI.options).start
@@ -0,0 +1,3 @@
1
+ module AppbundleUpdater
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,82 @@
1
+ Function Get-ChefMetadata($url) {
2
+ Try { $response = ($c = Make-WebClient).DownloadString($url) }
3
+ Finally { if ($c -ne $null) { $c.Dispose() } }
4
+
5
+ $md = ConvertFrom-StringData $response.Replace("`t", "=")
6
+ return @($md.url, $md.md5)
7
+ }
8
+
9
+ Function Get-MD5Sum($src) {
10
+ Try {
11
+ $c = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
12
+ $bytes = $c.ComputeHash(($in = (Get-Item $src).OpenRead()))
13
+ return ([System.BitConverter]::ToString($bytes)).Replace("-", "").ToLower()
14
+ } Finally { if (($c -ne $null) -and ($c.GetType().GetMethod("Dispose") -ne $null)) { $c.Dispose() }; if ($in -ne $null) { $in.Dispose() } }
15
+ }
16
+
17
+ Function Download-Chef($md_url, $dst) {
18
+ $url, $md5 = Get-ChefMetadata $md_url
19
+
20
+ Try {
21
+ Log "Downloading package from $url"
22
+ ($c = Make-WebClient).DownloadFile($url, $dst)
23
+ Log "Download complete."
24
+ } Finally { if ($c -ne $null) { $c.Dispose() } }
25
+
26
+ if (($dmd5 = Get-MD5Sum $dst) -eq $md5) { Log "Successfully verified $dst" }
27
+ else { throw "MD5 for $dst $dmd5 does not match $md5" }
28
+ }
29
+
30
+ Function Install-Chef($msi) {
31
+ Log "Installing ChefDK package $msi"
32
+ $p = Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /i $msi" -Passthru -Wait
33
+
34
+ if ($p.ExitCode -ne 0) { throw "msiexec was not successful. Received exit code $($p.ExitCode)" }
35
+
36
+ Remove-Item $msi -Force
37
+ Log "Installation complete"
38
+ }
39
+
40
+ Function Install-Git {
41
+ iex ((Make-WebClient).DownloadString("https://chocolatey.org/install.ps1"))
42
+ choco install git
43
+ }
44
+
45
+ Function Log($m) { Write-Host " $m`n" }
46
+
47
+ Function Banner ($m) { Write-Host "-----> $m`n" }
48
+
49
+ Function Make-WebClient {
50
+ $proxy = New-Object -TypeName System.Net.WebProxy
51
+ $proxy.Address = $env:http_proxy
52
+ $client = New-Object -TypeName System.Net.WebClient
53
+ $client.Proxy = $proxy
54
+ return $client
55
+ }
56
+
57
+ Function Unresolve-Path($p) {
58
+ if ($p -eq $null) { return $null }
59
+ else { return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($p) }
60
+ }
61
+
62
+ $chef_metadata_url = "http://www.chef.io/chef/metadata-chefdk?p=windows&m=x86_64&pv=2008r2&v=latest"
63
+ $chefdk_root = Unresolve-Path "$env:systemdrive\opscode\chefdk"
64
+ $msi = Unresolve-Path "$env:TEMP\chefdk-latest.msi"
65
+ $git_path = (Get-Item "ENV:ProgramFiles(x86)").Value + "\Git\bin"
66
+
67
+ if (-Not (Test-Path "$env:ALLUSERSPROFILE\chocolatey")) { Install-Git }
68
+
69
+ if (-Not (($env:PATH).split(";") -contains "$git_path")) { $env:PATH += ";" + "$git_path" }
70
+
71
+ if (-Not (Test-Path $chefdk_root)) {
72
+ Banner "Installing ChefDK"
73
+ Download-Chef "$chef_metadata_url" $msi
74
+ Install-Chef $msi
75
+ } else {
76
+ Banner "ChefDK installation detected"
77
+ }
78
+
79
+ Banner "Running ChefDK app update"
80
+ & "$env:TEMP\kitchen\data\chefdk-update-app.bat" test-kitchen -r v1.4.0.beta.1
81
+
82
+ exit $LASTEXITCODE
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env sh
2
+ set -e
3
+ set -x
4
+
5
+ if test ! -x /usr/bin/curl; then
6
+ sudo -E apt-get update -y
7
+ sudo -E apt-get install -y curl git-core
8
+ fi
9
+
10
+ if test ! -d /opt/chefdk; then
11
+ curl -L http://www.chef.io/chef/install.sh | sudo -E bash -s -- -P chefdk
12
+ fi
13
+
14
+ sudo -E /tmp/kitchen/data/chefdk-update-app.sh test-kitchen -r v1.4.0.beta.1
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appbundle-updater
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - lamont-granquist
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Updates appbundled apps in Chef's omnibus packages
28
+ email:
29
+ - lamont@chef.io
30
+ executables:
31
+ - appbundle-updater
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - ".kitchen.yml"
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - appbundler.gemspec
41
+ - bin/appbundle-updater
42
+ - lib/appbundle_updater/version.rb
43
+ - test/integration/bootstrap.ps1
44
+ - test/integration/bootstrap.sh
45
+ homepage: ''
46
+ licenses:
47
+ - Apache2
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.4.8
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Updates appbundled apps in Chef's omnibus packages
69
+ test_files:
70
+ - test/integration/bootstrap.ps1
71
+ - test/integration/bootstrap.sh