archive 0.0.3 → 0.0.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
  SHA1:
3
- metadata.gz: eea58532ddc940adf915b551058677861c5c6f1f
4
- data.tar.gz: c726a2100a1da44625735183dab2ebc5ede03281
3
+ metadata.gz: 5be52d8c272d2e8546d7c34358ede9900cc0c0e4
4
+ data.tar.gz: 9f8ac042c7698d9f9303f625631578fc05778146
5
5
  SHA512:
6
- metadata.gz: 46db2088dd9999ab72eacb831f09ddd0114a4eb8b93b12436958355d1f15ae77a03f4b8c6cee6a2570b59d3897b50f49bf86950d0e7e3d04ab3ee70c87e93b99
7
- data.tar.gz: 3f7c3c403a87b5a2316367a57f65b32308130250089893953a840ae1f23398a3a0cd375a4d244e79a274add1622df2e770ae29bba15692a78015fdf53a112119
6
+ metadata.gz: 98046ff9e54c3895f952a3b6ada2074e87dd511258540afdd441d5cb4fa7cedc40c10d709b5d107a2050c5117bc8e4c55204714af9e24136e06a904c5a3d2664
7
+ data.tar.gz: 87a51152ffe72b9faa5fdb266dbee868d418759724b16c7751368b678887e05a6b329435623c1395fcf09446a12e193440c582e91b278866919894e64d2db50a
@@ -1,3 +1,7 @@
1
+ # 0.0.4 (10/10/2013)
2
+ * Several fixes around hardlinks.
3
+ * Better support for OS X! Will use homebrew or macports' libarchive if
4
+ available so you can use a recent version.
1
5
  # 0.0.3 (09/15/2013)
2
6
  * ISO support on linux systems -- Thanks David Lutterkort!
3
7
  # 0.0.2 (05/02/2013)
data/README.md CHANGED
@@ -9,7 +9,7 @@ common subset of archive types:
9
9
  * gzipped
10
10
  * bzip2'd
11
11
  * zip (uncompressed, binary-only)
12
- * iso9660 (read-only, and not on OS X)
12
+ * iso9660 (read-only)
13
13
 
14
14
  ## Installation
15
15
 
@@ -66,7 +66,7 @@ Tests require bundler. Run `bundle exec rake test` to run the tests.
66
66
 
67
67
  We have verified that archive works as intended on these platforms:
68
68
 
69
- * Mac OS X 10.8, 10.9 (Except iso format)
69
+ * Mac OS X 10.8, 10.9 (see notes on ISO support)
70
70
  * Ubuntu Linux 12.04 LTS
71
71
  * FreeBSD 9
72
72
 
@@ -76,18 +76,23 @@ And these Rubies:
76
76
  * 2.0.0
77
77
  * JRuby 1.7 with Java 7
78
78
 
79
- It does not work on these platforms:
79
+ Notes about the following platforms:
80
80
 
81
- * On OS X iso formats are unsupported. The version of libarchive distributed
82
- with both 10.8 and 10.9 seems to have trouble with all iso derivatives.
83
- Patches welcome for fixes!
81
+ * On OS X iso formats are only supported if you have a 3.x version of
82
+ libarchive, which OS X doesn't ship with. The code makes an attempt to pick
83
+ the latest homebrew or macports libarchive, so if you use that packaging
84
+ system, you can `brew install libarchive` or `port install libarchive` and it
85
+ will "just work".
86
+ * Alternatively, you can set `LIBARCHIVE_PATH` in your environment to your
87
+ own build of libarchive 3.x which will also resolve this issue.
84
88
 
85
89
  * SmartOS "base64 1.9.1". The version of libarchive they distribute via pkgsrc
86
90
  is broken, see this URL:
87
91
 
88
92
  http://freebsd.1045724.n5.nabble.com/Extracting-tgz-file-Attempt-to-write-to-an-empty-file-td3910927.html
89
93
 
90
- Regardless, installing a newer libarchive by hand will likely fix this issue.
94
+ Regardless, installing a newer libarchive by hand and setting
95
+ `LIBARCHIVE_PATH` in your environment will likely fix this issue.
91
96
 
92
97
  Please let us know if your operating system isn't working! It'll likely
93
98
  complain about a part of a structure in a syscall called `stat` which varies
@@ -75,17 +75,24 @@ module Archive # :nodoc:
75
75
  entry_pointer = @entry.get_pointer(0)
76
76
 
77
77
  full_path = File.join(@dir, LibArchive.archive_entry_pathname(entry_pointer))
78
- LibArchive.archive_entry_set_pathname(entry_pointer, full_path)
79
-
80
- # TODO return value maybe?
78
+ LibArchive.archive_entry_set_pathname(entry_pointer, File.expand_path(full_path))
81
79
  puts LibArchive.archive_entry_pathname(entry_pointer) if verbose
82
80
 
83
- if ((result = LibArchive.archive_write_header(@out, entry_pointer)) != LibArchive::ARCHIVE_OK)
84
- raise LibArchive.archive_error_string(@out)
81
+ if hardlink_path = LibArchive.archive_entry_hardlink(entry_pointer)
82
+ begin
83
+ File.link(File.expand_path(hardlink_path, @dir), full_path)
84
+ rescue Errno::EEXIST
85
+ File.unlink(full_path)
86
+ retry
87
+ end
88
+ else
89
+ if ((result = LibArchive.archive_write_header(@out, entry_pointer)) != LibArchive::ARCHIVE_OK)
90
+ raise LibArchive.archive_error_string(@out)
91
+ end
92
+
93
+ unpack_loop
85
94
  end
86
95
 
87
- unpack_loop
88
-
89
96
  LibArchive.archive_write_finish_entry(@out)
90
97
  end
91
98
  end
@@ -78,6 +78,9 @@ module Archive # :nodoc:
78
78
  #--
79
79
  # this is necessary to pass rdoc's coverage tests
80
80
  #++
81
+ module RbConfig # :nodoc:
82
+ end
83
+
81
84
  module FFI # :nodoc:
82
85
  module Library # :nodoc:
83
86
  end
@@ -97,7 +100,7 @@ module Archive # :nodoc:
97
100
  def self.stat(*args) # :nodoc:
98
101
  stat64(*args)
99
102
  end
100
- elsif RbConfig::CONFIG['host_os'] =~ /linux/
103
+ elsif ::RbConfig::CONFIG['host_os'] =~ /linux/
101
104
  attach_function :__xstat, [:int, :string, :pointer], :int
102
105
  def self.stat(*args) # :nodoc:
103
106
  __xstat(0, *args)
@@ -106,7 +109,22 @@ module Archive # :nodoc:
106
109
  attach_function :stat, [:string, :pointer], :int
107
110
  end
108
111
 
109
- ffi_lib 'archive'
112
+
113
+ if ENV["LIBARCHIVE_PATH"]
114
+ ffi_lib ENV["LIBARCHIVE_PATH"]
115
+ elsif ::FFI::Platform.mac? and File.directory?('/usr/local/Cellar/libarchive')
116
+ latest = Dir['/usr/local/Cellar/libarchive/*'].
117
+ select { |x| File.directory?(x) }.
118
+ map { |x| File.basename(x) }.
119
+ sort.
120
+ last
121
+
122
+ ffi_lib "/usr/local/Cellar/libarchive/#{latest}/lib/libarchive.dylib"
123
+ elsif ::FFI::Platform.mac? and File.exist?('/opt/local/lib/libarchive.dylib')
124
+ ffi_lib '/opt/local/lib/libarchive.dylib'
125
+ else
126
+ ffi_lib 'archive'
127
+ end
110
128
 
111
129
  ARCHIVE_OK = 0 # :nodoc:
112
130
  ARCHIVE_EOF = 1 # :nodoc:
@@ -128,18 +146,12 @@ module Archive # :nodoc:
128
146
  attach_function :archive_read_support_format_tar, [:pointer], :void
129
147
  attach_function :archive_read_support_format_gnutar, [:pointer], :void
130
148
  attach_function :archive_read_support_format_zip, [:pointer], :void
131
-
132
- unless ::FFI::Platform.mac?
133
- attach_function :archive_read_support_format_iso9660, [:pointer], :void
134
- end
149
+ attach_function :archive_read_support_format_iso9660, [:pointer], :void
135
150
 
136
151
  def self.enable_input_formats(arg) # :nodoc:
137
152
  archive_read_support_format_gnutar(arg)
138
153
  archive_read_support_format_zip(arg)
139
- archive_read_support_format_zip(arg)
140
- unless ::FFI::Platform.mac?
141
- archive_read_support_format_iso9660(arg)
142
- end
154
+ archive_read_support_format_iso9660(arg)
143
155
  enable_input_compression(arg)
144
156
  end
145
157
 
@@ -225,6 +237,7 @@ module Archive # :nodoc:
225
237
  attach_function :archive_write_data, [:pointer, :pointer, :size_t], :void
226
238
 
227
239
  attach_function :archive_entry_pathname, [:pointer], :string
240
+ attach_function :archive_entry_hardlink, [:pointer], :string
228
241
  attach_function :archive_entry_set_pathname, [:pointer, :string], :void
229
242
  end
230
243
  end
@@ -1,3 +1,3 @@
1
1
  module Archive
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Hollensbe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-15 00:00:00.000000000 Z
11
+ date: 2013-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.0.6
179
+ rubygems_version: 2.1.8
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Simple library to manage tar and zip archives with libarchive and FFI