Merge remote-tracking branch 'remotes/alistair23/tags/pull-riscv-to-apply-20211022...
[qemu.git] / scripts / entitlement.sh
1 #!/bin/sh -e
2 #
3 # Helper script for the build process to apply entitlements
4
5 in_place=:
6 if [ "$1" = --install ]; then
7 shift
8 in_place=false
9 fi
10
11 SRC="$1"
12 DST="$2"
13 ENTITLEMENT="$3"
14
15 if $in_place; then
16 trap 'rm "$DST.tmp"' exit
17 cp -af "$SRC" "$DST.tmp"
18 SRC="$DST.tmp"
19 else
20 cd "$MESON_INSTALL_DESTDIR_PREFIX"
21 fi
22
23 codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
24 mv -f "$SRC" "$DST"
25 trap '' exit