File Coverage

alienfile
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


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