summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/MDV/Distribconf.pm42
-rw-r--r--t/01distribconf.t8
-rw-r--r--t/01history.t4
3 files changed, 51 insertions, 3 deletions
diff --git a/lib/MDV/Distribconf.pm b/lib/MDV/Distribconf.pm
index 8695c55..7f432b1 100644
--- a/lib/MDV/Distribconf.pm
+++ b/lib/MDV/Distribconf.pm
@@ -474,6 +474,10 @@ sub getvalue {
) : undef;
last;
};
+ /^rpmsrate$/ and do { $default = 'rpmsrate'; last; };
+ /^description$/ and do { $default = 'description'; last; };
+ /^provide$/ and do { $default = 'description'; last; };
+ /^depslist.ordered$/ and do { $default = 'description'; last; };
}
return $distrib->_expand($media, $distrib->{cfg}->val($media, $var, $default), $level);
}
@@ -552,6 +556,44 @@ sub getfullmediapath {
return $distrib->getpath(undef, 'root') . '/' . $path;
}
+=head2 $distrib->getdpath($media, $var)
+
+Does the same thing than getpath(), but the return always return the best for
+file having twice location (index).
+
+You may want to use this function to ensure you allways the good value.
+
+=cut
+
+sub getdpath {
+ my ($distrib, $media, $var) = @_;
+
+ if ($var =~ /^(hdlist|synthesis|pubkey|MD5SUM)$/) {
+ if ($distrib->{type} eq 'mandriva') {
+ return $distrib->getmediapath($media, $var);
+ } else {
+ return $distrib->getpath($media, $var);
+ }
+ } else {
+ return $distrib->getpath($media, $var);
+ }
+}
+
+=head2 $distrib->getfulldpath($media, $var)
+
+Does the same thing than getfullpath(), but the return always return the best
+for file having twice location (index).
+
+You may want to use this function to ensure you allways the good value.
+
+=cut
+
+sub getfulldpath {
+ my $distrib = shift;
+ my $path = $distrib->getdpath(@_) or return;
+ return $distrib->getpath(undef, 'root') . '/' . $path;
+}
+
1;
diff --git a/t/01distribconf.t b/t/01distribconf.t
index b411bea..987b284 100644
--- a/t/01distribconf.t
+++ b/t/01distribconf.t
@@ -12,7 +12,7 @@ my %testdpath = (
'http://server/path/' => 'testdata/test/media/media_info/media.cfg',
);
-plan tests => 14 + 22 * scalar(keys %testdpath);
+plan tests => 14 + 28 * scalar(keys %testdpath);
use_ok('MDV::Distribconf');
@@ -56,6 +56,12 @@ foreach my $path (keys %testdpath) {
like($dconf->getfullpath('main', 'hdlist'), qr!^/*$path/*media/+media_info/+hdlist_main.cz$!, "Can get media fullpath"); # vim color: */
like($dconf->getmediapath('main', 'hdlist'), qr!^/*media/+main/+media_info/+hdlist.cz$!, "Can get media path"); # vim color: */
like($dconf->getfullmediapath('main', 'hdlist'), qr!^/*$path/*media/+main/+media_info/+hdlist.cz$!, "Can get media fullpath"); # vim color: */
+ like($dconf->getdpath('main', 'hdlist'), qr!^/*media/+main/+media_info/+hdlist.cz$!, "can get dpath");
+ like($dconf->getfulldpath('main', 'hdlist'), qr!^/*$path/*media/+main/+media_info/+hdlist.cz$!, "can get fulldpath");
+ is($dconf->getdpath(undef, 'root'), $path, "can get fulldpath");
+ is($dconf->getfulldpath(undef, 'VERSION'), "$path/VERSION", "can get fulldpath");
+ is($dconf->getdpath('main', 'root'), $path, "can get fulldpath root even media is given");
+ is($dconf->getdpath('main', 'description'), 'media/media_info/description', "can get fulldpath description even media is given");
}
{
diff --git a/t/01history.t b/t/01history.t
index 92175fc..28eb6d3 100644
--- a/t/01history.t
+++ b/t/01history.t
@@ -27,10 +27,10 @@ foreach my $path (@testdpath) {
my $medias = 0;
foreach my $m ($dconf->listmedia()) {
$medias++;
- if (-f $dconf->getfullpath($m, 'hdlist')) {
+ if (-f $dconf->getfulldpath($m, 'hdlist')) {
$foundhd++;
} else {
- print STDERR "$m " . $dconf->getfullpath($m, 'hdlist') . " not found\n";
+ print STDERR "$m " . $dconf->getfulldpath($m, 'hdlist') . " not found\n";
}
}
SKIP: {