diff options
author | Olivier Thauvin <nanardon@mandriva.org> | 2006-07-20 13:11:00 +0000 |
---|---|---|
committer | Olivier Thauvin <nanardon@mandriva.org> | 2006-07-20 13:11:00 +0000 |
commit | 88216bcd4276aac93f4401974203087a00bcf8dc (patch) | |
tree | e8b9822fb47ea5593d16f105ea4c6f68765069ed /lib | |
parent | 020025ad9e21034c272e917479552a50df16ed42 (diff) | |
download | perl-MDV-Distribconf-88216bcd4276aac93f4401974203087a00bcf8dc.tar perl-MDV-Distribconf-88216bcd4276aac93f4401974203087a00bcf8dc.tar.gz perl-MDV-Distribconf-88216bcd4276aac93f4401974203087a00bcf8dc.tar.bz2 perl-MDV-Distribconf-88216bcd4276aac93f4401974203087a00bcf8dc.tar.xz perl-MDV-Distribconf-88216bcd4276aac93f4401974203087a00bcf8dc.zip |
- add mediacfg version management
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MDV/Distribconf.pm | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/lib/MDV/Distribconf.pm b/lib/MDV/Distribconf.pm index ecb58fb..7c0c4d3 100644 --- a/lib/MDV/Distribconf.pm +++ b/lib/MDV/Distribconf.pm @@ -2,7 +2,7 @@ package MDV::Distribconf; # $Id$ -our $VERSION = '1.01'; +our $VERSION = '2.01'; =head1 NAME @@ -158,6 +158,11 @@ use strict; use warnings; use Config::IniFiles; +sub mymediacfg_version { + $VERSION =~ /^(\d+)\./; + $1 +} + =head2 MDV::Distribconf->new($root) Returns a new MDV::Distribconf object, C<$root> being the top level @@ -166,13 +171,19 @@ directory of the tree. =cut sub new { - my ($class, $path) = @_; - bless { + my ($class, $path, $mediacfg_version) = @_; + my $distrib = { root => $path, infodir => '', mediadir => '', cfg => new Config::IniFiles(-default => 'media_info', -allowcontinue => 1), - }, $class; + }; + + if (!defined($mediacfg_version)) { + $distrib->{cfg}->newval('media_info', 'mediacfg_version', mymediacfg_version()); + } + + bless($distrib, $class) } =head2 $distrib->load() @@ -219,6 +230,24 @@ sub loadtree { return 1; } +=head2 check_mediacfg_version($wanted_version) + +Check current distrib use this version or lesser, which mean it is supported. + +=cut + +sub check_mediacfg_version { + my ($distrib, $wanted_version) = @_; + + # Check wanted version is <= than the module + # Otherwise the module can't properly handle it + return 0 if (mymediacfg_version() < $wanted_version); + + return 0 if ($wanted_version < $distrib->{cfg}->val('media_info', 'mediacfg_version', 1)); + + return 1 +} + =head2 $distrib->settree($spec) Virtual set the internal structure of the distrib. @@ -330,7 +359,8 @@ sub parse_mediacfg { (-f $mediacfg && -r _) && ($distrib->{cfg} = new Config::IniFiles( -file => $mediacfg, -default => 'media_info', -allowcontinue => 1)) or return 0; - return 1; + + return $distrib->check_mediacfg_version(mymediacfg_version()); } =head2 $distrib->listmedia() |