Alien-gdal
view release on metacpan or search on metacpan
# need to also do the bin dir - those files only need to have $ORIGIN/../lib added
use File::Find::Rule;
my (@so_files)
= grep {not -l $_}
File::Find::Rule
->file()
->name( qr/^libgdal.so/ )
->in( $dest_dir );
foreach my $so_file (@so_files) {
my ($old_rpath, $result, $stderr, @errors);
($old_rpath, $stderr, @errors)
= $pe->patchelf ('--print-rpath', $so_file);
$old_rpath //= '';
# prepend our paths
my $rpath = $alien_rpath_text . ($old_rpath ? (':' . $old_rpath) : '');
$build->log("Updating rpath for $so_file to $rpath, was $old_rpath");
($result, $stderr, @errors)
= $pe->patchelf ('--set-rpath', $rpath, $so_file);
warn $stderr if $stderr;
}
#my $xy = <STDIN>;
return;
}
sub patch_rpaths_macos {
my ($build) = @_;
# just for safety
my (@so_files)
= grep {not -l $_}
File::Find::Rule
->file()
->name( qr/^libgdal[.\d]*.dylib/ )
->in( $dest_dir );
foreach my $so_file (@so_files) {
use Capture::Tiny qw /capture/;
$build->log ("Updating rpath for $so_file");
my ($otool_text, $old_rpath, $result, $stderr, @errors);
$build ->log ("Calling: $otool, '-l', $so_file");
#eval {
($otool_text, $stderr, @errors)
= capture {system $otool, '-l', $so_file};
#};
#$build->log ($@) if $@;
#$build->log (@errors) if @errors;
$build->log ($stderr) if $stderr;
#$build->log($otool_text); # debug
# now we need to extract the rpaths
my @lines = split "\n", $otool_text;
my @existing_paths;
while (defined (my $line = shift @lines)) {
if ($line =~ /RPATH/) {
shift @lines;
$line = shift @lines;
$line =~ s/^\s+path\s//;
$line =~ s/\s\(offset.+$//;
push @existing_paths, $line;
}
}
# remove existing
if (@existing_paths) {
$build->log ("removing existing rpaths " . join ' ', @existing_paths);
my @delete_args = map {; '-delete_rpath' => $_} @existing_paths;
($result, $stderr, @errors)
= capture {system $install_name_tool, @delete_args, $so_file};
#$build->log($result);
$build->log($stderr) if $stderr;
}
# now append the existing ones
push @inst_tool_rpath_args, map {; '-add_rpath' => $_} @existing_paths;
# prepend our paths
($result, $stderr, @errors)
= capture {system $install_name_tool, @inst_tool_rpath_args, $so_file};
#$build->log($result);
$build->log($stderr) if $stderr;
}
return;
}
# we can get dangling -L values
# bandaid until we find the source
sub cleanup_ldflags {
my ($build, @args) = @_;
lib/Alien/gdal.pm view on Meta::CPAN
=head1 SYNOPSIS
use Alien::gdal;
use Env qw(@PATH);
unshift @PATH, Alien::gdal->bin_dir;
print Alien::gdal->dist_dir;
# assuming you have populated @args already
my ($stdout, $stderr, $exit_code)
= Alien::gdal->run_utility ('gdalwarp', @args);
# Note that this is currently experimental.
# Please report issues and solutions.
# Access the GDAL data directory
# (note that not all system installs include it)
my $path = Alien::gdal->data_dir;
=head1 DESCRIPTION
t/03-utilities.t view on Meta::CPAN
use Test::More;
use Test::Alien;
use Alien::gdal;
diag "LD_LIBRARY_PATH: " . ($ENV{LD_LIBRARY_PATH} // '');
diag "DYLD_LIBRARY_PATH: " . ($ENV{DYLD_LIBRARY_PATH} // '');
TODO:
{
local $TODO = 'possibly flaky in early release, but should not stop installation';
my ($result, $stderr, $exit) = Alien::gdal->run_utility ("gdalwarp", '--version');
like ($result, qr{GDAL \d+\.\d+\.\d+, released \d{4}/\d{2}/\d{2}},
'Got expected result from gdalwarp utility');
diag '';
diag ("\nUtility results:\n" . $result);
diag ($stderr) if $stderr;
diag "Exit code is $exit";
diag '';
}
done_testing();
( run in 1.501 second using v1.01-cache-2.11-cpan-49f99fa48dc )