diff options
author | Gustavo De Nardin <spuk@mandriva.org> | 2007-05-05 06:16:45 +0000 |
---|---|---|
committer | Gustavo De Nardin <spuk@mandriva.org> | 2007-05-05 06:16:45 +0000 |
commit | 267ff0d9584e91f20898b6d7366fc5b2505ad64c (patch) | |
tree | 5310deae8a928283d9a6e0c8684d32a5de85d2ef | |
parent | 2339521146cdbae5f43798cf9a3461f7cf0abade (diff) | |
download | mga-youri-submit-267ff0d9584e91f20898b6d7366fc5b2505ad64c.tar mga-youri-submit-267ff0d9584e91f20898b6d7366fc5b2505ad64c.tar.gz mga-youri-submit-267ff0d9584e91f20898b6d7366fc5b2505ad64c.tar.bz2 mga-youri-submit-267ff0d9584e91f20898b6d7366fc5b2505ad64c.tar.xz mga-youri-submit-267ff0d9584e91f20898b6d7366fc5b2505ad64c.zip |
Check if package submission was for the correct section.
-rw-r--r-- | lib/Youri/Submit/Check/Section.pm | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/Youri/Submit/Check/Section.pm b/lib/Youri/Submit/Check/Section.pm new file mode 100644 index 0000000..4ff1675 --- /dev/null +++ b/lib/Youri/Submit/Check/Section.pm @@ -0,0 +1,58 @@ +# $Id: Precedence.pm 1707 2006-10-16 16:26:42Z warly $ +package Youri::Submit::Check::Section; + +=head1 NAME + +Youri::Submit::Check::Section - Check if package was submitted to the right section + +=head1 DESCRIPTION + +This check plugin rejects packages which were submitted to a section +different than the one where an older version already exists. + +=cut + +use warnings; +use strict; +use Carp; +use base qw/Youri::Submit::Check/; + +sub run { + my ($self, $package, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + my @errors; + + my $submitted_main_section = $repository->_get_main_section($package, $target, $define); + + # undefine section, so that Repository::_get_section() of Mandriva_upload.pm + # finds the section from existing packages + my $defined_section = $define->{section}; + undef $define->{section}; + + my $old_main_section = $repository->_get_main_section($package, $target, $define); + my @older_revisions = $repository->get_older_revisions($package, $target, $define); + + # restore defined section + $define->{section} = $defined_section; + + if (@older_revisions && $submitted_main_section ne $old_main_section) { + push( + @errors, + "Section should be $old_main_section, not $submitted_main_section." + ); + } + + + return @errors; +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2007, Mandriva + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; |