Updates to scanner with CVE saving and auto update

This commit is contained in:
Mark Gregory
2026-10-22 15:11:17 +01:00
parent 1da7234864
commit 2c90bcb365
15 changed files with 2669 additions and 17 deletions
+27 -8
View File
@@ -1,11 +1,30 @@
#!/bin/zsh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CONFIG="${CONFIGURATION:-Debug}"
DERIVED="${DERIVED_DATA_PATH:-$ROOT/.build}"
command -v xcodebuild >/dev/null || { echo "Xcode command line tools required" >&2; exit 1; }
xcodebuild -project "$ROOT/PHPGuard.xcodeproj" -scheme PHPGuard -configuration "$CONFIG" -derivedDataPath "$DERIVED" CODE_SIGNING_ALLOWED=NO build
APP="$DERIVED/Build/Products/$CONFIG/PHPGuard.app"
[[ -d "$APP" ]] || { echo "Built application not found: $APP" >&2; exit 1; }
echo "Built: $APP"
if [[ "${LAUNCH_AFTER_BUILD:-1}" == "1" ]]; then open "$APP"; fi
cd "$ROOT"
DERIVED="$ROOT/.build"
xcodebuild \
-project PHPGuard.xcodeproj \
-scheme PHPGuard \
-configuration Debug \
-derivedDataPath "$DERIVED" \
CODE_SIGNING_ALLOWED=NO \
build
APP="$DERIVED/Build/Products/Debug/PHPGuard.app"
[[ -d "$APP" ]] || {
echo "PHPGuard.app not found" >&2
exit 1
}
"$ROOT/Scripts/install-app-icon.sh" "$APP"
echo
echo "Build complete: $APP"
pkill -x PHPGuard 2>/dev/null || true
open "$APP"
+11
View File
@@ -0,0 +1,11 @@
#!/bin/zsh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CONFIG="${CONFIGURATION:-Debug}"
DERIVED="${DERIVED_DATA_PATH:-$ROOT/.build}"
command -v xcodebuild >/dev/null || { echo "Xcode command line tools required" >&2; exit 1; }
xcodebuild -project "$ROOT/PHPGuard.xcodeproj" -scheme PHPGuard -configuration "$CONFIG" -derivedDataPath "$DERIVED" CODE_SIGNING_ALLOWED=NO build
APP="$DERIVED/Build/Products/$CONFIG/PHPGuard.app"
[[ -d "$APP" ]] || { echo "Built application not found: $APP" >&2; exit 1; }
echo "Built: $APP"
if [[ "${LAUNCH_AFTER_BUILD:-1}" == "1" ]]; then open "$APP"; fi
+40
View File
@@ -0,0 +1,40 @@
#!/bin/zsh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SOURCE="$ROOT/PHPGuard/Assets.xcassets/AppIcon.appiconset/icon-1024.png"
[[ -f "$SOURCE" ]] || {
echo "Missing PHPGuard icon: $SOURCE" >&2
exit 1
}
APP="${1:?Pass the path to PHPGuard.app}"
RESOURCES="$APP/Contents/Resources"
mkdir -p "$RESOURCES"
ICONSET="$(mktemp -d)/PHPGuard.iconset"
mkdir -p "$ICONSET"
for size in 16 32 128 256 512; do
sips -s format png -z "$size" "$size" "$SOURCE" \
--out "$ICONSET/icon_${size}x${size}.png" >/dev/null
double=$((size * 2))
sips -s format png -z "$double" "$double" "$SOURCE" \
--out "$ICONSET/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$ICONSET" -o "$RESOURCES/PHPGuard.icns"
/usr/libexec/PlistBuddy \
-c "Delete :CFBundleIconFile" \
"$APP/Contents/Info.plist" 2>/dev/null || true
/usr/libexec/PlistBuddy \
-c "Add :CFBundleIconFile string PHPGuard.icns" \
"$APP/Contents/Info.plist"
echo "PHPGuard application icon installed."
+49
View File
@@ -12,6 +12,22 @@ DERIVED="$ROOT/.build"
xcodebuild -project "$ROOT/PHPGuard.xcodeproj" -scheme PHPGuard -configuration Release -derivedDataPath "$DERIVED" CODE_SIGNING_ALLOWED=NO build
APP="$DERIVED/Build/Products/Release/PHPGuard.app"
[[ -d "$APP" ]] || { echo "Missing Release app" >&2; exit 1; }
echo "=== VERIFY APPLICATION ICON ==="
APP_ICON_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIconFile" "$APP/Contents/Info.plist" 2>/dev/null || true)
if [[ -z "$APP_ICON_NAME" ]]; then
echo "ERROR: Application icon is missing from Info.plist" >&2
exit 1
fi
echo "Application icon: $APP_ICON_NAME"
if [[ ! -f "$APP/Contents/Resources/Assets.car" ]]; then
echo "ERROR: Compiled asset catalog missing" >&2
exit 1
fi
VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")"
mkdir -p "$ROOT/dist"
STAGING="$(mktemp -d)"
@@ -29,7 +45,40 @@ if [[ -f "$INSTALLER_ICON" ]]; then
mkdir -p "$STAGING/.background"
cp "$INSTALLER_ICON" "$STAGING/.background/PHPGuard-Installer.png"
fi
# Generate a proper macOS installer icon.
INSTALLER_PNG="$ROOT/PHPGuard/Assets.xcassets/InstallerIcon.imageset/icon.png"
ICONSET="$ROOT/dist/PHPGuardInstaller.iconset"
INSTALLER_ICNS="$ROOT/dist/PHPGuardInstaller.icns"
if [[ -f "$INSTALLER_PNG" ]]; then
rm -rf "$ICONSET"
mkdir -p "$ICONSET"
for size in 16 32 128 256 512; do
sips -s format png -z "$size" "$size" "$INSTALLER_PNG" --out "$ICONSET/icon_${size}x${size}.png" >/dev/null
double=$((size * 2))
sips -s format png -z "$double" "$double" "$INSTALLER_PNG" --out "$ICONSET/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$ICONSET" -o "$INSTALLER_ICNS"
rm -rf "$ICONSET"
else
echo "ERROR: Installer artwork missing" >&2
exit 1
fi
hdiutil create -volname "PHPGuard $VERSION" -srcfolder "$STAGING" -ov -format UDZO "$DMG"
# Apply custom Finder icon to the DMG.
if command -v fileicon >/dev/null 2>&1; then
fileicon set "$DMG" "$INSTALLER_ICNS"
else
echo "WARNING: fileicon is not installed."
echo "Install with: brew install fileicon"
echo "DMG created without a custom Finder icon."
fi
xcrun notarytool submit "$DMG" --keychain-profile "$PROFILE" --wait
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
+36
View File
@@ -0,0 +1,36 @@
#!/bin/zsh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
command -v xcodebuild >/dev/null || { echo "Xcode is required" >&2; exit 1; }
command -v hdiutil >/dev/null || { echo "hdiutil missing" >&2; exit 1; }
IDENTITY="${SIGNING_IDENTITY:-$(security find-identity -v -p codesigning | sed -nE 's/.*"(Developer ID Application: [^"]+)".*/\1/p' | head -1)}"
[[ -n "$IDENTITY" ]] || { echo "Developer ID Application signing identity required. Set SIGNING_IDENTITY." >&2; exit 1; }
PROFILE="${NOTARY_PROFILE:-}"
[[ -n "$PROFILE" ]] || { echo "Set NOTARY_PROFILE to an existing notarytool keychain profile." >&2; exit 1; }
DERIVED="$ROOT/.build"
xcodebuild -project "$ROOT/PHPGuard.xcodeproj" -scheme PHPGuard -configuration Release -derivedDataPath "$DERIVED" CODE_SIGNING_ALLOWED=NO build
APP="$DERIVED/Build/Products/Release/PHPGuard.app"
[[ -d "$APP" ]] || { echo "Missing Release app" >&2; exit 1; }
VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")"
mkdir -p "$ROOT/dist"
STAGING="$(mktemp -d)"
trap 'rm -rf "$STAGING"' EXIT
cp -R "$APP" "$STAGING/PHPGuard.app"
# No --deep signing: sign embedded executables individually if added in future.
codesign --force --options runtime --timestamp --sign "$IDENTITY" "$STAGING/PHPGuard.app"
codesign --verify --strict --verbose=2 "$STAGING/PHPGuard.app"
DMG="$ROOT/dist/PHPGuard-$VERSION.dmg"
rm -f "$DMG"
ln -s /Applications "$STAGING/Applications"
# Include a branded installer graphic in the disk image.
INSTALLER_ICON="$ROOT/PHPGuard/Assets.xcassets/InstallerIcon.imageset/icon.png"
if [[ -f "$INSTALLER_ICON" ]]; then
mkdir -p "$STAGING/.background"
cp "$INSTALLER_ICON" "$STAGING/.background/PHPGuard-Installer.png"
fi
hdiutil create -volname "PHPGuard $VERSION" -srcfolder "$STAGING" -ov -format UDZO "$DMG"
xcrun notarytool submit "$DMG" --keychain-profile "$PROFILE" --wait
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
echo "Release ready: $DMG"