-
Notifications
You must be signed in to change notification settings - Fork 3
/
gen_pack.sh
107 lines (89 loc) · 2.29 KB
/
gen_pack.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Version: 1.0
# Date: 2018-05-25
# This bash script generates a CMSIS Software Pack:
#
# Requirements:
# bash shell
# curl
# zip (zip archiving utility)
#
# Upstream repository
UPSTREAM_URL=https://api.github.com/repos/intel/tinycbor
UPSTREAM_TAG=v0.5.3
# Pack Vendor
PACK_VENDOR=MDK-Packs
# Pack Name
PACK_NAME=TinyCBOR
# NO NEED TO EDIT BELOW
# Contributions merge
CONTRIB_MERGE=./contributions/merge
# Contributions additional folders/files
CONTRIB_ADD=./contributions/add
# Pack Destination Folder
PACK_DESTINATION=./
# Pack Build Folder
PACK_BUILD=./build
# Pack build utilities Repository
UTILITIES_URL=https://github.com/ARM-software/CMSIS_5/blob/master/
UTILITIES_TAG=1.0.0
UTILITIES_DIR=./Utilities
UTILITIES_OS=Win32
if [ $UTILITIES_OS = "Win32" ]; then
ZIP="/c/Program\ Files/7-Zip/7z.exe"
else
ZIP=zip
fi
# if not present, fetch utilities
if [ ! -d $UTILITIES_DIR ]; then
mkdir $UTILITIES_DIR
pushd $UTILITIES_DIR
mkdir $UTILITIES_OS
# PackChk
curl -L $UTILITIES_URL/CMSIS/Utilities/$UTILITIES_OS/PackChk.exe?raw=true -o $UTILITIES_OS/PackChk.exe
popd
fi
#if $PACK_BUILD folder does not exist create it and fetch content
if [ ! -d $PACK_BUILD ]; then
mkdir $PACK_BUILD
pushd $PACK_BUILD
curl -L $UPSTREAM_URL/tarball/$UPSTREAM_TAG | tar xz --strip=1
popd
fi
# Remove some unused files
rm -f $PACK_BUILD/.appveyor.yml
rm -f $PACK_BUILD/.gitattributes
rm -f $PACK_BUILD/.gitignore
rm -f $PACK_BUILD/.tag
rm -f $PACK_BUILD/.travis.yml
# Merge contributions into $PACK_BUILD
# add (must not overwrite)
cp -vr $CONTRIB_ADD/* $PACK_BUILD/
# Merge (will overwrite existing files)
#cp -vrf $CONTRIB_MERGE/* $PACK_BUILD/
# License file
cp -f $PACK_BUILD/LICENSE $PACK_BUILD/LICENSE.txt
# Run Pack Check and generate PackName file
$UTILITIES_DIR/$UTILITIES_OS/PackChk.exe $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc -n PackName.txt
errorlevel=$?
if [ $errorlevel -ne 0 ]; then
echo "build aborted: pack check failed"
exit
fi
PACKNAME=`cat PackName.txt`
rm -rf PackName.txt
# Archiving
# $ZIP a $PACKNAME
pushd $PACK_BUILD
/c/Program\ Files/7-Zip/7z.exe a ../$PACKNAME -tzip
popd
errorlevel=$?
if [ $errorlevel -ne 0 ]; then
echo "build aborted: archiving failed"
exit
fi
echo "build of pack succeeded"
# Clean up
echo "cleaning up"
rm -rf $PACK_BUILD
rm -rf $UTILITIES_DIR