helloSystem / ISO

helloSystem Live and installation ISO
https://github.com/helloSystem/
BSD 3-Clause "New" or "Revised" License
807 stars 58 forks source link

Support .dmg disk images #280

Open probonopd opened 2 years ago

probonopd commented 2 years ago

A .dmg mounter (...) can be implemented using darling-dmg (tested; known to work).

References:

probonopd commented 1 year ago

Make .dmg files mountable by double-click, like we do already for .iso and .img.

To make this happen using automount, we would need to:

But apparently this is not how darling-dmg works, as it seems to work only on files and not on mdX devices:

FreeBSD% ./darling-dmg /dev/md1 /mnt
Error: Unsupported file format

Possible reasons:
1) The file is corrupt.
2) The file is not really a DMG file, although it resembles one.
3) There is a bug in darling-dmg.

The question is, does automount (intend to) use FUSE filesystems like darling-dmg? And if the answer is "yes", can it operate on the file directly rather than a /dev/mdX device`?

Possibly we should handle .dmg files more akin to .zip and other archives:

However, in the case of a zip file, there is no icon shown on the desktop for the mounted file. Instead, double-clicking the file opens a Filer window at the mountpoint directly. In the case of .dmg and similar "image" files (as opposed to "archive" files), it is questionable whether this is desired. For .iso and .img, double-clicking those doesn't directly open a window that shows their contents, but they are mounted and shown on the desktop instead (like on the Mac). It is probably debatable whether the distinction between "archive" and "image" files is still relevant today and is understood by users; especially if we are technically treating "archive" files just like "image" files, namely, by mounting them.

We should align with @vermaden on whether he wants this kind of functionality (double-click on a .zip or .dmg or any other type of file that can be mounted using FUSE to get it automounted) in automount or not. If not, then the way we are currently doing it for .zip is perfectly fine for helloSystem.

probonopd commented 1 year ago

It is probably debatable whether the distinction between "archive" and "image" files is still relevant today and is understood by users; especially if we are technically treating "archive" files just like "image" files, namely, by mounting them.

Well, one "image" file can have multiple partitions (a.k.a. "volumes"); that's probably why double-clicking "image" files just mounts the volumes in those instead of opening a winow with their contents directly?

But then, darling-dmg (and macOS) only mount the main partition in .dmg files anyway...

probonopd commented 1 year ago

it seems to work only on files and not on mdX devices

Maybe we'd need to throw in fuseblk in there somehow; this seems to be the magic keyword at least on Linux for FUSE to work with block devices rather than with files.

If we even want to go down that path.

vermaden commented 1 year ago

Hi,

do you need anything from my side in this?

Regards.

probonopd commented 1 year ago

Hi @vermaden, just wanted to know whether mounting things like Mac .dmg disk image files with FUSE is in the scope of automount. Thanks!

vermaden commented 1 year ago

The automount(8) acts against devices - if we use md(4) to map that *.DMG to /dev/md* device then I have nothing against it.

probonopd commented 1 year ago

Description of the file format: http://newosxbook.com/DMG.html

commands such as "file" have a hard time identifying the DMG file type: In the absence of a fixed header, a DMG can start with any type of data (disk or partition headers), which can be further compressed by myriad means

In fact, there is no "header" but a "footer":

FreeBSD% tail -b 1  Downloads/Transmission-3.00.dmg | head -c 4 | strings
koly

If this returns koly, then it is a dmg.

Now, does the tail command even work on md(4) devices?

vermaden commented 1 year ago

This is the way.

% mdconfig.sh -l                              
md0     vnode    5564K  /home/vermaden/Transmission-3.00.dmg    

% SECTORS=$( diskinfo -v /dev/md0|awk '/mediasize in sectors/ {print $1}' ) 

% echo ${SECTORS}
11127

% SECTORSIZE=$( diskinfo -v /dev/md0 | awk '/sectorsize/ {print $1}' )

% echo ${SECTORSIZE}
512

% dd if=/dev/md0 skip=$(( ${SECTORS} - 1 )) bs=${SECTORSIZE} 2> /dev/null| strings | tail -1
koly
probonopd commented 1 year ago

Wow. But can you get mdX to mount with darling-dmg? It works for me on files but not on mdX devices...

vermaden commented 1 year ago

No such package:

% pkg search darling
% 
probonopd commented 1 year ago

Soon :) https://github.com/Martinfx/FreeBSD-Ports/pull/84 a.k.a. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267207

vermaden commented 1 year ago

Then please let me know when that 'soon' happens :)

grahamperrin commented 1 year ago

sysutils/darling-dmg

FUSE module for .dmg files (containing an HFS+ filesystem)

vermaden commented 1 year ago

Periodic reminder that I still has it in my TODO list :)

vermaden commented 1 year ago

Not possible with RAW devices:

Works with file:

% darling-dmg download/transmission-4.0.3.dmg /media/tmp
Skipping partition of type Primary GPT Header
Skipping partition of type Primary GPT Table
Skipping partition of type Apple_Free
Using partition #3 of type Apple_HFS
Everything looks OK, disk mounted

Does not work when device created from that file:

% mdconfig.sh -l                     
md0     vnode    7361K  /data/download/transmission-4.0.3.dmg   

% darling-dmg /dev/md0 /media/tmp   
Error: Unsupported file format

Possible reasons:
1) The file is corrupt.
2) The file is not really a DMG file, although it resembles one.
3) There is a bug in darling-dmg.

Sorry.