Alien-Plotly-Orca
view release on metacpan or search on metacpan
# $_[0] is one of the file names on https://github.com/plotly/orca/releases
join( '/', $github_base_url, "v${plotly_orca_version}", $_[0] );
};
my %download_url = (
MSWin32 => $make_url_anaconda->('win-64'),
darwin => $make_url_anaconda->('osx-64'),
linux => $make_url_github->("orca-${plotly_orca_version}.AppImage"),
);
die 'Unsupported OS' unless grep { $^O eq $_ } ( keys %download_url );
if ( MyInstallUtil::need_xvfb() and not MyInstallUtil::can_xvfb() ) {
die "plotly-orca requires a running X service. "
. "But your host seems to be headless and you don't have xvfb at all. "
. "Please install xvfb.";
}
plugin 'Probe::CommandLine' => (
command => MyInstallUtil::wrap_orca('orca'),
args => ['-h'],
match => qr/plotly/i,
);
configure {
requires 'Capture::Tiny' => 0;
requires 'File::Which' => 0;
requires 'Path::Tiny' => 0;
requires 'File::Copy::Recursive' => 0;
};
share {
require Path::Tiny;
start_url( $ENV{ALIEN_PLOTLY_ORCA_DOWNLOAD_URL} || $download_url{$^O} );
plugin 'Download';
if ( $^O eq 'linux' ) {
extract sub {
my ( $build, $src ) = @_;
my $dst = Path::Tiny::path('.')->absolute;
Path::Tiny::path($src)->copy($dst);
};
}
else {
plugin 'Extract' => 'tar.bz2';
}
patch sub {
my ($build) = @_;
if ( $^O eq 'linux' ) {
my $extract = $build->install_prop->{extract};
my ($appimage_file) = glob("$extract/*.AppImage");
my $orca = Path::Tiny::path( $extract, 'bin', 'orca' );
$orca->touchpath;
Path::Tiny::path($appimage_file)->move($orca);
$orca->chmod('0755');
}
else {
return patch_anaconda($build);
}
};
build sub {
my ($build) = @_;
my $extract = $build->install_prop->{extract};
my $prefix = $build->install_prop->{prefix};
require File::Copy::Recursive;
File::Copy::Recursive::dircopy( $extract, $prefix );
};
gather sub {
my ($build) = @_;
$build->runtime_prop->{version} = MyInstallUtil::detect_orca_version();
};
};
sub patch_anaconda {
my ($build) = @_;
my $extract = $build->install_prop->{extract};
# Patch orca.cmd as Anaconda's orca.cmd uses Anaconda's path.
if ( $^O eq 'MSWin32' ) {
# on Windows also adjust the directory structure.
Path::Tiny::path( $extract, 'orca.cmd' )->remove;
my $orca = Path::Tiny::path( $extract, 'bin', 'orca.cmd' );
$orca->touchpath;
$orca->spew(<<'END_OF_TEXT');
@echo off
%~dp0\..\orca_app\orca.exe %*
END_OF_TEXT
}
else {
my $orca = Path::Tiny::path( $extract, 'bin', 'orca' );
$orca->spew(<<'END_OF_TEXT');
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
exec ${DIR}/../lib/orca.app/Contents/MacOS/orca "$@"
else
# Assume linux
exec ${DIR}/../lib/orca_app/orca "$@"
fi
END_OF_TEXT
$orca->chmod('0755');
}
}
( run in 0.473 second using v1.01-cache-2.11-cpan-02777c243ea )