This repository has been archived by the owner on May 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
install_DeviceBuilder.sh
117 lines (98 loc) · 4.78 KB
/
install_DeviceBuilder.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
set -x #echo on
#############################
#
# copyright 2018 Open Connectivity Foundation, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#############################
CURPWD=`pwd`
#path of the code
code_path=OCFDeviceBuilder
# linux pi
# default
ARCH=`uname -m`
echo "using architecture: $ARCH"
cd ..
# clone the repo
git clone https://github.com/openconnectivityfoundation/DeviceBuilder.git
# get the initial example
cp DeviceBuilder/DeviceBuilderInputFormat-file-examples/input-lightdevice.json example.json
# clone the iotivity cbor conversion tool
git clone https://github.com/alshafi/iotivity-tool.git
# install the python libraries that are needed for iotivity-tool
cd iotivity-tool
pip3 install -U -r requirements.txt
# create the initial security file and place it in the code directory.
cd $CURPWD
sh svr2cbor.sh tocbor
cd ..
# create the generation script
echo "#!/bin/bash" > gen.sh
echo "cd DeviceBuilder" >> gen.sh
echo "sh ./DeviceBuilder_C++IotivityServer.sh ../example.json ../device_output \"oic.d.light\"" >> gen.sh
echo "cd .." >> gen.sh
echo "# copying source code to compile location" >> gen.sh
echo "cp ./device_output/code/server.cpp ./iotivity/examples/${code_path}/server.cpp " >> gen.sh
echo "# making executable folder" >> gen.sh
echo "mkdir -p ./iotivity/out/linux/${ARCH}/release/examples/${code_path} >/dev/null 2>&1" >> gen.sh
echo "# copying the introspection file to the executable folder" >> gen.sh
echo "cp ./device_output/code/server_introspection.dat ./iotivity/out/linux/${ARCH}/release/examples/${code_path}/server_introspection.dat" >> gen.sh
echo "# quick fix: using the iotivity supplied oic_svr_db_server_justworks.dat file" >> gen.sh
# working copy line of clarke
# copying the file so that reset.sh works
#cp ~/iot/iotivity/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat ~/iot/device_output/code/server_security.dat
echo "cp ./iotivity/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat ./device_output/code/server_security.dat"
# working copy line from clarke :
# cp ~/IOT/iotivity/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat ~/IOT/iotivity/out/linux/armv7l/release/examples/OCFDeviceBuilder/server_security.dat
echo "cp ./iotivity/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat ./iotivity/out/linux/${ARCH}/release/examples/${code_path}/server_security.dat" >> gen.sh
#echo "cp ./device_output/code/server_security.dat ./iotivity/out/linux/${ARCH}/release/examples/${code_path}/server_security.dat" >> gen.sh
# create the build script
echo "#!/bin/bash" > build.sh
echo "cd iotivity" >> build.sh
echo "#uncomment next line for building without security" >> build.sh
echo "#scons examples/${code_path} SECURED=0" >> build.sh
echo "scons examples/${code_path}" >> build.sh
echo "cd .." >> build.sh
# create the edit code script
echo "#!/bin/bash" > edit_code.sh
echo "nano ./iotivity/examples/${code_path}/server.cpp" >> edit_code.sh
# create the edit input script
echo "#!/bin/bash" > edit_input.sh
echo "nano ./example.json" >> edit_input.sh
# create the run script
echo "#!/bin/bash"> run.sh
echo 'CURPWD=`pwd`'>> run.sh
#echo 'CURPWD=$(pwd -P)'>> run.sh
echo "env LD_LIBRARY_PATH=${CURPWD}/mraa/build/src" >> run.sh
echo "sudo ldconfig" >> run.sh
echo "cd ./iotivity/out/linux/${ARCH}/release/examples/${code_path}" >> run.sh
echo "pwd" >> run.sh
echo "ls" >> run.sh
echo "./server" >> run.sh
echo 'cd $CURPWD' >> run.sh
# create the reset script
echo "#!/bin/bash"> reset.sh
echo "mkdir -p ./iotivity/out/linux/${ARCH}/release/examples/${code_path} >/dev/null 2>&1" >> reset.sh
echo "rm -f ./iotivity/out/linux/${ARCH}/release/examples/${code_path}/server_security.dat" >> reset.sh
echo "#cp ./device_output/code/server_security.dat ./iotivity/out/linux/${ARCH}/release/examples/${code_path}/server_security.dat" >> reset.sh
echo "cp ./iotivity/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat ./iotivity/out/linux/${ARCH}/release/examples/${code_path}/server_security.dat" >> reset.sh
cd $CURPWD
echo "making the example directory"
mkdir -p ../iotivity/examples/${code_path}
# add the build file
cp ./SConscript ../iotivity/examples/${code_path}/SConscript
# add the build dir
cp ./SConstruct ../iotivity/.
chmod a+x ../*.sh