aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2005-02-21 21:40:10 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2005-02-21 21:40:10 +0000
commit8e565f1b3dec1ff1a16718c0b7245fb4eece3a48 (patch)
treedac622d08229209b022e08d6ea1db006a640b5a8
parentf81e5cc5b92f6fc294edb1703c1fba6abb6bd130 (diff)
downloadrpmtools-8e565f1b3dec1ff1a16718c0b7245fb4eece3a48.tar
rpmtools-8e565f1b3dec1ff1a16718c0b7245fb4eece3a48.tar.gz
rpmtools-8e565f1b3dec1ff1a16718c0b7245fb4eece3a48.tar.bz2
rpmtools-8e565f1b3dec1ff1a16718c0b7245fb4eece3a48.tar.xz
rpmtools-8e565f1b3dec1ff1a16718c0b7245fb4eece3a48.zip
- add getfullpath
- s![ /]*!_! in default path - add check()
-rw-r--r--Distribconf.pm73
1 files changed, 68 insertions, 5 deletions
diff --git a/Distribconf.pm b/Distribconf.pm
index 8abb119..bbc1e6d 100644
--- a/Distribconf.pm
+++ b/Distribconf.pm
@@ -378,12 +378,13 @@ sub getvalue {
my ($distrib, $media, $var) = @_;
$media ||= 'media_info';
- my $default;
+ my $default = "";
SWITCH: for ($var) {
- /^synthesis$/ and do { $default = 'synthesis.' . lc($distrib->getvalue($media, 'hdlist')); last; };
- /^hdlist$/ and do { $default = 'hdlist_' . lc($distrib->getvalue($media, 'name')) . '.cz'; last; };
- /^pubkey$/ and do { $default = 'pubkey_' . lc($distrib->getvalue($media, 'name')); last; };
- /^name$/ and do { $default = $media; $default =~ s!/!_!g; last; };
+ /^synthesis$/ and do { $default = 'synthesis.' . lc($distrib->getvalue($media, 'hdlist')); };
+ /^hdlist$/ and do { $default = 'hdlist_' . lc($distrib->getvalue($media, 'name')) . '.cz'; };
+ /^pubkey$/ and do { $default = 'pubkey_' . lc($distrib->getvalue($media, 'name')); };
+ /^name$/ and do { $default = $media; };
+ $default =~ s![/ ]+!_!g;
/^path$/ and return $media;
/^root$/ and return $distrib->{root};
/^mediadir$|^infodir$/ and do { $default = $distrib->{$var}; last; };
@@ -431,8 +432,65 @@ sub getpath {
return ($val =~ m!/! ? "" : ($var eq 'path' ? $distrib->{mediadir} : $distrib->{infodir} ) . "/") . $val;
}
+=head2 getfullpath($media, $var)
+
+Does the same thing than L<getpath> but the return value is already
+prefixed by the 'root' path.
+This function is shortcut for:
+$distrib->getpath(undef, 'root') . '/' . $distrib->getpath($media, $var).
+
+=cut
+
+sub getfullpath {
+ my ($distrib, $media, $var) = @_;
+ return $distrib->getpath(undef, 'root') . '/' . $distrib->getpath($media, $var);
+}
+
1;
+=head2 check
+
+=cut
+
+sub check {
+ my ($distrib, $out) = @_;
+ $out ||= \*STDOUT;
+
+ $distrib->listmedia or print $out "W: No media found in this config\n";
+
+ # Checking no overlap
+ foreach my $var (qw/name hdlist synthesis path/) {
+ my %e;
+ foreach ($distrib->listmedia) {
+ my $v = $var eq 'name' ? $distrib->getvalue($_, $var) : $distrib->getpath($_, $var);
+ push @{$e{$v}}, $_;
+ }
+
+ foreach my $key (keys %e) {
+ if (@{$e{$key}} > 1) {
+ printf $out "E: medium %s have same %s (%s)\n",
+ join (", ", @{$e{$key}}),
+ $var,
+ $key;
+ }
+ }
+ }
+
+ foreach my $media ($distrib->listmedia) {
+ -d $distrib->getfullpath($media, 'path') or
+ printf $out "E: dir %s don't exist for media '%s'\n",
+ $distrib->getpath($media, 'path'),
+ $media;
+
+ foreach (qw/hdlist synthesis pubkey/) {
+ -f $distrib->getfullpath($media, $_) or
+ printf $out "E: $_ %s don't exist for media '%s'\n",
+ $distrib->getpath($media, $_),
+ $media;
+ }
+ }
+}
+
__END__
=head1 AUTHOR
@@ -449,6 +507,11 @@ Thanks to Sylvie Terjan <erinmargault@mandrake.org> for the spell checking.
=head1 ChangeLog
$Log$
+ Revision 1.6 2005/02/21 21:40:10 othauvin
+ - add getfullpath
+ - s![ /]*!_! in default path
+ - add check()
+
Revision 1.5 2005/02/21 15:34:56 othauvin
Distribconf