blob: 0f412949ec6c286c9655a7b0d8cd2d5f68271f9e [file] [log] [blame]
Alexander Graf8a74ce62021-01-20 23:44:34 +01001#!/bin/sh -e
2#
3# Helper script for the build process to apply entitlements
4
Akihiko Odaki237377a2021-02-25 09:06:14 +09005in_place=:
6if [ "$1" = --install ]; then
7 shift
8 in_place=false
9fi
10
Akihiko Odaki411ad8d2021-07-09 10:25:33 +090011DST="$1"
12SRC="$2"
13ICON="$3"
14ENTITLEMENT="$4"
Alexander Graf8a74ce62021-01-20 23:44:34 +010015
Akihiko Odaki237377a2021-02-25 09:06:14 +090016if $in_place; then
17 trap 'rm "$DST.tmp"' exit
Evan Miller4006a272021-11-30 12:30:12 -050018 cp -pPf "$SRC" "$DST.tmp"
Akihiko Odaki237377a2021-02-25 09:06:14 +090019 SRC="$DST.tmp"
20else
21 cd "$MESON_INSTALL_DESTDIR_PREFIX"
22fi
23
Akihiko Odaki411ad8d2021-07-09 10:25:33 +090024if test -n "$ENTITLEMENT"; then
John Arbuckle3983a762021-07-05 15:53:28 -040025 codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
26fi
27
28# Add the QEMU icon to the binary on Mac OS
29Rez -append "$ICON" -o "$SRC"
30SetFile -a C "$SRC"
31
Akihiko Odaki237377a2021-02-25 09:06:14 +090032mv -f "$SRC" "$DST"
Alexander Graf8a74ce62021-01-20 23:44:34 +010033trap '' exit