forked from asb/spindle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwheezy-stage3
executable file
·226 lines (208 loc) · 8.99 KB
/
wheezy-stage3
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
#!/bin/sh
# Part of spindle http://asbradbury.org/projects/spindle
#
# See LICENSE file for copyright and license details
set -ex
WORKDIR=work
OUTDIR=out
CURIMG=stage3.qed
. ./common
set_debconf_selections() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<EOF
debconf-set-selections <<SELEOF
# System's default wordlist:
# Choices: english (Webster's Second International English wordlist), Manual symlinks setting
dictionaries-common dictionaries-common/default-wordlist select english (Webster's Second International English wordlist)
# Use Control+Alt+Backspace to terminate the X server?
keyboard-configuration keyboard-configuration/ctrl_alt_bksp boolean true
# Backend to use for TrueType handling on X:
# Choices: freetype, xtt
x-ttcidfont-conf x-ttcidfont-conf/tt_backend select freetype
# Character set to support:
# Choices: . Arabic, # Armenian, # Cyrillic - KOI8-R and KOI8-U, # Cyrillic - non-Slavic languages, # Cyrillic - Slavic languages (also Bosnian and Serbian Latin), . Ethiopic, # Georgian, # Greek, # Hebrew, # Lao, # Latin1 and Latin5 - western Europe and Turkic languages, # Latin2 - central Europe and Romanian, # Latin3 and Latin8 - Chichewa; Esperanto; Irish; Maltese and Welsh, # Latin7 - Lithuanian; Latvian; Maori and Marshallese, . Latin - Vietnamese, # Thai, . Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic, . Combined - Latin; Slavic Cyrillic; Greek, . Combined - Latin; Slavic and non-Slavic Cyrillic
console-setup console-setup/codeset47 select . Combined - Latin; Slavic Cyrillic; Greek
# Time zone:
# Choices: GMT, GMT+0, GMT+1, GMT+10, GMT+11, GMT+12, GMT+2, GMT+3, GMT+4, GMT+5, GMT+6, GMT+7, GMT+8, GMT+9, GMT-0, GMT-1, GMT-10, GMT-11, GMT-12, GMT-13, GMT-14, GMT-2, GMT-3, GMT-4, GMT-5, GMT-6, GMT-7, GMT-8, GMT-9, GMT0, Greenwich, UCT, UTC, Universal, Zulu
tzdata tzdata/Zones/Etc select UTC
# Font for the console:
# Choices: Fixed, Terminus, TerminusBold, TerminusBoldVGA, VGA, Do not change the boot/kernel font
console-setup console-setup/fontface47 select Do not change the boot/kernel font
# Enable subpixel rendering for screen:
# Choices: Automatic, Always, Never
fontconfig-config fontconfig/subpixel_rendering select Automatic
# Method for toggling between national and Latin mode:
# Choices: Caps Lock, Right Alt (AltGr), Right Control, Right Shift, Right Logo key, Menu key, Alt+Shift, Control+Shift, Control+Alt, Alt+Caps Lock, Left Control+Left Shift, Left Alt, Left Control, Left Shift, Left Logo key, Scroll Lock key, No toggling
keyboard-configuration keyboard-configuration/toggle select No toggling
# Font size:
# Choices: 13, 14, 15, 16, 18
console-setup console-setup/fontsize-text47 select 16
# Locales to be generated:
# Choices: <SNIP>
locales locales/locales_to_be_generated multiselect en_GB.UTF-8 UTF-8
# Keyboard model:
# Choices: <SNIP>
keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC
# Users allowed to start the X server:
# Choices: Root Only, Console Users Only, Anybody
x11-common x11-common/xwrapper/allowed_users select Console Users Only
# Compose key:
# Choices: No compose key, Right Alt (AltGr), Right Control, Right Logo key, Menu key, Left Logo key, Caps Lock
keyboard-configuration keyboard-configuration/compose select No compose key
# Country of origin for the keyboard:
# Choices: <SNIP>
keyboard-configuration keyboard-configuration/layout select English (UK)
# for internal use
keyboard-configuration keyboard-configuration/layoutcode string gb
# Keymap to use:
# Choices: <SNIP>
keyboard-configuration keyboard-configuration/xkb-keymap select British English
# Choices: English (UK), English (UK) - English (UK\, Colemak), English (UK) - English (UK\, Dvorak), English (UK) - English (UK\, Dvorak with UK punctuation), English (UK) - English (UK\, extended WinKeys), English (UK) - English (UK\, international with dead keys), English (UK) - English (UK\, Macintosh), English (UK) - English (UK\, Macintosh international), Other
keyboard-configuration keyboard-configuration/variant select English (UK)
# Geographic area:
# Choices: Africa, America, Antarctica, Australia, Arctic, Asia, Atlantic, Europe, Indian, Pacific, SystemV, US, Etc
tzdata tzdata/Areas select Etc
# Method for temporarily toggling between national and Latin input:
# Choices: No temporary switch, Both Logo keys, Right Alt (AltGr), Right Logo key, Left Alt, Left Logo key
keyboard-configuration keyboard-configuration/switch select No temporary switch
# Encoding to use on the console:
# Choices: ARMSCII-8, CP1251, CP1255, CP1256, GEORGIAN-ACADEMY, GEORGIAN-PS, IBM1133, ISIRI-3342, ISO-8859-1, ISO-8859-10, ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, KOI8-R, KOI8-U, TIS-620, UTF-8, VISCII
console-setup console-setup/charmap47 select UTF-8
# Font tuning method for screen:
# Choices: Native, Autohinter, None
fontconfig-config fontconfig/hinting_type select Native
# Font size:
# Choices:
console-setup console-setup/fontsize-fb47 select 16
# The desktop environment to install when the desktop task is selected
# Choices: gnome, kde, xfce
tasksel tasksel/desktop multiselect xfce
# Key to function as AltGr:
# Choices: The default for the keyboard layout, No AltGr key, Right Alt (AltGr), Right Control, Right Logo key, Menu key, Left Alt, Left Logo key, Keypad Enter key, Both Logo keys, Both Alt keys
keyboard-configuration keyboard-configuration/altgr select The default for the keyboard layout
# Default locale for the system environment:
# Choices: None, en_GB.UTF-8
locales locales/default_environment_locale select en_GB.UTF-8
SELEOF
EOF
}
install_packages() {
# we may want to break out DEBIAN_FRONTEND=noninteractive
ssh_in_to_qemu chroot /mnt sh -l -ex - <<EOF
apt-get update
# install some utils
apt-get install -y ssh locales less fbset sudo psmisc strace module-init-tools ifplugd
apt-get install -y console-setup keyboard-configuration debconf-utils parted
apt-get install -y libudev-dev libicu-dev build-essential python bash-completion
apt-get install -y luajit lua5.1
apt-get install -y hardlink
apt-get install -y fake-hwclock ntp
apt-get install -y --allow-unauthenticated libraspberrypi-dev libraspberrypi-doc
/etc/init.d/fake-hwclock stop # save current time
update-rc.d hwclock.sh disable
EOF
}
add_pi_user_to_groups() {
onvm_chroot sh -l -ex - <<\EOF
for GRP in adm dialout cdrom audio users sudo video games; do
adduser pi $GRP
done
EOF
}
remove_ssh_host_keys() {
ssh_in_to_qemu sh -ex - <<EOF
rm -f /mnt/etc/ssh/ssh_host_*_key*
cat <<\RCL | tee /mnt/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# re-generate the ssh host keys if necessary
if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then
dpkg-reconfigure openssh-server
fi
exit 0
RCL
EOF
}
configure_ifplugd() {
onvm_chroot sh -l -ex - <<\EOF
sed /etc/default/ifplugd -i -e 's/^INTERFACES.*/INTERFACES="auto"/'
sed /etc/default/ifplugd -i -e 's/^HOTPLUG_INTERFACES.*/HOTPLUG_INTERFACES="all"/'
EOF
}
add_opt_vc_lib_to_ld_so() {
onvm_chroot sh -l -ex - <<EOF
echo "/opt/vc/lib" > /etc/ld.so.conf.d/vmcs.conf
ldconfig
EOF
}
setup_sudoers() {
onvm_chroot sh -l -ex - <<EOF
chmod +w /etc/sudoers
echo "pi ALL=(ALL) ALL" >> /etc/sudoers
chmod -w /etc/sudoers
EOF
}
# We use a swap file rather than a swap partition for greater flexibility
setup_swap() {
onvm_chroot sh -l -e - <<EOF
apt-get install dphys-swapfile
echo "CONF_SWAPSIZE=100" > /etc/dphys-swapfile
EOF
}
# It's not to have the sbin dirs in $PATH as that gives us ifconfig
fiddle_default_PATH() {
# This sed match is clearly brittle and specific to the current debian
# /etc/profile
onvm_chroot sh -l -ex - <<EOF
sed /etc/profile -i -e \
's|PATH="/usr/.*games.*$|PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"|'
EOF
}
add_qt5_apt_source() {
onvm_chroot sh -l -e <<\EOF
echo "deb http://archive.qmh-project.org/rpi-wheezy/debian/ unstable main" >> /etc/apt/sources.list.d/qt5pi.list
apt-get update
EOF
}
adjust_sysctl() {
onvm_chroot sh -l -e <<\EOF
printf "\n# rpi tweaks\nvm.swappiness=1\n" >> /etc/sysctl.conf
printf "vm.min_free_kbytes = 8192\n" >> /etc/sysctl.conf
EOF
}
set_default_kernel_modules() {
onvm_chroot sh -e - <<EOF
printf 'snd-bcm2835\n' >> /etc/modules
EOF
}
cd $WORKDIR
dotask branch_image ../$OUTDIR/stage2.qed $CURIMG
dotask run_qemu $CURIMG
dotask mount_apt_cache
dotask disable_starting_services
dotask set_debconf_selections
dotask install_packages
dotask configure_ifplugd
dotask add_pi_user_to_groups
#dotask add_opt_vc_lib_to_ld_so
dotask setup_sudoers
dotask setup_swap
dotask fiddle_default_PATH
dotask save_space_using_hardlink
dotask add_qt5_apt_source
dotask adjust_sysctl
dotask allow_starting_services
dotask remove_ssh_host_keys
dotask set_default_kernel_modules
dotask fingerprint_debian
dotask shutdown_qemu
dotask finish_image