-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up the addition of extra directories and/or files #125
base: main
Are you sure you want to change the base?
Conversation
The rsync'ing of ~/git/extra-scripts was hacked in before run_qemu was becoming a wider distributed tool. As such it is undocumented and could potentially cause odd or unexpected behavior. The addition of the user-extras provides the same functionality with more user control. Including being explicit for the users benefit. Remove extra-scripts rsync'ing. Signed-off-by: Ira Weiny <[email protected]>
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]>
fail "$extra_dirs not found" | ||
fi | ||
echo "Installing extra directories and files from: $extra_dirs" | ||
for d in `cat "$extra_dirs"`; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.shellcheck.net/wiki/SC2006
shellcheck -x run_qemu.sh
Don't forget the -x
otherwise there is a ton of false positives.
{ | ||
local p=$1 | ||
|
||
p=$(eval echo $p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line do?
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why save it again? It's already in "$_arg_working_dir"
@@ -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.], []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to say that:
- Relative directories inside that file are relative to --working-dir (which defaults to
.
) - symbolic links are resolved (NOT recursively like rsync -L does, but that's impossible to summarize clearly and fairly intuitive so don't say "not recursively")
if [[ $_arg_ndctl_build == "on" ]]; then | ||
if [ -n "$ndctl" ]; then | ||
rsync "${rsync_opts[@]}" "$ndctl/" mkosi.extra/root/ndctl | ||
prepare_ndctl_build # create mkosi.postinst which compiles | ||
fi | ||
fi | ||
|
||
if [[ "$_arg_extra_dirs" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if [[ "$_arg_extra_dirs" ]]; then | |
if [[ -n "$_arg_extra_dirs" ]]; then |
if [[ $_arg_ndctl_build == "on" ]]; then | ||
if [ -n "$ndctl" ]; then | ||
rsync "${rsync_opts[@]}" "$ndctl/" mkosi.extra/root/ndctl | ||
prepare_ndctl_build # create mkosi.postinst which compiles | ||
fi | ||
fi | ||
|
||
if [[ "$_arg_extra_dirs" ]]; then | ||
extra_dirs=$(make_canonical_path $_arg_extra_dirs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think make_canonical_path
should not be used here, otherwise it's incompatible with shell completion?
fail "$extra_dirs not found" | ||
fi | ||
echo "Installing extra directories and files from: $extra_dirs" | ||
for d in `cat "$extra_dirs"`; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for d in `cat "$extra_dirs"`; do | |
cat "$extra_dirs" | while read d; do |
read
is guaranteed to read line by line whereas for ... in ...
splits on any whitespace.
if [[ -e $d ]]; then | ||
rsync -a "$d" mkosi.extra/root/ | ||
else | ||
fail "$d not found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail "$d not found" | |
fail "extra-dir directory %s not found" "$d" |
BTW, this looks useful and a very welcome cleanup but... I will probably not use it :-) |
The ability to add random files and directories to the root image had previously been hacked in via a secret 'special' directory location. This functionality is nice but lacking for a couple of reasons.
Remove the existing hidden feature and add --extra-dirs as a parameter which can specify a list of directories (or files) to be added to /root within the image.
This functionality was discussed in #124
This does not remove or clean up the rsync's but should make one of it's uses much more clear.
To ensure explicit usage for the user no default is provided. But directories will not be removed without a -r wipe.