Subject: | Executable bit on files not propagated when creating Archives |
When adding files to an Archive::Tar (or ::Zip) object in
Archive::Builder::Archive::_tar (or ::_zip), the 'executable' property
of the Archive::Builder::File object is not propagated to the underlying
Archive::Tar::File (or Archive::Zip::Member) object.
This can be fixed by modifying the _tar() method as such:
--------------------------------------------------------
use constant UNIX_EXECUTABLE_MODE => 0755;
# [...]
sub _tar {
# [...]
# Add each file to it
foreach my $path ( $self->sorted_files ) {
my $file = $self->{files}->{$path};
my $file_object = $Archive->add_data( $path, ${ $file->contents } );
if( $file->{executable} ) {
$file_object->mode( UNIX_EXECUTABLE_MODE );
}
}
--------------------------------------------------------
The _zip() method also suffers from this issue, and is fixed similarly:
--------------------------------------------------------
sub _zip {
# [...]
# Add each file to it
foreach my $path ( keys %{ $self->{files} } ) {
my $file = $self->{files}->{$path};
my $member = $Archive->addString( ${ $file->contents }, $path );
$member->desiredCompressionMethod(
Archive::Zip::COMPRESSION_DEFLATED() );
if( $file->{executable} ) {
$member->unixFileAttributes( UNIX_EXECUTABLE_MODE );
}
}
--------------------------------------------------------