aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Upload/Check/Version.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Youri/Upload/Check/Version.pm')
-rw-r--r--lib/Youri/Upload/Check/Version.pm31
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