allow messing with s-s-d in hooks

Presently, mmdebstrap fails hard if e.g. a --setup-hook removes
start-stop-daemon.REAL.
This commit is contained in:
Helmut Grohne 2019-09-13 12:37:28 +02:00 committed by Johannes 'josch' Schauer
parent ea0a6bcd89
commit 4b440a0e01
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -861,7 +861,7 @@ sub run_chroot(&$) {
chmod 0755, "$options->{root}/usr/sbin/policy-rc.d" or error "cannot chmod policy-rc.d: $!";
}
{
if (-e "$options->{root}/sbin/start-stop-daemon") {
move("$options->{root}/sbin/start-stop-daemon", "$options->{root}/sbin/start-stop-daemon.REAL") or error "cannot move start-stop-daemon: $!";
open my $fh, '>', "$options->{root}/sbin/start-stop-daemon" or error "cannot open start-stop-daemon: $!";
print $fh "#!/bin/sh\n";
@ -873,7 +873,9 @@ sub run_chroot(&$) {
&{$cmd}();
# cleanup
move("$options->{root}/sbin/start-stop-daemon.REAL", "$options->{root}/sbin/start-stop-daemon") or error "cannot move start-stop-daemon: $!";
if (-e "$options->{root}/sbin/start-stop-daemon.REAL") {
move("$options->{root}/sbin/start-stop-daemon.REAL", "$options->{root}/sbin/start-stop-daemon") or error "cannot move start-stop-daemon: $!";
}
unlink "$options->{root}/usr/sbin/policy-rc.d" or error "cannot unlink policy-rc.d: $!";
};