unpack_macbinary 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE +15 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/unpack_macbinary +85 -0
- data/lib/macbinary_unpack.rb +35 -0
- data/lib/unpack_macbinary.rb +35 -0
- data/lib/unpack_macbinary/version.rb +3 -0
- data/unpack_macbinary.gemspec +24 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8f18f006fd2f33eec88dd43ee62e86261964384d
|
|
4
|
+
data.tar.gz: 55318a7e66a6e465adf3ec9ce44c0e84290b49c7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: eb67f1f07f167f93049c0d4e8f2a677f84c8153444889a3c31dd5d2e5fc26e73c5388e666a66b8322fe066f5a23c2055741f5b90bf35e554a7fe221603a4f603
|
|
7
|
+
data.tar.gz: 95ee4be1521c839e798a1482cd8c2f475210d5d4709bcf6c42fd21bb58b15f8b0ca17388a0def310d9ca691017db6247aef87a7da39ab66da3e32d210fbc9027
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at mistydemeo@gmail.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
KINDEST PUBLIC LICENSE
|
|
2
|
+
Version 1, September 2015
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2015 Misty De Meo <mistydemeo@gmail.com>
|
|
5
|
+
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
7
|
+
copies of this license document, and changing it is allowed as long
|
|
8
|
+
as the name is changed.
|
|
9
|
+
|
|
10
|
+
KINDEST PUBLIC LICENSE
|
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
12
|
+
|
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
14
|
+
1. At your option, you may perform an act of kindness for a stranger.
|
|
15
|
+
This is encouraged, but not a condition of using this software.
|
data/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# unpack_macbinary
|
|
2
|
+
|
|
3
|
+
This tool provides a helper to convert files from MacBinary format into native Mac HFS+ files.
|
|
4
|
+
|
|
5
|
+
Mac OS's HFS and HFS+ filesystems has a concept of file "forks"; each file has both a *data fork*, which contains arbitrary binary data like on other filesystems, and a *resource fork*, which contains structured data in a Mac OS-specific format.
|
|
6
|
+
The [MacBinary format](https://en.wikipedia.org/wiki/MacBinary) is a format designed to bundle files with both data and resource forks in a format which can be losslessly transferred to other filesystems; it was most widely used in the 1990s.
|
|
7
|
+
|
|
8
|
+
However, if a Mac user should *receive* a MacBinary file, it's not straightforward to convert that file back into a native Mac OS file.
|
|
9
|
+
This tool simplifies the process of turning a MacBinary file into a native Mac file by wrapping a tool from the [macutils](http://ibiblio.org/pub/linux/utils/compress/macutils.tar.gz) package.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
To run this, you'll need macutils to be installed.
|
|
14
|
+
If you use Homebrew, you can:
|
|
15
|
+
|
|
16
|
+
$ brew install mistydemeo/formulae/macutils
|
|
17
|
+
|
|
18
|
+
Then install the gem using:
|
|
19
|
+
|
|
20
|
+
$ gem install unpack_macbinary
|
|
21
|
+
|
|
22
|
+
Note that, because this produces native Mac OS files, you can only use this tool on OS X.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Just provide this tool the names of the files to unpack:
|
|
27
|
+
|
|
28
|
+
$ unpack_macbinary first.bin second.bin third.bin
|
|
29
|
+
|
|
30
|
+
The MacBinary files should all have filenames ending in ".bin".
|
|
31
|
+
The processed output file will be named the same as the input file, except without the file extension.
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
36
|
+
|
|
37
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/unpack_macbinary. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
unpack_macbinary is licensed using the Kindest Public License.
|
|
46
|
+
See LICENSE for usage details.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "unpack_macbinary"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
include FileUtils
|
|
6
|
+
|
|
7
|
+
require "slop"
|
|
8
|
+
|
|
9
|
+
require "unpack_macbinary"
|
|
10
|
+
|
|
11
|
+
def which(cmd, path = ENV["PATH"])
|
|
12
|
+
path.split(File::PATH_SEPARATOR).each do |p|
|
|
13
|
+
begin
|
|
14
|
+
pcmd = File.expand_path(cmd, p)
|
|
15
|
+
rescue ArgumentError
|
|
16
|
+
# File.expand_path will raise an ArgumentError if the path is malformed.
|
|
17
|
+
# See https://github.com/Homebrew/homebrew/issues/32789
|
|
18
|
+
next
|
|
19
|
+
end
|
|
20
|
+
return pcmd if File.file?(pcmd) && File.executable?(pcmd)
|
|
21
|
+
end
|
|
22
|
+
nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def unpack macbinary
|
|
26
|
+
output_files = MacBinary.unpack macbinary
|
|
27
|
+
|
|
28
|
+
output = File.basename(macbinary, ".bin")
|
|
29
|
+
|
|
30
|
+
# Data fork forms the basis of the output file.
|
|
31
|
+
mv output_files[:data], output
|
|
32
|
+
# Copy the resource fork into it
|
|
33
|
+
begin
|
|
34
|
+
MacBinary.add_resource_fork output, output_files[:rsrc]
|
|
35
|
+
rescue
|
|
36
|
+
# Remove the data fork if something goes wrong
|
|
37
|
+
rm output
|
|
38
|
+
raise
|
|
39
|
+
ensure
|
|
40
|
+
# Always make sure the temporary resource forks are cleaned up.
|
|
41
|
+
rm [output_files[:info], output_files[:rsrc]]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if self.to_s == "main"
|
|
46
|
+
opts = Slop.parse do |o|
|
|
47
|
+
o.on "-h", "--help", "Display this message" do
|
|
48
|
+
puts o
|
|
49
|
+
end
|
|
50
|
+
o.on "-v", "--version", "Print the version" do
|
|
51
|
+
puts MacBinary::VERSION
|
|
52
|
+
exit
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if !which "macunpack"
|
|
57
|
+
$stderr.puts "macunpack is not installed!"
|
|
58
|
+
exit 1
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if opts.arguments.empty?
|
|
62
|
+
$stderr.puts "No files specified!"
|
|
63
|
+
exit 1
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
missing_files = opts.arguments.select {|f| !File.exist? f}
|
|
67
|
+
if !missing_files.empty?
|
|
68
|
+
$stderr.puts "The following input files cannot be found: #{missing_files.join(" ")}"
|
|
69
|
+
exit 1
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
success = true
|
|
73
|
+
|
|
74
|
+
opts.arguments.each do |macbinary|
|
|
75
|
+
puts "Processing #{macbinary}..."
|
|
76
|
+
begin
|
|
77
|
+
unpack macbinary
|
|
78
|
+
rescue MacBinary::MacunpackException
|
|
79
|
+
$stderr.puts "macunpack failed while processing file \"#{macbinary}\"!"
|
|
80
|
+
success = false
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
exit success ? 0 : 1
|
|
85
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "unpack_macbinary/version"
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
module MacBinary
|
|
6
|
+
class MacunpackException < StandardError; end
|
|
7
|
+
|
|
8
|
+
def self.unpack macbinary, target_dir=Dir.pwd
|
|
9
|
+
# macunpack always unpacks into the working directory
|
|
10
|
+
cd target_dir do
|
|
11
|
+
# macunpack will sanitize the source filename if it contains spaces
|
|
12
|
+
sanitized = File.basename(macbinary.gsub(" ", "_"), ".bin")
|
|
13
|
+
|
|
14
|
+
# -3 extracts data and resource forks even if they're empty
|
|
15
|
+
if !system "macunpack", "-3", macbinary
|
|
16
|
+
raise MacunpackException, "macunpack returned non-zero exit status"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
output_files = {
|
|
20
|
+
data: "#{target_dir}/#{sanitized}.data",
|
|
21
|
+
info: "#{target_dir}/#{sanitized}.info",
|
|
22
|
+
rsrc: "#{target_dir}/#{sanitized}.rsrc"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
raise MacunpackException, "macunpack did not generate a data fork" unless File.exist? output_files[:data]
|
|
26
|
+
raise MacunpackException, "macunpack did not generate a data fork" unless File.exist? output_files[:rsrc]
|
|
27
|
+
|
|
28
|
+
return output_files
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.add_resource_fork data_fork, resource_fork
|
|
33
|
+
FileUtils.cp resource_fork, "#{data_fork}/..namedfork/rsrc"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "unpack_macbinary/version"
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
module MacBinary
|
|
6
|
+
class MacunpackException < StandardError; end
|
|
7
|
+
|
|
8
|
+
def self.unpack macbinary, target_dir=Dir.pwd
|
|
9
|
+
# macunpack always unpacks into the working directory
|
|
10
|
+
cd target_dir do
|
|
11
|
+
# macunpack will sanitize the source filename if it contains spaces
|
|
12
|
+
sanitized = File.basename(macbinary.gsub(" ", "_"), ".bin")
|
|
13
|
+
|
|
14
|
+
# -3 extracts data and resource forks even if they're empty
|
|
15
|
+
if !system "macunpack", "-3", macbinary
|
|
16
|
+
raise MacunpackException, "macunpack returned non-zero exit status"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
output_files = {
|
|
20
|
+
data: "#{target_dir}/#{sanitized}.data",
|
|
21
|
+
info: "#{target_dir}/#{sanitized}.info",
|
|
22
|
+
rsrc: "#{target_dir}/#{sanitized}.rsrc"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
raise MacunpackException, "macunpack did not generate a data fork" unless File.exist? output_files[:data]
|
|
26
|
+
raise MacunpackException, "macunpack did not generate a data fork" unless File.exist? output_files[:rsrc]
|
|
27
|
+
|
|
28
|
+
return output_files
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.add_resource_fork data_fork, resource_fork
|
|
33
|
+
FileUtils.cp resource_fork, "#{data_fork}/..namedfork/rsrc"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'unpack_macbinary/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "unpack_macbinary"
|
|
8
|
+
spec.version = MacBinary::VERSION
|
|
9
|
+
spec.authors = ["Misty De Meo"]
|
|
10
|
+
spec.email = ["mistydemeo@gmail.com"]
|
|
11
|
+
spec.licenses = ["kindest"]
|
|
12
|
+
|
|
13
|
+
spec.summary = %q{Tool to unpack MacBinary files into native Mac data/resource fork files.}
|
|
14
|
+
spec.homepage = "https://github.com/mistydemeo/unpack_macbinary"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
+
spec.bindir = "exe"
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_dependency "slop", "~> 4.2"
|
|
24
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: unpack_macbinary
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Misty De Meo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: slop
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '4.2'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '4.2'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- mistydemeo@gmail.com
|
|
58
|
+
executables:
|
|
59
|
+
- unpack_macbinary
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- CODE_OF_CONDUCT.md
|
|
65
|
+
- Gemfile
|
|
66
|
+
- LICENSE
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- bin/console
|
|
70
|
+
- bin/setup
|
|
71
|
+
- exe/unpack_macbinary
|
|
72
|
+
- lib/macbinary_unpack.rb
|
|
73
|
+
- lib/unpack_macbinary.rb
|
|
74
|
+
- lib/unpack_macbinary/version.rb
|
|
75
|
+
- unpack_macbinary.gemspec
|
|
76
|
+
homepage: https://github.com/mistydemeo/unpack_macbinary
|
|
77
|
+
licenses:
|
|
78
|
+
- kindest
|
|
79
|
+
metadata: {}
|
|
80
|
+
post_install_message:
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
requirements: []
|
|
95
|
+
rubyforge_project:
|
|
96
|
+
rubygems_version: 2.5.1
|
|
97
|
+
signing_key:
|
|
98
|
+
specification_version: 4
|
|
99
|
+
summary: Tool to unpack MacBinary files into native Mac data/resource fork files.
|
|
100
|
+
test_files: []
|