summaryrefslogtreecommitdiff
path: root/build-rootfs.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-06-22 12:08:07 -0400
committerAndrew Cady <d@jerkface.net>2019-06-22 12:08:07 -0400
commitcccf971c6170d65d814ae85a2f7437cc0e6def32 (patch)
tree945ec347671aa1f01f6b277b0f6eac2ffd90e34f /build-rootfs.sh
parent8a90cb26a04fdb0f6eac30669c4523deabec6e2c (diff)
remove build-rootfs.sh, obsoleted by fsmgr
Diffstat (limited to 'build-rootfs.sh')
-rwxr-xr-xbuild-rootfs.sh368
1 files changed, 0 insertions, 368 deletions
diff --git a/build-rootfs.sh b/build-rootfs.sh
deleted file mode 100755
index 76daf66..0000000
--- a/build-rootfs.sh
+++ /dev/null
@@ -1,368 +0,0 @@
1#!/bin/sh
2set -e
3release=stretch
4img_name=2018-06-27
5img_file=debootstrap/${release}-minbase-amd64.${img_name}.btrfs
6
7die() { printf '%s\n' "$*" >&2; exit 1; }
8
9chroot="./debootstrap.sh chroot $release $img_name"
10img_sh="./debootstrap.sh sh $release $img_name"
11
12install_packages()
13{
14# $chroot env DEBIAN_FRONTEND=noninteractive apt-get -y install "$@"
15 (set -x; ./debootstrap.sh add "$release" "$img_name" "$@")
16}
17
18defrag()
19{
20 $img_sh btrfs fi def -rc .
21}
22
23wordlines() { printf '%s\n' "$@"; }
24
25xorg_packages()
26{
27 wordlines xorg libxss1 xserver-xorg-input-all xserver-xorg-input-wacom
28}
29
30necessary_packages()
31{
32 wordlines systemd-sysv
33}
34
35useful_packages()
36{
37 wordlines vim-tiny git tmux ssh
38}
39
40network_packages()
41{
42 wordlines \
43 network-manager avahi-daemon libnss-mdns \
44 iproute2 iw iputils-ping \
45 firmware-iwlwifi firmware-linux firmware-linux-nonfree \
46 firmware-atheros firmware-linux-free firmware-b43legacy-installer \
47 firmware-ti-connectivity firmware-libertas firmware-ipw2x00 \
48 firmware-ralink firmware-b43-installer firmware-realtek firmware-iwlwifi \
49 firmware-brcm80211 firmware-zd1211
50}
51
52filesystem_tool_packages()
53{
54 wordlines btrfs-progs cryptsetup-bin hfsprogs mdadm nbd-client ntfs-3g
55}
56
57boot_tool_packages()
58{
59 wordlines grub-pc isolinux initramfs-tools
60}
61
62samizdat_dep_packages()
63{
64 wordlines \
65 ca-certificates cryptsetup-bin dnsmasq eject \
66 gnupg gnupg2 gnupg-agent grub2-common grub-common grub-pc \
67 grub-pc-bin hfsprogs hfsutils nbd-server netscript-ipfilter \
68 openssl pinentry-curses strongswan tor xorriso
69}
70
71find_prog()
72{
73 want_prog=$1
74 prog=$(which "$want_prog") && return
75 if [ "$SUDO_USER" -a "$(id -u)" = 0 ]; then
76 prog=$(sh -c 'su - "$SUDO_USER" -c "which \"'"${want_prog}"'\""')
77 else
78 false
79 fi
80}
81
82install_program_from_path1()
83{
84 find_prog "$1" || die "program not found: $1"
85 $img_sh cp -L "$prog" ./usr/local/bin/"$1"
86}
87
88install_program_from_path()
89{
90 local f
91 for f in "$@"; do
92 install_program_from_path1 "$f" || die "could not install package '$f'"
93 done
94}
95
96install_xmonad()
97{
98 install_program_from_path xmonad
99 $chroot ln -s /usr/local/bin/xmonad /etc/alternatives/x-window-manager
100 $chroot ln -s /etc/alternatives/x-window-manager /usr/bin/x-window-manager
101}
102
103kernel_packages()
104{
105 wordlines busybox cpio firmware-linux-free \
106 initramfs-tools initramfs-tools-core irqbalance \
107 klibc-utils kmod libklibc libnuma1 linux-base \
108 linux-image-4.9.0-6-amd64 linux-image-amd64
109}
110
111install_apt_cache()
112{
113 $img_sh rsync -RaP /var/lib/apt/lists --exclude partial ./
114}
115
116install_kiki()
117{
118 install_program_from_path cokiki kiki
119}
120
121install_samizdat()
122{
123 srcdir=$(pwd) || return
124 export srcdir
125 $img_sh sh -c 'instdir=$(pwd) && cd "$srcdir" && make instdir="${instdir}" install install-configuration'
126}
127
128make_bootable()
129{
130 ln -sf "$PWD"/"${img_file}" /srv/nbd.btrfs
131 btrfstune -S1 /srv/nbd.btrfs
132}
133
134print_config_dat()
135{
136 # perl -n -00 -e '/^Flags:.*seen/m && print;' /var/cache/debconf/config.dat > config.seen.dat
137 cat <<'EOF'
138
139Name: debconf/frontend
140Template: debconf/frontend
141Value: Noninteractive
142Owners: debconf
143Flags: seen
144
145Name: debconf/priority
146Template: debconf/priority
147Value: critical
148Owners: debconf
149Flags: seen
150
151Name: locales/locales_to_be_generated
152Template: locales/locales_to_be_generated
153Value: en_US.UTF-8 UTF-8
154Owners: locales
155Flags: seen
156
157Name: locales/default_environment_locale
158Template: locales/default_environment_locale
159Value: en_US.UTF-8
160Owners: locales
161Flags: seen
162Variables:
163 locales = en_US.UTF-8
164
165Name: tzdata/Areas
166Template: tzdata/Areas
167Value: US
168Owners: tzdata
169Flags: seen
170
171Name: tzdata/Zones/Etc
172Template: tzdata/Zones/Etc
173Value: UTC
174Owners: tzdata
175Flags: seen
176
177Name: tzdata/Zones/US
178Template: tzdata/Zones/US
179Value: Michigan
180Owners: tzdata
181Flags: seen
182
183Name: firmware-ipw2x00/license/accepted
184Template: firmware-ipw2x00/license/accepted
185Owners: firmware-ipw2x00
186
187Name: firmware-ipw2x00/license/error
188Template: firmware-ipw2x00/license/error
189Owners: firmware-ipw2x00
190
191Name: b43-fwcutter/install-unconditional
192Template: b43-fwcutter/install-unconditional
193Value: true
194Owners: b43-fwcutter
195
196EOF
197}
198
199install_config_dat()
200{
201 print_config_dat | $img_sh sh -c 'cat >> ./var/cache/debconf/config.dat'
202}
203
204all_packages()
205{
206 (kernel_packages
207 necessary_packages
208 network_packages
209 useful_packages
210 filesystem_tool_packages
211 boot_tool_packages
212 samizdat_dep_packages
213 xorg_packages) | sort -u
214}
215
216choose_hostname()
217{
218 true
219}
220
221main()
222{
223 ./debootstrap.sh init $release
224 ./debootstrap.sh new $release $img_name
225 ./debootstrap.sh with_img $release $img_name truncate -s 5G
226 # ./debootstrap.sh with_img $release $img_name btrfstune -S0 -f || true
227 ./debootstrap.sh sh $release $img_name btrfs filesystem resize max .
228
229 install_config_dat
230 install_packages $(necessary_packages)
231 install_packages $(kernel_packages)
232 install_packages $(network_packages)
233 install_packages $(useful_packages)
234 install_packages $(filesystem_tool_packages)
235 install_packages $(boot_tool_packages)
236 install_packages $(samizdat_dep_packages)
237 install_packages $(xorg_packages)
238 install_packages firefox-esr linphone alsa-utils
239 install_xmonad
240
241 # (Note: libglib2.0-bin is needed for mypaint to work correctly)
242 install_packages mypaint libglib2.0-bin emacs25 strongswan-pki strongswan-swanctl strongswan-nm
243 install_packages build-essential vim less xbindkeys w3m sudo dmenu psmisc rsync
244 install_apt_cache
245
246 install_samizdat
247 install_kiki
248 install_program_from_path google
249 install_program_from_path stack
250 install_program_from_path dhtd dht
251
252 add_user_account u
253 add_git_clone ../src/dotfiles home/u/src/dotfiles
254 add_git_clone ./ home/u/src/samizdat
255 add_git_clone ../src/bittorrent home/u/src/presence
256
257 make_bootable
258 echo done. >&2
259}
260
261add_user_account()
262{
263 local uname="$1"
264 $chroot useradd "$uname" -G sudo -m -p '' -s /bin/bash
265}
266
267add_git_clone()
268{
269 local src dst="$2"
270 src=$(realpath -e "$1") || die "add_git_clone: path does not exist: $1"
271 $img_sh git clone "$src" ./"$dst"
272
273 # todo: set up to properly push and pull via VPN
274
275 # From "man git clone":
276 #
277 # This default configuration is achieved by creating references to the
278 # remote branch heads under refs/remotes/origin and by initializing
279 # remote.origin.url and remote.origin.fetch configuration variables.
280}
281
282if [ "${0##*/}" = build-rootfs.sh ]; then
283 main
284fi
285
286
287exit
288: <<'EOF'
289# manual installs
290
291# essential tools
292vim-tiny
293git
294tmux
295ssh
296
297# filesystem access
298btrfs-tools
299cryptsetup
300hfsprogs
301mdadm
302nbd-client
303ntfs-3g
304
305# bootloaders
306grub-pc
307isolinux
308initramfs-tools
309
310# network
311network-manager
312avahi-daemon
313libnss-mdns
314
315# network tools
316iproute2
317iw
318iputils-ping
319
320# wifi
321firmware-iwlwifi
322firmware-linux
323firmware-linux-nonfree
324
325# apt-cache pkgnames firmware|while read line; do apt-cache show $line|grep -qi wireless && echo $line; done
326firmware-atheros
327firmware-linux-free
328firmware-b43legacy-installer
329firmware-ti-connectivity
330firmware-libertas
331firmware-ipw2x00
332firmware-ralink
333firmware-b43-installer
334firmware-realtek
335firmware-iwlwifi
336firmware-brcm80211
337firmware-zd1211
338
339# graphics
340xorg
341libxss1 # for xmonad, to be installed via binary
342
343# samizdat deps
344
345btrfs-progs
346ca-certificates
347cryptsetup-bin
348dnsmasq
349eject
350gnupg
351gnupg2
352gnupg-agent
353grub2-common
354grub-common
355grub-pc
356grub-pc-bin
357hfsprogs
358hfsutils
359nbd-server
360netscript-ipfilter
361openssl
362pinentry-curses
363strongswan
364tor
365xorriso
366
367
368EOF