[10669] | 1 | # ------------------------------------------------------------------------------ |
---|
| 2 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
| 3 | # |
---|
| 4 | # This file is part of FCM, tools for managing and building source code. |
---|
| 5 | # |
---|
| 6 | # FCM is free software: you can redistribute it and/or modify |
---|
| 7 | # it under the terms of the GNU General Public License as published by |
---|
| 8 | # the Free Software Foundation, either version 3 of the License, or |
---|
| 9 | # (at your option) any later version. |
---|
| 10 | # |
---|
| 11 | # FCM is distributed in the hope that it will be useful, |
---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | # GNU General Public License for more details. |
---|
| 15 | # |
---|
| 16 | # You should have received a copy of the GNU General Public License |
---|
| 17 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 18 | # ------------------------------------------------------------------------------ |
---|
| 19 | use strict; |
---|
| 20 | use warnings; |
---|
| 21 | # ------------------------------------------------------------------------------ |
---|
| 22 | package FCM::System::Make::Build::Task::Install; |
---|
| 23 | use base qw{FCM::Class::CODE}; |
---|
| 24 | |
---|
| 25 | use FCM::System::Exception; |
---|
| 26 | use File::Copy qw{copy}; |
---|
| 27 | |
---|
| 28 | my $E = 'FCM::System::Exception'; |
---|
| 29 | |
---|
| 30 | __PACKAGE__->class({util => '&'}, {action_of => {main => \&_main}}); |
---|
| 31 | |
---|
| 32 | sub _main { |
---|
| 33 | my ($attrib_ref, $target) = @_; |
---|
| 34 | my ($source, $dest) = ($target->get_path_of_source(), $target->get_path()); |
---|
| 35 | if ($source) { |
---|
| 36 | copy($source, $dest) || return $E->throw($E->COPY, [$source, $dest], $!); |
---|
| 37 | chmod((stat($source))[2] & oct(7777), $dest) |
---|
| 38 | || return $E->throw($E->DEST_CREATE, $dest, $!); |
---|
| 39 | } |
---|
| 40 | else { |
---|
| 41 | $attrib_ref->{util}->file_save($dest, q{}); |
---|
| 42 | } |
---|
| 43 | $target; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | # ------------------------------------------------------------------------------ |
---|
| 47 | 1; |
---|
| 48 | __END__ |
---|
| 49 | |
---|
| 50 | =head1 NAME |
---|
| 51 | |
---|
| 52 | FCM::System::Make::Build::Task::Install |
---|
| 53 | |
---|
| 54 | =head1 SYNOPSIS |
---|
| 55 | |
---|
| 56 | use FCM::System::Make::Build::Task::Install; |
---|
| 57 | my $build_task = FCM::System::Make::Build::Task::Install->new(\%attrib); |
---|
| 58 | $build_task->main( $target); |
---|
| 59 | |
---|
| 60 | =head1 DESCRIPTION |
---|
| 61 | |
---|
| 62 | Copies the source of the target to its path. |
---|
| 63 | |
---|
| 64 | =head1 METHODS |
---|
| 65 | |
---|
| 66 | =over 4 |
---|
| 67 | |
---|
| 68 | =item $class->new(\%attrib) |
---|
| 69 | |
---|
| 70 | Creates and returns a new instance. %attrib should contain: |
---|
| 71 | |
---|
| 72 | =over 4 |
---|
| 73 | |
---|
| 74 | =item {util} |
---|
| 75 | |
---|
| 76 | An instance of L<FCM::Util|FCM::Util>. |
---|
| 77 | |
---|
| 78 | =back |
---|
| 79 | |
---|
| 80 | =item $instance->main($target) |
---|
| 81 | |
---|
| 82 | Copies the source of the target to its path. |
---|
| 83 | |
---|
| 84 | =back |
---|
| 85 | |
---|
| 86 | =head1 COPYRIGHT |
---|
| 87 | |
---|
| 88 | (C) Crown copyright Met Office. All rights reserved. |
---|
| 89 | |
---|
| 90 | =cut |
---|