diff --git a/parser_generator.m4 b/parser_generator.m4 index 7746fa4..e1f649b 100644 --- a/parser_generator.m4 +++ b/parser_generator.m4 @@ -34,6 +34,7 @@ exit 11 #)Created by argbash-init v2.9.0 # ARG_OPTIONAL_BOOLEAN([debug], [v], [Debug script problems (enables set -x)], ) # ARG_OPTIONAL_BOOLEAN([ndctl-build], , [Enable ndctl build in root image], [on]) # 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]) +# 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.], []) # ARG_OPTIONAL_INCREMENTAL([quiet], [q], [quieten some output, can be repeated multiple times to quieten even more], ) # ARG_OPTIONAL_BOOLEAN([gdb], , [Wait for gdb to connect for kernel debug (port 10000)], ) # ARG_OPTIONAL_BOOLEAN([gdb-qemu], , [Start qemu with gdb], ) diff --git a/run_qemu.sh b/run_qemu.sh index a8cfe20..7b4b334 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -144,6 +144,21 @@ distro_vars="${script_dir}/${_distro}_vars.sh" pushd "$_arg_working_dir" > /dev/null || fail "couldn't cd to $_arg_working_dir" +# save the working directory +working_dir=$(pwd) + +# make a path canonical to the working dir +make_canonical_path() +{ + local p=$1 + + p=$(eval echo $p) + pushd $working_dir > /dev/null + p=$(realpath $p) + popd > /dev/null + echo $p +} + set_valid_mkosi_ver() { "$mkosi_bin" --version @@ -1125,6 +1140,7 @@ make_rootfs() process_mkosi_template "$tmpl" > "$dst" done + # Add user space items from host rsync -a "${script_dir}"/mkosi/extra/ mkosi.extra/ # misc rootfs setup @@ -1148,10 +1164,6 @@ make_rootfs() if [ -f ~/.vimrc ]; then rsync "${rsync_opts[@]}" ~/.vim* mkosi.extra/root/ fi - mkdir -p mkosi.extra/root/bin - if [ -d ~/git/extra-scripts ]; then - rsync "${rsync_opts[@]}" ~/git/extra-scripts/bin/* mkosi.extra/root/bin/ - fi if [[ $_arg_ndctl_build == "on" ]]; then if [ -n "$ndctl" ]; then rsync "${rsync_opts[@]}" "$ndctl/" mkosi.extra/root/ndctl @@ -1159,6 +1171,23 @@ make_rootfs() fi fi + if [[ "$_arg_extra_dirs" ]]; then + extra_dirs=$(make_canonical_path $_arg_extra_dirs) + if [[ ! -f $extra_dirs ]]; then + fail "$extra_dirs not found" + fi + echo "Installing extra directories and files from: $extra_dirs" + for d in `cat "$extra_dirs"`; do + d=$(make_canonical_path $d) + echo " $d" + if [[ -e $d ]]; then + rsync -a "$d" mkosi.extra/root/ + else + fail "$d not found" + fi + done + fi + # timedatectl defaults to UTC when /etc/localtime is missing local bld_tz; bld_tz=$( timedatectl | awk '/zone:/ { print $3 }' ) # v15 commit f11325afa02c "Adopt systemd-firstboot"