appbundle-updater 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 331e2d44703abdf38c526bc815036066fcbc08e9
4
- data.tar.gz: 8a9bfc9bb4feaa65e098dc8bb1caab03ebf935f5
3
+ metadata.gz: ac3bd055342dbbd8af2b4414052f38d1d151f890
4
+ data.tar.gz: 7f2353ffcb372150135f72a0f25dacc6a49ab7ab
5
5
  SHA512:
6
- metadata.gz: 49bb29d6a177ee723851a78fb0c0c0b67d9dc29901a576dc7a07f4210d5f1289d32122ba1f55b1e5b1b1ab390145a5b0651b672d71d9176d8b9d0b18f8be74eb
7
- data.tar.gz: 5c6c74485430d83b331e83d2df0b02b82fd5e6a69ee8667bc621b75a0a85bee6971d0fdad1591844c65eaf02d950b7425a53efcd201731c8541c6c1dcd94728d
6
+ metadata.gz: 41bf71dad53439581f2348dbd923f57d761007fb00ec2a5ca6671749536a860aa3cc8db6e0dffaa78563fe9de79fd5a209edbfbf9df5abeab338bbc58863fd46
7
+ data.tar.gz: c6e1b1e734b322b035ab625e4b228047f6673d13caef25228885aecac13ae8edcce604c2120c5bc970ee97f538c067cd1aa684a9db4b456c832ec6e96387b947
data/.gitignore CHANGED
@@ -1,7 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  .bundle
4
- Gemfile
5
4
  Gemfile.lock
6
5
  tmp
7
6
  .rvmrc
