58 lines
2.4 KiB
Bash
Executable File
58 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
build_for_arch() {
|
|
local arch="$1"
|
|
local scratch=".build/server-$arch"
|
|
swift build -c release --product EzServerMac --arch "$arch" --scratch-path "$scratch" >&2 || return
|
|
swift build -c release --arch "$arch" --scratch-path "$scratch" --show-bin-path
|
|
}
|
|
|
|
runtime="${EZSERVER_RUNTIME:-$PWD/.build/ezserver-macos/runtime}"
|
|
installer="$PWD/_source/EzServer V4.1.6 Setup.exe"
|
|
if [[ ! -e "$runtime" && -f "$installer" ]]; then
|
|
EZSERVER_RUNTIME="$runtime" ./server/prepare.sh "$installer"
|
|
fi
|
|
if [[ -e "$runtime" || "${EZSERVER_REQUIRE_PHP:-0}" == 1 ]]; then
|
|
if [[ ! -f "$runtime/www/ezwebserver/src/public/api/index.php" ||
|
|
! -f "$runtime/www/ezwebserver/src/vendor/autoload.php" ]]; then
|
|
printf 'Original PHP runtime missing or incomplete: %s\n' "$runtime" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
arm64_bin="$(build_for_arch arm64)"
|
|
x86_64_bin="$(build_for_arch x86_64)"
|
|
mkdir -p dist
|
|
stage="$(mktemp -d dist/.EzServer.XXXXXX)"
|
|
trap 'rm -rf "$stage"' EXIT
|
|
app="$stage/EzServer.app"
|
|
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
|
|
binary="$app/Contents/MacOS/EzServerMac"
|
|
xcrun lipo -create "$arm64_bin/EzServerMac" "$x86_64_bin/EzServerMac" -output "$binary"
|
|
xcrun lipo "$binary" -verify_arch arm64 x86_64
|
|
cp Packaging/Info.plist "$app/Contents/Info.plist"
|
|
cp README.md "$app/Contents/Resources/README.md"
|
|
ditto Packaging/webconsole "$app/Contents/Resources/webconsole"
|
|
if [[ -d "$runtime" ]]; then
|
|
php_resources="$app/Contents/Resources/php"
|
|
mkdir -p "$php_resources"
|
|
cp server/{run.sh,router.php,nginx.conf.in,php-fpm.conf.in,init-sqlite.php,patients.sqlite.sql,sqlite-database.php,sqlite-rest.php} \
|
|
"$php_resources/"
|
|
mkdir "$php_resources/runtime"
|
|
ditto "$runtime/www" "$php_resources/runtime/www"
|
|
cp "$runtime/index.html" "$php_resources/runtime/index.html"
|
|
application="$php_resources/runtime/www/ezwebserver/src/application"
|
|
rm -rf "$application/logs" "$application/cache/sessions"
|
|
mkdir -p "$application/logs" "$application/cache/sessions"
|
|
fi
|
|
codesign --force --sign - "$app"
|
|
codesign --verify --deep --strict "$app"
|
|
ditto -c -k --keepParent "$app" "$stage/EzServerMac-universal.zip"
|
|
rm -rf dist/EzServer.app
|
|
mv "$app" dist/EzServer.app
|
|
mv "$stage/EzServerMac-universal.zip" dist/EzServerMac-universal.zip
|
|
printf '%s\n' "$PWD/dist/EzServerMac-universal.zip"
|