Skip to content

Commit 2d688f3

Browse files
committed
run_qemu: Add extra-dirs option
Depending on the use case run_qemu may need additional user space software. ndctl was specifically included and built within the root image due to the initial run_qemu use case to test pmem/dax/cxl. One option would be to hard code the addition of each user space source tree similar to ndctl. This is not desirable for a few reasons. 1) Additional source trees will start to bloat the root image. 2) ndctl was added with very specific directory locations. Some users have worked around this with symlinks but it is inflexible. 3) making source trees optional bloats the parameter space for run_qemu 4) building each user package is very specific to each package A better alternative is to allow the user to specify additional source trees; in different locations. This allows different kernel/user space source combinations in whatever combination the user requires at a specific time. Add the extra-dirs option. The extra-dirs option specifies a file containing a list of paths to user source trees. Each of these source trees is installed in the /root home directory of the guest image. Building of source trees is left to the user. Signed-off-by: Ira Weiny <[email protected]>
1 parent bd77e58 commit 2d688f3

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

parser_generator.m4

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ exit 11 #)Created by argbash-init v2.9.0
3434
# ARG_OPTIONAL_BOOLEAN([debug], [v], [Debug script problems (enables set -x)], )
3535
# ARG_OPTIONAL_BOOLEAN([ndctl-build], , [Enable ndctl build in root image], [on])
3636
# ARG_OPTIONAL_BOOLEAN([kern-selftests], , [Enable kernel selftest build in root image (Warning: This option can take a long time and requires many support packages on the host; including some 32 bit)], [off])
37+
# ARG_OPTIONAL_SINGLE([extra-dirs], , [Specify a file with a list of directories (or files) to be copied to the /root directory within the image.], [])
3738
# ARG_OPTIONAL_INCREMENTAL([quiet], [q], [quieten some output, can be repeated multiple times to quieten even more], )
3839
# ARG_OPTIONAL_BOOLEAN([gdb], , [Wait for gdb to connect for kernel debug (port 10000)], )
3940
# ARG_OPTIONAL_BOOLEAN([gdb-qemu], , [Start qemu with gdb], )

run_qemu.sh

+32
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ distro_vars="${script_dir}/${_distro}_vars.sh"
144144

145145
pushd "$_arg_working_dir" > /dev/null || fail "couldn't cd to $_arg_working_dir"
146146

147+
# save the working directory
148+
working_dir=$(pwd)
149+
150+
# make a path canonical to the working dir
151+
make_canonical_path()
152+
{
153+
local p=$1
154+
155+
p=$(eval echo $p)
156+
pushd $working_dir > /dev/null
157+
p=$(realpath $p)
158+
popd > /dev/null
159+
echo $p
160+
}
161+
147162
set_valid_mkosi_ver()
148163
{
149164
"$mkosi_bin" --version
@@ -1156,6 +1171,23 @@ make_rootfs()
11561171
fi
11571172
fi
11581173

1174+
if [[ "$_arg_extra_dirs" ]]; then
1175+
extra_dirs=$(make_canonical_path $_arg_extra_dirs)
1176+
if [[ ! -f $extra_dirs ]]; then
1177+
fail "$extra_dirs not found"
1178+
fi
1179+
echo "Installing extra directories and files from: $extra_dirs"
1180+
for d in `cat "$extra_dirs"`; do
1181+
d=$(make_canonical_path $d)
1182+
echo " $d"
1183+
if [[ -e $d ]]; then
1184+
rsync -a "$d" mkosi.extra/root/
1185+
else
1186+
fail "$d not found"
1187+
fi
1188+
done
1189+
fi
1190+
11591191
# timedatectl defaults to UTC when /etc/localtime is missing
11601192
local bld_tz; bld_tz=$( timedatectl | awk '/zone:/ { print $3 }' )
11611193
# v15 commit f11325afa02c "Adopt systemd-firstboot"

0 commit comments

Comments
 (0)