-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-kivy.sh
executable file
·250 lines (208 loc) · 7.24 KB
/
install-kivy.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Albert Casals - [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# install-kivy.sh
#
# Script to run on the RaspberryPI to download, build and install the Kivy.org framework.
# With additions to install additional tools, some Kivy samples, and system tweaks.
#
# This script is targeted at Raspbian Jessie version
#
# System jail protection code
ARM_MUST_BE='armv7l'
mach=`uname -m`
if [ "$mach" != "$ARM_MUST_BE" ]; then
echo "Careful! Looks like I am not running inside an ARM system!"
echo "uname -m is telling me: $mach"
exit 1
else
# Avoid errors from stopping the script
set +e
fi
# If no Kivy source release is provided
# install the latest unstable master branch
if [ "$1" == "" ]; then
kivy_release="master"
else
kivy_release="$1"
fi
# List of packages needed to build Kivy and additional tools
BUILD_PKGS="
pkg-config libgl1-mesa-dev libgles2-mesa-dev
python-pygame python-setuptools python3-setuptools libgstreamer1.0-dev git-core
gstreamer1.0-plugins-bad gstreamer1.0-plugins-base
gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly
gstreamer1.0-omx gstreamer1.0-alsa python-dev python3-dev
vim vim-python-jedi emacs python-mode mc
libmtdev1
libpng12-dev
zip unzip sshfs
libsdl2-dev
libsdl2-gfx-dev
libsdl2-image-dev
libsdl2-mixer-dev
libsdl2-net-dev
libsdl2-ttf-dev
libpcre3 libfreetype6
fonts-freefont-ttf dbus
python-docutils
libssl1.0.0 libsmbclient libssh-4
python-rpi.gpio python3-rpi.gpio raspi-gpio wiringpi
libraspberrypi-dev wget
libvncserver-dev
python-beautifulsoup
python3-bs4
"
echo ">>> KivyPie build process starts at: `date`"
# Bring APT up to date and install dependant software
echo ">>> Bringing the system up to date"
apt-get update
apt-get install -y --force-yes $BUILD_PKGS
apt-get autoclean
# upgrade to latest PIP for python 2 and 3
echo ">>> Installing pip and pip3"
easy_install3 -U pip
easy_install -U pip
# Stop services started due to the installation
/etc/init.d/dbus stop
echo ">>> Build and install Cython"
pip install cython==0.23
pip3 install cython==0.23
echo ">>> Installing pygments"
pip install pygments
pip3 install pygments
# get Kivy source code
kivy_url="https://github.com/kivy/kivy/archive/$kivy_release.zip"
sourcezip=/tmp/kivy_source.zip
cd /tmp
# cleanup previous build
rm -fv $sourcezip
rm -rfv /tmp/kivi-$kivy_release
# download and unzip sources
echo ">>> Downloading kivy source code url: $kivy_url"
curl -s -L $kivy_url > $sourcezip
unzip -o $sourcezip
# build kivy for python 3
echo ">>> PIP3 is building kivy for Python 3...."
cd /tmp/kivy-$kivy_release
pip3 install --upgrade .
# cleanup previous kivy build for python 3
rm -rfv /tmp/kivi-$kivy_release
unzip -o $sourcezip
# now build kivy for python 2
echo ">>> PIP is building kivy for Python 2...."
cd /tmp/kivy-$kivy_release
pip install --upgrade .
echo ">>> Setting Kivy to point to Python3"
ln -sfv /usr/bin/python3 /usr/bin/kivy
kivy -V
# Build screnshot tool
cd /tmp
echo "Building raspi2png screenshot tool"
rm raspi2png.zip
rm -rf raspi2png-master
curl -L -k https://github.com/AndrewFromMelbourne/raspi2png/archive/master.zip > raspi2png.zip
unzip -o raspi2png.zip
cd raspi2png-master
make
cp -fv raspi2png /usr/bin
cd /tmp
rm -rf raspi2png-master
rm raspi2png.zip
# Build a VNC server for Kivy Apps
cd /tmp
rm dispmanx_vnc.zip
rm -rf dispmanx_vnc-master
curl -L -k https://github.com/hanzelpeter/dispmanx_vnc/archive/master.zip > dispmanx_vnc.zip
unzip -o dispmanx_vnc.zip
cd dispmanx_vnc-master
make
cp -fv dispmanx_vncserver /usr/local/bin/
cd /tmp
rm -rf dispmanx_vnc-master
rm dispmanx_vnc.zip
#
# System tweaks to make Kivy play well
#
username="sysop"
echo ">> Setup input device for regular keyboard and mouse"
usernamedir="/home/$username"
kivdir=$usernamedir/.kivy
kivini=$kivdir/config.ini
mkdir $kivdir
# Create kivy configuration file
cat <<EOF > $kivini
[input]
mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput
[modules]
touchring = scale=0.3,alpha=0.7,show_cursor=1
EOF
# Allow kivy apps to be run as root
echo ">>> configuring Kivy default configurations"
mkdir -p /root/.kivy
cp -fv /home/$username/.kivy/config.ini /root/.kivy
# Many kivy apps expect a .config home directory
mkdir -p /home/$username/.config
# Explain what we built to the logs
echo "Kivy version built:"
echo "import kivy; print kivy.__version__" | python -
echo "Copying Kivy sources used to build this version"
cp -fv ${kivy_source_zip}.zip $usernamedir
echo ">>> Getting latest kivy documentation in PDF"
kivypdf=$usernamedir/kivy-documentation.pdf
wget -q http://kivy.org/docs/pdf/Kivy-latest.pdf -O $kivypdf
#
# Clone sample projects and demos included in KivyPie
#
cd /home/$username
# sample 1: mesh objects
readmefile=/home/$username/mesh-manipulation/README.txt
mkdir -p /home/$username/mesh-manipulation
curl -L -k https://raw.githubusercontent.com/kivy/kivy/master/examples/canvas/mesh_manipulation.py > /home/$username/mesh-manipulation/mesh_manipulation.py
echo "Sample 1: Mesh manipulation" > $readmefile
echo " http://blog.tshirtman.fr/2014/1/29/kivy-image-manipulations-with-mesh-and-textures" >> $readmefile
echo "sample 2: flappykivy game"
curl -L -k https://github.com/superman3275/FlappyKivy/archive/master.tar.gz | tar zxf -
echo "sample 3: piki GPIO games"
curl -L -k https://github.com/kivy/piki/archive/master.tar.gz | tar zxf -
echo "sample 4: 3d picking objects"
curl -L -k https://github.com/nskrypnik/kivy-3dpicking/archive/master.tar.gz | tar zxf -
# http://inclem.net/pages/kivy-crash-course/
echo "sample 5: Kivy tutorial sources from Alexander Taylor"
curl -L -k https://github.com/inclement/kivycrashcourse/archive/master.tar.gz | tar zxf -
# http://inclem.net/pages/kivy-crash-course/
echo "sample 6: elUruguayo"
curl -L -k https://github.com/elParaguayo/RPi-InfoScreen-Kivy/archive/master.tar.gz | tar zxf -
# make it easier to reach the amazing examples :)
sudo ln -s /usr/local/share/kivy-examples/ /home/$username/kivy-examples
# Fix user permissions to all downloaded stuff
echo "Setting permissions for all $username home dir user files"
chown -R $username:$username $usernamedir
ls -auxlh $usernamedir
# Change the message of the day
echo "Welcome to KivyPie" > /etc/motd
echo "KivyPie build process finished at: `date`"
exit 0