die if copy() fails

This commit is contained in:
Johannes 'josch' Schauer 2018-10-01 22:51:50 +02:00
parent 640d854c2e
commit a9db385868
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -935,7 +935,7 @@ sub setup {
if (!-e $qemubin) { if (!-e $qemubin) {
die "cannot find $qemubin"; die "cannot find $qemubin";
} }
copy $qemubin, "$options->{root}/$qemubin"; copy $qemubin, "$options->{root}/$qemubin" or die "cannot copy $qemubin: $!";
} }
} }
@ -1106,8 +1106,8 @@ sub setup {
} }
# allow network access from within # allow network access from within
copy("/etc/resolv.conf", "$options->{root}/etc/resolv.conf"); copy("/etc/resolv.conf", "$options->{root}/etc/resolv.conf") or die "cannot copy /etc/resolv.conf: $!";
copy("/etc/hostname", "$options->{root}/etc/hostname"); copy("/etc/hostname", "$options->{root}/etc/hostname") or die "cannot copy /etc/hostname: $!";
print STDERR "I: installing remaining packages inside the chroot...\n"; print STDERR "I: installing remaining packages inside the chroot...\n";
run_apt_progress @chrootcmd, 'apt-get', '--yes', 'install', keys %pkgs_to_install; run_apt_progress @chrootcmd, 'apt-get', '--yes', 'install', keys %pkgs_to_install;
@ -1584,11 +1584,9 @@ sub main() {
close $wfh; close $wfh;
if ($options->{maketar}) { if ($options->{maketar}) {
if ($options->{target} ne '-') { if ($options->{target} ne '-') {
open(my $fh, '>', $options->{target}); copy($rfh, $options->{target}) or die "cannot copy to $options->{target}: $!";
copy($rfh, $fh);
close($fh);
} else { } else {
copy($rfh, *STDOUT); copy($rfh, *STDOUT) or die "cannot copy to standard output: $!";
} }
} }
close($rfh); close($rfh);