/libdmg

Rust port of the libdmg-hfsplus library

Primary LanguageRust

libdmg

Build Status

This is a port of some of the functionality of planetbeing/libdmg-hfsplus.

The goal is to replace the usage of genisoimage and libdmg-hfsplus in the Bitcoin Core gitian build process.

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 used by Bitcoin Core. For our usage, genisoimage does not create deterministic files by default, so it has also been patched. 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).

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:

Usage

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,
    ....