line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# system::freebsd::package Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::System::Freebsd::Package; |
7
|
1
|
|
|
1
|
|
748
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Shell::Command); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
682
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
commands => { |
19
|
|
|
|
|
|
|
search => [ qw(string) ], |
20
|
|
|
|
|
|
|
install => [ qw(package) ], |
21
|
|
|
|
|
|
|
update => [ ], |
22
|
|
|
|
|
|
|
upgrade => [ ], |
23
|
|
|
|
|
|
|
list => [ ], |
24
|
|
|
|
|
|
|
is_installed => [ qw(package|$package_list) ], |
25
|
|
|
|
|
|
|
which => [ qw(file) ], |
26
|
|
|
|
|
|
|
system_update => [ ], |
27
|
|
|
|
|
|
|
system_upgrade => [ qw(RELEASE|OPTIONAL) ], |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
require_binaries => { |
30
|
|
|
|
|
|
|
'pkg' => [ ], |
31
|
|
|
|
|
|
|
'freebsd-update' => [ ], |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub search { |
37
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
my ($package) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('search', $package) or return; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $cmd = "pkg search $package"; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self->capture($cmd); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub install { |
48
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
49
|
0
|
|
|
|
|
|
my ($package) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('install', $package) or return; |
52
|
0
|
0
|
|
|
|
|
my $ref = $self->brik_help_run_invalid_arg('install', $package, 'ARRAY', 'SCALAR') |
53
|
|
|
|
|
|
|
or return; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $r; |
56
|
0
|
0
|
|
|
|
|
if ($ref eq 'ARRAY') { |
57
|
0
|
|
|
|
|
|
for my $this (@$package) { |
58
|
0
|
|
|
|
|
|
$r = $self->sudo_system('pkg install '.$this); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
0
|
|
|
|
|
|
$r = $self->sudo_system('pkg install '.$package); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $r; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub update { |
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $cmd = 'pkg update'; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $self->sudo_system($cmd); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub upgrade { |
77
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $cmd = 'pkg upgrade'; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $self->sudo_system($cmd); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub list { |
85
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $cmd = 'pkg info'; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return $self->sudo_system($cmd); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub is_installed { |
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return $self->log->info("is_installed: not implemented on this system"); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub which { |
99
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
100
|
0
|
|
|
|
|
|
my ($file) = @_; |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('which', $file) or return; |
103
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('which', $file) or return; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $cmd = "pkg which $file"; |
106
|
0
|
0
|
|
|
|
|
my $lines = $self->capture($cmd) or return; |
107
|
0
|
|
|
|
|
|
for my $line (@$lines) { |
108
|
0
|
|
|
|
|
|
my @toks = split(/\s+/, $line); |
109
|
0
|
0
|
0
|
|
|
|
if (defined($toks[0]) && ($toks[0] eq $file) && defined($toks[5])) { |
|
|
|
0
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return $toks[5]; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
return 'undef'; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub system_update { |
118
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $cmd = 'freebsd-update fetch'; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $self->sudo_system($cmd); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub system_upgrade { |
126
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
127
|
0
|
|
|
|
|
|
my ($release) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $cmd = 'freebsd-update'; |
130
|
0
|
0
|
|
|
|
|
if (defined($release)) { |
131
|
0
|
|
|
|
|
|
$cmd .= ' upgrade -r '.$release; |
132
|
|
|
|
|
|
|
# We should also run a freebsd-update install after that |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else { |
135
|
0
|
|
|
|
|
|
$cmd .= ' install'; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $self->sudo_system($cmd); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__ |