@@ -0,0 +1,26 @@
1
+ # Change Log
2
+
3
+ ## [Unreleased](https://github.com/chef/appbundle-updater/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/chef/appbundle-updater/compare/v0.1.0...HEAD)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - add --github option for pulling forks [\#4](https://github.com/chef/appbundle-updater/pull/4) ([lamont-granquist](https://github.com/lamont-granquist))
10
+ - Suppress command output for successful commands [\#3](https://github.com/chef/appbundle-updater/pull/3) ([lamont-granquist](https://github.com/lamont-granquist))
11
+ - introduce --tarball option, default back to git clone [\#2](https://github.com/chef/appbundle-updater/pull/2) ([lamont-granquist](https://github.com/lamont-granquist))
12
+
13
+ ## [v0.1.0](https://github.com/chef/appbundle-updater/tree/v0.1.0) (2015-09-25)
14
+ [Full Changelog](https://github.com/chef/appbundle-updater/compare/v0.0.2...v0.1.0)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - use pure ruby to download tarball and extract [\#1](https://github.com/chef/appbundle-updater/pull/1) ([lamont-granquist](https://github.com/lamont-granquist))
19
+
20
+ ## [v0.0.2](https://github.com/chef/appbundle-updater/tree/v0.0.2) (2015-09-23)
21
+ [Full Changelog](https://github.com/chef/appbundle-updater/compare/v0.0.1...v0.0.2)
22
+
23
+ ## [v0.0.1](https://github.com/chef/appbundle-updater/tree/v0.0.1) (2015-09-23)
24
+
25
+
26
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :development do
5
+ gem "rake"
6
+ gem "github_changelog_generator"
7
+ end
data/README.md CHANGED
@@ -54,6 +54,27 @@ Windows users from PowerShell use the bat file:
54
54
 
55
55
  If you don't want "master" you can use any other git tag/branch/sha/etc that git understands.
56
56
 
57
+ ## Using a GitHub Fork
58
+
59
+ By default this gem clones from the official repos from the software. To override and point
60
+ at at fork use the `--github`` option on the command-line:
61
+
62
+ ```ruby
63
+ sudo appbundle-updater chef chef lcg/cool-feature --github lamont-granquist/chef
64
+ ```
65
+
66
+ ## Using a GitHub tarball instead of a git clone
67
+
68
+ Using the `--tarball` method will not use `git clone` and will not require the git binary being
69
+ installed on the system. By using this command the whole functionality should run in pure ruby,
70
+ be portable across all operating systems that omnibus-chef is ported to, and should only use
71
+ ruby stdlib functions. The disadvantage is that you do now wind up with a real git checkout
72
+ in the apps directory, just an extracted snapshot.
73
+
74
+ ```ruby
75
+ sudo appbundle-updater chef chef master --tarball
76
+ ```
77
+
57
78
  ## Execution and Target rubies
58
79
 
59
80
  This does not need to be installed into the embedded ruby that you are doing the update on.
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
+ require "github_changelog_generator/task"
1
2
  require "bundler/gem_tasks"
3
+
4
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
5
+ # config.since_tag = "1.0.1"
6
+ # config.exclude_labels = %w[duplicate question invalid wontfix changelog_skip]
7
+ end
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "rake"
22
+ # This Gem DELIBERATELY has no dependencies other than the ruby stdlib
23
23
  end
@@ -48,6 +48,8 @@ TAR_LONGLINK = '././@LongLink'
48
48
  # pure ruby `tar xzf`, handles longlinks and directories ending in '/'
49
49
  # (http://stackoverflow.com/a/31310593/506908)
50
50
  def extract_tgz(file, destination = '.')
51
+ # NOTE: THIS IS DELIBERATELY PURE RUBY USING NO NATIVE GEMS AND ONLY
52
+ # THE RUBY STDLIB BY DESIGN
51
53
  Gem::Package::TarReader.new( Zlib::GzipReader.open file ) do |tar|
52
54
  dest = nil
53
55
  tar.each do |entry|
@@ -127,11 +129,13 @@ CHEFDK_APPS = [
127
129
  ].freeze
128
130
 
129
131
  class Updater
130
- attr_reader :app, :ref
132
+ attr_reader :app, :ref, :tarball, :repo
131
133
 
132
134
  def initialize(options)
133
135
  @app = options[:app]
134
136
  @ref = options[:ref]
137
+ @tarball = options[:tarball]
138
+ @repo = options[:repo] || @app.repo
135
139
  end
136
140
 
137
141
  def start
@@ -139,22 +143,34 @@ class Updater
139
143
  abort "#{$0} needs to be run as root user or with sudo"
140
144
  end
141
145
 
142
- ruby("-rpp -e 'pp ENV'")
143
146
  banner("Cleaning #{app} checkout")
144
147
  app_dir.rmtree if app_dir.directory?
145
148
 
146
- git_url = "https://github.com/#{app.repo}/archive/#{ref}.tar.gz"
147
- banner("Extracting #{app} from #{git_url}")
148
- Dir.chdir(chefdk.join("embedded/apps")) do
149
- Tempfile.open('appbundle-updater') do |tempfile|
150
- open(git_url) do |uri|
151
- tempfile.write(uri.read)
149
+ if ( tarball )
150
+ # NOTE: THIS IS DELIBERATELY PURE RUBY USING NO NATIVE GEMS AND ONLY
151
+ # THE RUBY STDLIB BY DESIGN
152
+ git_url = "https://github.com/#{repo}/archive/#{ref}.tar.gz"
153
+ banner("Extracting #{app} from #{git_url}")
154
+ Dir.chdir(chefdk.join("embedded/apps")) do
155
+ Tempfile.open('appbundle-updater') do |tempfile|
156
+ open(git_url) do |uri|
157
+ tempfile.write(uri.read)
158
+ end
159
+ tempfile.close
160
+ extract_tgz(tempfile.path)
152
161
  end
153
- tempfile.close
154
- extract_tgz(tempfile.path)
162
+ base = File.basename repo
163
+ FileUtils.mv "#{base}-#{ref}".gsub(/\//, "-"), "#{app.name}"
164
+ end
165
+ else
166
+ git_url = "https://github.com/#{repo}.git"
167
+ banner("Cloning #{app} from #{git_url}")
168
+ run("git clone #{git_url} #{app_dir}")
169
+
170
+ banner("Checking out #{app} to #{ref}")
171
+ Dir.chdir(app_dir) do
172
+ run("git checkout #{ref}")
155
173
  end
156
- base = File.basename app.repo
157
- FileUtils.mv "#{base}-#{ref}", "#{app.name}"
158
174
  end
159
175
 
160
176
  banner("Installing dependencies")
@@ -200,7 +216,10 @@ class Updater
200
216
  ENV_KEYS.each { |key| ENV["_YOLO_#{key}"] = ENV[key]; ENV.delete(key) }
201
217
  ENV['PATH'] = "#{bin_dir}:#{ENV['_YOLO_PATH']}"
202
218
  puts " running: #{cmd}"
203
- system(cmd) or raise("Command [#{cmd}] failed!")
219
+ output = `#{cmd} 2>&1` #FIXME: bash/zsh-ism, will not work on csh
220
+ unless $?.exited? && $?.exitstatus == 0
221
+ raise("Command [#{cmd}] failed!\n\n---BEGIN OUTPUT--\n#{output}\n---END OUTPUT--\n")
222
+ end
204
223
  ENV_KEYS.each { |key| ENV[key] = ENV.delete("_YOLO_#{key}") }
205
224
  end
206
225
 
@@ -217,6 +236,12 @@ class CLI
217
236
  @options = Hash.new
218
237
  @parser = OptionParser.new { |opts|
219
238
  opts.banner = "Usage: #{$0} PROJECT APP_NAME GIT_REF"
239
+ opts.on("-t", "--[no-]tarball", "Do a tarball download instead of git clone") do |t|
240
+ options[:tarball] = t
241
+ end
242
+ opts.on("-g", "--github REPO", "Github repo (e.g. chef/chef) to pull from") do |g|
243
+ options[:repo] = g
244
+ end
220
245
  opts.on("-h", "--help", "Prints this help") do
221
246
  puts opts
222
247
  exit
@@ -1,3 +1,3 @@
1
1
  module AppbundleUpdater
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appbundle-updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lamont-granquist
@@ -9,21 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-09-25 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'
12
+ dependencies: []
27
13
  description: Updates appbundled apps in Chef's omnibus packages
28
14
  email:
29
15
  - lamont@chef.io
@@ -34,6 +20,8 @@ extra_rdoc_files: []
34
20
  files:
35
21
  - ".gitignore"
36
22
  - ".kitchen.yml"
23
+ - CHANGELOG.md
24
+ - Gemfile
37
25
  - LICENSE.txt
38
26
  - README.md
39
27
  - Rakefile
@@ -69,3 +57,4 @@ summary: Updates appbundled apps in Chef's omnibus packages
69
57
  test_files:
70
58
  - test/integration/bootstrap.ps1
71
59
  - test/integration/bootstrap.sh
60
+ has_rdoc: