-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
quiz-prepare-root
executable file
·64 lines (51 loc) · 1.76 KB
/
quiz-prepare-root
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
#!/usr/bin/env bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2023, Rob Norris <[email protected]>
set -uo pipefail
usage() {
cat <<EOF
create a minimal root filesystem for the quiz microvm
usage: quiz-prepare-root
EOF
exit 1
}
trace() {
local STAMP=$(date +%Y%m%d-%H:%M:%S)
echo "[quiz-prepare-root] $STAMP $@" >&2
}
fail() {
local TEXT=${@:-}
if [[ -z $TEXT ]] ; then
TEXT="[${BASH_SOURCE[0]}:${BASH_LINENO[0]}: $BASH_COMMAND]"
fi
trace "FATAL $TEXT"
exit 1
}
trap fail ERR
RUNDIR=$(realpath $(dirname $0))
source $RUNDIR/quiz-config
OPTIND=1
while getopts "h" opt
do
case "$opt" in
'h') usage ;;
*) exit 1 ;;
esac
done
shift $(expr $OPTIND - 1)
trace "building root image"
zfs_extras=libtirpc3,libjemalloc2,libasan8
zfstest_extras=bc,bzip2,cpio,file,fio,acl,sysstat,samba-common-bin,openssl,pamtester,pax,iputils-ping,python3-minimal,rsync,openssh-client,binutils,attr,nfs-kernel-server,lsscsi,parted,linux-base,sudo,xxhash
debug_extras=jq,gdb,strace,fio,bpftrace,linux-perf,xxd,blktrace,mdadm
mmdebstrap \
--variant=minbase \
--include=tini,udev,coreutils,procps,kmod,gdisk,dmsetup,ksh,tmux,cryptsetup,$zfs_extras,$zfstest_extras,$debug_extras \
--customize-hook='install -m 755 init/init1 "$1"/sbin/init' \
--customize-hook='mkdir "$1"/mnt/quiz-init "$1"/mnt/quiz-system "$1"/mnt/quiz-user' \
--customize-hook='mkdir "$1"/mnt/lower "$1"/mnt/overlay "$1"/mnt/newroot' \
$QUIZ_DEBIAN_RELEASE $RUNDIR/system/$QUIZ_DEBIAN_RELEASE.new.ext2
mv -vf $RUNDIR/system/$QUIZ_DEBIAN_RELEASE.new.ext2 $RUNDIR/system/$QUIZ_DEBIAN_RELEASE.ext2
trace "done"
# vim: ft=bash