Skip to content

ci: make the macOS .app self-contained - #36

Merged
transfix merged 3 commits into
masterfrom
ci/macos-self-contained-app
Nov 9, 2026
Merged

transfix merged 3 commits into
masterfrom
ci/macos-self-contained-app

Conversation

@transfix

@transfix transfix commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

The macOS .app / .dmg / .zip that package / macos (ci.yml) and the macos release job build shipped an empty Contents/Frameworks, so F2Dock could not start on any machine that lacks the build's cvcpkg prefix. Follow-up to #35.

Why it was empty

The packaging step copied only dylibs that otool -L showed by an absolute path matching libfftw. Since #35 the default build does not link FFTW. Everything F2Dock does link from the prefix is an @rpath/ reference, and no LC_RPATH is left after cmake --install. From the .zip of run 42292607979:

F2Dock.app/Contents/MacOS/F2Dock
    @rpath/libcvc.3.dylib
    @rpath/libboost_thread.1.86.0.dylib
    ... 18 more @rpath/ libraries, no LC_RPATH

GB-Rerank, FilterOutput and F2DockServer link only the OS's libraries (xmlrpc is static), so only F2Dock was affected. Linux was fixed in #35, which bundles every library ldd resolves from the prefix into the tarball. Windows already copies every DLL in the prefix.

What changes

  • .github/scripts/macos-bundle-app.sh APP PREFIX walks the executables' load commands transitively and copies every non-OS library into Contents/Frameworks.
    • Libraries keep their real, versioned names, and the other names they are reached by become symlinks to that one copy, as in the prefix. A library reached under two names stays one file and one loaded image.
    • A .framework is copied whole, symlinks and _CodeSignature included, so its reference resolves unchanged. freetype links @rpath/png.framework/Versions/1.6.44/png.
    • Anything that resolves outside the cvcpkg prefix is an error, never bundled, so a library from Homebrew or /usr/local cannot slip in.
    • Executables get @executable_path/../Frameworks and lose any absolute rpath. Every file whose load commands change is re-signed ad hoc, because arm64 macOS kills a binary whose signature no longer verifies. With today's prefix only the executables change; no dylib needs rewriting.
  • .github/scripts/macos-check-app.sh APP [--run] checks the result.
    • Statically: every reference in MacOS/ and in Frameworks/ (walked recursively) is either the OS's (/usr/lib, /System) or an @rpath/ name present in Frameworks.
    • With --run: it launches each executable from the unpacked .zip, with the build's prefix moved aside, no DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH=/usr/lib and DYLD_PRINT_LIBRARIES=1. Each must reach main() and print, without a dyld error or a signal, and every image dyld loads must come from the bundle or the OS. F2Dock --version prints its version; the others print their usage and start nothing. dyld binds every linked library before main(), so this covers the whole closure.
    • perl (the timeout) runs before env: macOS strips DYLD_* when launching SIP-protected binaries such as /usr/bin/perl and /usr/bin/env, so env has to be the last thing to set them.
  • Workflows: ci.yml's package-macos and release.yml's macos job run the same steps. A new step, "Check the .zip runs without the build's prefix", does the --run check on the artifact as shipped. The executables now move from Resources/bin to Contents/MacOS instead of being copied, so the .app no longer carries a second, unfixed copy of each.
  • 244ef7b, separate: every package job named its artifacts F2Dock--<sha>-… with no version. The metadata awk looked for a line starting with VERSION, and F2Dock's project() is a single line. This predates Licence hygiene: add LICENSE, header the unheadered files, quarantine the GPL modules #35 (0883fd3 has the same line) and would have produced release assets named F2Dock--linux-x86_64.*. All six jobs now read the version from project() with sed -E, which BSD, GNU and Git-for-Windows sed all accept.

Verification

Off macOS, with llvm-otool-18 / llvm-install-name-tool-18 (signing stubbed out), on the real .zip from run 42292607979 and the macos/arm64 cvcpkg prefix:

Check Result
bundle 142 libraries, 83 MB, plus png.framework whole
static check on the bundled .app passes: 146 Mach-O files, every reference inside the bundle or the OS
static check on the .app CI ships today fails, naming @rpath/libcvc.3.dylib and the rest
bundler with libgmp.10.dylib removed from the prefix fails: F2Dock loads @rpath/libgmp.10.dylib, which is not in <prefix>
shellcheck on both scripts clean

--run, codesign and BSD sed need macOS; they are exercised in CI, below.

CI

Run 42339527146 at 4609f28: all 10 jobs green. From package / macos, on the .zip unpacked fresh, with /Users/runner/work/_temp/f2dock-deps moved aside:

bundled 142 libraries ( 82M) into .../F2Dock.app/Contents/Frameworks
static: 146 Mach-O files, every reference resolves inside the bundle or the OS
run: F2Dock --version -> exit 0, 143 images from the bundle: F2Dock 2.1.0
run: F2DockServer  -> exit 255, 1 images from the bundle: Usage: F2DockServer serverPort platform(...)
run: FilterOutput  -> exit 255, 1 images from the bundle: Usage:./FilterOutput <Ligand PQR> ...
run: GB-Rerank  -> exit 1, 1 images from the bundle: Error: Input text file not specified!

Artifacts now carry the version: F2Dock-2.1.0-8ac0bb29-macos-arm64.dmg.

