-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreinclude.sh
72 lines (64 loc) · 1.82 KB
/
preinclude.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# -------------------------------------------------------
# Copyright (c) 2020-2021 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
# -------------------------------------------------------
# Version: 1.0
# Date: 2020-02-19
# This script installs the Keil.PreIncludeTestPack
#
# Pre-requisites:
# - bash shell (for Windows: install git for Windows)
usage() {
echo "Usage:"
echo " $(basename $0) <Test Output directory>"
echo ""
}
# check command line for 1 argument
if [ $# -eq 1 ]; then
echo "info: using directory: $1"
testoutdir="$1"
elif [ $# -eq 0 ]; then
echo "error: no argument passed"
usage
exit 1
else
# >1 arguments are passed
echo "error: more than one command line argument passed"
usage
exit 1
fi
if [ ! -d "${testoutdir}" ]; then
echo "error: directory ${testoutdir} does not exist"
exit 1
fi
# Set environment variables
source ${testoutdir}/cbuild/etc/setup
packfile="${PWD}/../integrationtests/pack/Keil.PreIncludeTestPack.0.0.2.pack"
# construct pack folder name
remainder=($(basename $packfile))
vendor="${remainder%%.*}"; remainder="${remainder#*.}"
packname="${remainder%%.*}"; remainder="${remainder#*.}"
major="${remainder%%.*}"; remainder="${remainder#*.}"
minor="${remainder%%.*}"; remainder="${remainder#*.}"
patch="${remainder%%.*}"; remainder="${remainder#*.}"
packdir=$CMSIS_PACK_ROOT/$vendor/$packname/$major.$minor.$patch
# Install pre-include test pack
if [ -d "$packdir" ]; then
echo "info: PreIncludeTestPack is already installed"
else
# create pack directory
mkdir -p "$packdir"
pushd "$packdir"
# extract pack into versioned pack directory
unzip "$packfile"
popd
if [ $? -ne 0 ]; then
echo "error: unzip failed for $packfile"
# remove version directory and content as the unzip failed
rm -rf "$packdir"
exit 1
fi
fi
exit 0