70 lines
2.4 KiB
Bash
Executable File
70 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Build and sign AppsManager.app after build_dylib.sh has produced the dylib.
|
|
#
|
|
# Required environment:
|
|
# APP_SOURCE Path to the original extracted ADManager.app
|
|
# PROVISION Path to a .mobileprovision for the target device(s)
|
|
# SIGN_IDENTITY Code signing identity, e.g. "Apple Distribution: Name (TEAMID)"
|
|
#
|
|
# Optional:
|
|
# ENTITLEMENTS Path to an entitlements plist (needed for App Group access)
|
|
# KEYCHAIN Keychain path for codesign
|
|
# INSERT_DYLIB Path to the insert_dylib/idylib tool (default: idylib)
|
|
# OUT_DIR Output directory (default: <source>/out)
|
|
# BUNDLE_ID CFBundleIdentifier (default: com.jbjf.appsmanager)
|
|
set -eu
|
|
|
|
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
APP_SOURCE=${APP_SOURCE:?Set APP_SOURCE to the extracted original ADManager.app}
|
|
PROVISION=${PROVISION:?Set PROVISION to your .mobileprovision}
|
|
SIGN_IDENTITY=${SIGN_IDENTITY:?Set SIGN_IDENTITY to your code signing identity}
|
|
ENTITLEMENTS=${ENTITLEMENTS:-}
|
|
KEYCHAIN=${KEYCHAIN:-}
|
|
INSERT_DYLIB=${INSERT_DYLIB:-idylib}
|
|
OUT_DIR=${OUT_DIR:-"$ROOT/out"}
|
|
BUNDLE_ID=${BUNDLE_ID:-com.jbjf.appsmanager}
|
|
DYLIB="$ROOT/hook/AppsManagerHook.dylib"
|
|
APP="$OUT_DIR/AppsManager.app"
|
|
|
|
if [ ! -f "$DYLIB" ]; then
|
|
echo "Missing $DYLIB; run build_dylib.sh first." >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -d "$APP_SOURCE" ]; then
|
|
echo "APP_SOURCE is not a directory: $APP_SOURCE" >&2
|
|
exit 1
|
|
fi
|
|
if ! command -v "$INSERT_DYLIB" >/dev/null 2>&1; then
|
|
echo "insert_dylib tool not found: $INSERT_DYLIB" >&2
|
|
exit 1
|
|
fi
|
|
|
|
rm -rf "$APP"
|
|
mkdir -p "$OUT_DIR"
|
|
cp -R "$APP_SOURCE" "$APP"
|
|
cp "$DYLIB" "$APP/AppsManagerHook.dylib"
|
|
cp "$PROVISION" "$APP/embedded.mobileprovision"
|
|
|
|
plutil -replace CFBundleIdentifier -string "$BUNDLE_ID" "$APP/Info.plist"
|
|
plutil -replace CFBundleDisplayName -string "Apps Manager" "$APP/Info.plist"
|
|
plutil -replace CFBundleName -string "AppsManager" "$APP/Info.plist"
|
|
|
|
cp "$APP/ADManager" "$APP/ADManager.orig"
|
|
"$INSERT_DYLIB" --inplace --overwrite --strip-codesig --all-yes \
|
|
"@executable_path/AppsManagerHook.dylib" "$APP/ADManager"
|
|
rm -f "$APP/ADManager.orig"
|
|
|
|
set -- -f -s "$SIGN_IDENTITY"
|
|
if [ -n "$KEYCHAIN" ]; then
|
|
set -- "$@" --keychain "$KEYCHAIN"
|
|
fi
|
|
if [ -n "$ENTITLEMENTS" ]; then
|
|
set -- "$@" --entitlements "$ENTITLEMENTS" --generate-entitlement-der
|
|
fi
|
|
|
|
codesign "$@" "$APP/AppsManagerHook.dylib"
|
|
codesign "$@" "$APP"
|
|
|
|
echo "built $APP"
|
|
otool -L "$APP/ADManager" | head -8
|