如何构建 dmg Mac OS X 文件(在非 Mac 平台上)?

发布于 2024-07-09 07:35:30 字数 53 浏览 6 评论 0原文

是否可以从非 Mac 平台构建 .dmg 文件(用于分发应用程序)? 如果是的话,怎么办?

Is it possible to build a .dmg file (for distributing apps) from a non-Mac platform?
And if yes, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

放低过去 2024-07-16 07:35:30

是的,mkfs.hfsplus 做到了。

dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64
mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg

这将创建一个可以安装在 Mac 上的 dmg 文件(在本例中为 64M)。 它也可以安装在 Linux 上,之后

mount -o loop /tmp/foo.dmg /mnt/foo

你只需将你想要的内容复制到它(在 /mnt/foo 中)。 卸载它,然后可以将 dmg 复制到 Mac 并安装在那里。

Yep, mkfs.hfsplus does it.

dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64
mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg

This creates a dmg file (in this case 64M) that can be mounted on a mac. It can also be mounted on linux, with something like

mount -o loop /tmp/foo.dmg /mnt/foo

after wich you just copy the content you want to it (in /mnt/foo). Unmount it, and the dmg can be copied over to a mac and mounted there.

郁金香雨 2024-07-16 07:35:30

我从事的一个项目使用 genisoimage 在 Linux 上创建 DMG 文件:

mkdir -p dmgdir/progname.app/Contents/{MacOS,Resources}
...copy your PkgInfo, Info.plist to Contents...
...copy your .icns to Resources...
...copy your other things to where you expect them to go...
genisoimage -V progname -D -R -apple -no-pad -o progname.dmg dmgdir 

如果您想要真正花哨,您可以从 Mac 上制作的卷名 progname 的 DMG 中窃取 .DS_Store 文件 和名为 progname.app 的应用程序包(即,与您想要在 Mac 上创建的内容相匹配),您已将背景放入 .background/background.png 和根目录中 /Applications 的符号链接,并将其与您自己的 /Applications 符号链接一起放入 dmgdir 中。

最后,如果您想创建压缩的 DMG,请从 libdmg-hfsplus 获取 dmg 工具:

dmg uncompressed.dmg compressed.dmg

A project I work on creates DMG files on Linux using genisoimage:

mkdir -p dmgdir/progname.app/Contents/{MacOS,Resources}
...copy your PkgInfo, Info.plist to Contents...
...copy your .icns to Resources...
...copy your other things to where you expect them to go...
genisoimage -V progname -D -R -apple -no-pad -o progname.dmg dmgdir 

If you want to be really fancy, you can steal the .DS_Store file from a DMG made on a Mac with a volume name progname and app bundle called progname.app (i.e., matching what you want to create off the Mac) where you've put a background in .background/background.png and a symbolic link to /Applications in the root dir, and put that in dmgdir along with your own a symbolic link to /Applications.

Finally, if you want to create a compressed DMG, get the dmg tool from libdmg-hfsplus:

dmg uncompressed.dmg compressed.dmg
暖树树初阳… 2024-07-16 07:35:30
git clone https://github.com/hamstergene/libdmg-hfsplus
cd libdmg-hfsplus && cmake . && make && cd dmg
./dmg --help

Makefile:

dmg:
    genisoimage -D -V "$(PROJECT) $(VERSION)" -no-pad -r -apple -o project-$(VERSION)-uncompressed.dmg $(DARWIN_DIR)
    ./dmg dmg project-$(VERSION)-uncompressed.dmg project-$(VERSION).dmg

未压缩的开箱即用,压缩可能会导致问题 - origin/master 至少会在雪豹上产生“校验和”错误

git clone https://github.com/hamstergene/libdmg-hfsplus
cd libdmg-hfsplus && cmake . && make && cd dmg
./dmg --help

Makefile:

dmg:
    genisoimage -D -V "$(PROJECT) $(VERSION)" -no-pad -r -apple -o project-$(VERSION)-uncompressed.dmg $(DARWIN_DIR)
    ./dmg dmg project-$(VERSION)-uncompressed.dmg project-$(VERSION).dmg

uncompressed works out of the box, compression may cause problems - the origin/master at least produces a 'checksum' error on snow-leopard

梦里泪两行 2024-07-16 07:35:30

似乎确实可以使用一些第三方工具创建 DMG 文件。 快速谷歌搜索至少会发现一些商业工具:

不确定是否有任何 OSS/免费软件选项,但如果您愿意的话,它至少看起来是可能的。

编辑:我还忘记了 MacDrive,它是 Windows 下使用 HFS+ 文件系统的另一个很棒的工具。 由于 DMG 基本上只是 HFS+ 文件系统快照,因此也可以使用 MacDrive 创建 DMG。

It does seem possible to create DMG files with some third party tools. A quick google search reveals at least a few commercial tools:

Not sure about any OSS/freeware options, but it does at least seem possible if you are so inclined.

Edit: I also forgot about MacDrive, which is another great tool for working with HFS+ filesystems under windows. Since a DMG is basically just a HFS+ filesystem snapshot, it is probably possible with MacDrive to create DMG's as well.

一张白纸 2024-07-16 07:35:30

我不确定是否有人仍在观看此帖子,但我按照 Nik Reiman 的推荐尝试了 TransMac

使用这个工具,我能够在Windows 7上运行,创建可在OSX 10.8.3上安装的dmg文件。


缺点

对我们来说唯一的缺点是这个工具似乎对命令行不友好; 对于我们来说,这是一个大问题,因为我们需要能够拥有一个自动化工具,我们的构建服务器(基于 Windows)可以使用它来即时构建 dmg 文件。

I'm not sure if anyone is still watching this thread, but I tried TransMac as recommended by Nik Reiman.

Using this tool I was able to, running on Windows 7, create dmg files which were mountable on OSX 10.8.3.


Downside

The only downside for us is that this tool doesn't appear to be command-line friendly; for us that's a deal-breaker as we need to be able to have an automated tool which our build server (Windows based) can use to build dmg files on-the-fly.

南笙 2024-07-16 07:35:30

请参阅 mkfs.hfsplus

See mkfs.hfsplus

合久必婚 2024-07-16 07:35:30

如果您要分发 Mac 应用程序,那么您肯定有一台 Mac 来编写和测试它们。 为什么不简单地使用同一台 Mac 来创建磁盘映像?

[编辑] 另外,如果您要分发便携式应用程序(例如 Java .jar 文件),为什么还要费心使用磁盘映像呢? Mac 可以很好地理解 .zip 和 .tar.gz 档案。

我想我的意思是,我不明白为什么人们可能需要 DMG 磁盘映像,但却没有一台可以用来创建它的 Mac。

If you're distributing Mac apps, then surely you have a Mac to write and test them. Why not simply use that same Mac to create the disk image?

[Edit] Alternatively, if you're distributing a portable app, for example a Java .jar file, why bother with a disk image? Macs understand .zip and .tar.gz archives just fine.

I guess what I'm getting at is, I don't understand how one might need a DMG disk image, but not have a Mac with which to create it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文