mixlib-archive 0.4.2 → 0.4.4

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
  SHA256:
3
- metadata.gz: e333d2af05598e7404ffdd49f2333d5edf345e7483aa7d03270da16e10001e52
4
- data.tar.gz: 26d5a8f15aef2788da1ce44636282e736172d6bd579b532e2c9efcb39c52e098
3
+ metadata.gz: e8685df8b7ce9e5ce9534e3475a5ecb35a01fd05f1491aad6cb096940c82bc37
4
+ data.tar.gz: 7baa4eee34d8d9c711aa88b790f516d76834ea608bf9f271f7a9cc66dd8c76cb
5
5
  SHA512:
6
- metadata.gz: d08e1d6b5e38ccf53381f412ca1d1ffb400c6262f74fc972b5f798f52abc2136f7317f2ee99b9cdb4de6ee3eb7f5358b417897d194fe315ae7fcbcba76249ee8
7
- data.tar.gz: 878e846762cae3ca0d21dcb9dc0975ad35c40705fa3cd29accf0d91b9b3eb15a65832be0ee95e0a6ec1379b9db1b6b56c5ed066db4e98cef94b9e15c6819c750
6
+ metadata.gz: e4f1224ad12d171a576482cdfcdc886cf6b52bd84f61a5acab5017e609db9effb7b2ad0fcde959e8be8ea3fb5ad2993c915d1c6a40dd99d7a1f8131675e32a5b
7
+ data.tar.gz: ecb2bc04a880797cc6fcf3b91e9be5b53c466ba2489634fff9b70c41e09a8b94cfe4c70f1230be7a70816f0d8003deb78b83c8620444883e223850e2135e7ab8
data/CHANGELOG.md CHANGED
@@ -1,10 +1,18 @@
1
1
  <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
2
2
  # Change Log
3
3
 
4
- <!-- latest_release -->
4
+ <!-- latest_release 0.4.4 -->
5
+ ## [v0.4.4](https://github.com/chef/mixlib-archive/tree/v0.4.4) (2018-04-30)
6
+
7
+ #### Merged Pull Requests
8
+ - Fix up creating archives [#18](https://github.com/chef/mixlib-archive/pull/18) ([thommay](https://github.com/thommay))
5
9
  <!-- latest_release -->
6
10
 
7
- <!-- release_rollup -->
11
+ <!-- release_rollup since=0.4.2 -->
12
+ ### Changes not yet released to rubygems.org
13
+
14
+ #### Merged Pull Requests
15
+ - Fix up creating archives [#18](https://github.com/chef/mixlib-archive/pull/18) ([thommay](https://github.com/thommay)) <!-- 0.4.4 -->
8
16
  <!-- release_rollup -->
9
17
 
10
18
  <!-- latest_stable_release -->
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
@@ -1,12 +1,18 @@
1
1
  require "mixlib/archive/tar"
2
2
  require "mixlib/archive/version"
3
3
  require "mixlib/log"
4
+ require "find"
4
5
 
5
6
  module Mixlib
6
7
  class Archive
7
8
  attr_reader :archiver
8
9
  alias_method :extractor, :archiver
9
10
 
11
+ def self.archive_directory(path, archive, gzip: false, format: :tar, compression: :none)
12
+ targets = Find.find(path).collect { |fn| fn }
13
+ new(archive).create(targets, gzip: gzip)
14
+ end
15
+
10
16
  def initialize(archive, empty: false)
11
17
  @empty = empty
12
18
 
@@ -19,6 +19,7 @@ module Mixlib
19
19
  def extract(destination, perms: true, ignore: [])
20
20
  ignore_re = Regexp.union(ignore)
21
21
  flags = perms ? ::Archive::EXTRACT_PERM : nil
22
+ FileUtils.mkdir_p(destination)
22
23
  Dir.chdir(destination) do
23
24
  reader = ::Archive::Reader.open_filename(@archive)
24
25
 
@@ -47,17 +48,38 @@ module Mixlib
47
48
  ::Archive.write_open_filename(archive, compression, format) do |tar|
48
49
  files.each do |fn|
49
50
  tar.new_entry do |entry|
51
+ content = nil
50
52
  entry.pathname = fn
51
- entry.copy_stat(fn)
52
- tar.write_header(entry)
53
+ stat = File.lstat(fn)
53
54
  if File.file?(fn)
54
55
  content = File.read(fn)
55
- tar.write_data(content)
56
+ entry.size = content.size
56
57
  end
58
+ entry.mode = stat.mode
59
+ entry.filetype = resolve_type(stat.ftype)
60
+ entry.atime = stat.atime
61
+ entry.mtime = stat.mtime
62
+ entry.symlink = File.readlink(fn) if File.symlink?(fn)
63
+ tar.write_header(entry)
64
+
65
+ tar.write_data(content) unless content.nil?
57
66
  end
58
67
  end
59
68
  end
60
69
  end
70
+
71
+ def resolve_type(type)
72
+ case type
73
+ when "characterSpecial"
74
+ ::Archive::Entry::CHARACTER_SPECIAL
75
+ when "blockSpecial"
76
+ ::Archive::Entry::BLOCK_SPECIAL
77
+ when "link"
78
+ ::Archive::Entry::SYMBOLIC_LINK
79
+ else
80
+ ::Archive::Entry.const_get(type.upcase)
81
+ end
82
+ end
61
83
  end
62
84
  end
63
85
  end
@@ -1,4 +1,5 @@
1
1
  require "rubygems/package"
2
+ require "tempfile"
2
3
  require "zlib"
3
4
 
4
5
  module Mixlib
@@ -85,10 +86,14 @@ module Mixlib
85
86
 
86
87
  target.close
87
88
  if gzip
88
- Zlib::GzipWriter.open(archive) do |gz|
89
+ Zlib::GzipWriter.open(archive, Zlib::BEST_COMPRESSION) do |gz|
89
90
  gz.mtime = File.mtime(target.path)
90
91
  gz.orig_name = File.basename(archive)
91
- gz.write IO.binread(target.path)
92
+ File.open(target.path) do |file|
93
+ while (chunk = file.read(16 * 1024))
94
+ gz.write(chunk)
95
+ end
96
+ end
92
97
  end
93
98
  else
94
99
  FileUtils.mv(target.path, archive)
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Archive
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.4"
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.2
4
+ version: 0.4.4
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-04-25 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake