-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalienfile
80 lines (71 loc) · 2.35 KB
/
alienfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use alienfile;
use strict;
use warnings;
use Data::Dump qw(dump);
configure sub {
## find out of pipx is actually installed
my $is_pipx_installed;
my $cmd = `pipx --version`;
$is_pipx_installed = $cmd =~ /[0..9]+/;
## if pipx is not installed, install it using OS appropriate package managers
unless ($is_pipx_installed) {
my $os = $^O;
my %os_mapping = (
'darwin' => {
install => 'brew install pipx',
setpath => 'pipx ensurepath',
upgrade => 'brew update && brew upgrade pipx',
},
'linux' => {
install => 'sudo apt install pipx',
setpath => 'pipx ensurepath',
upgrade => '',
},
'MSWin32' => {
install => 'scoop install pipx',
setpath => 'pipx ensurepath',
upgrade => 'scoop update pipx',
},
);
unless ( exists $os_mapping{$os} ) {
my @valid_oses = keys %os_mapping;
die "Unsupported os : $os, must be one of @valid_oses";
}
## adjust the linux install steps based on version
if ( $os eq 'linux' ) {
my @os_details = `cat /etc/os-release`;
chomp @os_details;
my %os_details = map { split /=/, $_ } @os_details;
$os_details{VERSION_ID} =~ s/\"//g;
if ( $os_details{VERSION_ID} <= 22.04 ) {
$os_mapping{linux} = {
install => 'python3 -m pip install --user pipx',
setpath => 'python3 -m pipx ensurepath',
upgrade => 'python3 -m pip install --user --upgrade pipx',
};
}
}
system $os_mapping{$os}->{install};
system $os_mapping{$os}->{setpath};
system $os_mapping{$os}->{upgrade};
}
};
## dummy probe to force a system install
probe sub {
'system';
};
sys sub {
##find out if cutadapt is actually installed
my $cmd = `pipx environment`;
$cmd = `cutadapt --help`;
my $is_cutadapt_installed = $cmd =~ /\Acutadapt\s+version\s+[0-9.]+/;
## if cutadapt is not installed, install it via pipx
unless ($is_cutadapt_installed) {
system 'pipx install cutadapt';
}
};
gather sub {
my ($build) = @_;
$build->runtime_prop->{command}= 'cutadapt';
};
1;