-
Notifications
You must be signed in to change notification settings - Fork 25
/
package.sh
executable file
·55 lines (44 loc) · 1015 Bytes
/
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
#!/bin/bash
set -eu
if [[ $# -eq 1 ]]
then
plugin=$1
version=''
elif [[ $# -eq 2 ]]
then
plugin=$1
version=$2
else
echo """Invalid number of arguments
Usage: ./package.sh <plugin> [<version>]
<plugin> is the name of the plugin, located in the directory with the same name
<version> (optional) is used to update main.py of the plugin"""
exit 1
fi
if [ $(uname -s) == 'Darwin' ]
then
tarcmd="tar -L"
md5cmd="md5"
else
tarcmd="tar -h"
md5cmd='md5sum'
fi
cd ${plugin}
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
if [[ -z "$version" ]]
then
version=`cat main.py | grep version | cut -d "\"" -f 2 | cut -d "'" -f 2 | head -n 1`
fi
if ! [[ $version =~ ^([0-9]+\.)([0-9]+\.)(\*|[0-9]+)$ ]]
then
echo "Not a valid plugin version $version"
exit 2
fi
tar_file=${plugin}_${version}.tgz
md5_file=${plugin}_${version}.md5
${tarcmd} -czf ${tar_file} *
mv ${tar_file} ..
cd ..
${md5cmd} ${tar_file} > ${md5_file}
cat ${md5_file}