line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PkgForge::Queue::Entry; # -*-perl-*- |
2
|
2
|
|
|
2
|
|
1481
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
84
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
132
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# $Id: Entry.pm.in 14566 2010-11-23 14:53:41Z squinney@INF.ED.AC.UK $ |
6
|
|
|
|
|
|
|
# $Source:$ |
7
|
|
|
|
|
|
|
# $Revision: 14566 $ |
8
|
|
|
|
|
|
|
# $HeadURL: https://svn.lcfg.org/svn/source/tags/PkgForge-Server/PkgForge_Server_1_1_10/lib/PkgForge/Queue/Entry.pm.in $ |
9
|
|
|
|
|
|
|
# $Date: 2010-11-23 14:53:41 +0000 (Tue, 23 Nov 2010) $ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.1.10'; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
10
|
use File::Spec (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
28
|
|
14
|
2
|
|
|
2
|
|
894
|
use File::stat (); |
|
2
|
|
|
|
|
7700
|
|
|
2
|
|
|
|
|
45
|
|
15
|
2
|
|
|
2
|
|
2248
|
use PkgForge::Utils (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use overload q{""} => sub { shift->stringify }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Moose; |
20
|
|
|
|
|
|
|
use PkgForge::Types qw(AbsolutePathDirectory); |
21
|
|
|
|
|
|
|
use MooseX::Types::Moose qw(Int Str); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'path' => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => AbsolutePathDirectory, |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'id' => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => Str, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'owner' => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => Int, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has 'timestamp' => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => Int, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub stringify { |
45
|
|
|
|
|
|
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
return $self->path; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub scrub { |
50
|
|
|
|
|
|
|
my ( $self, $options ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
PkgForge::Utils::remove_tree( $self->path, $options ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
undef $self; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub pretty_timestamp { |
60
|
|
|
|
|
|
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return scalar localtime($self->timestamp) |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub overdue { |
66
|
|
|
|
|
|
|
my ( $self, $timeout ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $now = time; |
69
|
|
|
|
|
|
|
return ( ($now - $timeout) > $self->timestamp ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
around 'BUILDARGS' => sub { |
73
|
|
|
|
|
|
|
my ( $orig, $class, @args ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my %args; |
76
|
|
|
|
|
|
|
if ( scalar @args == 1 ) { |
77
|
|
|
|
|
|
|
if ( defined $args[0] && ref $args[0] eq 'HASH' ) { |
78
|
|
|
|
|
|
|
%args = %{$args[0]}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ( defined $args[0] && !ref $args[0] ) { |
81
|
|
|
|
|
|
|
$args{path} = $args[0]; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
|
|
|
|
|
|
$class->throw_error( "Single parameters to new() must be a directory path or a HASH ref", data => $_[0] ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
|
|
|
|
|
|
%args = @args; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $path = $args{path}; |
92
|
|
|
|
|
|
|
if ( defined $path && -e $path ) { |
93
|
|
|
|
|
|
|
$args{id} = (File::Spec->splitdir($path))[-1]; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $info = File::stat::stat($path); |
96
|
|
|
|
|
|
|
$args{owner} = $info->uid; |
97
|
|
|
|
|
|
|
$args{timestamp} = $info->ctime; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return $class->$orig(%args); |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
no Moose; |
105
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
__END__ |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
PkgForge::Queue::Entry - Represents an entry in a build queue for the LCFG Package Forge |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 VERSION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This documentation refers to PkgForge::Queue::Entry version 1.1.10 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
use PkgForge::Queue::Entry; |
120
|
|
|
|
|
|
|
use PkgForge::Job; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $qentry = PkgForge::Queue::Entry->new($dir); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
print "Queue entry: " . $qentry->id . |
125
|
|
|
|
|
|
|
" submitted at: " . $qentry->pretty_timestamp . "\n"; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my $job = PkgForge::Job->new_from_qentry($qentry); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
In the LCFG Package Forge a build queue is represented by a |
132
|
|
|
|
|
|
|
directory. The jobs in a queue are each represented by separate |
133
|
|
|
|
|
|
|
sub-directories within that build queue directory. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This module is used as a lightweight representation of an entry within |
136
|
|
|
|
|
|
|
a queue. It is basically a means of querying useful meta-data |
137
|
|
|
|
|
|
|
associated with a physical directory. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
These attributes are all only settable when the Queue::Entry object is |
142
|
|
|
|
|
|
|
created. After that point they are all read-only. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over 4 |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item path |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is the path to a directory which represents an entry in a build |
149
|
|
|
|
|
|
|
queue. It must exist. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item id |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is the identifier for the build queue entry, it is the name of |
154
|
|
|
|
|
|
|
the specific sub-directory within the queue directory, (i.e. the |
155
|
|
|
|
|
|
|
final, deepest level of the directory tree only). |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item owner |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This is the UID of the owner of the queue entry directory. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item timestamp |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This is the ctime of the queue entry directory. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=over 4 |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item new($path) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Takes the path to the individual directory which represents a job in |
174
|
|
|
|
|
|
|
the build queue and returns a Queue::Entry object. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item overdue($timeout) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This takes a timeout, in seconds, and returns a boolean value which |
179
|
|
|
|
|
|
|
signifies whether or not the build queue entry is more than that many |
180
|
|
|
|
|
|
|
seconds old. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item scrub |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This method will erase the directory associated with this build queue |
185
|
|
|
|
|
|
|
entry. Note that it also blows away the object since it no longer has |
186
|
|
|
|
|
|
|
any physical meaning once the directory is gone. Internally this uses |
187
|
|
|
|
|
|
|
the C<remove_tree> subroutine provided by L<PkgForge::Utils>. It is |
188
|
|
|
|
|
|
|
possible, optionally, to pass in a reference to a hash of options to |
189
|
|
|
|
|
|
|
control how the C<remove_tree> subroutine functions. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item pretty_timestamp |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This method returns a nicely formatted string form of the C<timestamp> |
194
|
|
|
|
|
|
|
attribute. This uses the C<localtime> function and is provided mainly |
195
|
|
|
|
|
|
|
for prettier logging. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This module is powered by L<Moose> and uses L<MooseX::Types> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 SEE ALSO |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
L<PkgForge>, L<PkgForge::Queue>, L<PkgForge::Utils> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 PLATFORMS |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
This is the list of platforms on which we have tested this |
210
|
|
|
|
|
|
|
software. We expect this software to work on any Unix-like platform |
211
|
|
|
|
|
|
|
which is supported by Perl. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
ScientificLinux5, Fedora13 |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Please report any bugs or problems (or praise!) to bugs@lcfg.org, |
218
|
|
|
|
|
|
|
feedback and patches are also always very welcome. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Stephen Quinney <squinney@inf.ed.ac.uk> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Copyright (C) 201O University of Edinburgh. All rights reserved. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
229
|
|
|
|
|
|
|
it under the terms of the GPL, version 2 or later. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |