Skip to content

Commit a72f2dc

Browse files
authored
scripts: sign renamed macOS binary (ollama#8131)
1 parent 08a832b commit a72f2dc

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

scripts/build_darwin.sh

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,36 @@ export CGO_CXXFLAGS=-mmacosx-version-min=11.3
1515
export CGO_LDFLAGS=-mmacosx-version-min=11.3
1616

1717
rm -rf llama/build dist/darwin-*
18+
19+
# Generate the universal ollama binary for stand-alone usage: metal + avx
20+
echo "Building binary"
1821
echo "Building darwin arm64"
1922
GOOS=darwin ARCH=arm64 GOARCH=arm64 make -j 8 dist
2023
echo "Building darwin amd64 with AVX enabled"
2124
GOOS=darwin ARCH=amd64 GOARCH=amd64 CUSTOM_CPU_FLAGS="avx" make -j 8 dist_exe
22-
23-
# Generate the universal ollama binary for stand-alone usage: metal + avx
2425
lipo -create -output dist/ollama-darwin dist/darwin-arm64/bin/ollama dist/darwin-amd64/bin/ollama
2526

27+
# sign the binary and rename it
28+
if [ -n "$APPLE_IDENTITY" ]; then
29+
codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama-darwin
30+
else
31+
echo "WARNING: Skipping code signing - set APPLE_IDENTITY"
32+
fi
33+
ditto -c -k --keepParent dist/ollama-darwin dist/temp.zip
34+
if [ -n "$APPLE_IDENTITY" ]; then
35+
xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
36+
fi
37+
rm -f dist/temp.zip
38+
39+
# Build the app bundle
40+
echo "Building app"
2641
echo "Building darwin amd64 with runners"
2742
rm dist/darwin-amd64/bin/ollama
2843
GOOS=darwin ARCH=amd64 GOARCH=amd64 make -j 8 dist
44+
2945
# Generate the universal ollama binary for the app bundle: metal + no-avx
3046
lipo -create -output dist/ollama dist/darwin-arm64/bin/ollama dist/darwin-amd64/bin/ollama
3147

32-
33-
if [ -n "$APPLE_IDENTITY" ]; then
34-
codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama
35-
else
36-
echo "Skipping code signing - set APPLE_IDENTITY"
37-
fi
38-
chmod +x dist/ollama
39-
4048
# build and optionally sign the mac app
4149
npm install --prefix macapp
4250
if [ -n "$APPLE_IDENTITY" ]; then
@@ -46,14 +54,3 @@ else
4654
fi
4755
cp macapp/out/make/zip/darwin/universal/Ollama-darwin-universal-$VERSION.zip dist/Ollama-darwin.zip
4856

49-
# sign the binary and rename it
50-
if [ -n "$APPLE_IDENTITY" ]; then
51-
codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama
52-
else
53-
echo "WARNING: Skipping code signing - set APPLE_IDENTITY"
54-
fi
55-
ditto -c -k --keepParent dist/ollama dist/temp.zip
56-
if [ -n "$APPLE_IDENTITY" ]; then
57-
xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
58-
fi
59-
rm -f dist/temp.zip

0 commit comments

Comments
 (0)