xref: /openbmc/qemu/scripts/entitlement.sh (revision cbb45ff0)
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
11DST="$1"
12SRC="$2"
13ICON="$3"
14ENTITLEMENT="$4"
15
16if $in_place; then
17  trap 'rm "$DST.tmp"' exit
18  cp -pPf "$SRC" "$DST.tmp"
19  SRC="$DST.tmp"
20else
21  cd "$MESON_INSTALL_DESTDIR_PREFIX"
22fi
23
24if test -n "$ENTITLEMENT"; 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