forked from asb/spindle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwheezy-stage2
executable file
·114 lines (100 loc) · 2.98 KB
/
wheezy-stage2
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
#!/bin/sh
# Part of spindle http://asbradbury.org/projects/spindle
#
# See LICENSE file for copyright and license details
set -ex
CURIMG=stage2.qed
. ./common
# For now we add a root user (this is a totally minimal system). It should be
# disabled at a later stage
configure_users() {
onvm_chroot sh -l -ex - <<EOF
adduser --disabled-password --gecos "" pi
echo "pi:raspberry" | chpasswd
echo "root:root" | chpasswd
EOF
}
configure_fstab() {
onvm_chroot sh -l -e - <<EOF1
cat <<EOF2 > /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p2 / ext4 defaults,noatime 0 0
EOF2
EOF1
}
configure_sources_list() {
onvm_chroot sh -l -e - <<EOF
printf "deb $DEB_MIRROR wheezy main non-free\n" > /etc/apt/sources.list
EOF
}
configure_network_interfaces() {
onvm_chroot sh -l -e - <<EOF1
cat <<EOF2 > /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
EOF2
EOF1
}
configure_hostname() {
onvm_chroot sh -l -e - <<EOF
echo raspberrypi > /etc/hostname
printf "127.0.1.1\traspberrypi\n" >> /etc/hosts
EOF
}
disable_eth_renaming() {
onvm_chroot sh -l -e - <<EOF
sed -i -e 's/KERNEL\!="eth\*|/KERNEL\!="/' /lib/udev/rules.d/75-persistent-net-generator.rules
EOF
}
# Due to a change of behaviour in getty, we must pass --noclear to ensure our
# boot messages don't get cleared
keep_boot_messages() {
onvm_chroot sh -l -e - <<\EOF
sed -i -e "s/^\(1:2345.*\)getty\(.*tty1\)$/\1getty --noclear\2/" /etc/inittab
EOF
}
install_firmware() {
onvm_chroot sh -l -e - <<EOF
echo "deb http://asbradbury.org/tmp/raspi/tmp_repo wheezy main" > /etc/apt/sources.list.d/raspi.list
apt-get update
apt-get install --allow-unauthenticated -y libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader
cp -a /boot/arm192_start.elf /boot/start.elf # default to 129mb memory split
echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 \
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait" > /boot/cmdline.txt
EOF
}
# Deprecated in favour of using the Debian packaging
download_and_extract_firmware_if_necessary() {
if ! [ -d firmware ]; then
git clone git://github.com/raspberrypi/firmware.git
fi
}
cd $WORKDIR
dotask branch_image ../$OUTDIR/stage1.qed $CURIMG
dotask run_qemu $CURIMG
dotask mount_apt_cache
dotask disable_starting_services
dotask configure_users
dotask configure_fstab
dotask configure_sources_list
dotask configure_network_interfaces
dotask configure_hostname
dotask disable_eth_renaming
dotask keep_boot_messages
dotask install_firmware
dotask allow_starting_services
dotask shutdown_qemu
#dotask download_and_extract_firmware_if_necessary
sudo -v
# We have to copy the /boot from root partition to boot partition. Temporary
# hack
dotask attach_image_to_nbd $CURIMG $NBD_DEV
mkdir -p boot
dotask sudo mount $BOOT_DEV boot
mkdir -p rootfs
dotask sudo mount $ROOT_DEV rootfs
dotask sudo mv rootfs/boot/* boot
universal_cleanup
dotask finish_image