darling README

项目的 README,来自 github.com/darlinghq/darling。合并为一个 markdown 文件:README.md。

Darling logo


Darling Latest Release License Donate

Website • Community Discord • Bug Tracker • AppDB • Blog

Introduction

Darling is a runtime environment that allows running macOS applications on Linux without a virtual machine. It consists of a Mach-O binary loader and a userspace kernel server (darlingserver) that implements macOS's Mach IPC, POSIX, and Darwin syscall interfaces on top of Linux — along with reimplementations of Apple's frameworks, such as Foundation, AppKit (based on Cocotron), CoreAudio, and CoreFoundation.

Darling's low-level components (XNU, libSystem, Security) are based on Apple's open-source releases. Higher-level frameworks are being actively reimplemented, with many CLI tools already functional. GUI application support is in active development, backed by an AppKit implementation and an initial Metal backend powered by Vulkan translation.

The code of Darling is licensed under GNU GPL 3.0. Individual submodules may be licensed differently, as indicated within each of them.

Install

Official packages for some distributions are available under releases.

Community Packages

[!CAUTION] These packages are neither maintained nor vetted by the Darling team.
Use them at your own risk.

For a list of community packages, see the Community Packages section in the Darling documentation.

Build Instructions

For build instructions, visit Darling Docs.

Usage

Prefixes

Darling has support for DPREFIXes, which are very similar to WINEPREFIXes. They are virtual “chroot” environments with a macOS-like filesystem structure, where you can install software safely. The default DPREFIX location is ~/.darling, but this can be changed by exporting an identically named environment variable set to an absolute path. A prefix is automatically created and initialized on first use.

Please note that we use overlayfs for creating prefixes, and so we cannot support putting prefix on a filesystem like NFS or eCryptfs. In particular, the default prefix location won't work if you have an encrypted home directory.

Hello world

Let's start with a Hello world:

$ darling shell echo Hello world
Hello world

Congratulations, you have printed Hello world through Darling's OS X system call emulation and runtime libraries.

Installing software

Working with .pkg files

You can install .pkg packages with the installer tool available inside shell. It is a somewhat limited cousin of OS X's installer:

$ darling shell
Darling [~]$ installer -pkg mc-4.8.7-0.pkg -target /

Darling does not support installing .mpkg files yet

The Midnight Commander package from the above example is available for download.

You can uninstall and list packages with the uninstaller command.

Working with DMG images

