detee-sgx/build_client.sh

44 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
SCRIPT=$0
EXAMPLE=$1
EXEC=$2
if [ $# -eq 0 ] || [ "$EXAMPLE" != "https" ] && [ "$EXAMPLE" != "grpcs" ]; then
echo "usage: $SCRIPT https|grpcs [--run]"
exit 1
fi
FEATURES=$(if [ "$EXAMPLE" == "https" ]; then echo "reqwest,occlum"; else echo "tonic,occlum"; fi)
occlum-cargo build --release --example mratls_"${EXAMPLE}"_client --features="$FEATURES"
strip target/x86_64-unknown-linux-musl/release/examples/mratls_"${EXAMPLE}"_client
cat > client.yaml <<EOF
includes:
- base.yaml
targets:
- target: /bin
copy:
- files:
- ../target/x86_64-unknown-linux-musl/release/examples/mratls_${EXAMPLE}_client
- target: /lib
copy:
- files:
- /opt/occlum/toolchains/dcap_lib/musl/libocclum_dcap.so.0.1.0
EOF
rm -rf client_instance && mkdir client_instance && cd client_instance
occlum init && rm -rf image
cp ../Occlum.json ./
copy_bom -f ../client.yaml --root image --include-dir /opt/occlum/etc/template
# TODO: "--enable-edmm Y" must be only for platforms that support SGX2
# TODO: make sure the bundle needs SGX2 to run since SGX1 is vulnerable to https://x.com/PratyushRT/status/1828183761055330373
occlum build --sign-key ../examples/signing_key.pem
occlum package client.tar.gz
if [ "$EXEC" == "--run" ]; then
occlum run /bin/mratls_${EXAMPLE}_client
fi