diff options
author | Florent Villard <warly@mandriva.com> | 2006-10-12 08:49:55 +0000 |
---|---|---|
committer | Florent Villard <warly@mandriva.com> | 2006-10-12 08:49:55 +0000 |
commit | 0c56d657b96fcdaac01befe62cd81e1f9a81d710 (patch) | |
tree | 679f3595ad0d9b5f379ea055a7feb4c823370e49 | |
parent | 0157f0061990ad835ecbccb313a23f7e641fe098 (diff) | |
download | mga-youri-core-0c56d657b96fcdaac01befe62cd81e1f9a81d710.tar mga-youri-core-0c56d657b96fcdaac01befe62cd81e1f9a81d710.tar.gz mga-youri-core-0c56d657b96fcdaac01befe62cd81e1f9a81d710.tar.bz2 mga-youri-core-0c56d657b96fcdaac01befe62cd81e1f9a81d710.tar.xz mga-youri-core-0c56d657b96fcdaac01befe62cd81e1f9a81d710.zip |
use different config per target
-rw-r--r-- | lib/Youri/Upload/Check/Version.pm | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/Youri/Upload/Check/Version.pm b/lib/Youri/Upload/Check/Version.pm index efe8993..fe9f42b 100644 --- a/lib/Youri/Upload/Check/Version.pm +++ b/lib/Youri/Upload/Check/Version.pm @@ -15,37 +15,48 @@ in the configuration file or in a non frozen section. use warnings; use strict; use Carp; +use URPM; use base qw/Youri::Upload::Check/; sub _init { my $self = shift; my %options = ( - authorized_sections => undef, # sections where check is not done - authorized_packages => undef, # packages which can be uploaded with newer versions @_ ); - $self->{_authorized_sections} = $options{authorized_sections}; - $self->{_authorized_packages} = $options{authorized_packages} + 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); - return 1 if $section =~ /$self->{_authorized_sections}/; my $name = $package->get_canonical_name; - return 1 if $name =~ /$self->{_authorized_packages}/; + 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$/; - my @revisions = $repository->get_revisions($package, $target, $define, sub { my $source_package = $_[0]->get_source_package; my ($version) = $source_package =~ /-([^-]+)-[^-]+\.src\.rpm$/; $version ne $package_version }); + $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; + return 1 } =head1 COPYRIGHT AND LICENSE |