xref: /openbmc/qemu/scripts/entitlement.sh (revision 5111edaf)
1#!/bin/sh -e
2#
3# Helper script for the build process to apply entitlements
4
5in_place=:
6if [ "$1" = --install ]; then
7  shift
8  in_place=false
9fi
10
11SRC="$1"
12DST="$2"
13ENTITLEMENT="$3"
14ICON="$4"
15
16if $in_place; then
17  trap 'rm "$DST.tmp"' exit
18  cp -af "$SRC" "$DST.tmp"
19  SRC="$DST.tmp"
20else
21  cd "$MESON_INSTALL_DESTDIR_PREFIX"
22fi
23
24if test "$ENTITLEMENT" != '/dev/null'; then
25  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
32mv -f "$SRC" "$DST"
33trap '' exit
34