1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# Copyright (c) 2020, Linaro Limited.
4
5if [ $# -ne 2 ]; then
6	echo "usage: prepare_suite.sh <optee_test base dir> <gp suite archive>"
7	exit 1
8fi
9
10set -e
11
12if [ -e $1/host/xtest/gp-suite ]; then
13	# Clean up last patching in case it failed in some way
14	rm -rf $1/host/xtest/gp-suite
15fi
16mkdir -p $1/host/xtest/gp-suite
177z x -o$1/host/xtest/gp-suite $2
18cd $1/host/xtest/gp-suite
19mv TEE_Initial_Configuration-Test_Suite_v2_0_0_2-2017_06_09/* .
20rmdir TEE_Initial_Configuration-Test_Suite_v2_0_0_2-2017_06_09
21rm -f TTAs_Internal_API_1_1_1/TEE_include/tee_internal_api.h
22chmod -R u+w .
23for p in `echo ../gp/patches/*.patch | sort -n` ;do
24	echo Applying $p
25	patch -p1 < $p
26done
27