diff options
author | Olivier Blin <blino@mageia.org> | 2011-04-04 22:59:01 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2011-04-04 22:59:01 +0000 |
commit | 699c5e78d5512a2779ce834882cfdda895db32b1 (patch) | |
tree | 0e1d060beb87008d7e266d6fbafb071c8bce10e9 /lib/Youri/Submit/Action/UpdateMaintDb.pm | |
parent | b06110139b89597dbe34d33b907538c93991bfe4 (diff) | |
parent | 51d5d4e7a0d1d1cca9a5214782575b5f8aa7aa8b (diff) | |
download | mga-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
Diffstat (limited to 'lib/Youri/Submit/Action/UpdateMaintDb.pm')
-rw-r--r-- | lib/Youri/Submit/Action/UpdateMaintDb.pm | 80 |
1 files changed, 80 insertions, 0 deletions
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; |