| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tapper::Installer::Precondition::Package; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
1
|
|
|
1
|
|
170238
|
$Tapper::Installer::Precondition::Package::AUTHORITY = 'cpan:TAPPER'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$Tapper::Installer::Precondition::Package::VERSION = '4.1.1'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
11
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
11
|
1
|
|
|
1
|
|
18
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
53
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
689
|
use Tapper::Installer::Precondition::Exec; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use File::Basename; |
|
15
|
|
|
|
|
|
|
use Moose; |
|
16
|
|
|
|
|
|
|
extends 'Tapper::Installer::Precondition'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub install |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
|
|
|
|
|
|
my ($self, $package) = @_; |
|
23
|
|
|
|
|
|
|
if ($package->{url}) { |
|
24
|
|
|
|
|
|
|
my ($proto, $fullpath) = $package->{url} =~ m|^(\w+)://(.+)$|; |
|
25
|
|
|
|
|
|
|
given($proto) { |
|
26
|
|
|
|
|
|
|
when ('nfs') { |
|
27
|
|
|
|
|
|
|
my $nfs_dir='/mnt/nfs'; |
|
28
|
|
|
|
|
|
|
$self->makedir($nfs_dir); |
|
29
|
|
|
|
|
|
|
my $path = dirname $fullpath; |
|
30
|
|
|
|
|
|
|
my $filename = basename $fullpath; |
|
31
|
|
|
|
|
|
|
my ($error, $retval) = $self->log_and_exec("mount $path $nfs_dir"); |
|
32
|
|
|
|
|
|
|
return ("Can't mount nfs share $path to $nfs_dir: $retval") if $error; |
|
33
|
|
|
|
|
|
|
delete $package->{url}; |
|
34
|
|
|
|
|
|
|
$package->{filename} = "$nfs_dir/$filename"; |
|
35
|
|
|
|
|
|
|
$self->install($package); |
|
36
|
|
|
|
|
|
|
($error, $retval) = $self->log_and_exec("umount $nfs_dir"); |
|
37
|
|
|
|
|
|
|
return 0; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
default { return ("Procol'$proto' is not supported") } |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $filename = $package->{filename}; |
|
45
|
|
|
|
|
|
|
$self->log->debug("installing $filename"); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $basedir = $self->cfg->{paths}{base_dir}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# install into subdir |
|
50
|
|
|
|
|
|
|
if ($package->{target_directory}) { |
|
51
|
|
|
|
|
|
|
$basedir .= $package->{target_directory}; |
|
52
|
|
|
|
|
|
|
$self->makedir($basedir) if not -d $basedir; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $package_dir = ''; |
|
56
|
|
|
|
|
|
|
$package_dir = $self->cfg->{paths}{package_dir}; |
|
57
|
|
|
|
|
|
|
my $pkg = $filename; |
|
58
|
|
|
|
|
|
|
$pkg = "$package_dir/$filename" unless $filename =~ m(^/); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my ($error, $type) = $self->get_file_type("$pkg"); |
|
61
|
|
|
|
|
|
|
return("Can't get file type of $filename: $type") if $error; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $output; |
|
65
|
|
|
|
|
|
|
$self->log->debug("type is $type"); |
|
66
|
|
|
|
|
|
|
given($type){ |
|
67
|
|
|
|
|
|
|
when("gzip") { |
|
68
|
|
|
|
|
|
|
($error, $output) = $self->log_and_exec("tar --no-same-owner -C $basedir -xzf $pkg"); |
|
69
|
|
|
|
|
|
|
return("can't unpack package $filename: $output\n") if $error; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
when("tar") { |
|
72
|
|
|
|
|
|
|
($error, $output) = $self->log_and_exec("tar --no-same-owner -C $basedir -xf $pkg"); |
|
73
|
|
|
|
|
|
|
return("can't unpack package $filename: $output\n") if $error; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
when("bz2") { |
|
76
|
|
|
|
|
|
|
($error, $output) = $self->log_and_exec("tar --no-same-owner -C $basedir -xjf $pkg"); |
|
77
|
|
|
|
|
|
|
return("can't unpack package $filename: $output\n") if $error; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
when("deb") { |
|
80
|
|
|
|
|
|
|
system("cp $pkg $basedir/"); |
|
81
|
|
|
|
|
|
|
$pkg = basename $pkg; |
|
82
|
|
|
|
|
|
|
my $exec = Tapper::Installer::Precondition::Exec->new($self->cfg); |
|
83
|
|
|
|
|
|
|
return $exec->install({command => "dpkg -i $pkg"}); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
when("rpm") { |
|
86
|
|
|
|
|
|
|
system("cp $pkg $basedir/"); |
|
87
|
|
|
|
|
|
|
$pkg = basename $pkg; |
|
88
|
|
|
|
|
|
|
my $exec = Tapper::Installer::Precondition::Exec->new($self->cfg); |
|
89
|
|
|
|
|
|
|
# use -U to overwrite possibly existing older package |
|
90
|
|
|
|
|
|
|
return $exec->install({command => "rpm -U $pkg"}); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
default{ |
|
93
|
|
|
|
|
|
|
$self->log->warn(qq($pkg is of unrecognised file type "$type")); |
|
94
|
|
|
|
|
|
|
return(qq($pkg is of unrecognised file type "$type")); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
return(0); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |
|
103
|
|
|
|
|
|
|
=pod |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding utf-8 |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Tapper::Installer::Precondition::Package |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
use Tapper::Installer::Precondition::Package; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 NAME |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Tapper::Installer::Precondition::Package - Install a package to a given location |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 install |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This function encapsulates installing one single package. At the moment, .tar, |
|
124
|
|
|
|
|
|
|
.tar.gz, .tar.bz2, rpm and deb are recognised. |
|
125
|
|
|
|
|
|
|
Recognised options for package preconditions are: |
|
126
|
|
|
|
|
|
|
* filename - absolute or relative path of the package file (relativ to package_dir in config) |
|
127
|
|
|
|
|
|
|
* target_directory - directory where to unpack package |
|
128
|
|
|
|
|
|
|
* |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
@param hash reference - contains all information about the package |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
@return success - 0 |
|
133
|
|
|
|
|
|
|
@return error - error string |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Advanced Micro Devices, Inc.. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This is free software, licensed under: |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
|
148
|
|
|
|
|
|
|
|