Skip to content

Commit 5c4cc7f

Browse files
committed
fix: dereference symlinks before codesigning to fix notarization
1 parent 79cbfcd commit 5c4cc7f

1 file changed

Lines changed: 34 additions & 13 deletions

File tree

src-tauri/before_build.sh

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,46 @@ uv run pyinstaller backend/syft-space-backend.spec
3838
BACKEND_DIST="src-tauri/target/syft-space-backend-dist"
3939
rm -rf "$BACKEND_DIST"
4040
mkdir -p "$BACKEND_DIST"
41-
cp -R dist/syft-space-backend/* "$BACKEND_DIST/"
41+
cp -RL dist/syft-space-backend/* "$BACKEND_DIST/"
4242

4343
# 4. Ensure the main executable is executable
4444
chmod +x "$BACKEND_DIST/syft-space-backend${EXE_EXT}"
4545

46+
# Debug: verify no symlinks remain after copy
47+
echo "=== Checking for remaining symlinks ==="
48+
SYMLINKS=$(find "$BACKEND_DIST" -type l)
49+
if [ -n "$SYMLINKS" ]; then
50+
echo "WARNING: Symlinks still present:"
51+
echo "$SYMLINKS"
52+
else
53+
echo "OK: No symlinks found"
54+
fi
55+
56+
# Debug: show Python.framework structure
57+
echo "=== Python.framework structure ==="
58+
find "$BACKEND_DIST" -path "*/Python.framework/*" -exec ls -la {} \; 2>/dev/null | head -30
59+
4660
# 5. On macOS, codesign all binaries for notarization.
47-
# PyInstaller may hardlink _internal/Python -> Python.framework/Versions/X.Y/Python.
48-
# We sign the framework (which covers the hardlink too), then sign remaining
49-
# standalone Mach-O files, skipping any that are hardlinked into a framework.
61+
# cp -RL above dereferences all symlinks and breaks hardlinks, so
62+
# .framework bundles contain only regular files. This ensures codesign
63+
# produces valid signatures that survive Tauri's fs::copy resource bundling.
5064
if [[ "$TARGET_TRIPLE" == *"apple"* ]]; then
5165
ENTITLEMENTS="$PROJECT_ROOT/src-tauri/entitlements.plist"
5266
SIGN_IDENTITY="${APPLE_SIGNING_IDENTITY:--}"
5367
echo "Codesigning PyInstaller onedir output (identity: $SIGN_IDENTITY)..."
5468

55-
# a) Sign .framework bundles first (covers hardlinked binaries like _internal/Python)
69+
# a) Sign .framework bundles first with --deep
5670
find "$BACKEND_DIST" -type d -name "*.framework" | while read -r fw; do
5771
codesign --force --deep --options runtime --entitlements "$ENTITLEMENTS" \
5872
--sign "$SIGN_IDENTITY" "$fw"
5973
done
6074

61-
# b) Sign remaining Mach-O files outside .framework bundles.
62-
# Skip files that are hardlinked into a framework (link count > 1) —
63-
# they already share the framework's signature via the same inode.
75+
# b) Sign remaining standalone Mach-O files outside .framework bundles.
6476
find "$BACKEND_DIST" -type f ! -name "syft-space-backend" | while read -r f; do
6577
if [[ "$f" == *".framework/"* ]]; then
6678
continue
6779
fi
6880
if file "$f" | grep -q "Mach-O"; then
69-
link_count=$(stat -f '%l' "$f" 2>/dev/null || stat -c '%h' "$f" 2>/dev/null)
70-
if [ "$link_count" -gt 1 ]; then
71-
echo "Skipping hardlinked file: $f (link count: $link_count)"
72-
continue
73-
fi
7481
codesign --force --options runtime --entitlements "$ENTITLEMENTS" \
7582
--sign "$SIGN_IDENTITY" "$f"
7683
fi
@@ -80,6 +87,20 @@ if [[ "$TARGET_TRIPLE" == *"apple"* ]]; then
8087
codesign --force --options runtime --entitlements "$ENTITLEMENTS" \
8188
--sign "$SIGN_IDENTITY" "$BACKEND_DIST/syft-space-backend${EXE_EXT}"
8289
echo "Codesigning complete."
90+
91+
# Debug: verify signatures on the previously-problematic files
92+
echo "=== Verifying signatures ==="
93+
for f in \
94+
"$BACKEND_DIST/_internal/Python" \
95+
"$BACKEND_DIST/_internal/Python.framework/Python" \
96+
"$BACKEND_DIST/_internal/Python.framework/Versions/3.12/Python" \
97+
"$BACKEND_DIST/syft-space-backend"; do
98+
if [ -f "$f" ]; then
99+
echo "--- $f ---"
100+
codesign -dvvv "$f" 2>&1 | head -5
101+
codesign --verify --strict "$f" 2>&1 || true
102+
fi
103+
done
83104
fi
84105

85106
# 6. Build frontend

0 commit comments

Comments
 (0)