From 7f23105fffc1c5f0149ff44b6560d089dfaa47ea Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Thu, 24 Mar 2011 16:25:37 +0000 Subject: Add action to notify maintainers database of a package upload --- lib/Youri/Submit/Action/UpdateMaintDb.pm | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 lib/Youri/Submit/Action/UpdateMaintDb.pm diff --git a/lib/Youri/Submit/Action/UpdateMaintDb.pm b/lib/Youri/Submit/Action/UpdateMaintDb.pm new file mode 100644 index 0000000..3af27f6 --- /dev/null +++ b/lib/Youri/Submit/Action/UpdateMaintDb.pm @@ -0,0 +1,81 @@ +# $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 . + +=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); + $package->get_packager() =~ m/(\w[-_.\w]+\@[-_.\w]+)\W/; + my $pkg_commiter = $1; + + $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; -- cgit v1.2.1