aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <blino@mageia.org>2011-04-04 22:59:01 +0000
committerOlivier Blin <blino@mageia.org>2011-04-04 22:59:01 +0000
commit699c5e78d5512a2779ce834882cfdda895db32b1 (patch)
tree0e1d060beb87008d7e266d6fbafb071c8bce10e9
parentb06110139b89597dbe34d33b907538c93991bfe4 (diff)
parent51d5d4e7a0d1d1cca9a5214782575b5f8aa7aa8b (diff)
downloadmga-youri-submit-699c5e78d5512a2779ce834882cfdda895db32b1.tar
mga-youri-submit-699c5e78d5512a2779ce834882cfdda895db32b1.tar.gz
mga-youri-submit-699c5e78d5512a2779ce834882cfdda895db32b1.tar.bz2
mga-youri-submit-699c5e78d5512a2779ce834882cfdda895db32b1.tar.xz
mga-youri-submit-699c5e78d5512a2779ce834882cfdda895db32b1.zip
rename mdv-youri-submit as mga-youri-submit
-rw-r--r--[-rwxr-xr-x]Makefile.PL3
-rwxr-xr-xbin/mga-signpackage29
-rw-r--r--lib/Youri/Submit/Action/Archive.pm11
-rw-r--r--lib/Youri/Submit/Action/Install.pm3
-rw-r--r--lib/Youri/Submit/Action/Mail.pm17
-rw-r--r--lib/Youri/Submit/Action/Sign.pm12
-rw-r--r--lib/Youri/Submit/Action/UpdateMaintDb.pm80
-rw-r--r--lib/Youri/Submit/Check/Deps.pm92
-rw-r--r--lib/Youri/Submit/Post/CleanRpmsrate.pm3
-rw-r--r--lib/Youri/Submit/Post/Mirror.pm55
10 files changed, 283 insertions, 22 deletions
diff --git a/Makefile.PL b/Makefile.PL
index 09ff7f7..933d412 100755..100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -9,7 +9,8 @@ WriteMakefile(
EXE_FILES => [
'bin/youri-submit',
'bin/youri-submit-restricted',
- 'bin/youri-submit-proxy'
+ 'bin/youri-submit-proxy',
+ 'bin/mga-signpackage'
],
PREREQ_PM => {
'Youri::Config' => 0,
diff --git a/bin/mga-signpackage b/bin/mga-signpackage
new file mode 100755
index 0000000..435e92e
--- /dev/null
+++ b/bin/mga-signpackage
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+
+use strict;
+use RPM4::Sign;
+use File::Spec;
+
+sub signpackage {
+ my ($file, $name, $path) = @_;
+
+ # check if parent directory is writable
+ my $parent = (File::Spec->splitpath($file))[1];
+ die "Unsignable package, parent directory is read-only"
+ unless -w $parent;
+
+ my $sign = RPM4::Sign->new(
+ name => $name,
+ path => $path,
+ passphrase => '',
+ );
+
+ $sign->rpmssign($file)
+}
+
+if (@ARGV != 3) {
+ exit 1;
+}
+
+signpackage(@ARGV);
+
diff --git a/lib/Youri/Submit/Action/Archive.pm b/lib/Youri/Submit/Action/Archive.pm
index 98ff37c..41a8b8f 100644
--- a/lib/Youri/Submit/Action/Archive.pm
+++ b/lib/Youri/Submit/Action/Archive.pm
@@ -46,17 +46,6 @@ sub run {
) {
my $file = $replaced_package->get_file();
- # trap for debugging bug 34999
- if ($file =~ /\/[\d.]+\/(main\/updates|.*\/release)/) {
- my $bugmsg = "BUG#34999 WARNING: trying to remove from a release: $file\n";
- open(BUG34999LOG, '>>', "/home/mandrake/bug34999.log");
- print $bugmsg;
- print BUG34999LOG localtime().": ".$bugmsg;
- close BUG34999LOG;
-
- next;
- }
-
my ($rep_section, $rep_main_section) = $file =~ m,$path/(([^/]+)/.*)/[^/]+.rpm,;
# We do accept duplicate version for other submedia of the same main media section
print "(path '$path') file '$file' section '$rep_section' main_section '$rep_main_section'\n" if $self->{_verbose};
diff --git a/lib/Youri/Submit/Action/Install.pm b/lib/Youri/Submit/Action/Install.pm
index 83d0149..80e8de2 100644
--- a/lib/Youri/Submit/Action/Install.pm
+++ b/lib/Youri/Submit/Action/Install.pm
@@ -14,6 +14,7 @@ This action plugin ensures installation of new package revisions.
use warnings;
use strict;
use Carp;
+use File::Basename;
use base qw/Youri::Submit::Action/;
sub _init {
@@ -33,7 +34,7 @@ sub run {
croak "Not a class method" unless ref $self;
my $file = $package->as_file();
- my $rpm = $package->get_file_name();
+ my $rpm = basename($package->get_file_name());
my $dest = $repository->get_install_dir($package, $target, $define);
# FIXME remove prefix this should be done by a function
diff --git a/lib/Youri/Submit/Action/Mail.pm b/lib/Youri/Submit/Action/Mail.pm
index c9bbcbe..02e36cd 100644
--- a/lib/Youri/Submit/Action/Mail.pm
+++ b/lib/Youri/Submit/Action/Mail.pm
@@ -110,13 +110,24 @@ sub get_content {
my ($self, $package, $repository, $target, $define) = @_;
croak "Not a class method" unless ref $self;
- my $information = $package->get_information();
+ my $information = $package->as_formated_string(<<EOF);
+Name : %-27{NAME} Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|
+Version : %-27{VERSION} Vendor: %{VENDOR}
+Release : %-27{RELEASE} Build Date: %{BUILDTIME:date}
+Install Date: %|INSTALLTIME?{%-27{INSTALLTIME:date}}:{(not installed) }| Build Host: %{BUILDHOST}
+Group : %-27{GROUP} Source RPM: %{SOURCERPM}
+Size : %-27{SIZE}%|LICENSE?{ License: %{LICENSE}}|
+Signature : %|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|
+%|PACKAGER?{Packager : %{PACKAGER}\n}|%|URL?{URL : %{URL}\n}|Summary : %{SUMMARY}
+Description :\n%{DESCRIPTION}
+EOF
+
my $last_change = $package->get_last_change();
return
$information . "\n" .
- $last_change->[Youri::Package::CHANGE_AUTHOR] . ":\n" .
- $last_change->[Youri::Package::CHANGE_TEXT];
+ $last_change->get_author() . ":\n" .
+ $last_change->get_raw_text();
}
diff --git a/lib/Youri/Submit/Action/Sign.pm b/lib/Youri/Submit/Action/Sign.pm
index f016351..d9580b8 100644
--- a/lib/Youri/Submit/Action/Sign.pm
+++ b/lib/Youri/Submit/Action/Sign.pm
@@ -19,6 +19,8 @@ use base qw/Youri::Submit::Action/;
sub _init {
my $self = shift;
my %options = (
+ signuser => 'signbot',
+ signscript => '/usr/bin/mga-signpackage',
name => '',
path => $ENV{HOME} . '/.gnupg',
passphrase => '',
@@ -32,17 +34,17 @@ sub _init {
$self->{_name} = $options{name};
$self->{_path} = $options{path};
$self->{_passphrase} = $options{passphrase};
+ $self->{_signuser} = $options{signuser};
+ $self->{_signscript} = $options{signscript};
}
sub run {
my ($self, $package, $repository, $target, $define) = @_;
croak "Not a class method" unless ref $self;
- $package->sign(
- $self->{_name},
- $self->{_path},
- $self->{_passphrase}
- ) unless $self->{_test};
+ if (! $self->{_test}) {
+ system('/usr/bin/sudo', '-u', $self->{_signuser}, $self->{_signscript}, $package->{_file}, $self->{_name}, $self->{_path}) == 0;
+ }
}
=head1 COPYRIGHT AND LICENSE
diff --git a/lib/Youri/Submit/Action/UpdateMaintDb.pm b/lib/Youri/Submit/Action/UpdateMaintDb.pm
new file mode 100644
index 0000000..10eed21
--- /dev/null
+++ b/lib/Youri/Submit/Action/UpdateMaintDb.pm
@@ -0,0 +1,80 @@
+# $Id$
+package Youri::Submit::Action::UpdateMaintDb;
+
+=head1 NAME
+
+Youri::Submit::Action::UpdateMaintDb - Mageia maintainers database updater
+
+=head1 DESCRIPTION
+
+This action plugin HTTP POSTs to package maintainers database to notify
+of the action. See <http://maintdb.mageia.org/>.
+
+=cut
+
+use warnings;
+use strict;
+use Carp;
+use base qw/Youri::Submit::Action/;
+
+use HTTP::Request::Common qw(POST);
+use LWP::UserAgent;
+
+sub _init {
+ my $self = shift;
+ my %options = (
+ maintdb_url => '',
+ maintdb_key => '',
+ @_
+ );
+
+ $self->{_maintdb_url} = $options{maintdb_url};
+ $self->{_maintdb_key} = $options{maintdb_key};
+
+ return $self;
+}
+
+sub run {
+ my ($self, $package, $repository, $target, $define) = @_;
+ croak "Not a class method" unless ref $self;
+
+ # only SRPMs matter
+ return unless $package->is_source();
+
+ unless ($self->{_test}) {
+ my $pkg_name = $package->get_name();
+ my $pkg_media = $repository->_get_main_section($package, $target, $define);
+ my $pkg_commiter = $define->{user};
+
+ my $ua = LWP::UserAgent->new;
+ $ua->agent('Youri/0.1 ' . $ua->agent);
+
+ my $req = POST $self->{_maintdb_url},
+ [
+ key => $self->{_maintdb_key},
+ from => "youri",
+ package => $pkg_name,
+ media => $pkg_media,
+ uid => $pkg_commiter
+ ];
+
+ my $res = $ua->request($req);
+
+ if ($res->is_success) {
+ print "Updated package maintainers DB for '$pkg_name', '$pkg_media', '$pkg_commiter'.\n" if $self->{_verbose};
+ } else {
+ print "ERROR: POST failed to ".$self->{_maintdb_url}." for '$pkg_name', '$pkg_media', '$pkg_commiter'.\n";
+ }
+ }
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2007, Mandriva
+Copyright (C) 2011, Mageia.Org
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1;
diff --git a/lib/Youri/Submit/Check/Deps.pm b/lib/Youri/Submit/Check/Deps.pm
new file mode 100644
index 0000000..0adcf37
--- /dev/null
+++ b/lib/Youri/Submit/Check/Deps.pm
@@ -0,0 +1,92 @@
+package Youri::Submit::Check::Deps;
+
+=head1 NAME
+
+Youri::Submit::Check::Deps - Check dependencies
+
+=head1 DESCRIPTION
+
+This check plugin rejects packages with unresolved dependencies.
+
+=cut
+
+use warnings;
+use strict;
+use Carp;
+use Youri::Media::URPM;
+use base qw/Youri::Submit::Check/;
+
+sub resolvedep {
+ my ($media, @requires) = @_;
+
+ my @errors;
+ my $index = sub {
+ my ($package) = @_;
+
+ my @provides = $package->get_provides();
+
+ @requires = grep {
+ my $require = $_;
+ my $notfound = 1;
+ foreach my $provide (@provides) {
+ next unless $provide->[Youri::Package::Relationship::NAME] eq $require->[Youri::Package::Relationship::NAME];
+ if ($require->[Youri::Package::Relationship::RANGE]) {
+ next unless $package->check_ranges_compatibility($provide->[Youri::Package::Relationship::RANGE], $require->[Youri::Package::Relationship::RANGE]);
+ }
+ $notfound = 0;
+ }
+
+ if ($notfound && $require->[Youri::Package::Relationship::NAME] =~ m|/|) {
+ foreach my $file ($package->get_files()) {
+ next unless $file eq $require->[Youri::Package::Relationship::NAME];
+ $notfound = 0;
+ last;
+ }
+ }
+ $notfound;
+ } @requires;
+ };
+ $media->traverse_headers($index);
+ foreach my $require (@requires) {
+ push (@errors, "Unresolved dep on " . $require->[Youri::Package::Relationship::NAME] . " " . $require->[Youri::Package::Relationship::RANGE]);
+ }
+ return @errors;
+}
+
+sub run {
+ my ($self, $package, $repository, $target, $define) = @_;
+ croak "Not a class method" unless ref $self;
+
+ # FIXME Define some Youri::Media with allowed_deps in the config and
+ # match target + section to a media
+ my $section = $repository->_get_section($package, $target, $define);
+ return unless $target eq "cauldron" && $section eq 'core/release';
+
+ my @requires = $package->get_requires();
+
+ my $path = $repository->get_install_root() . "/" . $target;
+ # FIXME we need dependencies on all archs except for ExclusiveArch
+ # Unfortunately some dependencies depend on the arch were the src.rpm was geenrated
+ # Currently src.rpm is generated on x86_64, so we need to check on that one
+ # If the package is not buildable on x86_64 we just don't test anything
+ my $arch = 'x86_64';
+ my @exclusivearchs = $package->get_tag("exclusivearchs");
+ return if @exclusivearchs && ! (grep {$_ eq $arch} @exclusivearchs);
+# foreach my $arch ($repository->get_extra_arches()) {
+ my $media = new Youri::Media::URPM(name => "core.".$arch,
+ type => "binary",
+ hdlist => "$path/$arch/media/$section/media_info/hdlist.cz");
+ return resolvedep($media, @requires);
+# }
+
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2011, YOURI project
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1;
diff --git a/lib/Youri/Submit/Post/CleanRpmsrate.pm b/lib/Youri/Submit/Post/CleanRpmsrate.pm
index 977e2a0..899c80f 100644
--- a/lib/Youri/Submit/Post/CleanRpmsrate.pm
+++ b/lib/Youri/Submit/Post/CleanRpmsrate.pm
@@ -33,7 +33,8 @@ sub run {
}
foreach my $arch (@changed) {
my $rpmsrate = "$root/$target/$arch/media/media_info/rpmsrate";
- my @media = "$root/$target/$arch/media/main/release";
+ # FIXME: have a method to get core/release instead of hardcoding it
+ my @media = "$root/$target/$arch/media/core/release";
system("cp", "$rpmsrate-raw", "$rpmsrate-new");
system("clean-rpmsrate", "$rpmsrate-new", @media);
system("mv", "-f", "$rpmsrate-new", $rpmsrate);
diff --git a/lib/Youri/Submit/Post/Mirror.pm b/lib/Youri/Submit/Post/Mirror.pm
new file mode 100644
index 0000000..961cc1e
--- /dev/null
+++ b/lib/Youri/Submit/Post/Mirror.pm
@@ -0,0 +1,55 @@
+# $Id: Gendistrib.pm 115367 2007-01-30 09:47:04Z pixel $
+package Youri::Submit::Post::Mirror;
+
+=head1 NAME
+
+Youri::Submit::Post::Mirror - synchronizes repository to mirror
+
+=head1 DESCRIPTION
+
+Calls genhdlist2
+
+=cut
+
+use warnings;
+use strict;
+use Carp;
+use base qw/Youri::Submit::Post/;
+
+sub _init {
+ my $self = shift;
+ my %options = (
+ destination => '',
+ @_
+ );
+
+ foreach my $var ('destination') {
+ $self->{"_$var"} = $options{$var};
+ }
+}
+
+sub run {
+ my ($self, $repository, $target, $define) = @_;
+ croak "Not a class method" unless ref $self;
+ my $root = $repository->get_install_root();
+
+ croak "Missing destination" unless $self->{'_destination'};
+
+
+ if (system("rsync -alH --delete $root/$target/ $self->{_destination}/$target/")) {
+ $self->{_error} = "Rsync command failed ($!)";
+ }
+
+ return;
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2010, Mageia
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1;
+