forked from DGNum/liminix
min-copy-closure: add --root to copy to non-standard place
This commit is contained in:
parent
dbf1ecdcb7
commit
29f35cb902
2 changed files with 50 additions and 16 deletions
|
@ -1,20 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ssh_command=${SSH_COMMAND-ssh}
|
||||
target_host=$1
|
||||
shift
|
||||
|
||||
root_prefix=/
|
||||
verbose=true
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-r|--root)
|
||||
root_prefix="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-q|--quiet)
|
||||
verbose=""
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if test -z "$target_host"; then
|
||||
target_host="$1"
|
||||
else
|
||||
paths+=("$1") # save positional arg
|
||||
fi
|
||||
shift # past argument
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
progress() {
|
||||
test -n "$verbose" && echo $*
|
||||
}
|
||||
|
||||
if [ -z "$target_host" ] ; then
|
||||
echo Usage: min-copy-closure target-host paths
|
||||
echo Usage: min-copy-closure [--root /mnt] target-host paths
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$IN_NIX_BUILD" ] ; then
|
||||
if [ -z "$IN_NIX_BUILD" ] ; then
|
||||
# can't run nix-store in a derivation, so we have to
|
||||
# skip the requisites when running tests in hydra
|
||||
paths=$@
|
||||
else
|
||||
paths=$(nix-store -q --requisites "$@")
|
||||
paths=$(nix-store -q --requisites "$paths")
|
||||
fi
|
||||
needed=""
|
||||
|
||||
|
@ -25,16 +54,16 @@ coproc remote {
|
|||
exec 10>&${remote[1]}
|
||||
|
||||
for p in $paths; do
|
||||
echo -n Checking $(basename $p) ...
|
||||
echo "test -e $p && echo skip || echo $p" >&10
|
||||
progress -n Checking $(basename $p) ...
|
||||
echo "test -e ${root_prefix}$p && echo skip || echo $p" >&10
|
||||
read n <&${remote[0]}
|
||||
case $n in
|
||||
skip)
|
||||
echo skip
|
||||
progress skip
|
||||
;;
|
||||
*)
|
||||
needed="${needed} $n"
|
||||
echo will copy
|
||||
progress will copy
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
@ -44,10 +73,11 @@ if test -z "$needed" ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
echo "cd / && cpio -i >/dev/console" >&10
|
||||
echo "cd ${root_prefix} && cpio -d -i >/dev/console" >&10
|
||||
|
||||
find $needed | cpio -H newc -o >&10
|
||||
|
||||
echo "date" >&10
|
||||
# make sure the connection hasn't died
|
||||
echo "echo finished" >&10
|
||||
read n <&${remote[0]}
|
||||
echo $n
|
||||
|
|
|
@ -19,11 +19,15 @@ in pkgs.runCommand "check" {
|
|||
} ''
|
||||
. ${../test-helpers.sh}
|
||||
|
||||
(
|
||||
mkdir vm
|
||||
${img}/run.sh --lan user,hostfwd=tcp::2022-:22 --background ./vm
|
||||
expect ${./wait-until-ready.expect}
|
||||
export SSH_COMMAND="ssh -o StrictHostKeyChecking=no -p 2022 -i ${./id}"
|
||||
$SSH_COMMAND root@localhost echo ready
|
||||
IN_NIX_BUILD=true min-copy-closure root@localhost ${rogue}
|
||||
$SSH_COMMAND root@localhost ls -l ${rogue} >$out
|
||||
IN_NIX_BUILD=true min-copy-closure --quiet root@localhost ${rogue}
|
||||
$SSH_COMMAND root@localhost ls -ld ${rogue}
|
||||
IN_NIX_BUILD=true min-copy-closure --root /run root@localhost ${rogue}
|
||||
$SSH_COMMAND root@localhost ls -ld /run/${rogue}
|
||||
) 2>&1 | tee $out
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue