Skip to content

Commit

Permalink
Merge pull request #31 from jianingy/tarball
Browse files Browse the repository at this point in the history
add support for more tarball format
  • Loading branch information
grierj committed May 13, 2013
2 parents e961460 + 3fdccc7 commit d2061f7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions source/lib/Seco/Multipkg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ sub _init {
$self->{_rules} = [ $self->get_file_rules ];
}

sub taroption {
my $self = shift;
my $tarball = shift;

return 'zxf' if $tarball =~ /\.(tar\.gz|tgz)$/;
return 'jxf' if $tarball =~ /\.(tar\.bz2|tbz)$/;
return 'Jxf' if $tarball =~ /\.(tar\.xz)$/;
}

sub setrelease {
my $self = shift;

Expand Down Expand Up @@ -478,7 +487,8 @@ sub build {
and -f $self->info->data->{sourcetar} )
{
$self->infomsg( "Building from " . $self->info->data->{sourcetar} );
system( "tar zxf $self->{info}->{data}->{sourcetar} " . "-C $self->{builddir}" );
my $tar_opt = $self->taroption($self->info->data->{sourcetar});
system( "tar $tar_opt $self->{info}->{data}->{sourcetar} " . "-C $self->{builddir}" );
my $d;
opendir $d, $self->builddir;
foreach ( readdir $d ) {
Expand Down Expand Up @@ -670,7 +680,8 @@ sub copyroot {
and -f $self->info->data->{roottar} )
{
$self->infomsg( "Using " . $self->info->data->{roottar} );
system( "tar zxf $self->{info}->{data}->{roottar} " . " -C $self->{installdir}" );
my $tar_opt = $self->taroption($self->info->data->{roottar});
system( "tar $tar_opt $self->{info}->{data}->{roottar} " . " -C $self->{installdir}" );
}

# install daemontools service
Expand Down Expand Up @@ -1188,10 +1199,11 @@ sub _init {
$data->{$base}->{rootdir} ||= "$basedir/root"
if ( -d "$basedir/root" );

$data->{$base}->{sourcetar} ||= "$basedir/source.tar.gz"
if ( -f "$basedir/source.tar.gz" );
$data->{$base}->{roottar} ||= "$basedir/root.tar.gz"
if ( -f "$basedir/root.tar.gz" );
my @suffix = qw(.tar.gz .tgz .tar.bz2 .tbz .tar.xz);
my @sourcetar = grep { -f } map { "$basedir/source$_" } @suffix;
my @roottar = grep { -f } map { "$basedir/root$_" } @suffix;
$data->{$base}->{sourcetar} ||= shift @sourcetar if @sourcetar;
$data->{$base}->{roottar} ||= shift @roottar if @roottar;

for (qw/sourcedir rootdir/) {
next unless ( $data->{$base} and $data->{$base}->{$_} );
Expand Down

0 comments on commit d2061f7

Please sign in to comment.