The first run (42317485460, at 7d90e32) failed in "Check the .zip runs without the build's prefix", on mistakes in the check rather than in the bundle. F2Dock passed then too. F2DockServer and FilterOutput return -1, exit status 255, which a shell's $? cannot tell from a signal; GB-Rerank's message follows a blank line, which the check read as no output. 4609f28 runs each binary under a perl wrapper that reports the real wait status (exit, signal or timeout) and takes the first non-blank line. Checked on Linux against exit 255 / 1 / 0, signals 9, 11 and 15, and a timeout.

Not done here

  • Licence notices for the bundled libraries. The .app now ships about 140 third-party dylibs, among them gmp / mpfr (LGPL-3.0), ImageMagick, gRPC / abseil, HDF5 and assimp, without their licence texts. The cvcpkg bundles mostly do not install them: only eigen and libigl have share/licenses/. The same gap already exists for the Windows .zip (every prefix DLL) and the Linux tarball (Licence hygiene: add LICENSE, header the unheadered files, quarantine the GPL modules #35). Fixing it belongs in the cvcpkg recipes, after which these packaging steps can copy share/licenses/ along.
  • Leftover rpaths in the cvcpkg dylibs. The ImageMagick dylibs carry @loader_path/python3.11/site-packages/PIL/.dylibs, and two libjpeg-turbo libraries carry the builder's temporary install path. Neither can point inside a user's machine, so this is left alone, but the recipes should not be emitting them.
  • The .app has no Info.plist and is signed ad hoc only, so it is a directory of binaries rather than a proper bundle, and a downloaded copy is quarantined by Gatekeeper. That has not changed.

Every package job named its artifacts F2Dock--<sha>-..., with no version:

    F2Dock--b1998273-macos-arm64.zip

The metadata step looked for a line starting with VERSION, which is how
libcvc's multi-line project() is written. F2Dock's is one line,
`project(F2Dock VERSION 2.1.0 LANGUAGES C CXX)`, so nothing matched and
VERSION was empty. That predates the move to cvcpkg (0883fd3 has the same
line) and would have shipped release assets named F2Dock--linux-x86_64.*.

All six jobs, in ci.yml and release.yml, now take the version from the
project() call with sed -E, which macOS's BSD sed, GNU sed and Git for
Windows' sed all accept. Checked against the CRLF CMakeLists.txt: 2.1.0,
with no trailing carriage return.
The .app / .dmg / .zip shipped an empty Contents/Frameworks. The packaging
step only copied dylibs that otool showed by an absolute path matching
libfftw. The default build no longer links FFTW, and everything F2Dock
does link from the cvcpkg prefix is an @rpath/ reference with no LC_RPATH
left after install:

    F2Dock.app/Contents/MacOS/F2Dock
        @rpath/libcvc.3.dylib
        @rpath/libboost_thread.1.86.0.dylib
        ... 18 more

so F2Dock could not start on any machine without that prefix. (GB-Rerank,
FilterOutput and F2DockServer link only the OS's libraries.)

.github/scripts/macos-bundle-app.sh walks the executables' load commands
transitively and copies every non-OS library into Contents/Frameworks:

  * under its real, versioned name, with the other names it is reached by
    as symlinks to that one copy, as in the prefix;
  * a .framework (freetype links @rpath/png.framework/Versions/1.6.44/png)
    is copied whole, so its reference resolves unchanged;
  * anything that resolves outside the cvcpkg prefix is an error, not
    something to bundle;
  * each executable gets an @executable_path/../Frameworks rpath and loses
    any absolute one, and every file it changes is re-signed ad hoc, since
    arm64 macOS kills a binary whose signature no longer verifies.

.github/scripts/macos-check-app.sh fails the job if any reference in the
bundle still leads outside it and the OS. With --run it also launches
each executable from the unpacked .zip, with the build's prefix moved
aside, no DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH=/usr/lib and
DYLD_PRINT_LIBRARIES on, and requires each to reach main() and print,
loading images only from the bundle and the OS. dyld binds every linked
library before main(), so that covers the whole closure. perl (the
timeout) runs before env, because macOS strips DYLD_* from SIP-protected
binaries such as /usr/bin/perl and /usr/bin/env.

The executables now move from Resources/bin to Contents/MacOS instead of
being copied, so the .app no longer carries a second, unfixed copy.
ci.yml's package-macos and release.yml's macos job run the same steps.

Exercised off macOS with llvm-otool-18 / llvm-install-name-tool-18 on the
.zip from CI run 42292607979 and the macos/arm64 prefix: 142 libraries
(83 MB) bundled, and the static check passes on all 146 Mach-O files. It
fails on the unbundled .app, and the bundler fails naming the library
when one is removed from the prefix. The --run check needs macOS and
runs in CI.
The first macOS run of the check bundled 142 libraries, passed the static
check, and ran F2Dock from the unpacked .zip with the prefix moved aside:

    run: F2Dock --version -> exit 0, 143 images from the bundle: F2Dock 2.1.0

The other three failed on the check's own mistakes, not the bundle's:

    FAIL: F2DockServer died with signal 127
    FAIL: FilterOutput died with signal 127
    FAIL: GB-Rerank printed nothing

F2DockServer and FilterOutput `return -1` from main, which is exit status
255, and a shell's $? cannot tell that from 128 + 127. GB-Rerank's error
goes to stderr after a blank line, and the check only read the first line.

The binary now runs under a small perl wrapper that forks, waits, and
writes how the child ended -- "exit N", "signal N" or "timeout" -- to a
status file, so only a real signal or timeout fails. The output check
takes the first non-blank line. perl still comes before env, so the
DYLD_* settings reach the binary under test.

Checked on Linux: exit 255, exit 1, exit 0, signals 9, 11 and 15, and a
timeout are each reported as such.
@transfix
transfix merged commit 20e9f1d into master Nov 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant