diff options
Diffstat (limited to 'lib/MDV')
-rw-r--r-- | lib/MDV/Distribconf/Build.pm | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/MDV/Distribconf/Build.pm b/lib/MDV/Distribconf/Build.pm index 44a1ecb..dd71ff6 100644 --- a/lib/MDV/Distribconf/Build.pm +++ b/lib/MDV/Distribconf/Build.pm @@ -29,6 +29,70 @@ sub new { bless $self, $class; } +=item $distrib->init($flavour) + +Create initals directories in the distrib tree if missing. + +$flavour is either 'mandriva' or 'mandrake', depending the tree type +you want to create. + +See also L<MDV::Distribconf/settree> + +Return 1 on success, 0 otherwise. + +=cut + +sub init { + my ($self, $flavour) = @_; + $self->settree($flavour || 'mandriva') unless($self->{infodir}); + if (!-d $self->getfullpath(undef, 'root')) { + if (!mkdir($self->getfullpath(undef, 'root'))) { + warn 'Cannot create ' . $self->getfullpath(undef, 'root') .": $!\n"; + return 0; + } + } + foreach my $dir (map { $self->getfullpath(undef, $_) } qw(mediadir infodir)) { + if (!-d $dir) { + if (!mkdir($dir)) { + warn "Cannot create $dir: $!\n"; + return 0; + } + } + } + + foreach my $media ($self->listmedia()) { + $self->create_media($media) or return 0; + } + + 1; +} + +=item $distrib->create_media($media) + +Create a media $media if not exists and its directories if need. + +See also L<setvalue> + +Return 1 on success, 0 otherwise + +=cut + +sub create_media { + my ($self, $media) = @_; + foreach my $dir (map { $self->getfullmediapath($media, $_) } qw(path infodir)) { + if (!-d $dir) { + if (!mkdir($dir)) { + warn "Cannot create $dir: $!\n"; + return 0; + } + } + } + + $self->setvalue($media, undef, undef); + + 1; +} + =item $distrib->setvalue($media, $var, $val) Sets or adds $var parameter from $media to $val. If $media doesn't exist, |