diff options
author | Florent Villard <warly@mandriva.com> | 2006-10-16 11:30:28 +0000 |
---|---|---|
committer | Florent Villard <warly@mandriva.com> | 2006-10-16 11:30:28 +0000 |
commit | 02381cd87e37dc5d6df37e56eef5f1e222a794cd (patch) | |
tree | fec5b8db1aba238ca91f5506239dec3ac37d3929 /lib/Youri/Submit/Check/Version.pm | |
parent | 597e5f1d49cb0cc96a5655aeaa84a6fc4a83b041 (diff) | |
download | mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar.gz mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar.bz2 mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar.xz mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.zip |
add new youri subsections (from upstream)
Diffstat (limited to 'lib/Youri/Submit/Check/Version.pm')
-rw-r--r-- | lib/Youri/Submit/Check/Version.pm | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/Youri/Submit/Check/Version.pm b/lib/Youri/Submit/Check/Version.pm new file mode 100644 index 0000000..fe9f42b --- /dev/null +++ b/lib/Youri/Submit/Check/Version.pm @@ -0,0 +1,72 @@ +# $Id: /youri.mdv/trunk/lib/Youri/Upload/Check/Recency.pm 975 2006-08-05T08:30:57.188281Z warly $ +package Youri::Upload::Check::Version; + +=head1 NAME + +Youri::Upload::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::Upload::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 1 if $opt->{mode} eq 'normal'; + my $section = $repository->_get_section($package, $target, $define); + my $name = $package->get_canonical_name; + return 1 if $name =~ /$opt->{authorized_packages}/; + my $arch = $repository->get_arch($package, $target, $define); + return 1 if $arch =~ /$opt->{authorized_arches}/; + if ($opt->{mode} eq 'version_freeze') { + return 1 if $section =~ /$opt->{authorized_sections}/ + } elsif ($opt->{mode} eq 'freeze') { + if ($section !~ /$opt->{authorized_sections}/) { + $self->{_error} = "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>"; + return 0 + } + } + my $source = $package->get_source_package; + my ($package_version) = $source =~ /-([^-]+)-[^-]+\.src\.rpm$/; + $define->{arch} = 'src'; + my @revisions = $repository->get_revisions($package, $target, $define, sub { 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) { + $self->{_error} = "VERSION FREEZE, package @revisions of different versions exist in cooker\n"; + return 0 + } + return 1 +} + +=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; + |