This repository has been archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfbtft-stage1
executable file
·318 lines (244 loc) · 7.06 KB
/
fbtft-stage1
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/bin/sh
set -ex
. ./common
WORKDIR=work
OUTDIR=out
PREVIMG=../$OUTDIR/fbtft-stage0.$IMGFORMAT
CURIMG=fbtft-stage1.$IMGFORMAT
install_packages() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
evtest \
xinput \
python-pip
# Disable this package as it contains a kernel, and thus removes the FBTFT drivers
apt-mark hold raspberrypi-bootloader
EOC
}
install_tslib() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
DEBIAN_FRONTEND=noninteractive apt-get install -y tslib libts-bin
# install ts_test with Quit button
wget -O /usr/bin/ts_test http://tronnes.org/downloads/ts_test
chmod +x /usr/bin/ts_test
EOC
}
install_xinput_calibrator() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
cd /tmp
wget http://adafruit-download.s3.amazonaws.com/xinput-calibrator_0.7.5-1_armhf.deb
DEBIAN_FRONTEND=noninteractive dpkg -i -B xinput-calibrator_0.7.5-1_armhf.deb
# ?? /etc/X11/xorg.conf.d/99-calibration.conf
EOC
}
install_wiringpi() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
cd /tmp
wget https://github.com/hamishcunningham/wiringpi/raw/master/package/2.13/unstable/wiringpi_2.13_armhf.deb
DEBIAN_FRONTEND=noninteractive dpkg -i wiringpi_2.13_armhf.deb
EOC
}
install_fbcp() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
DEBIAN_FRONTEND=noninteractive apt-get install -y cmake
cd /tmp
git clone https://github.com/tasanakorn/rpi-fbcp
mkdir -p rpi-fbcp/build && cd rpi-fbcp/build
cmake .. && make
install fbcp /usr/local/bin/fbcp
cat <<\EOF | tee /etc/init.d/fbcp
#!/bin/sh
### BEGIN INIT INFO
# Provides: fbcp
# Required-Start: $local_fs $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Framebuffer copy daemon fb0->fb1
### END INIT INFO
# Author: Noralf Tronnes <[email protected]>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Framebuffer copy daemon"
NAME=fbcp
DAEMON=/usr/local/bin/fbcp
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
rm -f $PIDFILE
return "$RETVAL"
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart|reload|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2
exit 3
;;
esac
:
EOF
chmod +x /etc/init.d/fbcp
EOC
}
update_rpi_update() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update
chmod +x /usr/bin/rpi-update
EOC
}
install_rpi_source() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source
chmod +x /usr/bin/rpi-source
HOME=/home/pi /usr/bin/rpi-source --tag-update
EOC
}
install_xstroke() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
DEBIAN_FRONTEND=noninteractive apt-get -y install libxft-dev libxpm-dev libxtst-dev
cd /tmp
wget http://mirror.egtvedt.no/avr32linux.org/twiki/pub/Main/XStroke/xstroke-0.6.tar.gz
tar xfv xstroke-0.6.tar.gz
cd xstroke-0.6/
./configure
make
make install
wget http://www.ozzmaker.com/piscreen/xstrokekill.desktop -O /usr/share/applications/xstrokekill.desktop
wget http://www.ozzmaker.com/piscreen/xstroke.desktop -O /usr/share/applications/xstroke.desktop
EOC
}
install_matchbox_keyboard() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf libtool libfakekey-dev libpng-dev
cd /tmp
git clone https://github.com/mwilliams03/matchbox-keyboard.git
cd matchbox-keyboard
./autogen.sh
make
make install
DEBIAN_FRONTEND=noninteractive apt-get install libmatchbox1 -y
cat <<\EOF | tee /usr/bin/toggle-matchbox-keyboard.sh
#!/bin/bash
#This script toggle the virtual keyboard
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard
else
matchbox-keyboard&
fi
EOF
chmod +x /usr/bin/toggle-matchbox-keyboard.sh
cat <<\EOF | tee /usr/local/share/applications/toggle-matchbox-keyboard.desktop
[Desktop Entry]
Name=Toggle Matchbox Keyboard
Comment=Toggle Matchbox Keyboard
Exec=toggle-matchbox-keyboard.sh
Type=Application
Icon=matchbox-keyboard.png
Categories=Panel;Utility;MB
X-MB-INPUT-MECHANSIM=True
EOF
EOC
}
install_cleanup() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOC
rm -rf /tmp/*
DEBIAN_FRONTEND=noninteractive apt-get clean && apt-get autoremove
EOC
}
cd $WORKDIR
sudo -v
dotask branch_image $PREVIMG $CURIMG
dotask run_qemu $CURIMG
dotask disable_starting_services
#dotask mount_apt_cache
dotask install_packages
dotask install_tslib
dotask install_xinput_calibrator
dotask install_wiringpi
dotask install_fbcp
dotask update_rpi_update
dotask install_rpi_source
sudo -v
dotask install_xstroke
sudo -v
dotask install_matchbox_keyboard
dotask install_cleanup
#dotask save_space_using_hardlink
dotask allow_starting_services
#dotask fingerprint_debian
#dotask update_issue
dotask shutdown_qemu
dotask finish_image