aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Submit
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-10-16 16:26:42 +0000
committerFlorent Villard <warly@mandriva.com>2006-10-16 16:26:42 +0000
commitdb4080d6ec327d2f26b3c7d9395bfe71f210abf1 (patch)
treefd088c5b1805f1fe4c8bc574b07c08fe79b57271 /lib/Youri/Submit
parent363a191019f34e2f78edd2a92cd02be004ee4fd2 (diff)
downloadmga-youri-submit-db4080d6ec327d2f26b3c7d9395bfe71f210abf1.tar
mga-youri-submit-db4080d6ec327d2f26b3c7d9395bfe71f210abf1.tar.gz
mga-youri-submit-db4080d6ec327d2f26b3c7d9395bfe71f210abf1.tar.bz2
mga-youri-submit-db4080d6ec327d2f26b3c7d9395bfe71f210abf1.tar.xz
mga-youri-submit-db4080d6ec327d2f26b3c7d9395bfe71f210abf1.zip
merging dev with upstream
Diffstat (limited to 'lib/Youri/Submit')
-rw-r--r--lib/Youri/Submit/Check/History.pm21
-rw-r--r--lib/Youri/Submit/Check/Precedence.pm16
-rw-r--r--lib/Youri/Submit/Check/Recency.pm23
-rw-r--r--lib/Youri/Submit/Check/Rpmlint.pm75
-rw-r--r--lib/Youri/Submit/Check/Tag.pm17
-rw-r--r--lib/Youri/Submit/Check/Type.pm13
6 files changed, 108 insertions, 57 deletions
diff --git a/lib/Youri/Submit/Check/History.pm b/lib/Youri/Submit/Check/History.pm
index 82a1b05..326f2f1 100644
--- a/lib/Youri/Submit/Check/History.pm
+++ b/lib/Youri/Submit/Check/History.pm
@@ -1,9 +1,9 @@
# $Id$
-package Youri::Upload::Check::History;
+package Youri::Submit::Check::History;
=head1 NAME
-Youri::Upload::Check::History - Non-linear history check
+Youri::Submit::Check::History - Non-linear history check
=head1 DESCRIPTION
@@ -16,19 +16,22 @@ use warnings;
use strict;
use Carp;
use Youri::Package;
-use base qw/Youri::Upload::Check/;
+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 $last_revision =
$repository->get_last_older_revision($package, $target, $define);
if ($last_revision) {
# skip the test if last revision has been produced from another source package, as it occurs during package split/merges
- return 1
- if $last_revision->get_canonical_name() ne $package->get_canonical_name();
+ return
+ if $last_revision->get_canonical_name()
+ ne $package->get_canonical_name();
my ($last_revision_number) = $last_revision->get_last_change()->[Youri::Package::CHANGE_AUTHOR] =~ /(\S+)\s*$/;
my %entries =
@@ -37,12 +40,14 @@ sub run {
map { $_->[Youri::Package::CHANGE_AUTHOR] }
$package->get_changes();
unless ($entries{$last_revision_number}) {
- $self->{_error} = "Last changelog entry $last_revision_number from last revision " . $last_revision->get_full_name() . " missing from current changelog";
- return 0;
+ push(
+ @errors,
+ "Last changelog entry $last_revision_number from last revision " . $last_revision->get_full_name() . " missing from current changelog"
+ );
}
}
- return 1;
+ return @errors;
}
=head1 COPYRIGHT AND LICENSE
diff --git a/lib/Youri/Submit/Check/Precedence.pm b/lib/Youri/Submit/Check/Precedence.pm
index 296c154..c73446b 100644
--- a/lib/Youri/Submit/Check/Precedence.pm
+++ b/lib/Youri/Submit/Check/Precedence.pm
@@ -1,9 +1,9 @@
# $Id$
-package Youri::Upload::Check::Precedence;
+package Youri::Submit::Check::Precedence;
=head1 NAME
-Youri::Upload::Check::Precedence - Release check against another check
+Youri::Submit::Check::Precedence - Release check against another check
=head1 DESCRIPTION
@@ -15,7 +15,7 @@ another upload target.
use warnings;
use strict;
use Carp;
-use base qw/Youri::Upload::Check/;
+use base qw/Youri::Submit::Check/;
sub _init {
my $self = shift;
@@ -33,14 +33,18 @@ sub run {
my ($self, $package, $repository, $target, $define) = @_;
croak "Not a class method" unless ref $self;
+ my @errors;
+
my @older_revisions =
$repository->get_older_revisions($package, $self->{_target}, $define);
if (@older_revisions) {
- $self->{_error} = "Older revisions still exists for $self->{_target}: " . join(', ', @older_revisions);
- return 0;
+ push(
+ @errors,
+ "Older revisions still exists for $self->{_target}: " . join(', ', @older_revisions)
+ );
}
- return 1;
+ return @errors;
}
=head1 COPYRIGHT AND LICENSE
diff --git a/lib/Youri/Submit/Check/Recency.pm b/lib/Youri/Submit/Check/Recency.pm
index 58452a6..40e34e8 100644
--- a/lib/Youri/Submit/Check/Recency.pm
+++ b/lib/Youri/Submit/Check/Recency.pm
@@ -1,9 +1,9 @@
# $Id$
-package Youri::Upload::Check::Recency;
+package Youri::Submit::Check::Recency;
=head1 NAME
-Youri::Upload::Check::Recency - Release check against current target
+Youri::Submit::Check::Recency - Release check against current target
=head1 DESCRIPTION
@@ -15,26 +15,33 @@ exists for current upload target.
use warnings;
use strict;
use Carp;
-use base qw/Youri::Upload::Check/;
+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 $file = $repository->get_install_file($package, $target, $define);
if (-f $file) {
- $self->{_error} = "Current revision of package $file already exists for $target";
- return 0;
+ push(
+ @errors,
+ "Current revision already exists for $target"
+ );
}
my @newer_revisions =
$repository->get_newer_revisions($package, $target, $define);
if (@newer_revisions) {
- $self->{_error} = "Newer revisions of package $package already exists for $target: " . join(', ', @newer_revisions);
- return 0;
+ push(
+ @errors,
+ "Newer revisions already exists for $target: " .
+ join(', ', @newer_revisions)
+ );
}
- return 1;
+ return @errors;
}
=head1 COPYRIGHT AND LICENSE
diff --git a/lib/Youri/Submit/Check/Rpmlint.pm b/lib/Youri/Submit/Check/Rpmlint.pm
index 20e478b..c7bdf01 100644
--- a/lib/Youri/Submit/Check/Rpmlint.pm
+++ b/lib/Youri/Submit/Check/Rpmlint.pm
@@ -1,56 +1,85 @@
# $Id: Tag.pm 867 2006-04-11 20:34:56Z guillomovitch $
-package Youri::Upload::Check::Rpmlint;
+package Youri::Submit::Check::Rpmlint;
=head1 NAME
-Youri::Upload::Check::Tag - Incorrect tag values check
+Youri::Submit::Check::Rpmlint - Rpmlint-based check
=head1 DESCRIPTION
-This check plugin rejects packages with incorrect tag values, based on regular
-expressions.
+This check plugin wraps rpmlint, and reject packages triggering results
+declared as fatal.
=cut
use warnings;
use strict;
use Carp;
-use base qw/Youri::Upload::Check/;
+use base qw/Youri::Submit::Check/;
+
+=head2 new(%args)
+
+Creates and returns a new Youri::Submit::Check::Rpmlint object.
+
+Specific parameters:
+
+=over
+
+=item results $results
+
+List of rpmlint result id considered as fatal.
+
+=item path $path
+
+Path to the rpmlint executable (default: /usr/bin/rpmlint)
+
+=item config $config
+
+Specific rpmlint configuration.
+
+=back
+
+=cut
+
sub _init {
my $self = shift;
my %options = (
- fatal_error => '',
- @_
+ results => undef,
+ path => '/usr/bin/rpmlint',
+ config => '',
+ @_
);
- $self->{_fatal_error} = $options{fatal_error};
+
+ croak "no results to check" unless $options{results};
+ croak "fatal should be an arrayref" unless ref $options{results} eq 'ARRAY';
+
+ $self->{_pattern} = '^(?:' . join('|', @{$options{results}}) . ')$';
}
sub run {
my ($self, $package, $repository, $target, $define) = @_;
croak "Not a class method" unless ref $self;
- my $file = $package->get_file;
- open my $rpmlint, "/usr/bin/rpmlint $file |";
- my $fatal;
- my $error = "fatal errors detected, upload rejected:\n";
- while (<$rpmlint>) {
- if (/$self->{_fatal_error}/) {
- $fatal = 1;
- $error .= "- $_"
- }
- }
- if ($fatal) {
- $self->{_error} = $error;
- return 0
+ my @errors;
+
+ my $command = "$self->{_path} -f $self->{_config} " . $package->as_file();
+ open(RPMLINT, "$command |") or die "Can't run $command: $!";
+ while (my $line = <RPMLINT>) {
+ my ($id, $value) = $line =~ /^[EW]: \S+ (\S+) (.*)$/;
+ if ($id =~ /$self->{_pattern}/o) {
+ push(@errors, "$id $value");
+ }
}
- 1
+
+ return @errors;
}
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2002-2006, YOURI project
-This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
=cut
diff --git a/lib/Youri/Submit/Check/Tag.pm b/lib/Youri/Submit/Check/Tag.pm
index 453534c..3fadfa3 100644
--- a/lib/Youri/Submit/Check/Tag.pm
+++ b/lib/Youri/Submit/Check/Tag.pm
@@ -1,9 +1,9 @@
# $Id$
-package Youri::Upload::Check::Tag;
+package Youri::Submit::Check::Tag;
=head1 NAME
-Youri::Upload::Check::Tag - Incorrect tag values check
+Youri::Submit::Check::Tag - Incorrect tag values check
=head1 DESCRIPTION
@@ -15,7 +15,7 @@ expressions.
use warnings;
use strict;
use Carp;
-use base qw/Youri::Upload::Check/;
+use base qw/Youri::Submit::Check/;
sub _init {
my $self = shift;
@@ -34,15 +34,20 @@ sub run {
my ($self, $package, $repository, $target, $define) = @_;
croak "Not a class method" unless ref $self;
+ my @errors;
+
foreach my $tag (keys %{$self->{_tags}}) {
my $value = $package->get_tag($tag);
if ($value !~ /$self->{_tags}->{$tag}/) {
- $self->{_error} = "invalid value $value for tag $tag";
- return 0;
+ push(
+ @errors,
+ "invalid value $value for tag $tag"
+ );
}
}
- return 1;
+ return @errors;
+
}
=head1 COPYRIGHT AND LICENSE
diff --git a/lib/Youri/Submit/Check/Type.pm b/lib/Youri/Submit/Check/Type.pm
index e03fa80..4bdb793 100644
--- a/lib/Youri/Submit/Check/Type.pm
+++ b/lib/Youri/Submit/Check/Type.pm
@@ -1,9 +1,9 @@
# $Id: /local/youri/soft/trunk/lib/Youri/Upload/Check/Tag.pm 1642 2006-03-29T06:49:43.840267Z guillaume $
-package Youri::Upload::Check::Type;
+package Youri::Submit::Check::Type;
=head1 NAME
-Youri::Upload::Check::Type - Type check
+Youri::Submit::Check::Type - Type check
=head1 DESCRIPTION
@@ -14,7 +14,7 @@ This check plugin rejects packages with incorrect type.
use warnings;
use strict;
use Carp;
-use base qw/Youri::Upload::Check/;
+use base qw/Youri::Submit::Check/;
sub _init {
my $self = shift;
@@ -33,13 +33,14 @@ sub run {
my ($self, $package, $repository, $target, $define) = @_;
croak "Not a class method" unless ref $self;
+ my @errors;
+
my $type = $package->get_type();
if ($type ne $self->{_type}) {
- $self->{_error} = "invalid type $type";
- return 0;
+ push(@errors, "invalid type $type");
}
- return 1;
+ return @errors;
}
=head1 COPYRIGHT AND LICENSE