-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvm-setup.expect
41 lines (33 loc) · 1.33 KB
/
vm-setup.expect
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
#!/usr/bin/expect -f
set timeout 300
# It's not possible to boot into Raspbian in qemu normally because of a file in
# the image called "/etc/ld.so.preload", which loads a library that overrides the
# default memcpy implementation. It's called raspi-copies-and-fills.
#
# The following command patches this file by commenting the line. It's pretty
# fragile, as it relies on the first occurence of this string being the contents
# of the file /etc/ld.so.preload. So, yeah. Might need looking at when the base
# raspbian image is updated.
system "./patch-img.py '/usr/lib/arm-linux-gnueabihf/libarmmem.so\n' '#usr/lib/arm-linux-gnueabihf/libarmmem.so\n' build/disk.img"
spawn qemu-system-arm \
-kernel kernel-qemu \
-cpu arm1176 \
-m 256 \
-M versatilepb \
-no-reboot \
-nographic \
-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash console=ttyAMA0" \
-hda build/disk.img
# patch /etc/fstab to prevent errors during boot. It contains references
# to the memorycard that's not present on boot in qemu. In its place we
# put a reference to only the /proc filesystem
expect "root@(none):/# "
send "mv /etc/fstab /etc/fstab.bak\r"
expect "# "
send "echo 'proc /proc proc defaults 0 0' > /etc/fstab\r"
expect "# "
send "sync\r"
# reboot
expect "# "
send "\x04"
expect eof