diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-06-29 13:36:22 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-06-29 13:36:22 +0000 |
commit | f36deffb742a8d801280606006807f2ad95f3849 (patch) | |
tree | 06502c46a3112662abdac58a855abaa900e4c122 /lib/Youri/Submit/Test/Version.pm | |
parent | 30e5f11dbc78f154d8a8a4d4dd93af39fd223cd0 (diff) | |
download | mga-youri-submit-topic/mdv-to-merge.tar mga-youri-submit-topic/mdv-to-merge.tar.gz mga-youri-submit-topic/mdv-to-merge.tar.bz2 mga-youri-submit-topic/mdv-to-merge.tar.xz mga-youri-submit-topic/mdv-to-merge.zip |
prepare mergetopic/mdv-to-merge
Diffstat (limited to 'lib/Youri/Submit/Test/Version.pm')
-rw-r--r-- | lib/Youri/Submit/Test/Version.pm | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/lib/Youri/Submit/Test/Version.pm b/lib/Youri/Submit/Test/Version.pm new file mode 100644 index 0000000..289ffe0 --- /dev/null +++ b/lib/Youri/Submit/Test/Version.pm @@ -0,0 +1,100 @@ +# $Id$ +package Youri::Submit::Check::Version; + +=head1 NAME + +Youri::Submit::Check::Version - Check if older version already exist in cooker (used in freeze period) + +=head1 DESCRIPTION + +This check plugin rejects new version of packages if they are not mentioned as authorized +in the configuration file or in a non frozen section. + +=cut + +use warnings; +use strict; +use Carp; +use URPM; +use base qw/Youri::Submit::Check/; + +sub _init { + my $self = shift; + my %options = ( + @_ + ); + + foreach my $target (keys %options) { + $self->{$target} = $options{$target} + } +} + +sub run { + my ($self, $package, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + my $opt = $self->{$target}; + return if $opt->{mode} eq 'normal'; + my $section = $repository->_get_section($package, $target, $define); + my $name = $package->get_canonical_name; + return if $name =~ /$opt->{authorized_packages}/; + my $arch = $repository->get_arch($package, $target, $define); + return if $arch =~ /$opt->{authorized_arches}/; + if ($opt->{mode} eq 'version_freeze') { + return if $section =~ /$opt->{authorized_sections}/; + my $user = $define->{user}; + return if $user =~ /$opt->{authorized_users}/; + my ($package_version) = $package =~ /-([^-]+)-[^-]+\.src$/; + $define->{arch} = 'src'; + my @revisions = $repository->get_revisions($package, $target, $define, undef, + sub { + my ($version) = $_[0] =~ /-([^-]+)-[^-]+\.src$/; + URPM::ranges_overlap("== $version", "< $package_version") + } + ); + $define->{arch} = ''; + if (@revisions) { + return "FREEZE, package @revisions of different versions exist in $target\n"; + } + } + # FIXME: The following code is not working and must be reviewed. + elsif ($opt->{mode} eq 'freeze') { + # XXX: So freeze mode really only check for this exceptions? + if ($section !~ /$opt->{authorized_sections}/) { + return "FREEZE: repository $target section $section is frozen, you can still submit your packages in testing\nTo do so use your.devel --define section=<section> $target <package 1> <package 2> ... <package n>"; + } + } else { + # FIXME: Calls to get_source_package seems invalid nowadays. + # This results on $source having a null content. + my $source = $package->get_source_package; + my ($package_version) = $source =~ /-([^-]+)-[^-]+\.src\.rpm$/; + $define->{arch} = 'src'; + # FIXME: get_revisions now expects the filter as the 5th element, and not the 4th. + my @revisions = $repository->get_revisions($package, $target, $define, + sub { + # FIXME: Calls to get_source_package seems invalid nowadays. + # This results on $source_package having a null content. + my $source_package = $_[0]->get_source_package; + my ($version) = $source_package =~ /-([^-]+)-[^-]+\.src\.rpm$/; + print STDERR "Found version $version\n"; + URPM::ranges_overlap("== $version", "< $package_version") + } + ); + $define->{arch} = ''; + if (@revisions) { + return "FREEZE, package @revisions of different versions exist in $target\n"; + } + } + return +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2006, YOURI project +Copyright (C) 2006, Mandriva + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; + |