DMG images can be attached and detached from inside darling shell with hdiutil. This is how you can install Xcode along with its toolchain and SDKs (note that Xcode itself doesn't run yet):

Darling [~]$ hdiutil attach Xcode_7.2.dmg
/Volumes/Xcode_7.2
Darling [~]$ cp -r /Volumes/Xcode_7.2/Xcode.app /Applications
Darling [~]$ export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
Darling [~]$ echo 'void main() { puts("Hello world"); }' > helloworld.c
Darling [~]$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang helloworld.c -o helloworld
Darling [~]$ ./helloworld
Hello world

Congratulations, you have just compiled and run your own Hello world application with Apple's toolchain.

Opening files from the Linux desktop

darling open opens files of the host in Darling, as open does inside it. A disk image is mounted by DiskImageMounter (after you accept its licence agreement, if it has one) and its window is shown in Finder:

$ darling open ~/Downloads/SomeApp.dmg

Darling installs a desktop entry for disk images, "Disk Image Mounter (Darling)", so that file managers offer it under "Open With". To make it what a double-click on a .dmg does:

$ xdg-mime default org.darlinghq.Darling.DiskImageMounter.desktop application/x-apple-diskimage

Running macOS binaries directly (optional)

Darling ships a host-facing binfmt_misc configuration in share/darling/binfmt/darling.conf. It is not enabled by default: the lib/binfmt.d/darling.conf is for binaries already inside a container and must not be used on the host. With systemd-binfmt, opt in with:

$ sudo install -Dm644 /usr/local/share/darling/binfmt/darling.conf /etc/binfmt.d/darling-host.conf
$ sudo systemctl restart systemd-binfmt

Replace /usr/local with your installation prefix. Do not register this file together with the in-container lib/binfmt.d/darling.conf: both match the same magics, and only one interpreter can win. If your distribution installed that file under /usr/lib/binfmt.d, remove it first. The host handler also serves guest execve() calls, so containers keep working. A 64-bit, 32-bit or fat Mach-O executable can now be run directly; if no container is running, the handler starts one. Remove the file from /etc/binfmt.d and restart systemd-binfmt to undo this. On a host without systemd, the same lines can be written to /proc/sys/fs/binfmt_misc/register as root.

Desktop entries for installed apps

darling-desktop generates a desktop entry for each .app bundle found in a prefix:

$ darling-desktop

Entries go to $XDG_DATA_HOME/applications, or ~/.local/share/applications when that variable is unset. The MIME types are read from the guest's own UTI declarations (CoreTypes.bundle) and each app's CFBundleDocumentTypes, so an app that declares public.text is offered for text/plain files without a hard-coded list. Re-run the command after installing or removing apps. Use --prefix, --app-dir, --core-types or --output-dir to override the defaults.

Darling also installs generic desktop entries and shared MIME information for Mach-O executables and .app bundles, so file managers can offer Darling for them until an app-specific entry is preferred. The generated app entries call darling open -a, which also works by hand:

$ darling open -a TextEdit ~/Documents/notes.txt

Working with XIP archives

Xcode is now distributed in .xip files. These can be installed using unxip:

cd /Applications
unxip Xcode_11.3.xip

darling (darlinghq/darling)

正在搜索数据库…

这是什么?Darling 是一个运行时环境,无需虚拟机即可在 Linux 上运行 macOS 应用。
这有点像给 macOS 应用用的 Wine 吗?从概念上讲,它与 Wine 相似:它提供了一个 Mach-O 二进制加载器,以及一个用户态内核服务器(darlingserver),在 Linux 之上实现 macOS 的 Mach IPC、POSIX 和 Darwin 系统调用,还重新实现了 Foundation、AppKit、CoreAudio 和 CoreFoundation 等苹果框架。
我该如何安装并开始使用?部分发行版的官方安装包可以在发布页面下载;否则,请按照 Darling Docs 上的说明自行编译。安装完成后,首次使用时会自动创建一个 DPREFIX(类似 WINEPREFIX 的虚拟 chroot 环境),默认位于 ~/.darling。
我需要担心 macOS 文件系统或加密的主目录吗?Darling 使用 overlayfs 来创建其前缀目录,因此无法把前缀放在 NFS 或 eCryptfs 等文件系统上;如果你的主目录已加密,默认的前缀位置也将无法使用。
我能运行带图形界面的 macOS 应用,还是只能运行命令行工具?图形界面应用的支持仍在积极开发中,目前已有 AppKit 的实现和早期的 Metal-over-Vulkan 后端;许多命令行工具已经可以运行,但更高层的框架仍在重新实现中。
这个东西在什么平台上运行?Darling 运行在 Linux 上,并在其之上模拟 Darwin/macOS 环境。
我能在 Darling 里安装 Xcode 吗?可以。你可以挂载 Xcode 的 DMG 镜像,并使用 hdiutil 将其连同工具链和 SDK 一起安装;不过 Xcode 自身的图形界面目前还无法运行,但你仍然可以用它的工具链编译和运行程序。
怎样在 Darling 里安装 .pkg 或 .xip 软件?在 Darling 的 shell 中,使用 installer 工具安装 .pkg 包(暂不支持 mpkg),并使用卸载命令将其删除;对于 Xcode 现在采用的 .xip 压缩包,可以使用 unxip 解压。
作者
darlinghq
大小
46.3 MB
星标
13.8K
时长
13年
提交 · 90 天