| 1 | package MDV::Distribconf::Build; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||
| 5 | MDV::Distribconf::Build - Subclass to MDV::Distribconf to build configuration | ||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||
| 9 | =over 4 | ||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use MDV::Packdrakeng; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use File::Copy qw(cp); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Digest::MD5; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use base qw(MDV::Distribconf MDV::Distribconf::Checks); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | our $VERSION = (qq$Revision: 224942 $ =~ /(\d+)/)[0]; | |||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | =item MDV::Distribconf::Build->new($root_of_distrib) | ||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||
| 26 | Returns a new MDV::Distribconf::Build object. | ||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||
| 30 | sub new { | ||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||
| 33 | 2 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||
| 36 | =item $distrib->init($flavour) | ||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||
| 38 | Create initals directories in the distrib tree if missing. | ||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||
| 40 | $flavour is either 'mandriva' or 'mandrake', depending the tree type | ||||||||||||||||||||||||||||||||||||||||
| 41 | you want to create. | ||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||
| 43 | See also L<MDV::Distribconf/settree> | ||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||
| 45 | Return 1 on success, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | sub init { | ||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my ($self, $flavour) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->settree($flavour || 'mandriva') unless($self->{infodir}); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$flavour || 'mandriva'
MC/DC0%0/1
$flavour || 'mandriva'
$flavour
Truth table0%0/2
A
A= $flavour
| |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if (!-d $self->getfullpath(undef, 'root')) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (!mkdir($self->getfullpath(undef, 'root'))) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | warn 'Cannot create ' . $self->getfullpath(undef, 'root') .": $!\n"; | |||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | foreach my $dir (map { $self->getfullpath(undef, $_) } qw(mediadir infodir)) { | |||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if (!-d $dir) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | eval { mkpath($dir) }; | |||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | warn "Cannot create $dir: $@\n"; | |||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | foreach my $media ($self->listmedia()) { | |||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $self->create_media($media) or return 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||
| 75 | =item $distrib->create_media($media) | ||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | Create a media $media if not exists and its directories if need. | ||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||
| 79 | See also L<setvalue> | ||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||
| 81 | Return 1 on success, 0 otherwise | ||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||
| 85 | sub create_media { | ||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | my ($self, $media) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_media: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $self->setvalue($media, undef, undef); | |||||||||||||||||||||||||||||||||||||||
| 88 | 0 | foreach my $dir (map { $self->getfullmediapath($media, $_) } qw(path infodir)) { | |||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (!-d $dir) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | eval { mkpath($dir) }; | |||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | warn "Cannot create $dir: $@\n"; | |||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $self->delvalue($media, undef); | |||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||
| 102 | =item $distrib->setvalue($media, $var, $val) | ||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||
| 104 | Sets or adds $var parameter from $media to $val. If $media doesn't exist, | ||||||||||||||||||||||||||||||||||||||||
| 105 | it is implicitly created. If $var is C<undef>, a new media is created with | ||||||||||||||||||||||||||||||||||||||||
| 106 | no defined parameters. | ||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||
| 110 | sub setvalue { | ||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | my ($distrib, $media, $var, $val) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
setvalue: called CC=9 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | $media ||= 'media_info'; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$media ||= "media_info"
MC/DC100%1/1
$media ||= "media_info"
$media
Truth table100%2/2
A
A= $media
| |||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | $distrib->{cfg}->AddSection($media); | |||||||||||||||||||||||||||||||||||||||
| 114 | 3 | ▶ | if ($var) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | if ($media && !$distrib->mediaexists($media)) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$media and not $distrib->mediaexists($media)
MC/DC0%0/2
$media and not $distrib->mediaexists($media)
$media
not $distrib->mediaexists($media)
Truth table33%1/3
A and not(B)
A= $mediaB= not $distrib->mediaexists($media)
| |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $distrib->setvalue($media); | |||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | $var =~ /^(?:media|info)dir\z/ and do { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $distrib->{$var} = $val; | |||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 121 | }; | ||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | if ($val) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | ▶ | $distrib->{cfg}->newval($media, $var, $val) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 124 | or warn "Can't set value [$var=$val] for $media\n"; | ||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $distrib->{cfg}->delval($media, $var); | |||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | $distrib->_post_setvalue($media, $var, $val) if ($media); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||
| 132 | sub _post_setvalue { | ||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | ▶ | my ($distrib, $cmedia, $cvar, $cval) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_post_setvalue: called CC=12 SCAR=43.4
| |||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | ▶ | if ($cvar) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | my $vsettings = MDV::Distribconf::MediaCFG::_value_info($cvar); | |||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | if ($vsettings->{cross}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my %pointed_media = map { $_ => 1 } split(/\s/, $cval); | |||||||||||||||||||||||||||||||||||||||
| 138 | 0 | foreach my $media ($distrib->listmedia()) { | |||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my %ml = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||
| 140 | 0 | split(/\s/, $distrib->getvalue($media, $vsettings->{cross})); | |||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (exists($pointed_media{$media})) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | exists($ml{$cmedia}) and next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $ml{$cmedia} = 1; | |||||||||||||||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | exists($ml{$cmedia}) or next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | delete($ml{$cmedia}); | |||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||
| 149 | $distrib->setvalue( | ||||||||||||||||||||||||||||||||||||||||
| 150 | $media, | ||||||||||||||||||||||||||||||||||||||||
| 151 | $vsettings->{cross}, | ||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | join(" ", keys %ml), | |||||||||||||||||||||||||||||||||||||||
| 153 | ); | ||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | foreach my $media ($distrib->listmedia()) { | |||||||||||||||||||||||||||||||||||||||
| 158 | 1 | foreach my $val ($distrib->{cfg}->Parameters($media)) { | |||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $vsettings = MDV::Distribconf::MediaCFG::_value_info($val); | |||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ($vsettings->{cross}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if (grep { $_ eq $cmedia } | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 162 | split(/\s/, $distrib->getvalue($media, $val))) { | ||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my %ml = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||
| 164 | 0 | split(/\s/, $distrib->getvalue($cmedia, $vsettings->{cross})); | |||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | exists($ml{$media}) and next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $ml{$media} = 1; | |||||||||||||||||||||||||||||||||||||||
| 167 | $distrib->setvalue( | ||||||||||||||||||||||||||||||||||||||||
| 168 | $cmedia, | ||||||||||||||||||||||||||||||||||||||||
| 169 | $vsettings->{cross}, | ||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | join(" ", keys %ml), | |||||||||||||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||
| 180 | =item $distrib->delvalue($media, $var) | ||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||
| 182 | Delete $var parameter from $media. If $var is not specified, the media is | ||||||||||||||||||||||||||||||||||||||||
| 183 | is deleted. If $media is not specified, $var is remove from global settings. | ||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||
| 187 | sub delvalue { | ||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | ▶ | my ($distrib, $media, $var) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
delvalue: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | if ($var) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | $distrib->{cfg}->delval($media, $var); | |||||||||||||||||||||||||||||||||||||||
| 191 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | $distrib->{cfg}->DeleteSection($media); | |||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | $distrib->_post_delvalue($media, $var); | |||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||
| 197 | sub _post_delvalue { | ||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | my ($distrib, $cmedia, $cvar) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_post_delvalue: called CC=10 SCAR=40.2
| |||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | foreach my $media ($distrib->listmedia()) { | |||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if ($cvar) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | my $vsettings = MDV::Distribconf::MediaCFG::_value_info($cvar); | |||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | if ($vsettings->{cross}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if($distrib->getvalue($media, $vsettings->{cross})) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my %ml = map { $_ => 1 } split(/\s/, $distrib->getvalue($media, $vsettings->{cross})); | |||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | exists($ml{$cmedia}) or next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | delete($ml{$cmedia}); | |||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||
| 208 | $distrib->setvalue( | ||||||||||||||||||||||||||||||||||||||||
| 209 | $media, | ||||||||||||||||||||||||||||||||||||||||
| 210 | $vsettings->{cross}, | ||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | join(" ", keys %ml) | |||||||||||||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||
| 215 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | foreach my $val ($distrib->{cfg}->Parameters($media)) { | |||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $vsettings = MDV::Distribconf::MediaCFG::_value_info($val); | |||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($vsettings->{ismedialist} && $distrib->getvalue($media, $val)) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vsettings->{"ismedialist"} and $distrib->getvalue($media, $val)
MC/DC0%0/2
$vsettings->{"ismedialist"} and $distrib->getvalue($media, $val)
$vsettings->{"ismedialist"}
$distrib->getvalue($media, $val)
Truth table0%0/3
A and B
A= $vsettings->{"ismedialist"}B= $distrib->getvalue($media, $val)
| |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my %ml = map { $_ => 1 } split(/\s/, $distrib->getvalue($media, $val)); | |||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | exists($ml{$cmedia}) or next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | delete($ml{$cmedia}); | |||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $distrib->setvalue( | |||||||||||||||||||||||||||||||||||||||
| 223 | $media, | ||||||||||||||||||||||||||||||||||||||||
| 224 | $val, | ||||||||||||||||||||||||||||||||||||||||
| 225 | join(" ", keys %ml) | ||||||||||||||||||||||||||||||||||||||||
| 226 | ); | ||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||
| 234 | =item $distrib->write_hdlists($hdlists) | ||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||
| 236 | Writes the F<hdlists> file to C<$hdlists>, or if no parameter is given, in | ||||||||||||||||||||||||||||||||||||||||
| 237 | the media information directory. C<$hdlists> can be a file path or a file | ||||||||||||||||||||||||||||||||||||||||
| 238 | handle. Returns 1 on success, 0 on error. | ||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||
| 240 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||
| 242 | sub write_hdlists { | ||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my ($distrib, $hdlists) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_hdlists: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $h_hdlists; | |||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if (ref $hdlists eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $h_hdlists = $hdlists; | |||||||||||||||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $hdlists ||= "$distrib->{root}/$distrib->{infodir}/hdlists"; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hdlists ||= qq[$distrib->{"root"}/$distrib->{"infodir"}/hdlists]
MC/DC0%0/1
$hdlists ||= qq[$distrib->{"root"}/$distrib->{"infodir"}/hdlists]
$hdlists
Truth table0%0/2
A
A= $hdlists
| |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | open $h_hdlists, ">", $hdlists | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 250 | or return 0; | ||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | foreach my $media ($distrib->listmedia) { | |||||||||||||||||||||||||||||||||||||||
| 253 | printf($h_hdlists "%s%s\t%s\t%s\t%s\n", | ||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | join('', map { "$_:" } grep { $distrib->getvalue($media, $_) } qw/askmedia suppl noauto/) || "", | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
join('', map({"${_}:";} grep({$distrib->getvalue($media, $_);} 'askmedia', 'suppl', 'noauto'))) || ''
MC/DC0%0/1
join('', map({"${_}:";} grep({$distrib->getvalue($media, $_);} 'askmedia', 'suppl', 'noauto'))) || ''
join('', map({"${_}:";} grep({$distrib->getvalue($media, $_);} 'askmedia', 'suppl', 'noauto')))
Truth table0%0/2
A
A= join('', map({"${_}:";} grep({$distrib->getvalue($media, $_);} 'askmedia', 'suppl', 'noauto')))
| |||||||||||||||||||||||||||||||||||||||||
| 255 | $distrib->getvalue($media, 'hdlist'), | ||||||||||||||||||||||||||||||||||||||||
| 256 | $distrib->getpath($media, 'path'), | ||||||||||||||||||||||||||||||||||||||||
| 257 | $distrib->getvalue($media, 'name'), | ||||||||||||||||||||||||||||||||||||||||
| 258 | $distrib->getvalue($media, 'size') ? '('.$distrib->getvalue($media, 'size'). ')' : "", | ||||||||||||||||||||||||||||||||||||||||
| 259 | ) or return 0; | ||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||
| 264 | =item $distrib->write_mediacfg($mediacfg) | ||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||
| 266 | Write the media.cfg file into the media information directory, or into the | ||||||||||||||||||||||||||||||||||||||||
| 267 | $mediacfg given as argument. $mediacfg can be a file path, or a glob reference | ||||||||||||||||||||||||||||||||||||||||
| 268 | (\*STDOUT for example). | ||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||
| 270 | Returns 1 on success, 0 on error. | ||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||
| 272 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||
| 274 | sub write_mediacfg { | ||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | my ($distrib, $hdlistscfg) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_mediacfg: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | $hdlistscfg ||= "$distrib->{root}/$distrib->{infodir}/media.cfg"; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hdlistscfg ||= qq[$distrib->{"root"}/$distrib->{"infodir"}/media.cfg]
MC/DC0%0/1
$hdlistscfg ||= qq[$distrib->{"root"}/$distrib->{"infodir"}/media.cfg]
$hdlistscfg
Truth table0%0/2
A
A= $hdlistscfg
| |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $distrib->{cfg}->WriteConfig($hdlistscfg); | |||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||
| 280 | =item $distrib->write_version($version) | ||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||
| 282 | Write the VERSION file. Returns 0 on error, 1 on success. | ||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||
| 284 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||
| 286 | sub write_version { | ||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | my ($distrib, $version) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_version: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $h_version; | |||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if (ref($version) eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $h_version = $version; | |||||||||||||||||||||||||||||||||||||||
| 291 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $version ||= $distrib->getfullpath(undef, 'VERSION'); | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$version ||= $distrib->getfullpath(undef, "VERSION")
MC/DC0%0/2
$version ||= $distrib->getfullpath(undef, "VERSION")
$version
$distrib->getfullpath(undef, "VERSION")
Truth table0%0/3
A ||= B
A= $versionB= $distrib->getfullpath(undef, "VERSION")
| |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | open($h_version, ">", $version) or return 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my @gmt = gmtime(time); | |||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | printf($h_version "Mandriva Linux %s %s-%s-%s%s %s\n", | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$distrib->getvalue(undef, 'version') || 'cooker'
$distrib->getvalue(undef, 'branch') || 'cooker'
$distrib->getvalue(undef, 'arch') || 'noarch'
MC/DC0%0/1
$distrib->getvalue(undef, 'version') || 'cooker'
$distrib->getvalue(undef, 'version')
MC/DC0%0/1
$distrib->getvalue(undef, 'branch') || 'cooker'
$distrib->getvalue(undef, 'branch')
MC/DC0%0/1
$distrib->getvalue(undef, 'arch') || 'noarch'
$distrib->getvalue(undef, 'arch')
Truth table0%0/2
A
A= $distrib->getvalue(undef, 'version')
Truth table0%0/2
A
A= $distrib->getvalue(undef, 'branch')
Truth table0%0/2
A
A= $distrib->getvalue(undef, 'arch')
| |||||||||||||||||||||||||||||||||||||||||
| 299 | $distrib->getvalue(undef, 'version') || 'cooker', | ||||||||||||||||||||||||||||||||||||||||
| 300 | $distrib->getvalue(undef, 'branch') || 'cooker', | ||||||||||||||||||||||||||||||||||||||||
| 301 | $distrib->getvalue(undef, 'arch') || 'noarch', | ||||||||||||||||||||||||||||||||||||||||
| 302 | $distrib->getvalue(undef, 'product'), | ||||||||||||||||||||||||||||||||||||||||
| 303 | $distrib->getvalue(undef, 'tag') ? '-' . $distrib->getvalue(undef, 'tag') : '', | ||||||||||||||||||||||||||||||||||||||||
| 304 | sprintf("%04d%02d%02d %02d:%02d", $gmt[5] + 1900, $gmt[4]+1, $gmt[3], $gmt[2], $gmt[1]) | ||||||||||||||||||||||||||||||||||||||||
| 305 | ); | ||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if (ref($version) ne 'GLOB') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | close($h_version); | |||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||
| 313 | =item $distrib->write_productid($productid) | ||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||
| 315 | Write the productid file. Returns 0 on error, 1 on success. | ||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||
| 317 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||
| 319 | sub write_productid { | ||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | my ($distrib, $productid) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_productid: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $h_productid; | |||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if (ref($productid) eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $h_productid = $productid; | |||||||||||||||||||||||||||||||||||||||
| 324 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | $productid ||= $distrib->getfullpath(undef, 'product.id'); | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$productid ||= $distrib->getfullpath(undef, "product.id")
MC/DC0%0/2
$productid ||= $distrib->getfullpath(undef, "product.id")
$productid
$distrib->getfullpath(undef, "product.id")
Truth table0%0/3
A ||= B
A= $productidB= $distrib->getfullpath(undef, "product.id")
| |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | open($h_productid, ">", $productid) or return 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | print $h_productid $distrib->getvalue(undef, 'productid') . "\n"; | |||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if (ref($productid) ne 'GLOB') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | close($h_productid); | |||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||
| 338 | =item $distrib->list_existing_medias() | ||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||
| 340 | List media which really exists on the disk | ||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||
| 342 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||
| 344 | sub list_existing_medias { | ||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_existing_medias: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | grep { -d $self->getfullmediapath($_, 'path') } $self->listmedia(); | |||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||
| 349 | =item $distrib->set_medias_size($media) | ||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||
| 351 | Set media size into media.cfg for $media | ||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||
| 353 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||
| 355 | sub set_media_size { | ||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | my ($self, $media) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_media_size: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $size = 0; | |||||||||||||||||||||||||||||||||||||||
| 358 | 0 | foreach (glob($self->getfullmediapath($media, 'path') . '/*.rpm')) { | |||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $size += (stat($_))[7]; | |||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $blk = 1; | |||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $showsize = $size; | |||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my @unit = (' ', qw(k m g)); | |||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | while (@unit) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $u = shift(@unit); | |||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ($size / $blk < 1) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $showsize = sprintf('%d%s', $size / $blk, $u); | |||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $blk *= 1024; | |||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->setvalue($media, 'size', $showsize); | |||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||
| 375 | =item $distrib->set_all_medias_size() | ||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||
| 377 | Set media size into media.cfg | ||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||
| 379 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||
| 381 | sub set_all_medias_size { | ||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_all_medias_size: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | foreach my $media ($self->list_existing_medias()) { | |||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $self->set_media_size($media); | |||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||
| 390 | __END__ | ||||||||||||||||||||||||||||||||||||||||