File Coverage

blib/lib/Ixchel/functions/install_pip.pm
Criterion Covered Total %
statement 20 43 46.5
branch 0 16 0.0
condition 0 9 0.0
subroutine 7 8 87.5
pod 1 1 100.0
total 28 77 36.3


line stmt bran cond sub pod time code
1             package Ixchel::functions::install_pip;
2              
3 3     3   135291 use 5.006;
  3         14  
4 3     3   22 use strict;
  3         5  
  3         93  
5 3     3   15 use warnings;
  3         7  
  3         213  
6 3     3   20 use Exporter 'import';
  3         6  
  3         271  
7             our @EXPORT = qw(install_pip);
8 3     3   1236 use Rex -feature => [qw/1.4/];
  3         160349  
  3         30  
9 3     3   743881 use Rex::Commands::Gather;
  3         7  
  3         29  
10 3     3   3946 use Rex::Commands::Pkg;
  3         17  
  3         40  
11              
12             # prevents Rex from printing out rex is exiting after the script ends
13             $::QUIET = 2;
14              
15             =head1 NAME
16              
17             Ixchel::functions::install_pip - Installs pip for python3
18              
19             =head1 VERSION
20              
21             Version 0.0.1
22              
23             =cut
24              
25             our $VERSION = '0.0.1';
26              
27             =head1 SYNOPSIS
28              
29             use Ixchel::functions::install_pip;
30             use Data::Dumper;
31              
32             eval{ install_pip };
33             if ($@) {
34             print 'Failed to install pip...'.$@."\n";
35             }
36              
37             Supported OS families are...
38              
39             Alt Linux
40             Arch Linux
41             Debian Linux
42             FreeBSD
43             Mageia Linux
44             NetBSD
45             OpenBSD
46             Redhat Linux
47             Suse Linux
48             Void Linux
49              
50             =head1 Functions
51              
52             =head2 install_pip
53              
54             Installs pip for the OS.
55              
56             eval{ install_cpanm };
57             if ($@) {
58             print 'Failed to install cpanm ...'.$@;
59             }
60              
61             =cut
62              
63             sub install_pip {
64 0     0 1   my (%opts) = @_;
65              
66 0 0 0       if (is_freebsd) {
    0 0        
    0 0        
    0          
    0          
    0          
    0          
67 0           pkg( "python3", ensure => "present" );
68 0           my $which_python3 = `which python3 2> /dev/null`;
69 0           chomp($which_python3);
70 0 0         if ( $which_python3 !~ /python3$/ ) {
71 0           die( 'Unable to locate python3 with PATH=' . $ENV{PATH} );
72             }
73 0           my $python_link = readlink($which_python3);
74 0           $python_link =~ s/.*python3\.//;
75 0           my $pkg = 'py3' . $python_link . '-pip';
76 0           pkg( $pkg, ensure => "present" );
77             } elsif (is_debian|| is_redhat || is_mageia || is_void) {
78 0           pkg( "python3", ensure => "present" );
79 0           pkg( "python3-pip", ensure => "present" );
80             } elsif (is_arch) {
81 0           pkg( "python", ensure => "present" );
82 0           pkg( "python-pip", ensure => "present" );
83             } elsif (is_suse) {
84 0           pkg( "python311", ensure => "present" );
85 0           pkg( "python311-pip", ensure => "present" );
86             } elsif (is_alt) {
87 0           pkg( "python3", ensure => "present" );
88 0           pkg( "pip", ensure => "present" );
89             } elsif (is_netbsd) {
90 0           pkg( "python311", ensure => "present" );
91 0           pkg( "py311-pip", ensure => "present" );
92             } elsif (is_openbsd) {
93 0           pkg( "python311", ensure => "present" );
94 0           pkg( "py311-pip", ensure => "present" );
95             }
96              
97             } ## end sub install_pip
98              
99             1;