forked from josch/mmdebstrap
implement --format=null
This commit is contained in:
parent
4c17f36072
commit
2767b051bc
1 changed files with 45 additions and 30 deletions
41
mmdebstrap
41
mmdebstrap
|
@ -4440,7 +4440,8 @@ sub main() {
|
||||||
if ($format eq 'dir') {
|
if ($format eq 'dir') {
|
||||||
$format = 'directory';
|
$format = 'directory';
|
||||||
}
|
}
|
||||||
my @valid_formats = ('auto', 'directory', 'tar', 'squashfs', 'ext2');
|
my @valid_formats
|
||||||
|
= ('auto', 'directory', 'tar', 'squashfs', 'ext2', 'null');
|
||||||
if (none { $_ eq $format } @valid_formats) {
|
if (none { $_ eq $format } @valid_formats) {
|
||||||
error "invalid format. Choose from " . (join ', ', @valid_formats);
|
error "invalid format. Choose from " . (join ', ', @valid_formats);
|
||||||
}
|
}
|
||||||
|
@ -5142,7 +5143,9 @@ sub main() {
|
||||||
|
|
||||||
# figure out the right format
|
# figure out the right format
|
||||||
if ($format eq 'auto') {
|
if ($format eq 'auto') {
|
||||||
if ($options->{target} ne '-' and -d $options->{target}) {
|
if ($options->{target} eq '/dev/null') {
|
||||||
|
$format = 'null';
|
||||||
|
} elsif ($options->{target} ne '-' and -d $options->{target}) {
|
||||||
$format = 'directory';
|
$format = 'directory';
|
||||||
} elsif (
|
} elsif (
|
||||||
defined $tar_compressor
|
defined $tar_compressor
|
||||||
|
@ -5213,11 +5216,12 @@ sub main() {
|
||||||
info "automatically chosen format: $format";
|
info "automatically chosen format: $format";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($options->{target} eq '-' and $format ne 'tar') {
|
if ($options->{target} eq '-' and $format ne 'tar' and $format ne 'null') {
|
||||||
error "the $format format is unable to write to standard output";
|
error "the $format format is unable to write to standard output";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
if (any { $_ eq $format } ('tar', 'squashfs', 'ext2', 'null')) {
|
||||||
|
if ($format ne 'null') {
|
||||||
if ( any { $_ eq $options->{variant} } ('extract', 'custom')
|
if ( any { $_ eq $options->{variant} } ('extract', 'custom')
|
||||||
and any { $_ eq $options->{mode} } ('fakechroot', 'proot')) {
|
and any { $_ eq $options->{mode} } ('fakechroot', 'proot')) {
|
||||||
info "creating a tarball or squashfs image or ext2 image in"
|
info "creating a tarball or squashfs image or ext2 image in"
|
||||||
|
@ -5235,10 +5239,12 @@ sub main() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
open my $fh, '>', $options->{target}
|
open my $fh, '>', $options->{target}
|
||||||
or error "cannot open $options->{target} for writing: $!";
|
or error
|
||||||
|
"cannot open $options->{target} for writing: $!";
|
||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
# since the output is a tarball, we create the rootfs in a temporary
|
# since the output is a tarball, we create the rootfs in a temporary
|
||||||
# directory
|
# directory
|
||||||
$options->{root} = tempdir('mmdebstrap.XXXXXXXXXX', TMPDIR => 1);
|
$options->{root} = tempdir('mmdebstrap.XXXXXXXXXX', TMPDIR => 1);
|
||||||
|
@ -5391,7 +5397,7 @@ sub main() {
|
||||||
= sprintf("%06o\0", unpack("%16C*", $entry));
|
= sprintf("%06o\0", unpack("%16C*", $entry));
|
||||||
$devtar .= $entry;
|
$devtar .= $entry;
|
||||||
}
|
}
|
||||||
} elsif ($format eq 'directory') {
|
} elsif (any { $_ eq $format } ('directory', 'null')) {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
} else {
|
} else {
|
||||||
error "unknown format: $format";
|
error "unknown format: $format";
|
||||||
|
@ -5494,7 +5500,7 @@ sub main() {
|
||||||
or error "tar failed: $?";
|
or error "tar failed: $?";
|
||||||
|
|
||||||
info "done";
|
info "done";
|
||||||
} elsif ($format eq 'directory') {
|
} elsif (any { $_ eq $format } ('directory', 'null')) {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
} else {
|
} else {
|
||||||
error "unknown format: $format";
|
error "unknown format: $format";
|
||||||
|
@ -5596,7 +5602,7 @@ sub main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
info "done";
|
info "done";
|
||||||
} elsif ($format eq 'directory') {
|
} elsif (any { $_ eq $format } ('directory', 'null')) {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
} else {
|
} else {
|
||||||
error "unknown format: $format";
|
error "unknown format: $format";
|
||||||
|
@ -5667,7 +5673,7 @@ sub main() {
|
||||||
|
|
||||||
if ($options->{dryrun}) {
|
if ($options->{dryrun}) {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
} elsif ($format eq 'directory') {
|
} elsif (any { $_ eq $format } ('directory', 'null')) {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
||||||
# we use eval() so that error() doesn't take this process down and
|
# we use eval() so that error() doesn't take this process down and
|
||||||
|
@ -5765,7 +5771,7 @@ sub main() {
|
||||||
# change signal handler message
|
# change signal handler message
|
||||||
$waiting_for = "cleanup";
|
$waiting_for = "cleanup";
|
||||||
|
|
||||||
if ($format eq 'directory') {
|
if (any { $_ eq $format } ('directory', 'null')) {
|
||||||
# nothing to do
|
# nothing to do
|
||||||
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
||||||
if (!-e $options->{root}) {
|
if (!-e $options->{root}) {
|
||||||
|
@ -5953,8 +5959,8 @@ information.
|
||||||
=item B<--format>=I<name>
|
=item B<--format>=I<name>
|
||||||
|
|
||||||
Choose the output format. Valid format I<name>s are B<auto>, B<directory>,
|
Choose the output format. Valid format I<name>s are B<auto>, B<directory>,
|
||||||
B<tar>, B<squashfs>, and B<ext2>. The default format is B<auto>. See the
|
B<tar>, B<squashfs>, B<ext2> and B<null>. The default format is B<auto>. See
|
||||||
section B<FORMATS> for more information.
|
the section B<FORMATS> for more information.
|
||||||
|
|
||||||
=item B<--aptopt>=I<option>|I<file>
|
=item B<--aptopt>=I<option>|I<file>
|
||||||
|
|
||||||
|
@ -6393,7 +6399,8 @@ Without that option the default format is I<auto>. The following formats exist:
|
||||||
|
|
||||||
When selecting this format (the default), the actual format will be inferred
|
When selecting this format (the default), the actual format will be inferred
|
||||||
from the I<TARGET> positional argument. If I<TARGET> was not specified, then
|
from the I<TARGET> positional argument. If I<TARGET> was not specified, then
|
||||||
the B<tar> format will be chosen. If I<TARGET> is an existing directory, and
|
the B<tar> format will be chosen. If I<TARGET> happens to be F</dev/null>, then
|
||||||
|
the B<null> format will be chosen. If I<TARGET> is an existing directory, and
|
||||||
does not equal to C<->, then the B<directory> format will be chosen. If
|
does not equal to C<->, then the B<directory> format will be chosen. If
|
||||||
I<TARGET> ends with C<.tar> or with one of the filename extensions listed in
|
I<TARGET> ends with C<.tar> or with one of the filename extensions listed in
|
||||||
the section B<COMPRESSION>, or if I<TARGET> equals C<->, or if I<TARGET> is a
|
the section B<COMPRESSION>, or if I<TARGET> equals C<->, or if I<TARGET> is a
|
||||||
|
@ -6449,6 +6456,14 @@ has_journal TARGET> and to convert it to ext4, use C<tune2fs -O
|
||||||
extents,uninit_bg,dir_index,has_journal TARGET>. Since C<genext2fs> does not
|
extents,uninit_bg,dir_index,has_journal TARGET>. Since C<genext2fs> does not
|
||||||
support extended attributes, the resulting image will not contain them.
|
support extended attributes, the resulting image will not contain them.
|
||||||
|
|
||||||
|
=item B<null>
|
||||||
|
|
||||||
|
A temporary chroot directory will be created in C<$TMPDIR> or F</tmp> if
|
||||||
|
C<$TMPDIR> is not set. After the bootstrap is complete, the temporary chroot
|
||||||
|
will be deleted without being part of the output. This is most useful when the
|
||||||
|
desired artifact is generated inside the chroot and it is transferred using
|
||||||
|
special hooks such as B<sync-out>.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 HOOKS
|
=head1 HOOKS
|
||||||
|
|
Loading…
Reference in a new issue