add --skip=chroot/start-stop-daemon and --skip=chroot/policy-rc.d
This commit is contained in:
parent
18c1e9bbc5
commit
e61e352f67
3 changed files with 68 additions and 32 deletions
|
@ -264,6 +264,8 @@ Test: not-having-to-install-apt-in-include-because-a-hook-did-it-before
|
|||
|
||||
Test: remove-start-stop-daemon-and-policy-rc-d-in-hook
|
||||
|
||||
Test: skip-start-stop-daemon-policy-rc
|
||||
|
||||
Test: compare-output-with-pre-seeded-var-cache-apt-archives
|
||||
Needs-QEMU: true
|
||||
Variants: any
|
||||
|
|
88
mmdebstrap
88
mmdebstrap
|
@ -1426,48 +1426,66 @@ sub run_chroot {
|
|||
# existing inside the chroot
|
||||
#
|
||||
# See #911290 for more problems of this interface
|
||||
if (-d "$options->{root}/usr/sbin/") {
|
||||
open my $fh, '>', "$options->{root}/usr/sbin/policy-rc.d"
|
||||
or error "cannot open policy-rc.d: $!";
|
||||
print $fh "#!/bin/sh\n";
|
||||
print $fh "exit 101\n";
|
||||
close $fh;
|
||||
chmod 0755, "$options->{root}/usr/sbin/policy-rc.d"
|
||||
or error "cannot chmod policy-rc.d: $!";
|
||||
if (any { $_ eq 'chroot/policy-rc.d' } @{ $options->{skip} }) {
|
||||
info "skipping chroot/policy-rc.d as requested";
|
||||
} else {
|
||||
if (-d "$options->{root}/usr/sbin/") {
|
||||
open my $fh, '>', "$options->{root}/usr/sbin/policy-rc.d"
|
||||
or error "cannot open policy-rc.d: $!";
|
||||
print $fh "#!/bin/sh\n";
|
||||
print $fh "exit 101\n";
|
||||
close $fh;
|
||||
chmod 0755, "$options->{root}/usr/sbin/policy-rc.d"
|
||||
or error "cannot chmod policy-rc.d: $!";
|
||||
}
|
||||
}
|
||||
|
||||
# the file might not exist if it was removed in a hook
|
||||
if (-f "$options->{root}/sbin/start-stop-daemon") {
|
||||
if (-e "$options->{root}/sbin/start-stop-daemon.REAL") {
|
||||
error "$options->{root}/sbin/start-stop-daemon.REAL already"
|
||||
. " exists";
|
||||
if (any { $_ eq 'chroot/start-stop-daemon' } @{ $options->{skip} }) {
|
||||
info "skipping chroot/start-stop-daemon as requested";
|
||||
} else {
|
||||
if (-f "$options->{root}/sbin/start-stop-daemon") {
|
||||
if (-e "$options->{root}/sbin/start-stop-daemon.REAL") {
|
||||
error
|
||||
"$options->{root}/sbin/start-stop-daemon.REAL already"
|
||||
. " exists";
|
||||
}
|
||||
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";
|
||||
print $fh
|
||||
"echo \"Warning: Fake start-stop-daemon called, doing"
|
||||
. " nothing\">&2\n";
|
||||
close $fh;
|
||||
chmod 0755, "$options->{root}/sbin/start-stop-daemon"
|
||||
or error "cannot chmod 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";
|
||||
print $fh "echo \"Warning: Fake start-stop-daemon called, doing"
|
||||
. " nothing\">&2\n";
|
||||
close $fh;
|
||||
chmod 0755, "$options->{root}/sbin/start-stop-daemon"
|
||||
or error "cannot chmod start-stop-daemon: $!";
|
||||
}
|
||||
|
||||
&{$cmd}();
|
||||
|
||||
# cleanup
|
||||
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: $!";
|
||||
if (any { $_ eq 'chroot/start-stop-daemon' } @{ $options->{skip} }) {
|
||||
info "skipping chroot/start-stop-daemon as requested";
|
||||
} else {
|
||||
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: $!";
|
||||
}
|
||||
}
|
||||
if (-f "$options->{root}/usr/sbin/policy-rc.d") {
|
||||
unlink "$options->{root}/usr/sbin/policy-rc.d"
|
||||
or error "cannot unlink policy-rc.d: $!";
|
||||
if (any { $_ eq 'chroot/policy-rc.d' } @{ $options->{skip} }) {
|
||||
info "skipping chroot/policy-rc.d as requested";
|
||||
} else {
|
||||
if (-f "$options->{root}/usr/sbin/policy-rc.d") {
|
||||
unlink "$options->{root}/usr/sbin/policy-rc.d"
|
||||
or error "cannot unlink policy-rc.d: $!";
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -6765,6 +6783,12 @@ out in B<extract> mode.
|
|||
Run B<--customize-hook> options and all F<customize*> scripts in B<--hook-dir>.
|
||||
This step is not carried out in B<extract> mode.
|
||||
|
||||
For each command that is run inside the chroot, B<mmdebstrap> will disable
|
||||
running services by temporarily moving F</usr/sbin/policy-rc.d> and
|
||||
F</sbin/start-stop-daemon> if they exist. This can be disabled with
|
||||
B<--skip=chroot/policy-rc.d> and B<--skip=chroot/start-stop-daemon>,
|
||||
respectively.
|
||||
|
||||
=item B<cleanup>
|
||||
|
||||
Performs cleanup tasks, unless B<--skip=cleanup> is used:
|
||||
|
|
10
tests/skip-start-stop-daemon-policy-rc
Normal file
10
tests/skip-start-stop-daemon-policy-rc
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
export LC_ALL=C.UTF-8
|
||||
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
|
||||
{{ CMD }} --mode={{ MODE }} --variant=apt \
|
||||
--skip=chroot/start-stop-daemon,chroot/policy-rc.d \
|
||||
--customize-hook='test ! -e "$1/sbin/start-stop-daemon.REAL"' \
|
||||
--customize-hook='test ! -e "$1/usr/sbin/policy-rc.d"' \
|
||||
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
Loading…
Reference in a new issue