blob: a1c00f1857ffc13945efd1f2ee517fd9faf4617c (
plain)
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
|
name_version=bluez-5.34-snappy
config_opts=\
--prefix=/usr \
--enable-experimental \
--disable-cups \
--disable-obex \
--disable-monitor \
--disable-systemd \
--disable-silent-rules
# NOTE: kvm.img is something you need to provide out-of-band NOTE: the usb
# device to redirect (a USB bluetooth controller) can be identified by running
# lsusb and looking at the bus and host addresses printed there.
# For example I was seeing:
# Bus 004 Device 003: ID 0a5c:2145 Broadcom Corp. BCM2045B (BDC-2.1) [Bluetooth Controller]
qemu_opts=\
-m 768 \
-nographic \
-snapshot \
-redir tcp:8022::22 \
-usb -device usb-host,hostbus=4,hostaddr=3 \
kvm.img
# NOTE: you may need to tweak the ssh hey that is compatible with the image
ssh_opts=\
-i $(HOME)/.ssh/id_rsa \
-oStrictHostKeyChecking=no \
-oUserKnownHostsFile=/dev/null \
-oKbdInteractiveAuthentication=no
.PHONY: all
all: snapped.stamp
.PHONY: clean
clean:
rm -rf src build stage *.stamp snap/*.snap
.PRECIOUS: build
build:
mkdir -p $@
configured.stamp: src | build
( cd src && ./bootstrap )
( cd build && ../src/configure $(config_opts) )
touch $@
built.stamp: configured.stamp | build
$(MAKE) -C build && touch $@
staged.stamp: built.stamp | build
$(MAKE) -C build install DESTDIR=$(shell pwd)/stage/ && touch $@
snapped.stamp: staged.stamp
install -d snap/bin
install --strip stage/usr/libexec/bluetooth/bluetoothd snap/bin/
install --strip stage/usr/bin/bluetoothctl snap/bin/
( cd snap/ && snappy build -o ..)
touch $@
src:
ifndef LOCAL_BLUEZ_TREE
git clone -b snappy git+ssh://git.launchpad.net/~zyga/+git/bluez $@
else
ln -s $(LOCAL_BLUEZ_TREE) $@
endif
touch $@
.PHONY: run
.ONESHELL: run
run: snapped.stamp
sudo qemu-system-x86_64 $(qemu_opts) >qemu-serial.log &
qemu_pid=$$!
trap "sudo kill $$qemu_pid" 0
while sleep 10s; do ssh $(ssh_opts) -p 8022 ubuntu@localhost true >/dev/null 2>&1 && break; done
scp $(ssh_opts) -P 8022 *.snap 'ubuntu@localhost:~/'
ssh $(ssh_opts) -p 8022 ubuntu@localhost sudo snappy install '*.snap'
ssh $(ssh_opts) -p 8022 ubuntu@localhost
.PHONY: reinstall
reinstall: snapped.stamp
while sleep 10s; do ssh $(ssh_opts) -p 8022 ubuntu@localhost true && break; done
scp $(ssh_opts) -P 8022 *.snap 'ubuntu@localhost:~/'
ssh $(ssh_opts) -p 8022 ubuntu@localhost sudo snappy install '*.snap'
|