| 1 | # | ||||||||||||||||||||
| 2 | # Work with ALT Linux APT-RPM package management system | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Rex::Pkg::ALT; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use Rex::Commands::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 1 | ▶ | use Rex::Commands::Fs; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 1 | ▶ | use Rex::Pkg::Base; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 1 | ▶ | use base qw(Rex::Pkg::Base); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 19 | 0 | my $that = shift; | |||||||||||||||||||
| 20 | 0 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 21 | 0 | my $self = $proto->SUPER::new(@_); | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | bless( $self, $proto ); | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | $self->{commands} = { | ||||||||||||||||||||
| 26 | 0 | install => '/usr/bin/apt-get -y install %s', | |||||||||||||||||||
| 27 | install_version => '/usr/bin/apt-get -y install %s-%s', | ||||||||||||||||||||
| 28 | remove => '/usr/bin/apt-get -y remove %s', | ||||||||||||||||||||
| 29 | update_package_db => '/usr/bin/apt-get update', | ||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | return $self; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | ▶ | sub get_installed { | ||||||||||||||||||
|
Subroutine
get_installed: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 36 | 0 | my ($self) = @_; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | my @lines = i_run | |||||||||||||||||||
| 39 | '/usr/bin/rpm -qa --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"'; | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | my @pkg; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | for my $line (@lines) { | |||||||||||||||||||
| 44 | 0 | ▶ | if ( $line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | push( | |||||||||||||||||||
| 46 | @pkg, | ||||||||||||||||||||
| 47 | { | ||||||||||||||||||||
| 48 | name => $1, | ||||||||||||||||||||
| 49 | epoch => $2, | ||||||||||||||||||||
| 50 | version => $3, | ||||||||||||||||||||
| 51 | release => $4, | ||||||||||||||||||||
| 52 | arch => $5, | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | return @pkg; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub add_repository { | ||||||||||||||||||
|
Subroutine
add_repository: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 62 | 0 | my ( $self, %data ) = @_; | |||||||||||||||||||
| 63 | 0 | my $name = $data{"name"}; | |||||||||||||||||||
| 64 | 0 | ▶ | my $sign = $data{"sign_key"} || ""; | ||||||||||||||||||
|
Condition0%0/2
$data{'sign_key'} || ''
MC/DC0%0/1
$data{'sign_key'} || ''
$data{'sign_key'}
Truth table0%0/2
A
A= $data{'sign_key'}
| |||||||||||||||||||||
| 65 | 0 | my @arch = split( /, */, $data{"arch"} ); | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | my $fh = file_write "/etc/apt/sources.list.d/$name.list"; | |||||||||||||||||||
| 68 | 0 | $fh->write("# This file is managed by Rex\n"); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | foreach (@arch) { | |||||||||||||||||||
| 71 | $fh->write( "rpm " | ||||||||||||||||||||
| 72 | . ( $sign ? "[" . $sign . "] " : "" ) | ||||||||||||||||||||
| 73 | . $data{"url"} . " " | ||||||||||||||||||||
| 74 | . $_ . " " | ||||||||||||||||||||
| 75 | 0 | ▶ | . $data{"repository"} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | . "\n" ); | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | 0 | $fh->close; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 0 | ▶ | sub rm_repository { | ||||||||||||||||||
|
Subroutine
rm_repository: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 82 | 0 | my ( $self, $name ) = @_; | |||||||||||||||||||
| 83 | 0 | unlink "/etc/apt/sources.list.d/$name.list"; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||||