Alien-ROOT
view release on metacpan or search on metacpan
inc/Alien/ROOT/Builder.pm view on Meta::CPAN
sub fetch_ROOT {
my $self = shift;
return if defined $self->notes('build_data')->{archive}
and -f $self->notes('build_data')->{archive};
$self->_load_bundled_modules;
print "Fetching ROOT...\n";
print "fetching from: ", $self->notes('build_data')->{url}, "\n";
my $ff = File::Fetch->new( uri => $self->notes('build_data')->{url} );
my $path = $ff->fetch(to => File::Spec->curdir);
die 'Unable to fetch archive' unless $path;
$self->notes('build_data')->{archive} = $path;
}
sub extract_ROOT {
my $self = shift;
return if -d $self->notes( 'build_data' )->{directory};
my $archive = $self->notes( 'build_data' )->{archive};
if (not $archive or not -e $archive) {
$self->fetch_ROOT;
$archive = $self->notes( 'build_data' )->{archive};
}
print "Extracting ROOT...\n";
$self->_load_bundled_modules;
$Archive::Extract::PREFER_BIN = 1;
my $ae = Archive::Extract->new( archive => $archive );
die 'Error: ', $ae->error unless $ae->extract;
#$self->patch_ROOT;
}
sub build_ROOT {
my $self = shift;
my $prefix = $self->aroot_install_arch_auto_dir('root');
my @cmd = (
qw(sh configure),
'--prefix='.$prefix,
'--etcdir='.File::Spec->catfile($prefix, 'etc'),
'--enable-explicitlink', # needed for SOOT
);
my $dir = $self->notes('build_data')->{directory};
chdir $dir;
$ENV{PWD} = Cwd::cwd();
# do not reconfigure unless necessary
if (not -f 'config.status') {
system(@cmd) and die "Build failed while running '@cmd': $?";
}
my $make = $self->notes('make');
my $parallel_procs = $self->notes('build_data')->{parallel_processes};
if (defined $parallel_procs and $parallel_procs > 1) {
system($make, "-j$parallel_procs")
and die "Build failed while running '$make -j$parallel_procs': $?";
}
else {
system($make) and die "Build failed while running '$make': $?";
}
chdir $ORIG_DIR;
}
sub install_ROOT {
my $self = shift;
require File::Path;
File::Path::mkpath($self->aroot_install_arch_auto_dir('root'));
my $dir = $self->notes('build_data')->{directory};
chdir $dir;
my $make = $self->notes('make');
system($make, 'install') and die "Build failed while running '$make install': $?";
$self->write_packlist_ROOT;
chdir $ORIG_DIR;
}
sub write_packlist_ROOT {
my $self = shift;
my $root_dir = $self->aroot_install_arch_auto_dir('root');
my $root_plist = $self->get_root_packlist_file;
open my $fh, '>', $root_plist
or die "Could not open file '$root_plist' for writing the ROOT packlist: $!";
# merge the previous source for .packlist
my $from_to = $self->install_map;
if (exists $from_to->{'read'}
and defined $from_to->{'read'})
{
my $ih;
if (open $ih, '<', $from_to->{'read'}) {
print $fh $_ for <$ih>;
}
}
require File::Find;
File::Find::find(
sub {
print $fh $File::Find::name, "\n";
},
$root_dir
);
close $fh;
}
sub get_root_packlist_file {
my $self = shift;
my $root_dir = $self->aroot_install_arch_auto_dir('root');
( run in 0.549 second using v1.01-cache-2.11-cpan-97f6503c9c8 )