forked from mod-audio/mod-plugin-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish
executable file
·92 lines (72 loc) · 3.05 KB
/
publish
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
#!/bin/bash
#######################################################################################################################
# check arguments
PLATFORM=$1
PACKAGE=$2
if [[ "${PLATFORM}" == "" ]] || [[ "${PACKAGE}" == "" ]]; then
echo "Usage: $0 <platform> <plugin-package-name>"
echo " Where platform can be modduo[-static], modduox[-static], moddwarf or x86_64"
echo " and plugin-package-name is a folder inside ./plugins/package"
exit 1
fi
if [ "${PLATFORM}" != "modduo" ] && [ "${PLATFORM}" != "modduo-static" ] && [ "${PLATFORM}" != "modduox" ] && [ "${PLATFORM}" != "modduox-static" ] && [ "${PLATFORM}" != "moddwarf" ] && [ "${PLATFORM}" != "x86_64" ]; then
echo -e "\e[0;31mPlease provide either modduo[-static], modduox[-static], moddwarf or x86_64 as platform argument\e[0m"
exit 1
fi
#######################################################################################################################
# Import common code and variables
source .common
#######################################################################################################################
# Check if requested plugin package exists
PACKAGE=$(basename ${PACKAGE} | sed "s|\.mk||")
PKGNAME=$(echo ${PACKAGE} | tr a-z- A-Z_)
if [ ! -d ${SOURCE_DIR}/plugins/package/${PACKAGE} ]; then
error "Plugin package name '${PACKAGE}' does not exist"
exit 1
fi
if [ ! -f ${SOURCE_DIR}/plugins/package/${PACKAGE}/${PACKAGE}.mk ]; then
error "Requested plugin package has no 'mk' file"
exit 1
fi
bundles=($(cat ${SOURCE_DIR}/plugins/package/${PACKAGE}/${PACKAGE}.mk | awk 'sub("'${PKGNAME}'_BUNDLES = ","")'))
if [[ "${bundles}" == "" ]]; then
error "Requested plugin package has no bundles"
exit 1
fi
#######################################################################################################################
# Check if plugin path exists
PLUGIN_PATH="${WORKDIR}/${PLATFORM}/plugins"
if [ ! -e "${PLUGIN_PATH}" ]; then
error "Failed to find plugin installed bundles"
exit 1
fi
#######################################################################################################################
# check if all bundles are present
function bundle_has_binaries
{
if find "$1" -name "*.so" >/dev/null; then
return 0
else
return 1
fi
}
for bundle in ${bundles[@]}; do
if [ ! -d ${PLUGIN_PATH}/${bundle} ]; then
error "Failed to find plugin installed bundles"
exit 1
fi
if ! bundle_has_binaries ${PLUGIN_PATH}/${bundle}; then
error "Failed to find plugin installed bundles"
exit 1
fi
done
#######################################################################################################################
# alright, good to go
pushd "${PLUGIN_PATH}" >/dev/null
for bundle in ${bundles[@]}; do
tar cz "${bundle}" | base64 | curl -F 'package=@-' http://192.168.51.1/sdk/install; echo
done
popd >/dev/null
info "All plugin bundles installed"
exit 0
#######################################################################################################################