From 2b62ac660d258858f7a7795a113a7056d0d2c79d Mon Sep 17 00:00:00 2001 From: "Frédéric Pierret (fepitre)" Date: Sun, 4 Feb 2024 12:03:50 +0100 Subject: feat(mkarchroot): allow to specify file destination inside chroot Co-authored-by: Christian Heusel --- src/mkarchroot.in | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/mkarchroot.in') diff --git a/src/mkarchroot.in b/src/mkarchroot.in index fc60b4e..06cf5d2 100644 --- a/src/mkarchroot.in +++ b/src/mkarchroot.in @@ -22,13 +22,14 @@ nspawn_args=() usage() { echo "Usage: ${0##*/} [options] working-dir package-list..." echo ' options:' - echo ' -U Use pacman -U to install packages' - echo ' -C Location of a pacman config file' - echo ' -M Location of a makepkg config file' - echo ' -c Set pacman cache' - echo ' -f Copy file from the host to the chroot' - echo ' -s Do not run setarch' - echo ' -h This message' + echo ' -U Use pacman -U to install packages' + echo ' -C Location of a pacman config file' + echo ' -M Location of a makepkg config file' + echo ' -c Set pacman cache' + echo ' -f [:] Copy src file from the host to the chroot.' + echo ' If dst file is not provided, it defaults to src' + echo ' -s Do not run setarch' + echo ' -h This message' exit 1 } @@ -84,8 +85,10 @@ if is_btrfs "$working_dir"; then fi for file in "${files[@]}"; do - mkdir -p "$(dirname "$working_dir$file")" - cp "$file" "$working_dir$file" + src="${file%%:*}" + dst="${file#*:}" + mkdir -p "$(dirname "$working_dir$dst")" + cp "$src" "$working_dir$dst" done unshare --mount pacstrap -${umode}Mc ${pac_conf:+-C "$pac_conf"} "$working_dir" \ -- cgit v1.2.3-70-g09d2