-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathquiz-zfs
More file actions
executable file
·135 lines (117 loc) · 3.04 KB
/
quiz-zfs
File metadata and controls
executable file
·135 lines (117 loc) · 3.04 KB
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
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
#
# 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-2025, Rob Norris <robn@despairlabs.com>
set -uo pipefail
usage() {
cat <<EOF
build OpenZFS with options to work well with quiz
usage: quiz-zfs [opts] <configure|make> [program args...]
options:
-k <kernel> kernel to use for this run
-a <arch> architecture to build for
-h this help
EOF
exit 1
}
trace() {
local STAMP=$(date +%Y%m%d-%H:%M:%S)
echo "[quiz-zfs] $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
source $RUNDIR/quiz-lib
opt_arch=""
opt_kernel=""
# take the default kernel version from the last configured version
if [[ -f config.log ]] ; then
opt_kernel=$( ( grep ^LINUX_VERSION= config.log || true ) | cut -f2 -d"'" )
fi
OPTIND=1
while getopts "a:k:h" opt
do
case "$opt" in
'a') opt_arch=$OPTARG ;;
'k') opt_kernel=$OPTARG ;;
'h') usage ;;
*) exit 1 ;;
esac
done
shift $(expr $OPTIND - 1)
if [[ $# -lt 1 ]] ; then
usage
fi
quiz_arch_vars ${opt_arch:-$QUIZ_ARCH}
quiz_kernel_best_available ${opt_kernel:-$QUIZ_KERNEL_VERSION}
do_configure() {
local cross_opts=""
if [[ -z $_quiz_arch_native ]] ; then
cross_opts="
--host=$_quiz_arch_prefix
KERNEL_CROSS_COMPILE=${_quiz_arch_prefix}-
KERNEL_ARCH=$_quiz_arch_kernel
"
fi
# XXX bunch of this needs to go into configure proper, disabling contrib
# and whatnot. installing to /opt/zfs would be preferable, but
# zts-tests.sh is hardcoded to /usr for now -- robn, 2025-01-13
$QUIZ_BUILD_CMD_PREFIX ./configure \
--config-cache \
--with-linux=$RUNDIR/system/kernel/$_quiz_arch_kernel/kbuild/$_quiz_kver \
--prefix=/usr/local \
--disable-sysvinit \
--disable-systemd \
--disable-pam \
--disable-pyzfs \
--with-mounthelperdir=/usr/local/sbin \
--with-dracutdir=/usr/local/lib/dracut \
--with-udevdir=/usr/local/lib/udev \
$cross_opts \
"lt_cv_sys_lib_dlsearch_path_spec=/lib /usr/lib /usr/lib/$_quiz_arch_prefix" \
"$@"
}
do_make() {
$QUIZ_BUILD_CMD_PREFIX make "$@"
}
do_make_install() {
# merged /usr setup
for d in lib lib32 lib64 bin sbin ; do
mkdir -p $RUNDIR/system/work/usr/$d
ln -sf usr/$d $RUNDIR/system/work/$d
done
kdest=$RUNDIR/system/kernel/$_quiz_arch_kernel
$QUIZ_BUILD_CMD_PREFIX make install \
INSTALL_MOD_PATH=$kdest \
DESTDIR=$RUNDIR/system/work \
"$@"
$QUIZ_BUILD_CMD_PREFIX /sbin/depmod -A -b $kdest $_quiz_kver
}
case "$1" in
configure)
do_configure "${@:2}"
;;
make)
if [[ $# -ge 2 && $2 == install ]] ; then
do_make_install "${@:3}"
else
do_make "${@:2}"
fi
;;
*)
usage
;;
esac
# vim: ft=bash