Changeset 11013 in ntrip for trunk/BNC/scripts


Ignore:
Timestamp:
Sep 10, 2026, 11:48:43 AM (6 hours ago)
Author:
stuerze
Message:

mac package script improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/scripts/mac_package.sh

    r11012 r11013  
    1111#          - optionally signs with a real "Developer ID Application"
    1212#            identity if CODESIGN_IDENTITY is set in the environment
    13 #          - packages the result as a zip (via ditto, which preserves the
    14 #            code signature - plain `zip`/tar can corrupt it)
     13#          - packages the result as a dmg (drag-to-Applications, the
     14#            expected format for external users) and/or a zip
    1515#
    16 # Usage:   scripts/mac_package.sh [path/to/bnc.app]
     16# Usage:   scripts/mac_package.sh [--format dmg|zip|both] [path/to/bnc.app]
    1717#          CODESIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" \
    1818#            scripts/mac_package.sh
     
    3333fi
    3434
    35 APP_PATH="${1:-bnc.app}"
     35FORMAT="dmg"
     36APP_PATH=""
     37while [[ $# -gt 0 ]]; do
     38  case "$1" in
     39    --format)
     40      FORMAT="$2"
     41      shift 2
     42      ;;
     43    *)
     44      APP_PATH="$1"
     45      shift
     46      ;;
     47  esac
     48done
     49case "$FORMAT" in
     50  dmg|zip|both) ;;
     51  *) echo "error: --format must be dmg, zip, or both (got '$FORMAT')" >&2; exit 1 ;;
     52esac
     53
     54APP_PATH="${APP_PATH:-bnc.app}"
    3655if [[ ! -d "$APP_PATH" ]]; then
    3756  # fall back to the usual qmake output location (src.pro: TARGET = ../bnc)
     
    4564fi
    4665APP_PATH="$(cd "$(dirname "$APP_PATH")" && pwd)/$(basename "$APP_PATH")"
     66APP_NAME="$(basename "$APP_PATH" .app)"
    4767
    4868command -v macdeployqt >/dev/null 2>&1 || {
     
    5878  codesign --force --deep --options runtime --sign "$CODESIGN_IDENTITY" "$APP_PATH"
    5979  echo "   (remember to notarize + staple for Gatekeeper-clean distribution:"
    60   echo "    xcrun notarytool submit <zip> --keychain-profile <profile> --wait"
     80  echo "    xcrun notarytool submit <dmg-or-zip> --keychain-profile <profile> --wait"
    6181  echo "    xcrun stapler staple \"$APP_PATH\")"
    6282else
     
    6888codesign --verify --deep --strict --verbose=2 "$APP_PATH"
    6989
    70 ZIP_PATH="${APP_PATH%.app}.zip"
    71 echo "== packaging $ZIP_PATH =="
    72 rm -f "$ZIP_PATH"
    73 ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
     90if [[ "$FORMAT" == "zip" || "$FORMAT" == "both" ]]; then
     91  ZIP_PATH="${APP_PATH%.app}.zip"
     92  echo "== packaging $ZIP_PATH =="
     93  rm -f "$ZIP_PATH"
     94  # ditto preserves the code signature; plain zip/tar can corrupt it
     95  ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
     96  echo "Done: $ZIP_PATH"
     97fi
     98
     99if [[ "$FORMAT" == "dmg" || "$FORMAT" == "both" ]]; then
     100  DMG_PATH="${APP_PATH%.app}.dmg"
     101  echo "== packaging $DMG_PATH =="
     102  rm -f "$DMG_PATH"
     103  STAGING_DIR="$(mktemp -d)"
     104  trap 'rm -rf "$STAGING_DIR"' EXIT
     105  ditto "$APP_PATH" "$STAGING_DIR/$APP_NAME.app"
     106  ln -s /Applications "$STAGING_DIR/Applications"
     107  hdiutil create -volname "$APP_NAME" -srcfolder "$STAGING_DIR" -ov -format UDZO "$DMG_PATH"
     108  echo "Done: $DMG_PATH"
     109fi
    74110
    75111echo
    76 echo "Done: $ZIP_PATH"
    77112echo "Recipients of an unsigned/ad-hoc build must bypass Gatekeeper once:"
    78113echo "  - right-click the app -> Open -> confirm, or"
    79 echo "  - run: xattr -cr \"$(basename "$APP_PATH")\"  after unzipping"
     114echo "  - run: xattr -cr \"$APP_NAME.app\"  after mounting/unzipping"
Note: See TracChangeset for help on using the changeset viewer.