/usr/share/perl5/FCM/Context/Make/Extract.pm is in fcm 2016.12.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | # ------------------------------------------------------------------------------
# (C) British Crown Copyright 2006-16 Met Office.
#
# This file is part of FCM, tools for managing and building source code.
#
# FCM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FCM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FCM. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------
use strict;
use warnings;
# ------------------------------------------------------------------------------
package FCM::Context::Make::Extract;
use base qw{FCM::Class::HASH};
use FCM::Context::Make;
use constant {
CTX_PROJECT => 'FCM::Context::Make::Extract::Project',
CTX_SOURCE => 'FCM::Context::Make::Extract::Source',
CTX_TARGET => 'FCM::Context::Make::Extract::Target',
CTX_TREE => 'FCM::Context::Make::Extract::Tree',
ID_OF_CLASS => 'extract',
MIRROR => 1,
};
__PACKAGE__->class({
dest => '$',
id => {isa => '$', default => ID_OF_CLASS},
id_of_class => {isa => '$', default => ID_OF_CLASS},
ns_list => '@',
project_of => '%',
status => {isa => '$', default => FCM::Context::Make->ST_UNKNOWN},
target_of => '%',
prop_of => '%',
});
# ------------------------------------------------------------------------------
package FCM::Context::Make::Extract::Project;
use base qw{FCM::Class::HASH};
__PACKAGE__->class({
cache => '$',
inherited => '$',
locator => 'FCM::Context::Locator',
ns => '$',
path_excl => '@',
path_incl => '@',
path_root => {isa => '$', default => q{}},
trees => '@',
});
# ------------------------------------------------------------------------------
package FCM::Context::Make::Extract::Tree;
use base qw{FCM::Class::HASH};
__PACKAGE__->class({
cache => '$',
inherited => '$',
key => '$',
locator => 'FCM::Context::Locator',
ns => '$',
sources => '@',
});
# ------------------------------------------------------------------------------
package FCM::Context::Make::Extract::Source;
use base qw{FCM::Class::HASH};
use constant {
ST_NORMAL => 'ST_NORMAL',
ST_UNCHANGED => 'ST_UNCHANGED',
ST_MISSING => 'ST_MISSING',
};
__PACKAGE__->class({
cache => '$',
key_of_tree => '$',
locator => 'FCM::Context::Locator',
ns => '$',
ns_in_tree => '$',
status => {isa => '$', default => ST_NORMAL},
});
# Shorthand for $source->get_status() eq $source->ST_MISSING.
sub is_missing {
$_[0]->get_status() eq ST_MISSING;
}
# Shorthand for $source->get_status() eq $source->ST_UNCHANGED.
sub is_unchanged {
$_[0]->get_status() eq ST_UNCHANGED;
}
# ------------------------------------------------------------------------------
package FCM::Context::Make::Extract::Target;
use base qw{FCM::Class::HASH};
use constant {
ST_ADDED => 'ST_ADDED',
ST_DELETED => 'ST_DELETED',
ST_MERGED => 'ST_MERGED',
ST_MODIFIED => 'ST_MODIFIED',
ST_O_ADDED => 'ST_O_ADDED',
ST_O_DELETED => 'ST_O_DELETED',
ST_UNCHANGED => 'ST_UNCHANGED',
ST_UNKNOWN => 'ST_UNKNOWN',
can_be_source => 1,
};
__PACKAGE__->class({
dests => '@',
ns => '$',
path => '$',
source_of => '%',
status => {isa => '$', default => ST_UNKNOWN},
status_of_source => {isa => '$', default => ST_UNKNOWN},
});
# Returns true if target has an OK status.
sub is_ok {
my ($self) = @_;
my $status = $self->get_status();
grep {$_ eq $status}
(ST_ADDED, ST_MERGED, ST_MODIFIED, ST_O_ADDED, ST_UNCHANGED);
}
# Shorthand for $target->get_status() eq $target->ST_UNCHANGED.
sub is_unchanged {
$_[0]->get_status() eq ST_UNCHANGED;
}
# ------------------------------------------------------------------------------
1;
__END__
=head1 NAME
FCM::Context::Make::Extract
=head1 SYNOPSIS
use FCM::Context::Make::Extract;
my $ctx = FCM::Context::Make::Extract->new();
=head1 DESCRIPTION
Provides a context object for the FCM extract system. All the classes described
below are sub-classes of L<FCM::Class::HASH|FCM::Class::HASH>.
=head1 OBJECTS
=head2 FCM::Context::Make::Extract
An instance of this class represents an extract. It has the following
attributes:
=over 4
=item dest
The destination of the extract.
=item id
The ID of the current context. (default="extract")
=item id_of_class
The class ID of the current context. (default="extract")
=item ns_list
An ARRAY of name-spaces of the projects to extract.
=item project_of
A HASH to map (key) the name-spaces of the projects in this extract to (value)
their corresponding contexts.
=item prop_of
A HASH containing the named properties (i.e. options and settings of named
external tools). Expects a value to be an instance of
L<FCM::Context::Make::Share::Property|FCM::Context::Make::Share::Property>.
=item status
The status of the extract. See L<FCM::Context::Make|FCM::Context::Make> for the
status constants.
=item target_of
A HASH to map (key) the name-spaces of the targets in this extract to (value)
their corresponding contexts.
=back
=head2 FCM::Context::Make::Extract::Project
An instance of this class represents a project in an extract. It has the
following attributes:
=over 4
=item cache
The file system location (cache) of this project.
=item inherited
This project is inherited?
=item locator
An instance of L<FCM::Context::Locator|FCM::Context::Locator> that represents
the locator of this project.
=item ns
The name-space of this project.
=item path_excl
An ARRAY of patterns to match the names of the paths that will be excluded in
this project.
=item path_incl
An ARRAY of patterns to match the names of the paths that will always be
included in this project.
=item path_root
The relative path in a project tree for the root name-space. If this is
specified, the system will extract only files under this path, and their
name-spaces will be adjusted to be relative to this path.
=item trees
An ARRAY of the tree contexts in this project. By convention, the 0th element is
the base tree.
=back
=head2 FCM::Context::Make::Extract::Tree
An instance of this class represents a tree in a project. It has the following
attributes:
=over 4
=item cache
The file system location (cache) of this tree.
=item inherited
A flag to indicate whether this tree is provided by an inherited extract.
=item key
The key of this tree. By convention, the base tree is the 0th key.
=item locator
An instance of L<FCM::Context::Locator|FCM::Context::Locator> that represents
the locator of this tree.
=item ns
The name-space of the project in which this tree belongs.
=item sources
An ARRAY of source file contexts provided by this tree.
=back
=head2 FCM::Context::Make::Extract::Source
An instance of this class represents a source file provided by a project tree.
It has the following attributes:
=over 4
=item cache
The file system location (cache) of this source file.
=item key_of_tree
The key of the tree that provides this source file.
=item locator
An instance of L<FCM::Context::Locator|FCM::Context::Locator> that represents
the locator of the source file.
=item ns
The full (mapped) name-space of the source file, (including the leading project
name-space).
=item ns_in_tree
The original name-space of the source file, relative to its path in the tree.
=item status
The status of the source file. It can take the value of one of the
FCM::Context::Make::Extract::Source->ST_* constants. See </CONSTANTS> for detail.
=back
In addition, an instance of FCM::Context::Make::Extract::Source has the
following methods:
=over 4
=item $source->is_missing()
Shorthand for $source->get_status() eq $source->ST_MISSING.
=item $source->is_unchanged()
Shorthand for $source->get_status() eq $source->ST_UNCHANGED.
=back
=head2 FCM::Context::Make::Extract::Target
An instance of this class represents an extract target. It has the following
attributes:
=over 4
=item dests
An ARRAY containing the destination search path of this target. The first
element is the path to the destination of the current extract, and the rest are
destinations to inherited extracts.
=item ns
The full name-space of this target.
=item path
Returns the actual destination path of this target.
=item source_of
A HASH for mapping (key) the keys of the trees to (value) the corresponding
contexts of the source files provided by the trees to this target.
=item status
The status of the target destination. It can take the value of one of the
FCM::Context::Make::Extract::Target->ST_* constants. See </CONSTANTS> for detail.
=item status_of_source
The status of the target, with respect to its sources. It can take the value of
one of the FCM::Context::Make::Extract::Target->ST_* constants. See </CONSTANTS>
for detail.
=back
In addition, an instance of FCM::Context::Make::Extract::Target has the
following methods:
=over 4
=item $target->can_be_source()
Returns true if the destination status indicates that the target is usable as a
source file of a subsequent a make (step).
=item $target->is_ok()
Returns true if the target has a OK destination status.
=item $target->is_unchanged()
Shorthand for $target->get_status() eq $target->ST_UNCHANGED.
=back
=head1 CONSTANTS
The following is a list of constants:
=over 4
=item FCM::Context::Make::Extract->CTX_PROJECT
An alias to FCM::Context::Make::Extract::Project.
=item FCM::Context::Make::Extract->CTX_SOURCE
An alias to FCM::Context::Make::Extract::Source.
=item FCM::Context::Make::Extract->CTX_TARGET
An alias to FCM::Context::Make::Extract::Target.
=item FCM::Context::Make::Extract->CTX_TREE
An alias to FCM::Context::Make::Extract::Tree.
=item FCM::Context::Make::Extract->ID_OF_CLASS
The default value of the "id" attribute (of an instance), and the ID of the
functional class. ("extract")
=item FCM::Context::Make::Extract->MIRROR
A flag to tell the mirror sub-system that the targets of this context can be
used as inputs sources to subsequent steps for the configuration file in the
mirror destination.
=item FCM::Context::Make::Extract::Source->ST_NORMAL
Source status: normal.
=item FCM::Context::Make::Extract::Source->ST_UNCHANGED
Source status: source is unchanged (against base).
=item FCM::Context::Make::Extract::Source->ST_MISSING
Source status: source is a placeholder in a target. It does not actually exist
in the source tree.
=item FCM::Context::Make::Extract::Target->ST_ADDED
As destination status: new file in the target destination. As source status:
added by a source in a diff tree.
=item FCM::Context::Make::Extract::Target->ST_DELETED
As destination status: file removed from the target destination. As source
status: target removed by a diff tree.
=item FCM::Context::Make::Extract::Target->ST_MERGED
As source status: modified by 2 or more diff trees.
=item FCM::Context::Make::Extract::Target->ST_MODIFIED
As destination status: target destination is modified. As source status:
modified by 1 diff tree.
=item FCM::Context::Make::Extract::Target->ST_O_ADDED
As destination status: new file in the target destination, overriding a file in
an inherited destination.
=item FCM::Context::Make::Extract::Target->ST_O_DELETED
As destination status: target destination should be removed, but there is still
a file in an inherited destination.
=item FCM::Context::Make::Extract::Target->ST_UNCHANGED
As destination status: target destination is unchanged. As source status:
unchanged by a diff tree.
=item FCM::Context::Make::Extract::Target->ST_UNKNOWN
Status is unknown.
=back
=head1 SEE ALSO
L<FCM::System::Make::Extract|FCM::System::Make::Extract>
=head1 COPYRIGHT
(C) Crown copyright Met Office. All rights reserved.
=cut
|