-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
67 lines (54 loc) · 1.91 KB
/
Makefile
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
include config.mk
all: testroot pindestino.img
testroot:
@if [ "$$(whoami)" != "root" ]; then echo "Must be root. Run with sudo."; exit 1; fi
kernel-qemu:
wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
raspbian.zip:
wget http://downloads.raspberrypi.org/raspbian_latest -O raspbian.zip
raspbian.img: raspbian.zip
unzip raspbian.zip
mv ????-??-??-raspbian.img raspbian.img
touch raspbian.img
pindestino.img: raspbian.img kernel-qemu
cp raspbian.img pindestino.img
# mount filesystems:
mkdir -p workboot
mkdir -p work
mount -o loop,offset=4194304 pindestino.img workboot
mount -o loop,offset=62914560 -t ext4 pindestino.img work
# run pre-install scripts
for F in ${FEATURES}; do . features/$$F/pre-install.sh; done
# add our install script to .bashrc.
# since we are auto logging in on serial interface,
# it will run at boot.
cp work/home/pi/.bashrc work/home/pi/.bashrc-backup
echo "#!/bin/bash" >work/home/pi/.bashrc
chmod a+x work/home/pi/.bashrc
for F in ${FEATURES}; do cat features/$$F/install.sh >>work/home/pi/.bashrc; done
echo '' >>work/home/pi/.bashrc
echo 'sudo sync' >>work/home/pi/.bashrc
echo 'sudo reboot' >>work/home/pi/.bashrc
# start virtual machine to run install script:
sync
umount -l workboot
umount -l work
rmdir workboot
rmdir work
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda pindestino.img -nographic
mkdir -p workboot
mkdir -p work
mount -o loop,offset=4194304 pindestino.img workboot
mount -o loop,offset=62914560 -t ext4 pindestino.img work
# remove install script:
cp work/home/pi/.bashrc-backup work/home/pi/.bashrc
rm work/home/pi/.bashrc-backup
# run post-install scripts
for F in ${FEATURES}; do . features/$$F/post-install.sh; done
# finish
sync
umount -l workboot
umount -l work
rmdir workboot
rmdir work
chmod 444 pindestino.img