entitlement.sh 555 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh -e
  2. #
  3. # Helper script for the build process to apply entitlements
  4. in_place=:
  5. if [ "$1" = --install ]; then
  6. shift
  7. in_place=false
  8. fi
  9. DST="$1"
  10. SRC="$2"
  11. ICON="$3"
  12. ENTITLEMENT="$4"
  13. if $in_place; then
  14. trap 'rm "$DST.tmp"' exit
  15. cp -pPf "$SRC" "$DST.tmp"
  16. SRC="$DST.tmp"
  17. else
  18. cd "$MESON_INSTALL_DESTDIR_PREFIX"
  19. fi
  20. if test -n "$ENTITLEMENT"; then
  21. codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
  22. fi
  23. # Add the QEMU icon to the binary on Mac OS
  24. Rez -append "$ICON" -o "$SRC"
  25. SetFile -a C "$SRC"
  26. mv -f "$SRC" "$DST"
  27. trap '' exit