line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Slackware::Slackget::Network; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
36383
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
73
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
62
|
|
5
|
|
|
|
|
|
|
use constant { |
6
|
2
|
|
|
|
|
4576
|
SLACK_GET_PROTOCOL_VERSION => 0.5, |
7
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_MESSAGE_START => 0x4200, |
8
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_ACK => 0x4201, |
9
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NACK => 0x4202, |
10
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_SERVER_END_CONNECTION => 0x4203, |
11
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_MESSAGE_STOP => 0x4242, |
12
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NEGOCIATION_QUERY_SEND_BACKENDS_LIST => 0x4211, |
13
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NEGOCIATION_QUERY_SEND_AGREEMENT => 0x4212, |
14
|
|
|
|
|
|
|
SLACK_GET_PROTOCOL_NEGOCIATION_QUERY_SEND_ACK => 0x4213, |
15
|
2
|
|
|
2
|
|
7
|
}; |
|
2
|
|
|
|
|
2
|
|
16
|
|
|
|
|
|
|
require Slackware::Slackget::Network::Message ; |
17
|
|
|
|
|
|
|
# require XML::Simple; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Slackware::Slackget::Network - A class for network communication |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 VERSION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Version 1.0.0 (this version number is absolutly irrelevant and should be considered as an error, real version number is 0.8.2 and is accessible through the $VERSION_REAL variable) |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
30
|
|
|
|
|
|
|
our $VERSION_REAL='0.8.2'; |
31
|
|
|
|
|
|
|
our @ISA; |
32
|
|
|
|
|
|
|
my @BACKENDS = ('XML'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
WARNING WARNING : this module's API and behaviour changed a lot since the 0.12 release ! Please take good care of this : WARNING WARNING |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This class' purpose is to make all network dialog transparent. You give to this class the raw (XML) network message sent to (or from) a slack-get daemon (sg_daemon) and Slackware::Slackget::Network decode and wrap it for you. |
39
|
|
|
|
|
|
|
The "plus" of this system is that sg_daemon (or any slack-get client) developpers are safe if something change in the network protocol : it will never change the API. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use Slackware::Slackget::Network; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $net = Slackware::Slackget::Network->new(); |
44
|
|
|
|
|
|
|
my $message_object = new Slackware::Slackget::Network::Message ; |
45
|
|
|
|
|
|
|
$message_object->action('get_connection_id'); |
46
|
|
|
|
|
|
|
my $xml_msg = $net->encode($message_object); |
47
|
|
|
|
|
|
|
my $response_object = $net->decode($xml_msg); |
48
|
|
|
|
|
|
|
# $message_object and $response_object are equals in term of values |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
All methods from this module return a Slackware::Slackget::Network::Message (L<Slackware::Slackget::Network::Message>) object. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Since the 0.12 release of this module this module is nothing more than a encoder/decoder for slack-get's network messages. So no more network handling nor automatic response sent directly through the socket passed as argument. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new |
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
0
|
1
|
|
my ($class,%args) = @_ ; |
59
|
|
|
|
|
|
|
sub _create_random_id |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
0
|
|
|
my $newpass=''; |
62
|
0
|
|
|
|
|
|
for (my $k=1;$k<=56;$k++) |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
|
|
|
my $lettre = ('a'...'z',1...9)[35*rand]; |
65
|
0
|
|
|
|
|
|
$newpass.=$lettre; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
return $newpass; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
my $self = { _backends => [], _supported_backends => [], _mode => 'server' }; |
70
|
0
|
0
|
0
|
|
|
|
$self->{_mode} = $args{mode} if( defined($args{mode}) && ($args{mode} eq 'server' || $args{mode} eq 'client') ); |
|
|
|
0
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] debug mode activated\n" if($ENV{SG_DAEMON_DEBUG}); |
72
|
|
|
|
|
|
|
# my $backend = 'Slackware::Slackget::Network::Backend::XML'; |
73
|
|
|
|
|
|
|
# $backend = $args{backend} if(defined($args{backend})); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
$args{backends} = [@BACKENDS] unless( defined($args{backends}) ); |
76
|
0
|
|
|
|
|
|
foreach my $b (@{$args{backends}}){ |
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $backend = "Slackware::Slackget::Network::Backend::$b"; |
78
|
0
|
|
|
|
|
|
eval "require $backend;"; |
79
|
0
|
0
|
|
|
|
|
if($@){ |
80
|
0
|
|
|
|
|
|
warn "[Slackware::Slackget::Network] backend \"$backend\" cannot be load ($@).\n";# Fall back to Slackware::Slackget::Network::Backend::XML.\n" ; |
81
|
|
|
|
|
|
|
# eval "require Slackware::Slackget::Network::Backend::XML;"; |
82
|
|
|
|
|
|
|
# if($@){ |
83
|
|
|
|
|
|
|
# warn "[Slackware::Slackget::Network] backend Slackware::Slackget::Network::Backend::XML is not available either. This is critical we can't continue.\n" ; |
84
|
|
|
|
|
|
|
# return undef; |
85
|
|
|
|
|
|
|
# } |
86
|
|
|
|
|
|
|
}else{ |
87
|
0
|
|
|
|
|
|
my $bo; |
88
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] creating new $backend object.\n" if($ENV{SG_DAEMON_DEBUG}); |
89
|
0
|
|
|
|
|
|
$bo = $backend->new ; |
90
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] object is $bo.\n" if($ENV{SG_DAEMON_DEBUG}); |
91
|
0
|
|
|
|
|
|
push @{$self->{_backends}}, $bo; |
|
0
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
push @{$self->{_supported_backends}}, $b; |
|
0
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CONNID} = _create_random_id() ; |
96
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] [constructor] CONNID is $self->{_PRIV}->{CONNID}.\n" if($ENV{SG_DAEMON_DEBUG}); |
97
|
0
|
|
|
|
|
|
$self->{_PRIV}->{ACTIONID} = int((rand(10000)+1) * (rand(10000)+1)); |
98
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CACHE} = ''; |
99
|
0
|
|
|
|
|
|
bless($self,$class); |
100
|
0
|
|
|
|
|
|
return $self; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 new |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
You can pass the following arguments to the constructor : |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
* backends => <ARRAYREF> |
110
|
|
|
|
|
|
|
my $net = Slackware::Slackget::Network->new(backends => [ 'ZIP' , 'XML' ]); |
111
|
|
|
|
|
|
|
# **ATTENTION ** : the order you give to the backends determine the way it will encode/decode messages ! |
112
|
|
|
|
|
|
|
# in this exemple, decode() will call : |
113
|
|
|
|
|
|
|
# |_ ZIP->backend_decode() |
114
|
|
|
|
|
|
|
# |_ XML->backend_decode() |
115
|
|
|
|
|
|
|
# And encode() will call : |
116
|
|
|
|
|
|
|
# |_ XML->backend_encode() |
117
|
|
|
|
|
|
|
# |_ ZIP->backend_encode() |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
The only included backend is the XML one for the moment. If the backend could not be loaded the constructor fall back to the XML backend. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 FUNCTIONS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
All methods return a Slackware::Slackget::Network::Message (L<Slackware::Slackget::Network::Message>) object, and if the remote slack-getd return some data they are accessibles via the data() accessor of the Slackware::Slackget::Network::Message object. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 decode |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Decode a Slackware::Slackget::Network::Message by going through the backend decoding stack. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub decode { |
134
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
135
|
0
|
|
|
|
|
|
my $input = shift; |
136
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] decode($input)\n" if($ENV{SG_DAEMON_DEBUG}); |
137
|
0
|
|
|
|
|
|
my $output = $input ; |
138
|
0
|
|
|
|
|
|
foreach my $backend (@{$self->{_backends}}){ |
|
0
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] using backend $backend to decode data\n" if($ENV{SG_DAEMON_DEBUG}); |
140
|
0
|
|
|
|
|
|
$output = $backend->backend_decode($output); |
141
|
|
|
|
|
|
|
} |
142
|
0
|
|
|
|
|
|
return $output; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 encode |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Encode a Slackware::Slackget::Network::Message by going through the backend encoding stack. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub encode { |
152
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
153
|
0
|
|
|
|
|
|
my $message = shift ; |
154
|
0
|
0
|
|
|
|
|
if($ENV{SG_DAEMON_DEBUG}){ |
155
|
0
|
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] encode() incoming message : $message, dump is :\n"; |
156
|
0
|
|
|
|
|
|
require Data::Dumper; print Data::Dumper::Dumper($message),"\n"; |
|
0
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
158
|
0
|
|
|
|
|
|
my $output = $message ; |
159
|
0
|
|
|
|
|
|
foreach my $backend (reverse( @{$self->{_backends}} )){ |
|
0
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] encode() going through $backend\n" if($ENV{SG_DAEMON_DEBUG}); |
161
|
0
|
|
|
|
|
|
$output = $backend->backend_encode($output); |
162
|
|
|
|
|
|
|
} |
163
|
0
|
|
|
|
|
|
return $output ; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 interpret |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Interpret a Slackware::Slackget::Network::Message. "Interpret" means "execute actions". |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
So the interpretable Slackware::Slackget::Network::Message are those supported by this module. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Currently supported actions are : get_connection_id |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub interpret { |
177
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
178
|
0
|
|
|
|
|
|
my $message = shift ; |
179
|
0
|
0
|
|
|
|
|
return undef unless(defined($message)); |
180
|
0
|
0
|
|
|
|
|
if(defined($message->action)){ |
181
|
0
|
|
|
|
|
|
my $func = '__'.$message->action; |
182
|
0
|
0
|
|
|
|
|
if($self->can($func.'_mode_'.$self->{_mode})) { |
|
|
0
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
$func = $func.'_mode_'.$self->{_mode}; |
184
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] interpret($message) through $func\n" if($ENV{SG_DAEMON_DEBUG}); |
185
|
0
|
|
|
|
|
|
return $self->$func($message) ; |
186
|
|
|
|
|
|
|
}elsif($self->can($func)){ |
187
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] interpret($message) through $func\n" if($ENV{SG_DAEMON_DEBUG}); |
188
|
0
|
|
|
|
|
|
return $self->$func($message) ; |
189
|
|
|
|
|
|
|
}else{ |
190
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] cannot interpret $message\n" if($ENV{SG_DAEMON_DEBUG}); |
191
|
0
|
|
|
|
|
|
return undef; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 generate |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Generate a new Slackware::Slackget::Network::Message formatted for a specific action. Like interpret() it works only with a subset of available actions. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Only the major actions are hardcoded to be automatically generated. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
You can generate messages for the following actions : search, build_medias_list, build_update_list, build_installed_list, notification, upgradepkg, installpkg, removepkg, get_patches_list. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub generate { |
207
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
208
|
0
|
|
|
|
|
|
my $str_msg = shift; |
209
|
0
|
|
|
|
|
|
my @extra_args = @_; |
210
|
0
|
0
|
|
|
|
|
return undef unless(defined($str_msg)); |
211
|
0
|
|
|
|
|
|
my $func = '__'.$str_msg; |
212
|
0
|
0
|
|
|
|
|
if( $self->can($func.'_generate') ){ |
|
|
0
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$func = $func.'_generate'; |
214
|
0
|
|
|
|
|
|
return $self->$func(@extra_args) ; # only *_generate specific function can receive arguments |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
elsif($self->can($func)){ |
217
|
0
|
|
|
|
|
|
return $self->$func() ; |
218
|
|
|
|
|
|
|
}else{ |
219
|
0
|
|
|
|
|
|
return undef; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 backends_list |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Return the list of supported backends. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
backends_list() returned list contains only backends that can be loaded an instanciated. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub backends_list { |
232
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
233
|
0
|
|
|
|
|
|
return @{$self->{_supported_backends}} |
|
0
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 scan_backends |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Return a list of available backends on the system. Some of those backends can be completly broken. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
At this point you have absolutly no garanties that all the backends will works. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub scan_backends { |
245
|
0
|
|
|
0
|
1
|
|
my @backends; |
246
|
0
|
|
|
|
|
|
foreach my $lib (@INC){ |
247
|
0
|
|
|
|
|
|
while(<$lib/Slackware/Slackget/Network/Backend/*.pm>){ |
248
|
0
|
|
|
|
|
|
print "scan_backends: $_\n"; |
249
|
|
|
|
|
|
|
# TODO: check the actual need of this scan_backends() method. And if it's usefull, then make it actually return something |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head2 cache_data |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
This method allow you to cache data (incredible isn't it ?). It's use by slack-get to fill network buffer until the complete network message is received. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$net->cache_data('some kind of stupid data'); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub cache_data { |
263
|
0
|
|
|
0
|
1
|
|
my ($self,@data)=@_; |
264
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CACHE} .= join('',@data); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head2 cached_data |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Return previously cached data. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
my $data = $net->cached_data() ; |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub cached_data { |
276
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
277
|
0
|
|
|
|
|
|
return $self->{_PRIV}->{CACHE}; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 clear_cache |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Unconditionnally delete cached data from memory. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$net->clear_cache(); |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=cut |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub clear_cache { |
289
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
290
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CACHE} = ''; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub _get_action_id { |
294
|
0
|
|
|
0
|
|
|
my $self = shift; |
295
|
0
|
|
|
|
|
|
$self->{_PRIV}->{ACTIONID} += int(rand(1000)+1) ; |
296
|
0
|
|
|
|
|
|
return $self->{_PRIV}->{ACTIONID}; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head2 __get_connection_id |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Set the id of the connection. The id is generate by the constructor and must not be modified. This method is automatically called by the constructor and is mostly private. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
$net->__get_connection_id ; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=cut |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub __get_connection_id |
308
|
|
|
|
|
|
|
{ |
309
|
0
|
|
|
0
|
|
|
my $self = shift; |
310
|
0
|
|
|
|
|
|
my $message = shift ; |
311
|
0
|
0
|
|
|
|
|
if($message){ |
312
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id as a response (seems so...)\n" if($ENV{SG_DAEMON_DEBUG}); |
313
|
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
314
|
|
|
|
|
|
|
action => 'get_connection_id', |
315
|
|
|
|
|
|
|
raw_data => { |
316
|
|
|
|
|
|
|
Enveloppe => { |
317
|
|
|
|
|
|
|
Action => { |
318
|
|
|
|
|
|
|
id => $message->{raw_data}->{Enveloppe}->{Action}->{id} , |
319
|
|
|
|
|
|
|
content => 'get_connection_id', |
320
|
|
|
|
|
|
|
}, |
321
|
|
|
|
|
|
|
Data => { |
322
|
|
|
|
|
|
|
content => $self->{_PRIV}->{CONNID}, |
323
|
|
|
|
|
|
|
}, |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
}, |
326
|
0
|
|
|
|
|
|
); |
327
|
|
|
|
|
|
|
}else{ |
328
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id as a request (seems so...)\n" if($ENV{SG_DAEMON_DEBUG}); |
329
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
330
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
331
|
|
|
|
|
|
|
action => 'get_connection_id', |
332
|
|
|
|
|
|
|
action_id => $aid, |
333
|
|
|
|
|
|
|
raw_data => { |
334
|
|
|
|
|
|
|
Enveloppe => { |
335
|
|
|
|
|
|
|
Action => { |
336
|
|
|
|
|
|
|
id => $aid , |
337
|
|
|
|
|
|
|
content => 'get_connection_id', |
338
|
|
|
|
|
|
|
}, |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
}, |
341
|
|
|
|
|
|
|
); |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
sub __get_connection_id_mode_client { |
346
|
0
|
|
|
0
|
|
|
my $self = shift; |
347
|
0
|
|
|
|
|
|
my $message = shift ; |
348
|
0
|
0
|
|
|
|
|
if($message){ |
349
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id_mode_client interpreting $message\n" if($ENV{SG_DAEMON_DEBUG}); |
350
|
0
|
|
|
|
|
|
$self->{_PRIV}->{CONNID} = $message->data()->{Enveloppe}->{Data}; |
351
|
0
|
0
|
|
|
|
|
print "[Slackware::Slackget::Network] [debug] __get_connection_id_mode_client new CONNID is $self->{_PRIV}->{CONNID}.\n" if($ENV{SG_DAEMON_DEBUG}); |
352
|
0
|
|
|
|
|
|
return $message; |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub __search_generate { |
357
|
0
|
|
|
0
|
|
|
my ($self, @query) = @_ ; |
358
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
359
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
360
|
|
|
|
|
|
|
action => 'search', |
361
|
|
|
|
|
|
|
action_id => $aid, |
362
|
|
|
|
|
|
|
raw_data => { |
363
|
|
|
|
|
|
|
Enveloppe => { |
364
|
|
|
|
|
|
|
Action => { |
365
|
|
|
|
|
|
|
id => $aid , |
366
|
|
|
|
|
|
|
content => 'search', |
367
|
|
|
|
|
|
|
}, |
368
|
|
|
|
|
|
|
Data => { |
369
|
|
|
|
|
|
|
li => [@query], |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
}, |
372
|
|
|
|
|
|
|
}, |
373
|
|
|
|
|
|
|
); |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
sub __build_medias_list_generate { |
377
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
378
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
379
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
380
|
|
|
|
|
|
|
action => 'build_medias_list', |
381
|
|
|
|
|
|
|
action_id => $aid, |
382
|
|
|
|
|
|
|
raw_data => { |
383
|
|
|
|
|
|
|
Enveloppe => { |
384
|
|
|
|
|
|
|
Action => { |
385
|
|
|
|
|
|
|
id => $aid , |
386
|
|
|
|
|
|
|
content => 'build_medias_list', |
387
|
|
|
|
|
|
|
}, |
388
|
|
|
|
|
|
|
}, |
389
|
|
|
|
|
|
|
}, |
390
|
|
|
|
|
|
|
); |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub __build_update_list_generate { |
394
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
395
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
396
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
397
|
|
|
|
|
|
|
action => 'build_update_list', |
398
|
|
|
|
|
|
|
action_id => $aid, |
399
|
|
|
|
|
|
|
raw_data => { |
400
|
|
|
|
|
|
|
Enveloppe => { |
401
|
|
|
|
|
|
|
Action => { |
402
|
|
|
|
|
|
|
id => $aid , |
403
|
|
|
|
|
|
|
content => 'build_update_list', |
404
|
|
|
|
|
|
|
}, |
405
|
|
|
|
|
|
|
}, |
406
|
|
|
|
|
|
|
}, |
407
|
|
|
|
|
|
|
); |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
sub __build_installed_list_generate { |
411
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
412
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
413
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
414
|
|
|
|
|
|
|
action => 'build_installed_list', |
415
|
|
|
|
|
|
|
action_id => $aid, |
416
|
|
|
|
|
|
|
raw_data => { |
417
|
|
|
|
|
|
|
Enveloppe => { |
418
|
|
|
|
|
|
|
Action => { |
419
|
|
|
|
|
|
|
id => $aid , |
420
|
|
|
|
|
|
|
content => 'build_installed_list', |
421
|
|
|
|
|
|
|
}, |
422
|
|
|
|
|
|
|
}, |
423
|
|
|
|
|
|
|
}, |
424
|
|
|
|
|
|
|
); |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
sub __notification_generate { |
428
|
0
|
|
|
0
|
|
|
my $self = shift; |
429
|
0
|
|
|
|
|
|
my @notifications = @_; |
430
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
431
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
432
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
433
|
0
|
|
|
|
|
|
$msg->action('notification'); |
434
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
435
|
0
|
0
|
|
|
|
|
if(scalar(@notifications) >= 1 ){ |
436
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
437
|
0
|
|
|
|
|
|
foreach my $nm (@notifications){ |
438
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },$nm; |
|
0
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
} |
441
|
0
|
|
|
|
|
|
return $msg; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
sub __removepkg_generate { |
445
|
0
|
|
|
0
|
|
|
my $self = shift; |
446
|
0
|
|
|
|
|
|
my @pkgs = @_ ; |
447
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
448
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
449
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
450
|
0
|
|
|
|
|
|
$msg->action('removepkg'); |
451
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
452
|
0
|
0
|
|
|
|
|
if(scalar(@pkgs) >= 1 ){ |
453
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
454
|
0
|
|
|
|
|
|
foreach my $p (@pkgs){ |
455
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },$p; |
|
0
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
} |
458
|
0
|
|
|
|
|
|
return $msg; |
459
|
|
|
|
|
|
|
} |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
sub __get_patches_list_generate { |
462
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
463
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
464
|
0
|
|
|
|
|
|
return Slackware::Slackget::Network::Message->new( |
465
|
|
|
|
|
|
|
action => 'get_patches_list', |
466
|
|
|
|
|
|
|
action_id => $aid, |
467
|
|
|
|
|
|
|
raw_data => { |
468
|
|
|
|
|
|
|
Enveloppe => { |
469
|
|
|
|
|
|
|
Action => { |
470
|
|
|
|
|
|
|
id => $aid , |
471
|
|
|
|
|
|
|
content => 'get_patches_list', |
472
|
|
|
|
|
|
|
}, |
473
|
|
|
|
|
|
|
}, |
474
|
|
|
|
|
|
|
}, |
475
|
|
|
|
|
|
|
); |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
sub __upgradepkg_generate { |
479
|
0
|
|
|
0
|
|
|
my ($self,@pkgs) = @_ ; |
480
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
481
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
482
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
483
|
0
|
|
|
|
|
|
$msg->action('upgradepkg'); |
484
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
485
|
0
|
0
|
|
|
|
|
if(scalar(@pkgs) >= 1 ){ |
486
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
487
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },@pkgs; |
|
0
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
} |
489
|
0
|
|
|
|
|
|
return $msg; |
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
sub __installpkg_generate { |
493
|
0
|
|
|
0
|
|
|
my ($self,@pkgs) = @_ ; |
494
|
0
|
|
|
|
|
|
my $aid = $self->_get_action_id; |
495
|
0
|
|
|
|
|
|
my $msg = new Slackware::Slackget::Network::Message; |
496
|
0
|
|
|
|
|
|
$msg->create_enveloppe ; |
497
|
0
|
|
|
|
|
|
$msg->action('installpkg'); |
498
|
0
|
|
|
|
|
|
$msg->action_id($aid); |
499
|
0
|
0
|
|
|
|
|
if(scalar(@pkgs) >= 1 ){ |
500
|
0
|
|
|
|
|
|
$msg->data()->{Enveloppe}->{Data}->{li} = []; |
501
|
0
|
|
|
|
|
|
push @{ $msg->data()->{Enveloppe}->{Data}->{li} },@pkgs; |
|
0
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
} |
503
|
0
|
|
|
|
|
|
return $msg; |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
# |
507
|
|
|
|
|
|
|
# =head2 __get_installed_list |
508
|
|
|
|
|
|
|
# |
509
|
|
|
|
|
|
|
# get the list of installed packages on the remote daemon. |
510
|
|
|
|
|
|
|
# |
511
|
|
|
|
|
|
|
# my $installed_list = $net->get_installed_list ; |
512
|
|
|
|
|
|
|
# |
513
|
|
|
|
|
|
|
# If an error occured call the appropriate handler. |
514
|
|
|
|
|
|
|
# |
515
|
|
|
|
|
|
|
# In all case return a Slackware::Slackget::Network::Message (L<Slackware::Slackget::Network::Message>) object. |
516
|
|
|
|
|
|
|
# |
517
|
|
|
|
|
|
|
# =cut |
518
|
|
|
|
|
|
|
# |
519
|
|
|
|
|
|
|
# sub __get_installed_list { |
520
|
|
|
|
|
|
|
# my $self = shift; |
521
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
522
|
|
|
|
|
|
|
# $self->send_data("get_installed_list:$self->{CONNID}\n") ; |
523
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
524
|
|
|
|
|
|
|
# { |
525
|
|
|
|
|
|
|
# return $self->_handle_responses("get_installed_list") ; |
526
|
|
|
|
|
|
|
# } |
527
|
|
|
|
|
|
|
# } |
528
|
|
|
|
|
|
|
# |
529
|
|
|
|
|
|
|
# =head2 __get_packages_list |
530
|
|
|
|
|
|
|
# |
531
|
|
|
|
|
|
|
# get the list of new avalaible packages on the remote daemon. |
532
|
|
|
|
|
|
|
# |
533
|
|
|
|
|
|
|
# my $status = $net->get_packages_list ; |
534
|
|
|
|
|
|
|
# |
535
|
|
|
|
|
|
|
# If an error occured call the appropriate handler. |
536
|
|
|
|
|
|
|
# |
537
|
|
|
|
|
|
|
# In all case return a Slackware::Slackget::Network::Message (L<Slackware::Slackget::Network::Message>) object. |
538
|
|
|
|
|
|
|
# |
539
|
|
|
|
|
|
|
# =cut |
540
|
|
|
|
|
|
|
# |
541
|
|
|
|
|
|
|
# sub __get_packages_list { |
542
|
|
|
|
|
|
|
# my $self = shift; |
543
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
544
|
|
|
|
|
|
|
# $self->send_data("get_packages_list:$self->{CONNID}\n") ; |
545
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
546
|
|
|
|
|
|
|
# { |
547
|
|
|
|
|
|
|
# return $self->_handle_responses("get_packages_list") ; |
548
|
|
|
|
|
|
|
# } |
549
|
|
|
|
|
|
|
# } |
550
|
|
|
|
|
|
|
# |
551
|
|
|
|
|
|
|
# =head2 __get_html_info |
552
|
|
|
|
|
|
|
# |
553
|
|
|
|
|
|
|
# Get an HTML encoded string which give some general information on the remote slack-getd |
554
|
|
|
|
|
|
|
# |
555
|
|
|
|
|
|
|
# print $net->get_html_info ; |
556
|
|
|
|
|
|
|
# |
557
|
|
|
|
|
|
|
# =cut |
558
|
|
|
|
|
|
|
# |
559
|
|
|
|
|
|
|
# sub __get_html_info |
560
|
|
|
|
|
|
|
# { |
561
|
|
|
|
|
|
|
# my $self = shift; |
562
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
563
|
|
|
|
|
|
|
# $self->send_data("get_html_info:$self->{CONNID}\n") ; |
564
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
565
|
|
|
|
|
|
|
# { |
566
|
|
|
|
|
|
|
# return $self->_handle_responses("get_html_info") ; |
567
|
|
|
|
|
|
|
# } |
568
|
|
|
|
|
|
|
# } |
569
|
|
|
|
|
|
|
# |
570
|
|
|
|
|
|
|
# =head2 __build_packages_list |
571
|
|
|
|
|
|
|
# |
572
|
|
|
|
|
|
|
# Said to the remote slack-getd to build the new packages cache. |
573
|
|
|
|
|
|
|
# |
574
|
|
|
|
|
|
|
# my $status = $net->build_packages_list ; |
575
|
|
|
|
|
|
|
# |
576
|
|
|
|
|
|
|
# The returned status contains no significant data in case of success. |
577
|
|
|
|
|
|
|
# |
578
|
|
|
|
|
|
|
# =cut |
579
|
|
|
|
|
|
|
# |
580
|
|
|
|
|
|
|
# sub __build_packages_list |
581
|
|
|
|
|
|
|
# { |
582
|
|
|
|
|
|
|
# my ($self) = @_ ; |
583
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
584
|
|
|
|
|
|
|
# $self->send_data("build_packages_list:$self->{CONNID}\n") ; |
585
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
586
|
|
|
|
|
|
|
# { |
587
|
|
|
|
|
|
|
# return $self->_handle_responses("build_packages_list") ; |
588
|
|
|
|
|
|
|
# } |
589
|
|
|
|
|
|
|
# } |
590
|
|
|
|
|
|
|
# |
591
|
|
|
|
|
|
|
# =head2 __build_installed_list |
592
|
|
|
|
|
|
|
# |
593
|
|
|
|
|
|
|
# Said to the remote slack-getd to build the installed packages cache. |
594
|
|
|
|
|
|
|
# |
595
|
|
|
|
|
|
|
# my $status = $net->build_installed_list ; |
596
|
|
|
|
|
|
|
# |
597
|
|
|
|
|
|
|
# The returned status contains no significant data in case of success. |
598
|
|
|
|
|
|
|
# |
599
|
|
|
|
|
|
|
# =cut |
600
|
|
|
|
|
|
|
# |
601
|
|
|
|
|
|
|
# sub __build_installed_list |
602
|
|
|
|
|
|
|
# { |
603
|
|
|
|
|
|
|
# my ($self) = @_ ; |
604
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
605
|
|
|
|
|
|
|
# $self->send_data("build_installed_list:$self->{CONNID}\n") ; |
606
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
607
|
|
|
|
|
|
|
# { |
608
|
|
|
|
|
|
|
# return $self->_handle_responses("build_installed_list") ; |
609
|
|
|
|
|
|
|
# } |
610
|
|
|
|
|
|
|
# } |
611
|
|
|
|
|
|
|
# |
612
|
|
|
|
|
|
|
# =head2 __build_media_list |
613
|
|
|
|
|
|
|
# |
614
|
|
|
|
|
|
|
# Said to the remote slack-getd to build the media list (medias.xml file). |
615
|
|
|
|
|
|
|
# |
616
|
|
|
|
|
|
|
# my $status = $net->build_media_list ; |
617
|
|
|
|
|
|
|
# |
618
|
|
|
|
|
|
|
# The returned status contains no significant data in case of success. |
619
|
|
|
|
|
|
|
# |
620
|
|
|
|
|
|
|
# =cut |
621
|
|
|
|
|
|
|
# |
622
|
|
|
|
|
|
|
# sub __build_media_list |
623
|
|
|
|
|
|
|
# { |
624
|
|
|
|
|
|
|
# my ($self) = @_ ; |
625
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
626
|
|
|
|
|
|
|
# $self->send_data("build_media_list:$self->{CONNID}\n") ; |
627
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
628
|
|
|
|
|
|
|
# { |
629
|
|
|
|
|
|
|
# return $self->_handle_responses("build_media_list") ; |
630
|
|
|
|
|
|
|
# } |
631
|
|
|
|
|
|
|
# } |
632
|
|
|
|
|
|
|
# |
633
|
|
|
|
|
|
|
# =head2 __diskspace |
634
|
|
|
|
|
|
|
# |
635
|
|
|
|
|
|
|
# Ask to the remote daemon for the state of the disk space on a specify partition. |
636
|
|
|
|
|
|
|
# |
637
|
|
|
|
|
|
|
# $net->handle_responses(1); # We want Slackware::Slackget::Network handle the response and return the hashref. |
638
|
|
|
|
|
|
|
# my $response = $net->diskspace( "/" ) ; |
639
|
|
|
|
|
|
|
# $net->handle_responses(0); |
640
|
|
|
|
|
|
|
# print "Free space on remote computer / directory is ",$response->data()->{avalaible_space}," KB\n"; |
641
|
|
|
|
|
|
|
# |
642
|
|
|
|
|
|
|
# Return a Slackware::Slackget::Network::Message object which contains (in case of success) a HASHREF build like that : |
643
|
|
|
|
|
|
|
# |
644
|
|
|
|
|
|
|
# $space = { |
645
|
|
|
|
|
|
|
# device => <NUMBER>, |
646
|
|
|
|
|
|
|
# total_size => <NUMBER>, |
647
|
|
|
|
|
|
|
# used_space => <NUMBER>, |
648
|
|
|
|
|
|
|
# available_space => <NUMBER>, |
649
|
|
|
|
|
|
|
# use_percentage => <NUMBER>, |
650
|
|
|
|
|
|
|
# mount_point => <NUMBER> |
651
|
|
|
|
|
|
|
# }; |
652
|
|
|
|
|
|
|
# |
653
|
|
|
|
|
|
|
# =cut |
654
|
|
|
|
|
|
|
# |
655
|
|
|
|
|
|
|
# sub __diskspace |
656
|
|
|
|
|
|
|
# { |
657
|
|
|
|
|
|
|
# my ($self,$dir) = @_ ; |
658
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
659
|
|
|
|
|
|
|
# # print STDOUT "[DEBUG::Network.pm] sending command \"diskspace:$dir\" to remote daemon\n"; |
660
|
|
|
|
|
|
|
# $self->send_data("diskspace:$self->{CONNID}:$dir\n") ; |
661
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
662
|
|
|
|
|
|
|
# { |
663
|
|
|
|
|
|
|
# my $str = ''; |
664
|
|
|
|
|
|
|
# my $ds = {}; |
665
|
|
|
|
|
|
|
# while(<$socket>) |
666
|
|
|
|
|
|
|
# { |
667
|
|
|
|
|
|
|
# chomp; |
668
|
|
|
|
|
|
|
# if($_=~ /^wait:$self->{CONNID}:/) |
669
|
|
|
|
|
|
|
# { |
670
|
|
|
|
|
|
|
# sleep 1; |
671
|
|
|
|
|
|
|
# next ; |
672
|
|
|
|
|
|
|
# } |
673
|
|
|
|
|
|
|
# if ($_=~ /auth_violation:$self->{CONNID}:\s*(.*)/) |
674
|
|
|
|
|
|
|
# { |
675
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
676
|
|
|
|
|
|
|
# is_success => undef, |
677
|
|
|
|
|
|
|
# ERROR_MSG => $1, |
678
|
|
|
|
|
|
|
# DATA => $_ |
679
|
|
|
|
|
|
|
# ); |
680
|
|
|
|
|
|
|
# last ; |
681
|
|
|
|
|
|
|
# } |
682
|
|
|
|
|
|
|
# if($_=~ /^diskspace:$self->{CONNID}:(device=[^;]+;total_size=[^;]+;used_space=[^;]+;available_space=[^;]+;use_percentage=[^;]+;mount_point=[^;]+)/) |
683
|
|
|
|
|
|
|
# { |
684
|
|
|
|
|
|
|
# my $tmp = $1; |
685
|
|
|
|
|
|
|
# print STDOUT "[DEBUG::Network.pm] $tmp contient des info sur diskspace\n"; |
686
|
|
|
|
|
|
|
# foreach my $pair (split(/;/,$tmp)) |
687
|
|
|
|
|
|
|
# { |
688
|
|
|
|
|
|
|
# my ($key,$value) = split(/=/,$pair); |
689
|
|
|
|
|
|
|
# print STDOUT "[DEBUG::Network.pm] $key => $value\n"; |
690
|
|
|
|
|
|
|
# $ds->{$key} = $value; |
691
|
|
|
|
|
|
|
# } |
692
|
|
|
|
|
|
|
# } |
693
|
|
|
|
|
|
|
# else |
694
|
|
|
|
|
|
|
# { |
695
|
|
|
|
|
|
|
# my $code = $self->_handle_protocol($_) ; |
696
|
|
|
|
|
|
|
# last if($code==2); |
697
|
|
|
|
|
|
|
# print STDOUT "[DEBUG::Network.pm] $_ ne contient pas d'info sur diskspace\n"; |
698
|
|
|
|
|
|
|
# } |
699
|
|
|
|
|
|
|
# last if($_=~ /^end:$self->{CONNID}:\s*diskspace/); |
700
|
|
|
|
|
|
|
# } |
701
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
702
|
|
|
|
|
|
|
# is_success => 1, |
703
|
|
|
|
|
|
|
# DATA => $ds |
704
|
|
|
|
|
|
|
# ); |
705
|
|
|
|
|
|
|
# } |
706
|
|
|
|
|
|
|
# |
707
|
|
|
|
|
|
|
# } |
708
|
|
|
|
|
|
|
# |
709
|
|
|
|
|
|
|
# =head2 __search |
710
|
|
|
|
|
|
|
# |
711
|
|
|
|
|
|
|
# take at least two parameters : the word you search for, and a field. Valid fields are those who describe a package entity in the packages.xml file. |
712
|
|
|
|
|
|
|
# |
713
|
|
|
|
|
|
|
# my $response = $net->search('gcc','name','description') ; # search for package containing 'gcc' in fields 'name' and 'description' |
714
|
|
|
|
|
|
|
# |
715
|
|
|
|
|
|
|
# Return the remote slack-getd's response in the DATA section of the response (L<Slackware::Slackget::Network::Message>). |
716
|
|
|
|
|
|
|
# |
717
|
|
|
|
|
|
|
# =cut |
718
|
|
|
|
|
|
|
# |
719
|
|
|
|
|
|
|
# sub __search |
720
|
|
|
|
|
|
|
# { |
721
|
|
|
|
|
|
|
# my ($self,$word,@args) = @_ ; |
722
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
723
|
|
|
|
|
|
|
# my $fields = join(';',@args); |
724
|
|
|
|
|
|
|
# # chop $fields ; |
725
|
|
|
|
|
|
|
# $self->send_data("search:$self->{CONNID}:$word:$fields\n") ; |
726
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
727
|
|
|
|
|
|
|
# { |
728
|
|
|
|
|
|
|
# return $self->_handle_responses("search") ; |
729
|
|
|
|
|
|
|
# } |
730
|
|
|
|
|
|
|
# } |
731
|
|
|
|
|
|
|
# |
732
|
|
|
|
|
|
|
# =head2 __websearch |
733
|
|
|
|
|
|
|
# |
734
|
|
|
|
|
|
|
# Take 2 parameters : a reference on an array which contains the words to search for, and another array reference which contains a list of fields (valid fields are thoses describe in the packages.xml file). |
735
|
|
|
|
|
|
|
# |
736
|
|
|
|
|
|
|
# |
737
|
|
|
|
|
|
|
# The DATA section of the response (L<Slackware::Slackget::Network::Message>) will contain an ARRAYREF. Each cell of this array will contains a package in HTML |
738
|
|
|
|
|
|
|
# The returned data is HTML, each package are separed by a line wich only contain the string "__MARK__" |
739
|
|
|
|
|
|
|
# |
740
|
|
|
|
|
|
|
# my $response = $network->websearch([ 'burn', 'cd' ], [ 'name', 'description' ]) ; |
741
|
|
|
|
|
|
|
# |
742
|
|
|
|
|
|
|
# =cut |
743
|
|
|
|
|
|
|
# |
744
|
|
|
|
|
|
|
# sub __websearch |
745
|
|
|
|
|
|
|
# { |
746
|
|
|
|
|
|
|
# my ($self,$requests,$args) = @_ ; |
747
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
748
|
|
|
|
|
|
|
# my $fields = join(';',@{$args}); |
749
|
|
|
|
|
|
|
# my $words = join(';',@{$requests}) ; |
750
|
|
|
|
|
|
|
# # chop $fields ; |
751
|
|
|
|
|
|
|
# warn "[Slackware::Slackget::Network] (debug::websearch) self=$self, words=$words, fields=$fields\n"; |
752
|
|
|
|
|
|
|
# $self->send_data("websearch:$self->{CONNID}:$words:$fields\n") ; |
753
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
754
|
|
|
|
|
|
|
# { |
755
|
|
|
|
|
|
|
# my $str = []; |
756
|
|
|
|
|
|
|
# my $idx = 0; |
757
|
|
|
|
|
|
|
# while(<$socket>) |
758
|
|
|
|
|
|
|
# { |
759
|
|
|
|
|
|
|
# if($_=~ /^wait:$self->{CONNID}:/) |
760
|
|
|
|
|
|
|
# { |
761
|
|
|
|
|
|
|
# sleep 1; |
762
|
|
|
|
|
|
|
# next ; |
763
|
|
|
|
|
|
|
# } |
764
|
|
|
|
|
|
|
# last if($_=~ /^end:$self->{CONNID}: websearch/); |
765
|
|
|
|
|
|
|
# if ($_=~ /auth_violation:$self->{CONNID}:\s*(.*)/) |
766
|
|
|
|
|
|
|
# { |
767
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
768
|
|
|
|
|
|
|
# is_success => undef, |
769
|
|
|
|
|
|
|
# ERROR_MSG => $1, |
770
|
|
|
|
|
|
|
# DATA => $_ |
771
|
|
|
|
|
|
|
# ); |
772
|
|
|
|
|
|
|
# last ; |
773
|
|
|
|
|
|
|
# } |
774
|
|
|
|
|
|
|
# my $code = $self->_handle_protocol($_) ; |
775
|
|
|
|
|
|
|
# if($_=~/__MARK__/) |
776
|
|
|
|
|
|
|
# { |
777
|
|
|
|
|
|
|
# $idx++; |
778
|
|
|
|
|
|
|
# } |
779
|
|
|
|
|
|
|
# else |
780
|
|
|
|
|
|
|
# { |
781
|
|
|
|
|
|
|
# $str->[$idx] .= $_; |
782
|
|
|
|
|
|
|
# } |
783
|
|
|
|
|
|
|
# last if($code==2); |
784
|
|
|
|
|
|
|
# } |
785
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
786
|
|
|
|
|
|
|
# is_success => 1, |
787
|
|
|
|
|
|
|
# DATA => $str |
788
|
|
|
|
|
|
|
# ); |
789
|
|
|
|
|
|
|
# } |
790
|
|
|
|
|
|
|
# |
791
|
|
|
|
|
|
|
# } |
792
|
|
|
|
|
|
|
# |
793
|
|
|
|
|
|
|
# =head2 __multisearch |
794
|
|
|
|
|
|
|
# |
795
|
|
|
|
|
|
|
# Take 2 parameters : a reference on an array which contains the words to search for, and another array reference which contains a list of fields (valid fields are thoses describe in the packages.xml file). |
796
|
|
|
|
|
|
|
# |
797
|
|
|
|
|
|
|
# |
798
|
|
|
|
|
|
|
# The DATA section of the response (L<Slackware::Slackget::Network::Message>) will contain the XML encoded response. |
799
|
|
|
|
|
|
|
# |
800
|
|
|
|
|
|
|
# my $response = $network->websearch([ 'burn', 'cd' ], [ 'name', 'description' ]) ; |
801
|
|
|
|
|
|
|
# |
802
|
|
|
|
|
|
|
# =cut |
803
|
|
|
|
|
|
|
# |
804
|
|
|
|
|
|
|
# sub __multisearch |
805
|
|
|
|
|
|
|
# { |
806
|
|
|
|
|
|
|
# my ($self,$requests,$args) = @_ ; |
807
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
808
|
|
|
|
|
|
|
# my $fields = join(';',@{$args}); |
809
|
|
|
|
|
|
|
# my $words = join(';',@{$requests}) ; |
810
|
|
|
|
|
|
|
# # chop $fields ; |
811
|
|
|
|
|
|
|
# $self->send_data("multisearch:$self->{CONNID}:$words:$fields\n") ; |
812
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
813
|
|
|
|
|
|
|
# { |
814
|
|
|
|
|
|
|
# return $self->_handle_responses("search") ; |
815
|
|
|
|
|
|
|
# } |
816
|
|
|
|
|
|
|
# |
817
|
|
|
|
|
|
|
# } |
818
|
|
|
|
|
|
|
# |
819
|
|
|
|
|
|
|
# |
820
|
|
|
|
|
|
|
# =head2 __getfile |
821
|
|
|
|
|
|
|
# |
822
|
|
|
|
|
|
|
# This method allow you to download one or more files from a slack-get daemon. This method of download is specific to slack-get and is based on the EBCS protocol. |
823
|
|
|
|
|
|
|
# |
824
|
|
|
|
|
|
|
# Arguments are : |
825
|
|
|
|
|
|
|
# |
826
|
|
|
|
|
|
|
# files : pass a Slackware::Slackget::PackageList to this option. |
827
|
|
|
|
|
|
|
# |
828
|
|
|
|
|
|
|
# destdir : a string wich is the directory where will be stored the downloaded files. |
829
|
|
|
|
|
|
|
# |
830
|
|
|
|
|
|
|
# Here is a little code example : |
831
|
|
|
|
|
|
|
# |
832
|
|
|
|
|
|
|
# # $pkgl is a Slackware::Slackget::PackageList object. |
833
|
|
|
|
|
|
|
# $net->getfile( |
834
|
|
|
|
|
|
|
# file => $pkgl, |
835
|
|
|
|
|
|
|
# destdir => $sgo->config()->{common}->{'update-directory'}."/package-cache/" |
836
|
|
|
|
|
|
|
# ); |
837
|
|
|
|
|
|
|
# |
838
|
|
|
|
|
|
|
# =cut |
839
|
|
|
|
|
|
|
# |
840
|
|
|
|
|
|
|
# sub __getfile |
841
|
|
|
|
|
|
|
# { |
842
|
|
|
|
|
|
|
# my $self = shift; |
843
|
|
|
|
|
|
|
# my %args = @_ ; |
844
|
|
|
|
|
|
|
# # my $pkgl = $args{'file'}; |
845
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
846
|
|
|
|
|
|
|
# is_success => undef, |
847
|
|
|
|
|
|
|
# ERROR_MSG => "An object of Slackware::Slackget::PackageList type was waited, but another type of object has come.", |
848
|
|
|
|
|
|
|
# DATA => undef |
849
|
|
|
|
|
|
|
# ) if(ref($args{'file'}) ne 'Slackware::Slackget::PackageList') ; |
850
|
|
|
|
|
|
|
# # my $destdir = shift; |
851
|
|
|
|
|
|
|
# my $socket = $self->{SOCKET} ; |
852
|
|
|
|
|
|
|
# my $str = 'The following files have been successfully saved : '; |
853
|
|
|
|
|
|
|
# my $file; |
854
|
|
|
|
|
|
|
# my $write_in = 0; |
855
|
|
|
|
|
|
|
# # TODO: termin�ici : envoy�le message de requete de fichiers, et finir le code de r�up�ation des fichiers (voir par ex si il n'y as pas d'erreur). |
856
|
|
|
|
|
|
|
# my $requested_pkgs = ''; |
857
|
|
|
|
|
|
|
# $args{'file'}->index_list() ; |
858
|
|
|
|
|
|
|
# foreach (@{$args{'file'}->get_all}) |
859
|
|
|
|
|
|
|
# { |
860
|
|
|
|
|
|
|
# $requested_pkgs .= $_->get_id().';' |
861
|
|
|
|
|
|
|
# } |
862
|
|
|
|
|
|
|
# chop $requested_pkgs; |
863
|
|
|
|
|
|
|
# $self->send_data("getfile:$self->{CONNID}:$requested_pkgs\n"); |
864
|
|
|
|
|
|
|
# if($self->{handle_responses}) |
865
|
|
|
|
|
|
|
# { |
866
|
|
|
|
|
|
|
# my $current_file; |
867
|
|
|
|
|
|
|
# while(<$socket>) |
868
|
|
|
|
|
|
|
# { |
869
|
|
|
|
|
|
|
# if($_=~ /^wait:$self->{CONNID}:/) |
870
|
|
|
|
|
|
|
# { |
871
|
|
|
|
|
|
|
# print "wait\n"; |
872
|
|
|
|
|
|
|
# sleep 2; |
873
|
|
|
|
|
|
|
# next ; |
874
|
|
|
|
|
|
|
# } |
875
|
|
|
|
|
|
|
# last if($_=~ /^end:$self->{CONNID}:\s*getfile/); |
876
|
|
|
|
|
|
|
# if ($_=~ /auth_violation:$self->{CONNID}:\s*(.*)/) |
877
|
|
|
|
|
|
|
# { |
878
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
879
|
|
|
|
|
|
|
# is_success => undef, |
880
|
|
|
|
|
|
|
# ERROR_MSG => $1, |
881
|
|
|
|
|
|
|
# DATA => $_ |
882
|
|
|
|
|
|
|
# ); |
883
|
|
|
|
|
|
|
# last ; |
884
|
|
|
|
|
|
|
# } |
885
|
|
|
|
|
|
|
# elsif($_ =~ /binaryfile:$self->{CONNID}:\s*(.+)/) |
886
|
|
|
|
|
|
|
# { |
887
|
|
|
|
|
|
|
# undef($file); |
888
|
|
|
|
|
|
|
# $file = Slackware::Slackget::File->new("$args{'destdir'}/$1",'no-auto-load' => 1, 'mode' => 'write','binary' => 1); |
889
|
|
|
|
|
|
|
# $current_file=$1; |
890
|
|
|
|
|
|
|
# $current_file=~ s/\.tgz//; |
891
|
|
|
|
|
|
|
# $write_in = 1; |
892
|
|
|
|
|
|
|
# } |
893
|
|
|
|
|
|
|
# elsif($_ =~ /end:$self->{CONNID}:binaryfile/) |
894
|
|
|
|
|
|
|
# { |
895
|
|
|
|
|
|
|
# $file->Write_and_close ; |
896
|
|
|
|
|
|
|
# $args{'file'}->get_indexed($current_file)->setValue('is-installable',1) ; |
897
|
|
|
|
|
|
|
# $current_file = ''; |
898
|
|
|
|
|
|
|
# $str .= $file->filename().' '; |
899
|
|
|
|
|
|
|
# $write_in = 0; |
900
|
|
|
|
|
|
|
# } |
901
|
|
|
|
|
|
|
# my $code = $self->_handle_protocol($_) ; |
902
|
|
|
|
|
|
|
# last if($code==2); |
903
|
|
|
|
|
|
|
# $file->Add($_) if($write_in && $code == 1); |
904
|
|
|
|
|
|
|
# } |
905
|
|
|
|
|
|
|
# return Slackware::Slackget::Network::Message->new( |
906
|
|
|
|
|
|
|
# is_success => 1, |
907
|
|
|
|
|
|
|
# DATA => $str |
908
|
|
|
|
|
|
|
# ); |
909
|
|
|
|
|
|
|
# } |
910
|
|
|
|
|
|
|
# |
911
|
|
|
|
|
|
|
# } |
912
|
|
|
|
|
|
|
# |
913
|
|
|
|
|
|
|
# =head2 __reboot |
914
|
|
|
|
|
|
|
# |
915
|
|
|
|
|
|
|
# This method ask the remote daemon to reboot the remote computer. |
916
|
|
|
|
|
|
|
# |
917
|
|
|
|
|
|
|
# =cut |
918
|
|
|
|
|
|
|
# |
919
|
|
|
|
|
|
|
# sub __reboot |
920
|
|
|
|
|
|
|
# { |
921
|
|
|
|
|
|
|
# my $self = shift; |
922
|
|
|
|
|
|
|
# $self->send_data("reboot:$self->{CONNID}\n"); |
923
|
|
|
|
|
|
|
# } |
924
|
|
|
|
|
|
|
# |
925
|
|
|
|
|
|
|
# =head2 __quit |
926
|
|
|
|
|
|
|
# |
927
|
|
|
|
|
|
|
# Close the current connection. |
928
|
|
|
|
|
|
|
# |
929
|
|
|
|
|
|
|
# $net->__quit ; |
930
|
|
|
|
|
|
|
# |
931
|
|
|
|
|
|
|
# =cut |
932
|
|
|
|
|
|
|
# |
933
|
|
|
|
|
|
|
# sub __quit { |
934
|
|
|
|
|
|
|
# my ($self,$mess) = @_ ; |
935
|
|
|
|
|
|
|
# $mess = "end session" unless(defined($mess)); |
936
|
|
|
|
|
|
|
# chomp $mess; |
937
|
|
|
|
|
|
|
# # print "[debug Slackware::Slackget::Network] sending \"quit:$self->{CONNID}:$mess\"\n"; |
938
|
|
|
|
|
|
|
# $self->send_data("quit:$self->{CONNID}:$mess\n") ; |
939
|
|
|
|
|
|
|
# # $self->{SOCKET}->close() ; |
940
|
|
|
|
|
|
|
# } |
941
|
|
|
|
|
|
|
# |
942
|
|
|
|
|
|
|
# =head1 ACCESSORS |
943
|
|
|
|
|
|
|
# |
944
|
|
|
|
|
|
|
# =head2 slackget (read only) |
945
|
|
|
|
|
|
|
# |
946
|
|
|
|
|
|
|
# return the current slackget10 object. |
947
|
|
|
|
|
|
|
# |
948
|
|
|
|
|
|
|
# =cut |
949
|
|
|
|
|
|
|
# |
950
|
|
|
|
|
|
|
# sub slackget |
951
|
|
|
|
|
|
|
# { |
952
|
|
|
|
|
|
|
# my $self = shift ; |
953
|
|
|
|
|
|
|
# return $self->{SGO} ; |
954
|
|
|
|
|
|
|
# } |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
=head2 connection_id |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
Get or set the connection ID. |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
$net->connection_id(1234); |
961
|
|
|
|
|
|
|
print "Connection ID : ", $net->connection_id , "\n"; |
962
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
=cut |
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
sub connection_id |
966
|
|
|
|
|
|
|
{ |
967
|
0
|
0
|
|
0
|
1
|
|
return $_[1] ? $_[0]->{CONNID}=$_[1] : $_[0]->{CONNID}; |
968
|
|
|
|
|
|
|
} |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
# =head2 handle_responses (read/write) |
971
|
|
|
|
|
|
|
# |
972
|
|
|
|
|
|
|
# Boolean accessor, get/set the value of the handle_responses option. |
973
|
|
|
|
|
|
|
# |
974
|
|
|
|
|
|
|
# =cut |
975
|
|
|
|
|
|
|
# |
976
|
|
|
|
|
|
|
# sub handle_responses |
977
|
|
|
|
|
|
|
# { |
978
|
|
|
|
|
|
|
# return $_[1] ? $_[0]->{DATA}->{data}=$_[1] : $_[0]->{DATA}->{data}; |
979
|
|
|
|
|
|
|
# } |
980
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
=head1 PKGTOOLS BINDINGS |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
Methods in this section are the remote call procedure for pkgtools interactions. The slack-getd daemon use another class for direct call to the pkgtools (L<Slackware::Slackget::PkgTools>). |
984
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
The 3 methods have the same operating mode : |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
1) Take a single Slackware::Slackget::PackageList as argument |
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
2) Do the job |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
3) If their is more than one choice for the package you try to install, the daemon ask for a choice of you. |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
3bis) Re-do the job |
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
4) For each package in the Slackware::Slackget::PackageList set a 'status' field which contain the status of the (install|upgrade|remove) process. |
996
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
=head2 __installpkg |
998
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
$net->installpkg($packagelist) ; |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=cut |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
sub __installpkg |
1004
|
|
|
|
|
|
|
{ |
1005
|
0
|
|
|
0
|
|
|
my ($self,$packagelist) = @_ ; |
1006
|
0
|
0
|
|
|
|
|
return undef if(ref($packagelist) ne 'Slackware::Slackget::PackageList') ; |
1007
|
0
|
|
|
|
|
|
my $request; |
1008
|
0
|
|
|
|
|
|
foreach (@{$packagelist->get_all}) |
|
0
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
{ |
1010
|
0
|
|
|
|
|
|
$request .= $_->get_id().';'; |
1011
|
|
|
|
|
|
|
} |
1012
|
0
|
|
|
|
|
|
chop $request; |
1013
|
0
|
|
|
|
|
|
print "[DEBUG::Network::installpkg] request => $request\n"; |
1014
|
0
|
|
|
|
|
|
my $socket = $self->{SOCKET} ; |
1015
|
0
|
|
|
|
|
|
$self->send_data("installpkg:$self->{CONNID}:$request\n") ; |
1016
|
0
|
0
|
|
|
|
|
if($self->{handle_responses}) |
1017
|
|
|
|
|
|
|
{ |
1018
|
0
|
|
|
|
|
|
return $self->_handle_responses("installpkg","All packages marked for installation have been treated.") ; |
1019
|
|
|
|
|
|
|
} |
1020
|
0
|
|
|
|
|
|
return 1; |
1021
|
|
|
|
|
|
|
} |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
=head2 __upgradepkg |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
$net->upgradepkg($packagelist) ; |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=cut |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
sub __upgradepkg |
1030
|
|
|
|
|
|
|
{ |
1031
|
0
|
|
|
0
|
|
|
my ($self,$packagelist) = @_ ; |
1032
|
0
|
0
|
|
|
|
|
return undef if(ref($packagelist) ne 'Slackware::Slackget::PackageList') ; |
1033
|
0
|
|
|
|
|
|
my $request; |
1034
|
0
|
|
|
|
|
|
foreach (@{$packagelist->get_all}) |
|
0
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
{ |
1036
|
0
|
|
|
|
|
|
$request .= $_->get_id().';'; |
1037
|
|
|
|
|
|
|
} |
1038
|
0
|
|
|
|
|
|
chop $request; |
1039
|
0
|
|
|
|
|
|
print "[DEBUG::Network::installpkg] request => $request\n"; |
1040
|
0
|
|
|
|
|
|
my $socket = $self->{SOCKET} ; |
1041
|
0
|
|
|
|
|
|
$self->send_data("upgradepkg:$self->{CONNID}:$request\n") ; |
1042
|
0
|
0
|
|
|
|
|
if($self->{handle_responses}) |
1043
|
|
|
|
|
|
|
{ |
1044
|
0
|
|
|
|
|
|
return $self->_handle_responses("upgradepkg","All packages marked for upgrade have been treated.") ; |
1045
|
|
|
|
|
|
|
} |
1046
|
0
|
|
|
|
|
|
return 1; |
1047
|
|
|
|
|
|
|
} |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
=head2 __removepkg |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
Send network commands to a slack-get daemon. This method (like other pkgtools network call), do nothing by herself, but sending a "removepkg:pkg1;pkg2;..;pkgN" to the slack-getd. |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
$net->removepkg($packagelist) ; |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
=cut |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
sub __removepkg |
1058
|
|
|
|
|
|
|
{ |
1059
|
0
|
|
|
0
|
|
|
my ($self,$packagelist) = @_ ; |
1060
|
0
|
|
|
|
|
|
print "[DEBUG::Network::removepkg] packagelist => $packagelist\n"; |
1061
|
0
|
0
|
|
|
|
|
return undef if(ref($packagelist) ne 'Slackware::Slackget::PackageList') ; |
1062
|
0
|
|
|
|
|
|
my $request; |
1063
|
0
|
|
|
|
|
|
foreach (@{$packagelist->get_all}) |
|
0
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
{ |
1065
|
0
|
|
|
|
|
|
$request .= $_->get_id().';'; |
1066
|
|
|
|
|
|
|
} |
1067
|
0
|
|
|
|
|
|
chop $request; |
1068
|
0
|
|
|
|
|
|
print "[DEBUG::Network::removepkg] request => $request\n"; |
1069
|
0
|
|
|
|
|
|
my $socket = $self->{SOCKET} ; |
1070
|
0
|
|
|
|
|
|
$self->send_data("removepkg:$self->{CONNID}:$request\n") ; |
1071
|
0
|
0
|
|
|
|
|
if($self->{handle_responses}) |
1072
|
|
|
|
|
|
|
{ |
1073
|
0
|
|
|
|
|
|
return $self->_handle_responses("removepkg","All packages marked for remove have been treated.") ; |
1074
|
|
|
|
|
|
|
} |
1075
|
0
|
|
|
|
|
|
return 1; |
1076
|
|
|
|
|
|
|
} |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
=head1 DEFAULT HANDLERS |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
Since the 0.12 release there is no more default handlers. |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=cut |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
=head1 AUTHOR |
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >> |
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
=head1 BUGS |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
1092
|
|
|
|
|
|
|
C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at |
1093
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>. |
1094
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
1095
|
|
|
|
|
|
|
your bug as I make changes. |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
=head1 SUPPORT |
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
perldoc Slackware::Slackget |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
You can also look for information at: |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
=over 4 |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
=item * Infinity Perl website |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
L<http://www.infinityperl.org/category/slack-get> |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
=item * slack-get specific website |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
L<http://slackget.infinityperl.org> |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget> |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Slackware-Slackget> |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
=item * CPAN Ratings |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Slackware-Slackget> |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=item * Search CPAN |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Slackware-Slackget> |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
=back |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
=head1 SEE ALSO |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
L<Slackware::Slackget::Network::Message>, L<Slackware::Slackget::Status>, L<Slackware::Slackget::Network::Connection> |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
Copyright 2005 DUPUIS Arnaud, All Rights Reserved. |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
1147
|
|
|
|
|
|
|
under the same terms as Perl itself. |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
=cut |
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
1; # End of Slackware::Slackget::Network |