appbundle-updater 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c86a316a3b0b32c0ad3faae9e906d40b77a998bb
4
- data.tar.gz: cd63ea96c0b3c7ed571fa6c663803b42927410c9
3
+ metadata.gz: 331e2d44703abdf38c526bc815036066fcbc08e9
4
+ data.tar.gz: 8a9bfc9bb4feaa65e098dc8bb1caab03ebf935f5
5
5
  SHA512:
6
- metadata.gz: 9e7c82d24cc5cb92ba88131a114d3a017c6274c8e6259d8de18f5f2df39aeda51af311a7c70f24c5b438a08c756842a854be53ede242e94720b44b6e7bfb408c
7
- data.tar.gz: 5b45da84a4b848f4fa9c078e9179cca90676ae45b3eed18294870a0a536b4b0d43fd79a484c73c928f9289003e833df249c2b09a8dc04cb1509fa30c3b7fdd73
6
+ metadata.gz: 49bb29d6a177ee723851a78fb0c0c0b67d9dc29901a576dc7a07f4210d5f1289d32122ba1f55b1e5b1b1ab390145a5b0651b672d71d9176d8b9d0b18f8be74eb
7
+ data.tar.gz: 5c6c74485430d83b331e83d2df0b02b82fd5e6a69ee8667bc621b75a0a85bee6971d0fdad1591844c65eaf02d950b7425a53efcd201731c8541c6c1dcd94728d
@@ -19,6 +19,11 @@
19
19
 
20
20
  require "pathname"
21
21
  require "optparse"
22
+ require "open-uri"
23
+ require "fileutils"
24
+ require "rubygems/package"
25
+ require "zlib"
26
+ require "tempfile"
22
27
 
23
28
  # FIXME: move to helpers mixin
24
29
 
@@ -38,7 +43,39 @@ def bin_dir
38
43
  chefdk.join("embedded/bin")
39
44
  end
40
45
 
41
- App = Struct.new(:name, :url, :bundle_without, :install_command) do
46
+ TAR_LONGLINK = '././@LongLink'
47
+
48
+ # pure ruby `tar xzf`, handles longlinks and directories ending in '/'
49
+ # (http://stackoverflow.com/a/31310593/506908)
50
+ def extract_tgz(file, destination = '.')
51
+ Gem::Package::TarReader.new( Zlib::GzipReader.open file ) do |tar|
52
+ dest = nil
53
+ tar.each do |entry|
54
+ if entry.full_name == TAR_LONGLINK
55
+ dest = File.join destination, entry.read.strip
56
+ next
57
+ end
58
+ dest ||= File.join destination, entry.full_name
59
+ if entry.directory? || (entry.header.typeflag == '' && entry.full_name.end_with?('/'))
60
+ File.delete dest if File.file? dest
61
+ FileUtils.mkdir_p dest, :mode => entry.header.mode, :verbose => false
62
+ elsif entry.file? || (entry.header.typeflag == '' && !entry.full_name.end_with?('/'))
63
+ FileUtils.rm_rf dest if File.directory? dest
64
+ File.open dest, "wb" do |f|
65
+ f.print entry.read
66
+ end
67
+ FileUtils.chmod entry.header.mode, dest, :verbose => false
68
+ elsif entry.header.typeflag == '2' #Symlink!
69
+ File.symlink entry.header.linkname, dest
70
+ else
71
+ puts "Unkown tar entry: #{entry.full_name} type: #{entry.header.typeflag}."
72
+ end
73
+ dest = nil
74
+ end
75
+ end
76
+ end
77
+
78
+ App = Struct.new(:name, :repo, :bundle_without, :install_command) do
42
79
  def to_s
43
80
  name
44
81
  end
@@ -47,43 +84,43 @@ end
47
84
  CHEFDK_APPS = [
48
85
  App.new(
49
86
  "berkshelf",
50
- "https://github.com/berkshelf/berkshelf.git",
87
+ "berkshelf/berkshelf",
51
88
  "guard test",
52
89
  "#{bin_dir.join("rake")} install",
53
90
  ),
54
91
  App.new(
55
92
  "chef",
56
- "https://github.com/chef/chef.git",
93
+ "chef/chef",
57
94
  "server docgen test development",
58
95
  "#{bin_dir.join("rake")} install",
59
96
  ),
60
97
  App.new(
61
98
  "chef-dk",
62
- "https://github.com/chef/chef-dk.git",
99
+ "chef/chef-dk",
63
100
  "dev test development",
64
101
  "#{bin_dir.join("rake")} install",
65
102
  ),
66
103
  App.new(
67
104
  "chef-vault",
68
- "https://github.com/Nordstrom/chef-vault.git",
105
+ "Nordstrom/chef-vault",
69
106
  "test",
70
107
  "#{bin_dir.join("rake")} install",
71
108
  ),
72
109
  App.new(
73
110
  "foodcritic",
74
- "https://github.com/acrmp/foodcritic.git",
111
+ "acrmp/foodcritic",
75
112
  nil,
76
113
  "#{bin_dir.join("rake")} install",
77
114
  ),
78
115
  App.new(
79
116
  "ohai",
80
- "https://github.com/chef/ohai.git",
117
+ "chef/ohai",
81
118
  "test development",
82
119
  "#{bin_dir.join("rake")} install",
83
120
  ),
84
121
  App.new(
85
122
  "test-kitchen",
86
- "https://github.com/test-kitchen/test-kitchen.git",
123
+ "test-kitchen/test-kitchen",
87
124
  "guard test",
88
125
  "#{bin_dir.join("rake")} install",
89
126
  )
@@ -106,12 +143,18 @@ class Updater
106
143
  banner("Cleaning #{app} checkout")
107
144
  app_dir.rmtree if app_dir.directory?
108
145
 
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}")
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)
152
+ end
153
+ tempfile.close
154
+ extract_tgz(tempfile.path)
155
+ end
156
+ base = File.basename app.repo
157
+ FileUtils.mv "#{base}-#{ref}", "#{app.name}"
115
158
  end
116
159
 
117
160
  banner("Installing dependencies")
@@ -1,3 +1,3 @@
1
1
  module AppbundleUpdater
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appbundle-updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lamont-granquist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake