output tarball if output is named pipe or character special

This commit is contained in:
Johannes 'josch' Schauer 2020-03-22 14:10:06 +01:00
parent 412039bd66
commit 323a353548
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -3658,9 +3658,13 @@ sub main() {
# figure out whether a tarball has to be created in the end # figure out whether a tarball has to be created in the end
$options->{maketar} = 0; $options->{maketar} = 0;
$options->{makesqfs} = 0; $options->{makesqfs} = 0;
if ( defined $tar_compressor if (
defined $tar_compressor
or $options->{target} =~ /\.tar$/ or $options->{target} =~ /\.tar$/
or $options->{target} eq '-') { or $options->{target} eq '-'
or -p $options->{target} # named pipe (fifo)
or -c $options->{target} # character special like /dev/null
) {
$options->{maketar} = 1; $options->{maketar} = 1;
# check if the compressor is installed # check if the compressor is installed
if (defined $tar_compressor) { if (defined $tar_compressor) {
@ -4567,30 +4571,31 @@ https URI, then the packages apt-transport-https and ca-certificates will be
installed inside the chroot. If any mirror contains a tor+xxx URI, then the installed inside the chroot. If any mirror contains a tor+xxx URI, then the
apt-transport-tor package will be installed inside the chroot. apt-transport-tor package will be installed inside the chroot.
The optional I<TARGET> argument can either be the path to a directory, the The optional I<TARGET> argument can either be the path to a directory, the path
path to a tarball filename, the path to a squashfs image or C<->. If I<TARGET> to a tarball filename, the path to a squashfs image, a FIFO, a character
ends with C<.tar>, or with any of the filename extensions listed in the special device, or C<->. If I<TARGET> ends with C<.tar>, or with any of the
section B<COMPRESSION>, then I<TARGET> will be interpreted as a path to a filename extensions listed in the section B<COMPRESSION>, or if I<TARGET> is a
tarball filename. If I<TARGET> ends with C<.squashfs> or C<.sqfs>, then FIFO or a character special device, then I<TARGET> will be interpreted as a
I<TARGET> will be interpreted as a path to a squashfs image. If I<TARGET> is path to a tarball filename. If I<TARGET> ends with C<.squashfs> or C<.sqfs>,
the path to a tarball filename or a squashfs image or if I<TARGET> is C<-> or then I<TARGET> will be interpreted as a path to a squashfs image. If I<TARGET>
if no I<TARGET> was specified, B<mmdebstrap> will create a temporary chroot is the path to a tarball filename or a squashfs image or if I<TARGET> is C<->
or if no I<TARGET> was specified, B<mmdebstrap> will create a temporary chroot
directory in C<$TMPDIR> or F</tmp>. If I<TARGET> is the path to a tarball directory in C<$TMPDIR> or F</tmp>. If I<TARGET> is the path to a tarball
filename, B<mmdebstrap> will create a tarball of that directory and store it filename, B<mmdebstrap> will create a tarball of that directory and store it as
as I<TARGET>, optionally applying a compression algorithm as indicated by its I<TARGET>, optionally applying a compression algorithm as indicated by its
filename extension. If I<TARGET> is C<-> or if no I<TARGET> was specified, filename extension. If I<TARGET> is C<-> or if no I<TARGET> was specified, then
then an uncompressed tarball of that directory will be sent to standard an uncompressed tarball of that directory will be sent to standard output. When
output. When B<mmdebstrap> creates a tarball it also stores extended B<mmdebstrap> creates a tarball it also stores extended attributes. To preserve
attributes. To preserve the extended attributes, you have to pass B<--xattrs the extended attributes, you have to pass B<--xattrs --xattrs-include='*'> to
--xattrs-include='*'> to tar when extracting the tarball. If I<TARGET> is the tar when extracting the tarball. If I<TARGET> is the path to a squashfs image,
path to a squashfs image, B<mmdebstrap> will create an xz compressed image B<mmdebstrap> will create an xz compressed image with a blocksize of 1048576
with a blocksize of 1048576 bytes. If I<TARGET> does neither end with C<.tar> bytes. If I<TARGET> does neither end with C<.tar> nor with any of the filename
nor with any of the filename extensions listed in the section B<COMPRESSION>, extensions listed in the section B<COMPRESSION>, nor with C<.squashfs> or
nor with C<.squashfs> or C<.sqfs>, then I<TARGET> will be interpreted as the C<.sqfs>, then I<TARGET> will be interpreted as the path to a directory. If the
path to a directory. If the directory already exists, it must either be empty directory already exists, it must either be empty or only contain an empty
or only contain an empty C<lost+found> directory. If a directory is chosen as C<lost+found> directory. If a directory is chosen as output in any other mode
output in any other mode than B<sudo>, then its contents will have wrong than B<sudo>, then its contents will have wrong ownership information and
ownership information and special device files will be missing. special device files will be missing.
The I<SUITE> may be a valid release code name (eg, sid, stretch, jessie) or a The I<SUITE> may be a valid release code name (eg, sid, stretch, jessie) or a
symbolic name (eg, unstable, testing, stable, oldstable). Any suite name that symbolic name (eg, unstable, testing, stable, oldstable). Any suite name that