summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild-rootfs.sh99
-rwxr-xr-xdebootstrap.sh33
2 files changed, 104 insertions, 28 deletions
diff --git a/build-rootfs.sh b/build-rootfs.sh
index 63eb4c9..76daf66 100755
--- a/build-rootfs.sh
+++ b/build-rootfs.sh
@@ -1,6 +1,7 @@
1#!/bin/sh -e 1#!/bin/sh
2set -e
2release=stretch 3release=stretch
3img_name=t3 4img_name=2018-06-27
4img_file=debootstrap/${release}-minbase-amd64.${img_name}.btrfs 5img_file=debootstrap/${release}-minbase-amd64.${img_name}.btrfs
5 6
6die() { printf '%s\n' "$*" >&2; exit 1; } 7die() { printf '%s\n' "$*" >&2; exit 1; }
@@ -19,13 +20,17 @@ defrag()
19 $img_sh btrfs fi def -rc . 20 $img_sh btrfs fi def -rc .
20} 21}
21 22
23wordlines() { printf '%s\n' "$@"; }
24
22xorg_packages() 25xorg_packages()
23{ 26{
24 wordlines xorg libxss1 27 wordlines xorg libxss1 xserver-xorg-input-all xserver-xorg-input-wacom
25
26} 28}
27 29
28wordlines() { printf '%s\n' "$@"; } 30necessary_packages()
31{
32 wordlines systemd-sysv
33}
29 34
30useful_packages() 35useful_packages()
31{ 36{
@@ -68,18 +73,26 @@ find_prog()
68 want_prog=$1 73 want_prog=$1
69 prog=$(which "$want_prog") && return 74 prog=$(which "$want_prog") && return
70 if [ "$SUDO_USER" -a "$(id -u)" = 0 ]; then 75 if [ "$SUDO_USER" -a "$(id -u)" = 0 ]; then
71 prog=$(sh -c 'su - "$SUDO_USER" -c "which xmonad"') 76 prog=$(sh -c 'su - "$SUDO_USER" -c "which \"'"${want_prog}"'\""')
72 else 77 else
73 false 78 false
74 fi 79 fi
75} 80}
76 81
77install_program_from_path() 82install_program_from_path1()
78{ 83{
79 find_prog "$1" || die "program not found: $1" 84 find_prog "$1" || die "program not found: $1"
80 $img_sh cp -L "$prog" ./usr/local/bin/"$1" 85 $img_sh cp -L "$prog" ./usr/local/bin/"$1"
81} 86}
82 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
83install_xmonad() 96install_xmonad()
84{ 97{
85 install_program_from_path xmonad 98 install_program_from_path xmonad
@@ -92,19 +105,17 @@ kernel_packages()
92 wordlines busybox cpio firmware-linux-free \ 105 wordlines busybox cpio firmware-linux-free \
93 initramfs-tools initramfs-tools-core irqbalance \ 106 initramfs-tools initramfs-tools-core irqbalance \
94 klibc-utils kmod libklibc libnuma1 linux-base \ 107 klibc-utils kmod libklibc libnuma1 linux-base \
95 linux-image-4.9.0-6-amd64 linux-image-amd64 \ 108 linux-image-4.9.0-6-amd64 linux-image-amd64
96 systemd-sysv
97} 109}
98 110
99install_apt_cache() 111install_apt_cache()
100{ 112{
101 $img_sh rsync -RaP /var/cache/apt --exclude archives ./ 113 $img_sh rsync -RaP /var/lib/apt/lists --exclude partial ./
102} 114}
103 115
104install_kiki() 116install_kiki()
105{ 117{
106 install_program_from_path cokiki 118 install_program_from_path cokiki kiki
107 install_program_from_path kiki
108} 119}
109 120
110install_samizdat() 121install_samizdat()
@@ -193,21 +204,30 @@ install_config_dat()
193all_packages() 204all_packages()
194{ 205{
195 (kernel_packages 206 (kernel_packages
196 network_packages 207 necessary_packages
197 useful_packages 208 network_packages
198 filesystem_tool_packages 209 useful_packages
199 boot_tool_packages 210 filesystem_tool_packages
200 samizdat_dep_packages 211 boot_tool_packages
201 xorg_packages) | sort -u 212 samizdat_dep_packages
213 xorg_packages) | sort -u
214}
215
216choose_hostname()
217{
218 true
202} 219}
203 220
204main() 221main()
205{ 222{
206 ./debootstrap.sh init $release 223 ./debootstrap.sh init $release
207 ./debootstrap.sh new $release $img_name 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 .
208 228
209 install_config_dat 229 install_config_dat
210 230 install_packages $(necessary_packages)
211 install_packages $(kernel_packages) 231 install_packages $(kernel_packages)
212 install_packages $(network_packages) 232 install_packages $(network_packages)
213 install_packages $(useful_packages) 233 install_packages $(useful_packages)
@@ -215,13 +235,48 @@ main()
215 install_packages $(boot_tool_packages) 235 install_packages $(boot_tool_packages)
216 install_packages $(samizdat_dep_packages) 236 install_packages $(samizdat_dep_packages)
217 install_packages $(xorg_packages) 237 install_packages $(xorg_packages)
238 install_packages firefox-esr linphone alsa-utils
218 install_xmonad 239 install_xmonad
219 240
220 # install_apt_cache 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
221 install_samizdat 246 install_samizdat
222 install_kiki 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
223 256
224 make_bootable 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.
225} 280}
226 281
227if [ "${0##*/}" = build-rootfs.sh ]; then 282if [ "${0##*/}" = build-rootfs.sh ]; then
diff --git a/debootstrap.sh b/debootstrap.sh
index 0971c0c..2ef288b 100755
--- a/debootstrap.sh
+++ b/debootstrap.sh
@@ -12,11 +12,21 @@ usage()
12{ 12{
13 cat <<EOF >&2 13 cat <<EOF >&2
14Usage: 14Usage:
15
16# creation & deletion
15 $0 init <suite> 17 $0 init <suite>
16 $0 new <suite> <new-name> 18 $0 new <suite> <new-name>
17 $0 clone <suite> <source-name> <new-name> 19 $0 clone <suite> <source-name> <new-name>
18 $0 chroot <suite> <name> 20 $0 rm <suite> <source-name>
19 $0 add <suite> <name> <package> [packages...] 21
22# modification
23 $0 add <suite> <name> <package> [packages...]
24 $0 chroot <suite> <name> [command] [args...]
25 $0 sh <suite> <name> [command] [args...]
26 $0 with_mp <suite> <name> <command> [args...]
27 $0 with_img <suite> <name> <command> [args...]
28
29# inspection
20 $0 list 30 $0 list
21 $0 show unpackaged <suite> <name> 31 $0 show unpackaged <suite> <name>
22 $0 show unpackaged-du <suite> <name> ["filtered"] 32 $0 show unpackaged-du <suite> <name> ["filtered"]
@@ -46,7 +56,7 @@ list()
46 f=${f##*/} 56 f=${f##*/}
47 f=${f%.btrfs} 57 f=${f%.btrfs}
48 suite=${f%%-*} 58 suite=${f%%-*}
49 name=${f##*.} 59 name=${f#*.}
50 [ "$header_printed" ] || echo 'Existing images:' 60 [ "$header_printed" ] || echo 'Existing images:'
51 printf ' %s %s\n' "$suite" "$name" 61 printf ' %s %s\n' "$suite" "$name"
52 header_printed=y 62 header_printed=y
@@ -139,6 +149,17 @@ show_unpackaged_du()
139 fi 149 fi
140} 150}
141 151
152with_img()
153{
154 local suite="$1" name="$2" command="$3"
155 shift 3
156 [ "$suite" -a "$name" ] || usage
157 imagename=$(suite_name_to_imagename "$suite" "$name")
158 [ -e "$imagename" ] || die "no such file: $imagename"
159
160 "$command" "$@" "$imagename"
161}
162
142run_command_with_mountpoint() 163run_command_with_mountpoint()
143{ 164{
144 local suite="$1" name="$2" command="$3" 165 local suite="$1" name="$2" command="$3"
@@ -172,13 +193,13 @@ add()
172 shift 2 193 shift 2
173 running_suite=$(lsb_release -cs) || die 'lsb_release failed' 194 running_suite=$(lsb_release -cs) || die 'lsb_release failed'
174 if [ "$suite" = "$running_suite" -a -x ./src/selfstrap ]; then 195 if [ "$suite" = "$running_suite" -a -x ./src/selfstrap ]; then
175 run_mp "$suite" "$name" ./src/selfstrap "$@" -t 196 with_mp "$suite" "$name" ./src/selfstrap "$@" -t
176 else 197 else
177 exit 1 198 exit 1
178 fi 199 fi
179} 200}
180 201
181run_mp() 202with_mp()
182{ 203{
183 suite=$1 204 suite=$1
184 name=$2 205 name=$2
@@ -363,7 +384,7 @@ show()
363} 384}
364 385
365case "$1" in 386case "$1" in
366 init|new|clone|list|show|add|run_mp) cmd=$1; shift; $cmd "$@" ;; 387 init|new|clone|list|show|add|with_mp|with_img) cmd=$1; shift; $cmd "$@" ;;
367 chroot|sh|rm) cmd=${1}_image; shift; $cmd "$@" ;; 388 chroot|sh|rm) cmd=${1}_image; shift; $cmd "$@" ;;
368 *) usage ;; 389 *) usage ;;
369esac 390esac