https://github.com/fanquake/libdmg
Rust port of the libdmg-hfsplus library
https://github.com/fanquake/libdmg
dmg rust
Last synced: 7 months ago
JSON representation
Rust port of the libdmg-hfsplus library
- Host: GitHub
- URL: https://github.com/fanquake/libdmg
- Owner: fanquake
- Created: 2019-07-08T01:47:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-07T00:46:09.000Z (almost 6 years ago)
- Last Synced: 2024-10-15T21:48:47.043Z (8 months ago)
- Topics: dmg, rust
- Language: Rust
- Size: 79.1 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libdmg
[](https://travis-ci.org/fanquake/libdmg)
This is a port of some of the functionality of [planetbeing/libdmg-hfsplus](https://github.com/planetbeing/libdmg-hfsplus).
The goal is to replace the usage of [`genisoimage`](https://manpages.debian.org/stretch/genisoimage/genisoimage.1.en.html) and `libdmg-hfsplus` in the Bitcoin Core [gitian build process](https://github.com/bitcoin/bitcoin/blob/master/contrib/gitian-descriptors/gitian-osx.yml#L141).
The reason for the port is that `libdmg-hfsplus` is seemingly unmaintained and contains various bugs; some of which have been patched in a [fork](https://github.com/theuni/libdmg-hfsplus) used by Bitcoin Core. For our usage, `genisoimage` does not create deterministic files by default, so it has also been [patched](https://github.com/bitcoin/bitcoin/blob/master/depends/patches/native_cdrkit/cdrkit-deterministic.patch). It cannot compress DMGs, hence the need for `libdmg-hfsplus`.
Ideally we could have a single, well-documented tool, that can not only create and compress DMGs from scratch, but also take care of inserting `.DS_Store` related metadata (which would remove the need for [another script](https://github.com/bitcoin/bitcoin/blob/master/contrib/macdeploy/custom_dsstore.py)).
The `DMG` format is proprietary and not well documented. As a result it has been reverse engineered by multiple parties. The following resources are useful when trying to understand it:
* [ApplePartitions.ppt](http://www.cse.scu.edu/~tschwarz/COEN252_09/PPtPre/ApplePartitions.ppt)
* http://newosxbook.com/DMG.html
* [hdiutil](https://ss64.com/osx/hdiutil.html)
* [Deterministic macOS DMG Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md#deterministic-macos-dmg-notes)
* [Secrets of the GPT](https://developer.apple.com/library/archive/technotes/tn2166/_index.html)## Usage
```bash
mkdir my_dmg
echo "Hello World" > my_dmg/hello.txt# create a basic dmg containing hello.txt
hdiutil create -ov -volname "Test DMG" -srcfolder my_dmg my.dmg
> created: ..../my.dmg# open DMG and inspect contents
hdiutil attach my.dmg# Build binary
carog build# Inspect dmg
cargo run inspect my.dmg
...
Inspecting: "my.dmg"udif: KolyBlock {
magic: 1802464377,
version: 4,
header_size: 512,
flags: 1,
running_data_fork_offset: 0,
data_fork_offset: 0,
data_fork_length: 8162,
....
```