summaryrefslogtreecommitdiffstats
path: root/lib/MDV
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2006-09-01 01:56:25 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2006-09-01 01:56:25 +0000
commit375b524b3f466fb8cbd26f81007528b75283cc7c (patch)
tree61751b9309f6543ace69812b960a3bc545d15e07 /lib/MDV
parent0c87377b1650edc8b726b375edda0f7b00d96ee6 (diff)
downloadperl-MDV-Distribconf-375b524b3f466fb8cbd26f81007528b75283cc7c.tar
perl-MDV-Distribconf-375b524b3f466fb8cbd26f81007528b75283cc7c.tar.gz
perl-MDV-Distribconf-375b524b3f466fb8cbd26f81007528b75283cc7c.tar.bz2
perl-MDV-Distribconf-375b524b3f466fb8cbd26f81007528b75283cc7c.tar.xz
perl-MDV-Distribconf-375b524b3f466fb8cbd26f81007528b75283cc7c.zip
- add init() and create_media()
Diffstat (limited to 'lib/MDV')
-rw-r--r--lib/MDV/Distribconf/Build.pm64
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,