Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions scripts/build-macos-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,9 @@ cp -- "${cli_build_target}/release/chat2db" "${cli_resource_directory}/chat2db"
chmod 755 "${cli_resource_directory}/chat2db"
sign_developer_id_code "${cli_resource_directory}/chat2db"

signed_runtime_macho_count=0
while IFS= read -r -d '' runtime_file; do
if [[ "$(file -b "${runtime_file}")" != *"Mach-O"* ]]; then
continue
fi
sign_developer_id_code "${runtime_file}"
signed_runtime_macho_count=$((signed_runtime_macho_count + 1))
done < <(find "${repository_root}/target/macos-runtime" -type f -print0)
if [[ "${signed_runtime_macho_count}" -eq 0 ]]; then
echo "macOS Java runtime contains no Mach-O code to sign" >&2
exit 1
fi
echo "Signed ${signed_runtime_macho_count} macOS Java runtime binaries"
# Preserve Temurin's Developer ID signatures and JVM entitlements. Re-signing
# the jlink output without the vendor entitlements prevents the JVM from
# enabling JIT write protection on a normal SIP-enabled macOS installation.

staged_resource_root="${build_target}/release/chat2db"
if [[ -L "${staged_resource_root}" || ( -e "${staged_resource_root}" && ! -d "${staged_resource_root}" ) ]]; then
Expand Down
13 changes: 13 additions & 0 deletions scripts/verify-macos-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repository_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
app_path="${1:-${repository_root}/target/macos-package-build/release/bundle/macos/Chat2DB Rust.app}"
resource_root="${app_path}/Contents/Resources/chat2db"
java_bin="${resource_root}/java/bin/java"
jvm_library="${resource_root}/java/lib/server/libjvm.dylib"
engine_jar="${resource_root}/engine/chat2db-compat-runtime.jar"
community_classpath="${resource_root}/community-classpath"
driver_root="${resource_root}/driver-packs"
Expand Down Expand Up @@ -35,6 +36,7 @@ fi
require_directory "${app_path}"
require_file "${binary}"
require_file "${java_bin}"
require_file "${jvm_library}"
require_file "${engine_jar}"
require_directory "${community_classpath}"
require_directory "${driver_root}"
Expand Down Expand Up @@ -175,6 +177,17 @@ if [[ "${CHAT2DB_REQUIRE_DEVELOPER_ID_SIGNATURE:-false}" == true ]]; then
verify_developer_id_code "${app_path}" "package" "${APPLE_TEAM_ID:-}"
verify_developer_id_code "${cli_binary}" "embedded CLI" "${APPLE_TEAM_ID:-}"

jvm_entitlements="$(codesign -d --entitlements :- "${jvm_library}" 2>/dev/null)"
for required_entitlement in \
com.apple.security.cs.allow-jit \
com.apple.security.cs.allow-unsigned-executable-memory \
com.apple.security.cs.disable-library-validation; do
if ! grep -Fq "<key>${required_entitlement}</key>" <<<"${jvm_entitlements}"; then
echo "packaged JVM is missing required entitlement ${required_entitlement}" >&2
exit 1
fi
done

runtime_macho_count=0
while IFS= read -r -d '' runtime_file; do
if [[ "$(file -b "${runtime_file}")" != *"Mach-O"* ]]; then
Expand Down
Loading