-
Notifications
You must be signed in to change notification settings - Fork 50
/
publish
executable file
·122 lines (97 loc) · 3.86 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
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
cd $(dirname ${0})
#######################################################################################################################
# check arguments
PLATFORM=$1
PACKAGE=$2
if [ -z "${PLATFORM}" ] || [ -z "${PACKAGE}" ] || [ ! -e "plugins-dep/configs/${PLATFORM}_defconfig" ]; then
echo "Usage: $0 <platform> <plugin-package-name>"
echo " Where platform can be one of: $(echo $(ls plugins-dep/configs | grep _defconfig | sed 's/_defconfig//g' | sort))"
echo " and plugin-package-name is a folder inside ./plugins/package"
exit 1
fi
if [[ "${PACKAGE}" == "kernel" ]]; then
PLATFORM+="-kernel"
fi
#######################################################################################################################
# Verify device connection
if ping -c 1 -W 0.05 192.168.51.1 > /dev/null; then
TARGET=192.168.51.1
elif ping -c 1 -W 0.05 192.168.52.1 > /dev/null; then
TARGET=192.168.52.1
elif ping -c 1 -W 0.2 moddwarf.local > /dev/null; then
TARGET=moddwarf.local
elif ping -c 1 -W 0.2 modduox.local > /dev/null; then
TARGET=modduox.local
elif ping -c 1 -W 0.2 modduo.local > /dev/null; then
TARGET=modduo.local
else
echo "not connected"
exit 1
fi
#######################################################################################################################
# Import common code and variables
source .common
#######################################################################################################################
# kernel "package"
if [[ "${PACKAGE}" == "kernel" ]]; then
ssh root@${TARGET} "mount / -o remount,rw"
# FIXME find name automatically
scp -O ${WORKDIR}/${PLATFORM}/images/Image root@${TARGET}:/boot/Image-ff-px30
scp -O -r ${WORKDIR}/${PLATFORM}/target/lib/modules/*.* root@${TARGET}:/lib/modules/
exit 0
fi
#######################################################################################################################
# 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://${TARGET}/sdk/install; echo
done
popd >/dev/null
info "All plugin bundles installed"
exit 0
#######################################################################################################################