diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Youri/Submit/Action/Archive.pm | 11 | ||||
-rw-r--r-- | lib/Youri/Submit/Action/Install.pm | 3 | ||||
-rw-r--r-- | lib/Youri/Submit/Action/Mail.pm | 17 | ||||
-rw-r--r-- | lib/Youri/Submit/Action/Sign.pm | 12 | ||||
-rw-r--r-- | lib/Youri/Submit/Action/UpdateMaintDb.pm | 80 | ||||
-rw-r--r-- | lib/Youri/Submit/Check/Deps.pm | 92 | ||||
-rw-r--r-- | lib/Youri/Submit/Post/CleanRpmsrate.pm | 3 | ||||
-rw-r--r-- | lib/Youri/Submit/Post/Mirror.pm | 55 |
8 files changed, 252 insertions, 21 deletions
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; + |