diff options
-rw-r--r-- | lib/Youri/Submit/Action/RebuildPackage.pm | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/Youri/Submit/Action/RebuildPackage.pm b/lib/Youri/Submit/Action/RebuildPackage.pm new file mode 100644 index 0000000..d121090 --- /dev/null +++ b/lib/Youri/Submit/Action/RebuildPackage.pm @@ -0,0 +1,60 @@ +# $Id$ +package Youri::Submit::Action::RebuildPackage; + +=head1 NAME + +Youri::Submit::Action::RebuildPackage - rebuild packages dependant on this one + +=head1 DESCRIPTION + +This action plugin rebuilds some packages dependant on this one + +=cut + +use warnings; +use strict; +use Carp; +use File::Temp; +use Youri::Package::RPM::Updater; +use base qw/Youri::Submit::Action/; + +sub _init { + my $self = shift; + my %options = (@_); + + $self->{'rules'} = $options{'rules'}; + + return $self; +} + +sub run { + my ($self, $package, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + $package->is_source or return 1; + my $srpm_name = $package->get_canonical_name; + my @packages = $self->{rules}{$srpm_name} or return 1; + my $svn = $repository->get_svn_url(); + my $updater = Youri::Package::RPM::Updater->new; + my $oldcwd = getcwd(); + foreach my $pkg (@packages) { + my $tmpdir = File::Temp->newdir; + chdir $tmpdir->dirname; + system('svn', 'co', "${svn}/${pkg}/current"); + chdir 'current'; + $updater->update_from_spec(glob('SPECS/*.spec')); + system('svn', 'ci', '-m', "Rebuild for new $srpm_name"); + system("mgarepo submit &"); + chdir $oldcwd; + } +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2013, Mageia project + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; |