summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2006-08-18 10:36:23 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2006-08-18 10:36:23 +0000
commit43f19b38993c3f57cebaff4cc10425900f7d5246 (patch)
tree8492b237b619ea91722fd35bfaf62259a5c6f623
parent733e2b8c0699e602fc617149a96b61a4e07dce35 (diff)
downloadperl-MDV-Distribconf-43f19b38993c3f57cebaff4cc10425900f7d5246.tar
perl-MDV-Distribconf-43f19b38993c3f57cebaff4cc10425900f7d5246.tar.gz
perl-MDV-Distribconf-43f19b38993c3f57cebaff4cc10425900f7d5246.tar.bz2
perl-MDV-Distribconf-43f19b38993c3f57cebaff4cc10425900f7d5246.tar.xz
perl-MDV-Distribconf-43f19b38993c3f57cebaff4cc10425900f7d5246.zip
- add MDV::Distribconf::MediaCFG
-rw-r--r--MANIFEST1
-rw-r--r--lib/MDV/Distribconf/MediaCFG.pm144
-rw-r--r--t/03mediacfg.t9
3 files changed, 154 insertions, 0 deletions
diff --git a/MANIFEST b/MANIFEST
index 284601f..a3f9312 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,6 +1,7 @@
ChangeLog
lib/MDV/Distribconf/Build.pm
lib/MDV/Distribconf.pm
+lib/MDV/Distribconf/MediaCFG.pm
Makefile.PL
MANIFEST
t/01distribconf.t
diff --git a/lib/MDV/Distribconf/MediaCFG.pm b/lib/MDV/Distribconf/MediaCFG.pm
new file mode 100644
index 0000000..46b3dc5
--- /dev/null
+++ b/lib/MDV/Distribconf/MediaCFG.pm
@@ -0,0 +1,144 @@
+package MDV::Distribconf::MediaCFG;
+
+use strict;
+use warnings;
+
+our $VERSION = (qq$Revision$ =~ /(\d+)/)[0];
+
+=head1 NAME
+
+MDV::Distribconf::MediaCFG
+
+=head1 DESCRIPTION
+
+This module provide documenation of know value in media.cfg
+
+=head1 VALUE
+
+=cut
+
+my $value = {};
+
+=head2 GLOBAL VALUES
+
+This value can only be set into 'media_info' section.
+
+=head3 mediacfg_version
+
+The version of the media_cfg
+
+See L<MDV::Distribconf> for more detail about it
+
+=cut
+
+$value->{version} = { section => 'media_info' };
+
+=head3 version
+
+The version of distrib
+
+=cut
+
+$value->{arch} = { section => 'media_info' };
+
+=head3 arch
+
+The arcitecture of the distribution
+
+=cut
+
+$value->{branch} = { section => 'media_info' };
+
+=head3 branch
+
+The branch of the distribution.
+
+=cut
+
+=head2 MEDIA VALUES
+
+=cut
+
+foreach (qw(hdlist name synthesis pubkey)) {
+ $value->{$_} = { };
+}
+
+=head3 name
+
+The name of the media. If unset, the section is the name.
+
+=head3 hdlist
+
+The hdlist file holding rpm infos for the media
+
+=head3 synthesis
+
+The synthesis file holding rpm infos for the media
+
+=head3 pubkey
+
+The file holding public gpg key used to sign rpms in this media.
+
+=cut
+
+$value->{srpms} = { deny => 'rpms' };
+
+=head3 srpms
+
+If the media hold binaries rpms, this parameter contains
+the list of medias holding corresponding sources rpms.
+
+=cut
+
+$value->{rpms} = { deny => 'srpms' };
+
+=head3 rpms
+
+If the media hold sources rpms, this parameter contains
+the list of media holding binaries rpms build by srpms from this media.
+
+=cut
+
+$value->{debugfor} = {};
+
+=head3 debugfor
+
+If the media contain debug rpms, it contain the list of media for which
+rpms are debug rpms.
+
+=cut
+
+$value->{noauto} = {};
+
+=head3 noauto
+
+This value is used by tools to assume if the media should automatically
+added to the config (urpmi).
+
+=cut
+
+$value->{size} = {};
+
+=head3 size
+
+The size of the media. The value is suffixed by the unit.
+
+=cut
+
+sub valid_param {
+ my ($media, $var, $val) = @_[-3..-1];
+ if (!exists($value->{$var})) {
+ return ("unknow var");
+ }
+ $media ||= 'media_info'; # assume default
+ my @errors;
+ if ($value->{$var}{section} && $value->{$var}{section} ne $media) {
+ push(@errors, "wrong section: should be in $value->{$var}{section}");
+ }
+ if ($value->{$var}{validation}) {
+ push(@errors, $value->{$var}{validation}->($val));
+ }
+ return @errors;
+}
+
+1;
diff --git a/t/03mediacfg.t b/t/03mediacfg.t
new file mode 100644
index 0000000..0c3f58a
--- /dev/null
+++ b/t/03mediacfg.t
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+use_ok('MDV::Distribconf::MediaCFG');
+is(MDV::Distribconf::MediaCFG::valid_param('foo', 'name', 'toto'), 0,
+ "Valid value return no error");