forked from arduino/ArduinoCore-mbed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·97 lines (81 loc) · 2.34 KB
/
package.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
#!/bin/bash
# The scope of this file is splitting the build into self consistent packages for distribution
echo "========== Configuration ==============="
source $1
export VERSION=2.0.0
echo $VERSION
echo $FLAVOUR
echo $VARIANTS
echo $FQBNS
# Remove libraries not in $LIBRARIES list
if [ x$FLAVOUR != x ]; then
mkdir _libraries
cd libraries
for library in $LIBRARIES; do
mv $library ../_libraries
done
cd ..
rm -rf libraries
mv _libraries libraries
# Remove variants not in $VARIANTS list
mkdir _variants
cd variants
for variant in $VARIANTS; do
mv $variant ../_variants
done
cd ..
rm -rf variants
mv _variants variants
# Remove fqbns not in $FQBNS list
touch _boards.txt
# Save all menus (will not be displayed if unused)
cat boards.txt | grep "^menu\." >> _boards.txt
for board in $FQBNS; do
cat boards.txt | grep "$board\." >> _boards.txt
done
mv _boards.txt boards.txt
fi
# Remove bootloaders not in $BOOTLOADERS list
mkdir _bootloaders
cd bootloaders
for bootloaders in $BOOTLOADERS; do
mv $bootloaders ../_bootloaders
done
cd ..
rm -rf bootloaders
mv _bootloaders bootloaders
#Patch title in platform.txt
touch _platform.txt
cat platform.txt |
sed "s/%%NAME%%/Electronic Cats Mbed OS test Boards/g" |
sed "s/%%VERSION%%/$VERSION/g" > _platform.txt
rm platform.txt
mv _platform.txt platform.txt
BASE_FOLDER=`basename $PWD`
#Move one folder up, erase if any release exists
cd ..
if [ -d "release" ]; then
rm -rf release
fi
#Package! (remove .git, patches folders)
tar --exclude='*.git*' --exclude='*patches*' -cjhf electroniccats-mbed-$FLAVOUR-$VERSION.tar.bz2 $BASE_FOLDER
if [ x$FLAVOUR == x ]; then
mv electroniccats-mbed-$FLAVOUR-$VERSION.tar.bz2 ArduinoCore-mbed-$VERSION.tar.bz2
export FILENAME=electroniccats-mbed-$VERSION.tar.bz2 > /tmp/env
else
export FILENAME=electroniccats-mbed-$FLAVOUR-$VERSION.tar.bz2 > /tmp/env
fi
mkdir release
mv $FILENAME release/$FILENAME
CHKSUM=`shasum -a 256 release/$FILENAME | awk '{ print $1 }'`
SIZE=`wc -c release/$FILENAME | awk '{ print $1 }'`
cat ARDUINOCORE-MBED/extras/package_index.json.NewTag.template |
# sed "s/%%BUILD_NUMBER%%/${BUILD_NUMBER}/" |
# sed "s/%%CURR_TIME%%/${CURR_TIME_SED}/" |
sed "s/%%VERSION%%/${VERSION}/" |
sed "s/%%FILENAME%%/${FILENAME}/" |
sed "s/%%CHECKSUM%%/${CHKSUM}/" |
sed "s/%%SIZE%%/${SIZE}/" > release/package_${CORE_NAME}_${VERSION}_index.json
cd -
git reset --hard
echo "release complete"