2021-05-14 17:07:44 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-06-22 21:56:35 +00:00
|
|
|
|
2021-05-14 17:07:44 +00:00
|
|
|
set -e
|
2022-06-22 21:56:35 +00:00
|
|
|
|
2022-08-12 22:57:00 +00:00
|
|
|
if [ "@CODESIGN@" != "ON" ]; then
|
2022-06-22 21:56:35 +00:00
|
|
|
echo "Cannot codesign: this build was not configured with codesigning" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-08-12 22:57:00 +00:00
|
|
|
signit() {
|
|
|
|
target="$1"
|
|
|
|
entitlements="$2"
|
|
|
|
echo -e "\n\e[33;1mSigning ${target/*\/Lokinet.app/Lokinet.app}...\e[0m" >&2
|
|
|
|
codesign \
|
|
|
|
--verbose=4 \
|
|
|
|
--force \
|
|
|
|
-s "@CODESIGN_ID@" \
|
|
|
|
--entitlements "$entitlements" \
|
|
|
|
--strict \
|
|
|
|
--timestamp \
|
|
|
|
--options=runtime \
|
|
|
|
"$target"
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_entitlements="@PROJECT_SOURCE_DIR@/gui/node_modules/app-builder-lib/templates/entitlements.mac.plist"
|
|
|
|
ext_entitlements="@PROJECT_SOURCE_DIR@/contrib/macos/lokinet-extension.@LOKINET_ENTITLEMENTS_TYPE@.entitlements.plist"
|
|
|
|
app_entitlements="@PROJECT_SOURCE_DIR@/contrib/macos/lokinet.@LOKINET_ENTITLEMENTS_TYPE@.entitlements.plist"
|
|
|
|
|
2022-08-30 17:00:58 +00:00
|
|
|
SIGN_TARGET="@PROJECT_BINARY_DIR@/Lokinet @PROJECT_VERSION@/Lokinet.app"
|
2022-08-12 22:57:00 +00:00
|
|
|
|
2022-06-22 21:56:35 +00:00
|
|
|
for ext in systemextension appex; do
|
2022-08-12 22:57:00 +00:00
|
|
|
netext="$SIGN_TARGET/@lokinet_ext_dir@/org.lokinet.network-extension.$ext"
|
|
|
|
if [ -e "$netext" ]; then
|
|
|
|
signit "$netext" "$ext_entitlements"
|
2022-06-22 21:56:35 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-08-12 22:57:00 +00:00
|
|
|
if [ "@BUILD_GUI@" == "ON" ]; then
|
|
|
|
gui_app="$SIGN_TARGET"/Contents/Helpers/Lokinet-GUI.app
|
|
|
|
gui_sign_targets=()
|
|
|
|
for bundle in \
|
|
|
|
"$gui_app"/Contents/Frameworks/*.framework \
|
|
|
|
"$gui_app"/Contents/Frameworks/*.app
|
|
|
|
do
|
|
|
|
|
|
|
|
if [ -d "$bundle/Libraries" ]; then
|
|
|
|
gui_sign_targets+=("$bundle"/Libraries/*.dylib)
|
|
|
|
fi
|
|
|
|
if [ -d "$bundle/Helpers" ]; then
|
|
|
|
gui_sign_targets+=("$bundle"/Helpers/*)
|
|
|
|
fi
|
|
|
|
if [ -d "$bundle/Resources" ]; then
|
|
|
|
for f in "$bundle/Resources"/*; do
|
|
|
|
if [[ -f "$f" && -x "$f" && "$(file -b "$f")" == Mach-O* ]]; then
|
|
|
|
gui_sign_targets+=("$f")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
gui_sign_targets+=("$bundle")
|
|
|
|
done
|
|
|
|
|
|
|
|
gui_sign_targets+=("$gui_app")
|
|
|
|
|
|
|
|
for target in "${gui_sign_targets[@]}"; do
|
|
|
|
signit "$target" "$gui_entitlements"
|
|
|
|
done
|
|
|
|
|
|
|
|
signit "$SIGN_TARGET"/Contents/MacOS/Lokinet "$app_entitlements"
|
|
|
|
fi
|
|
|
|
|
|
|
|
signit "$SIGN_TARGET" "$app_entitlements"
|
2022-08-29 15:53:08 +00:00
|
|
|
|
|
|
|
touch "@PROJECT_BINARY_DIR@"/macos-signed.stamp
|