mixlib-archive 0.4.4 → 0.4.5

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
  SHA256:
3
- metadata.gz: e8685df8b7ce9e5ce9534e3475a5ecb35a01fd05f1491aad6cb096940c82bc37
4
- data.tar.gz: 7baa4eee34d8d9c711aa88b790f516d76834ea608bf9f271f7a9cc66dd8c76cb
3
+ metadata.gz: fc6683cb1ac7178e4fb261923f6a5c1849e2e8a73b7ab95afbb28af5e30b7496
4
+ data.tar.gz: fde910fa8c62984f215bbea2b0dabc97f039d56268fc2de5b75a52b5541170a7
5
5
  SHA512:
6
- metadata.gz: e4f1224ad12d171a576482cdfcdc886cf6b52bd84f61a5acab5017e609db9effb7b2ad0fcde959e8be8ea3fb5ad2993c915d1c6a40dd99d7a1f8131675e32a5b
7
- data.tar.gz: ecb2bc04a880797cc6fcf3b91e9be5b53c466ba2489634fff9b70c41e09a8b94cfe4c70f1230be7a70816f0d8003deb78b83c8620444883e223850e2135e7ab8
6
+ metadata.gz: d515dcc2ae6b37114e3abb384af186eab308317d5356782e6b4e48a25fa91592f4a8b6eaa4378191202ebce96d3f9d2ee853d43debd224d41ec79c20b539f3e0
7
+ data.tar.gz: 515ee38251f667317dfb88d3ea4df349d8c5d640508f534e7c71628b1d3654e9e406a6a8b661dae2cd7e488eb11ec0792babb18a73d64278aa99d30649a58ab0
data/CHANGELOG.md CHANGED
@@ -1,17 +1,18 @@
1
1
  <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
2
2
  # Change Log
3
3
 
4
- <!-- latest_release 0.4.4 -->
5
- ## [v0.4.4](https://github.com/chef/mixlib-archive/tree/v0.4.4) (2018-04-30)
4
+ <!-- latest_release 0.4.5 -->
5
+ ## [v0.4.5](https://github.com/chef/mixlib-archive/tree/v0.4.5) (2018-05-04)
6
6
 
7
7
  #### Merged Pull Requests
8
- - Fix up creating archives [#18](https://github.com/chef/mixlib-archive/pull/18) ([thommay](https://github.com/thommay))
8
+ - Fix up writing tar archives with the rubygems tar [#19](https://github.com/chef/mixlib-archive/pull/19) ([thommay](https://github.com/thommay))
9
9
  <!-- latest_release -->
10
10
 
11
11
  <!-- release_rollup since=0.4.2 -->
12
12
  ### Changes not yet released to rubygems.org
13
13
 
14
14
  #### Merged Pull Requests
15
+ - Fix up writing tar archives with the rubygems tar [#19](https://github.com/chef/mixlib-archive/pull/19) ([thommay](https://github.com/thommay)) <!-- 0.4.5 -->
15
16
  - Fix up creating archives [#18](https://github.com/chef/mixlib-archive/pull/18) ([thommay](https://github.com/thommay)) <!-- 0.4.4 -->
16
17
  <!-- release_rollup -->
17
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.5
@@ -5,6 +5,8 @@ require "find"
5
5
 
6
6
  module Mixlib
7
7
  class Archive
8
+ class TarError < StandardError; end
9
+
8
10
  attr_reader :archiver
9
11
  alias_method :extractor, :archiver
10
12
 
@@ -34,7 +34,7 @@ module Mixlib
34
34
  Mixlib::Archive::Log.warn "ignoring entry #{entry.full_name}"
35
35
  next
36
36
  end
37
- dest ||= File.join(destination, entry.full_name)
37
+ dest ||= File.expand_path(File.join(destination, entry.full_name))
38
38
  parent = File.dirname(dest)
39
39
  FileUtils.mkdir_p(parent)
40
40
 
@@ -76,11 +76,18 @@ module Mixlib
76
76
  Gem::Package::TarWriter.new(target) do |tar|
77
77
  files.each do |fn|
78
78
  mode = File.stat(fn).mode
79
- file = File.open(fn, "rb")
80
- tar.add_file(fn, mode) do |io|
81
- io.write(file)
79
+ if File.symlink?(fn)
80
+ target = File.readlink(fn)
81
+ tar.add_symlink(fn, target, mode)
82
+ elsif File.directory?(fn)
83
+ tar.mkdir(fn, mode)
84
+ elsif File.file?(fn)
85
+ file = File.open(fn, "rb")
86
+ tar.add_file(fn, mode) do |io|
87
+ io.write(file.read)
88
+ end
89
+ file.close
82
90
  end
83
- file.close
84
91
  end
85
92
  end
86
93
 
@@ -110,6 +117,14 @@ module Mixlib
110
117
  IO.binread(path, 2) == [0x1F, 0x8B].pack("C*")
111
118
  end
112
119
 
120
+ # tar's magic is at byte 257 and is "ustar\0"
121
+ def is_tar_archive?(io)
122
+ io.rewind
123
+ magic = io.read[257..262]
124
+ io.rewind
125
+ magic == "ustar\0"
126
+ end
127
+
113
128
  def reader(&block)
114
129
  raw = File.open(archive, "rb")
115
130
 
@@ -120,6 +135,8 @@ module Mixlib
120
135
  raw
121
136
  end
122
137
 
138
+ raise Mixlib::Archive::TarError, "Unrecognized archive format" unless is_tar_archive?(file)
139
+
123
140
  Gem::Package::TarReader.new(file, &block)
124
141
  ensure
125
142
  if file
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Archive
3
- VERSION = "0.4.4"
3
+ VERSION = "0.4.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-02 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake