excavate 0.1.1 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/Gemfile +0 -2
- data/README.adoc +17 -0
- data/excavate.gemspec +1 -0
- data/lib/excavate/archive.rb +3 -0
- data/lib/excavate/extractors.rb +1 -0
- data/lib/excavate/extractors/cpio_extractor.rb +2 -0
- data/lib/excavate/extractors/xar_extractor.rb +35 -0
- data/lib/excavate/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dedf2dff68fab0c162340e9dc591f1675612d2b6f46335c6fe599ecead65434
|
4
|
+
data.tar.gz: 8d8dd45fbe6ba733d4aa759a3f9f1bb5fc457be3fa0ae176b48bc0d1a417c8ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f6c9a0f90d398afe6ee88c64004aaa5aad6ef50382d095e9df67a2841b3ae7c1af46a2f760718837d10350d2de4b90f727b495c2d8fdd6f32ae9dd290b7de1
|
7
|
+
data.tar.gz: c33b1e35ec3c7478b9236ee705f683b937394f495bb60b57e7602841136e951cbd8eee71ceaabf586548218302e6c495010b7a30020726056d6dd3f47e2bd0ff
|
data/.github/workflows/rspec.yml
CHANGED
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
image:https://img.shields.io/gem/v/excavate.svg["Gem Version", link="https://rubygems.org/gems/excavate"]
|
2
|
+
// image:https://codeclimate.com/github/fontist/expressir/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/fontist/excavate"]
|
3
|
+
image:https://github.com/fontist/excavate/workflows/rspec/badge.svg["Build Status", link="https://github.com/fontist/excavate/actions?workflow=rspec"]
|
4
|
+
|
1
5
|
= Excavate: Ruby gem to extract nested archives
|
2
6
|
|
3
7
|
Extract nested archives with a single command.
|
@@ -65,6 +69,19 @@ $ excavate path/to/archive.cab
|
|
65
69
|
----
|
66
70
|
|
67
71
|
|
72
|
+
== Dependencies
|
73
|
+
|
74
|
+
Depends on
|
75
|
+
https://github.com/fontist/ffi-libarchive-binary[ffi-libarchive-binary] which
|
76
|
+
has the following requirements:
|
77
|
+
|
78
|
+
* zlib
|
79
|
+
* Expat
|
80
|
+
* OpenSSL (for Linux only)
|
81
|
+
|
82
|
+
These dependencies are generally present on all systems.
|
83
|
+
|
84
|
+
|
68
85
|
== Development
|
69
86
|
|
70
87
|
We are following Sandi Metz's Rules for this gem, you can read the
|
data/excavate.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.add_runtime_dependency "arr-pm", "~> 0.0"
|
30
|
+
spec.add_runtime_dependency "ffi-libarchive-binary", "~> 0.0"
|
30
31
|
spec.add_runtime_dependency "libmspack", "~> 0.1"
|
31
32
|
spec.add_runtime_dependency "ruby-ole", "~> 1.0"
|
32
33
|
spec.add_runtime_dependency "rubyzip", "~> 2.3"
|
data/lib/excavate/archive.rb
CHANGED
@@ -7,6 +7,7 @@ module Excavate
|
|
7
7
|
"msi" => Extractors::OleExtractor,
|
8
8
|
"rpm" => Extractors::RpmExtractor,
|
9
9
|
"tar" => Extractors::TarExtractor,
|
10
|
+
"pkg" => Extractors::XarExtractor,
|
10
11
|
"zip" => Extractors::ZipExtractor }.freeze
|
11
12
|
|
12
13
|
def initialize(archive)
|
@@ -104,6 +105,8 @@ module Excavate
|
|
104
105
|
end
|
105
106
|
|
106
107
|
def archive?(file)
|
108
|
+
return false unless File.file?(file)
|
109
|
+
|
107
110
|
ext = normalized_extension(file)
|
108
111
|
TYPES.key?(ext)
|
109
112
|
end
|
data/lib/excavate/extractors.rb
CHANGED
@@ -6,4 +6,5 @@ require_relative "extractors/ole_extractor"
|
|
6
6
|
require_relative "extractors/rpm_extractor"
|
7
7
|
require_relative "extractors/seven_zip_extractor"
|
8
8
|
require_relative "extractors/tar_extractor"
|
9
|
+
require_relative "extractors/xar_extractor"
|
9
10
|
require_relative "extractors/zip_extractor"
|
@@ -21,6 +21,7 @@ module Excavate
|
|
21
21
|
if entry.directory?
|
22
22
|
FileUtils.mkdir_p(path)
|
23
23
|
else
|
24
|
+
FileUtils.mkdir_p(File.dirname(path))
|
24
25
|
File.write(path, file.read, mode: "wb")
|
25
26
|
end
|
26
27
|
end
|
@@ -34,6 +35,7 @@ module Excavate
|
|
34
35
|
if entry.directory?
|
35
36
|
FileUtils.mkdir_p(path)
|
36
37
|
else
|
38
|
+
FileUtils.mkdir_p(File.dirname(path))
|
37
39
|
File.write(path, entry.data, mode: "wb")
|
38
40
|
end
|
39
41
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "ffi-libarchive-binary"
|
2
|
+
|
3
|
+
module Excavate
|
4
|
+
module Extractors
|
5
|
+
class XarExtractor < Extractor
|
6
|
+
def extract(target)
|
7
|
+
Dir.chdir(target) do
|
8
|
+
extract_with_libarchive
|
9
|
+
rename_payload(target)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def extract_with_libarchive
|
16
|
+
flags = ::Archive::EXTRACT_PERM
|
17
|
+
reader = ::Archive::Reader.open_filename(@archive)
|
18
|
+
|
19
|
+
reader.each_entry do |entry|
|
20
|
+
reader.extract(entry, flags.to_i)
|
21
|
+
end
|
22
|
+
|
23
|
+
reader.close
|
24
|
+
end
|
25
|
+
|
26
|
+
def rename_payload(target)
|
27
|
+
Dir.glob(File.join(target, "**", "Payload")).each do |file|
|
28
|
+
next unless File.file?(file)
|
29
|
+
|
30
|
+
FileUtils.mv(file, "#{file}.cpio.gz")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/excavate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excavate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arr-pm
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ffi-libarchive-binary
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: libmspack
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,6 +141,7 @@ files:
|
|
127
141
|
- lib/excavate/extractors/rpm_extractor.rb
|
128
142
|
- lib/excavate/extractors/seven_zip_extractor.rb
|
129
143
|
- lib/excavate/extractors/tar_extractor.rb
|
144
|
+
- lib/excavate/extractors/xar_extractor.rb
|
130
145
|
- lib/excavate/extractors/zip_extractor.rb
|
131
146
|
- lib/excavate/file_magic.rb
|
132
147
|
- lib/excavate/utils.rb
|