forked from josch/mmdebstrap
hook-helper: repurpose third arg for skip options now that qemu-user info does not need to be propagated anymore (was only needed for proot)
This commit is contained in:
parent
27d1bad2a5
commit
84c53fc120
3 changed files with 18 additions and 5 deletions
17
mmdebstrap
17
mmdebstrap
|
@ -1755,7 +1755,8 @@ sub run_hooks {
|
||||||
# does for python
|
# does for python
|
||||||
my @args = shellwords $script;
|
my @args = shellwords $script;
|
||||||
hookhelper($options->{root}, $options->{mode}, $name,
|
hookhelper($options->{root}, $options->{mode}, $name,
|
||||||
$options->{qemu}, $verbosity_level, @args);
|
(join ',', @{ $options->{skip} }),
|
||||||
|
$verbosity_level, @args);
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
waitpid($pid, 0);
|
waitpid($pid, 0);
|
||||||
|
@ -3356,8 +3357,20 @@ sub pivot_root {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hookhelper {
|
sub hookhelper {
|
||||||
my ($root, $mode, $hook, $qemu, $verbosity, $command, @args) = @_;
|
my ($root, $mode, $hook, $skipopt, $verbosity, $command, @args) = @_;
|
||||||
$verbosity_level = $verbosity;
|
$verbosity_level = $verbosity;
|
||||||
|
my @skipopts = ();
|
||||||
|
if (length $skipopt) {
|
||||||
|
for my $skip (split /[,\s]+/, $skipopt) {
|
||||||
|
# strip leading and trailing whitespace
|
||||||
|
$skip =~ s/^\s+|\s+$//g;
|
||||||
|
# skip if the remainder is an empty string
|
||||||
|
if ($skip eq '') {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
push @skipopts, $skip;
|
||||||
|
}
|
||||||
|
}
|
||||||
# we put everything in an eval block because that way we can easily handle
|
# we put everything in an eval block because that way we can easily handle
|
||||||
# errors without goto labels or much code duplication: the error handler
|
# errors without goto labels or much code duplication: the error handler
|
||||||
# has to send an "error" message to the other side
|
# has to send an "error" message to the other side
|
||||||
|
|
|
@ -8,7 +8,7 @@ mkdir /tmp/root/real
|
||||||
run_testA() {
|
run_testA() {
|
||||||
echo content > /tmp/foo
|
echo content > /tmp/foo
|
||||||
# shellcheck disable=SC2094
|
# shellcheck disable=SC2094
|
||||||
{ { { {{ CMD }} --hook-helper /tmp/root root setup env 1 upload /tmp/foo "$1" < /tmp/myfifo 3>&-; echo $? >&3; printf "\\000\\000adios";
|
{ { { {{ CMD }} --hook-helper /tmp/root root setup '' 1 upload /tmp/foo "$1" < /tmp/myfifo 3>&-; echo $? >&3; printf "\\000\\000adios";
|
||||||
} | {{ CMD }} --hook-listener 1 3>&- >/tmp/myfifo; echo $?; } 3>&1;
|
} | {{ CMD }} --hook-listener 1 3>&- >/tmp/myfifo; echo $?; } 3>&1;
|
||||||
} | { read -r xs1; [ "$xs1" -eq 0 ]; read -r xs2; [ "$xs2" -eq 0 ]; }
|
} | { read -r xs1; [ "$xs1" -eq 0 ]; read -r xs2; [ "$xs2" -eq 0 ]; }
|
||||||
echo content | diff -u - /tmp/root/real/foo
|
echo content | diff -u - /tmp/root/real/foo
|
||||||
|
|
|
@ -8,12 +8,12 @@ echo "MMDEBSTRAP_APT_CONFIG $MMDEBSTRAP_APT_CONFIG"
|
||||||
echo "$MMDEBSTRAP_HOOK" >> /tmp/hooks
|
echo "$MMDEBSTRAP_HOOK" >> /tmp/hooks
|
||||||
[ "$MMDEBSTRAP_MODE" = "root" ]
|
[ "$MMDEBSTRAP_MODE" = "root" ]
|
||||||
echo test-content $MMDEBSTRAP_HOOK > test
|
echo test-content $MMDEBSTRAP_HOOK > test
|
||||||
{{ CMD }} --hook-helper "$1" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" env 1 upload test /test <&$MMDEBSTRAP_HOOKSOCK >&$MMDEBSTRAP_HOOKSOCK
|
{{ CMD }} --hook-helper "$1" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" '' 1 upload test /test <&$MMDEBSTRAP_HOOKSOCK >&$MMDEBSTRAP_HOOKSOCK
|
||||||
rm test
|
rm test
|
||||||
echo "content inside chroot:"
|
echo "content inside chroot:"
|
||||||
cat "$1/test"
|
cat "$1/test"
|
||||||
[ "test-content $MMDEBSTRAP_HOOK" = "$(cat "$1/test")" ]
|
[ "test-content $MMDEBSTRAP_HOOK" = "$(cat "$1/test")" ]
|
||||||
{{ CMD }} --hook-helper "$1" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" env 1 download /test test <&$MMDEBSTRAP_HOOKSOCK >&$MMDEBSTRAP_HOOKSOCK
|
{{ CMD }} --hook-helper "$1" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" '' 1 download /test test <&$MMDEBSTRAP_HOOKSOCK >&$MMDEBSTRAP_HOOKSOCK
|
||||||
echo "content outside chroot:"
|
echo "content outside chroot:"
|
||||||
cat test
|
cat test
|
||||||
[ "test-content $MMDEBSTRAP_HOOK" = "$(cat test)" ]
|
[ "test-content $MMDEBSTRAP_HOOK" = "$(cat test)" ]
|
||||||
|
|
Loading…
Reference in a new issue