forked from tenbaht/sduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_tools_entry.sh
More file actions
executable file
·122 lines (100 loc) · 2.55 KB
/
gen_tools_entry.sh
File metadata and controls
executable file
·122 lines (100 loc) · 2.55 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# helper script for automatic releases.
#
# Prints one platform entry for the given file to be added to the
# package_*.json file.
if [ $# -ne 3 ]; then
echo "
helper script for automatic releases.
Prints a full tool entry for the given filename stem to be added to the
package_*_index.json file. It will include all OS variants found with the
same filename stem and the same version specifier.
usage: $0 toolfile-stem toolversion coreversion
Lists info for all files matching the filename pattern
[toolsfile-stem]*[version]*
The coreversion is only needed to build the download link.
Example: $0 release/sduino-tools 2017-10-21 0.3.1
prints information for all files matching the filename pattern
release/sduino-tools*2017-10-21* and generates download links
for a github release directory download/v0.3.1.
"
exit 1
fi
TRUNK=$1
VERSION=$2
COREVERSION=$3
BASEURL=https://github.com/tenbaht/sduino/releases/download/v${COREVERSION}
### helper functions #####################################################
# format ID information for a file
#
# usage: print_filedata filename
#
print_filedata()
{
FILENAME=$(basename "$1")
URL=${BASEURL}/${FILENAME}
SIZE=$(stat --printf="%s" $1)
CHKSUM=$(shasum -a 256 $1|cut "-d " -f1)
cat << EOF
"url": "$URL",
"archiveFileName": "$FILENAME",
"checksum": "SHA-256:$CHKSUM",
"size": "$SIZE"
EOF
}
# detect the host system type for the given file
detect_hosttype()
{
case $1 in
*amd64-unknown-linux* | *linux64* )
HOST="x86_64-pc-linux-gnu"
;;
*mingw32*)
HOST="i686-mingw32"
;;
*i386-unknown-linux* | *linux32* )
HOST="i686-pc-linux-gnu"
;;
*macosx*)
HOST="x86_64-apple-darwin"
;;
esac
}
# detect the tool type/name for the given file
detect_tooltype()
{
case $1 in
*sduino-tools* )
NAME=STM8Tools
VERSIONSTRING=$VERSION
;;
*sdcc* )
NAME=sdcc
VERSIONSTRING=build.$VERSION
;;
esac
}
### print a tool entry for the given file ############################
detect_tooltype "$TRUNK"
cat << EOF
{
"name": "$NAME",
"version": "$VERSIONSTRING",
"systems": [
{
EOF
n=0
for FILE in $TRUNK*$VERSION.*; do
if [ $n -gt 0 ]; then
echo " },{"
fi
detect_hosttype "$FILE"
echo " \"host\": \"$HOST\","
print_filedata "$FILE"
n=$((n+1))
done
cat << EOF
}
]
},
EOF