diff options
author | Pascal Terjan <pterjan@mageia.org> | 2011-01-07 08:07:11 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@mageia.org> | 2011-01-07 08:07:11 +0000 |
commit | abc9a802404902718dc808fdce36f226533f02de (patch) | |
tree | fc46dc3b0da9bf9fead8a50c9a6a3d8a5e27a75a /lib/Youri/Submit/Reject | |
download | mga-youri-submit-abc9a802404902718dc808fdce36f226533f02de.tar mga-youri-submit-abc9a802404902718dc808fdce36f226533f02de.tar.gz mga-youri-submit-abc9a802404902718dc808fdce36f226533f02de.tar.bz2 mga-youri-submit-abc9a802404902718dc808fdce36f226533f02de.tar.xz mga-youri-submit-abc9a802404902718dc808fdce36f226533f02de.zip |
get_file_name returns a full path, which Install does not like
Diffstat (limited to 'lib/Youri/Submit/Reject')
-rw-r--r-- | lib/Youri/Submit/Reject/Archive.pm | 61 | ||||
-rw-r--r-- | lib/Youri/Submit/Reject/Clean.pm | 36 | ||||
-rw-r--r-- | lib/Youri/Submit/Reject/Install.pm | 63 | ||||
-rw-r--r-- | lib/Youri/Submit/Reject/Mail.pm | 112 |
4 files changed, 272 insertions, 0 deletions
diff --git a/lib/Youri/Submit/Reject/Archive.pm b/lib/Youri/Submit/Reject/Archive.pm new file mode 100644 index 0000000..e90bc19 --- /dev/null +++ b/lib/Youri/Submit/Reject/Archive.pm @@ -0,0 +1,61 @@ +# $Id: Archive.pm 4747 2007-01-30 10:02:41Z pixel $ +package Youri::Submit::Reject::Install; + +=head1 NAME + +Youri::Submit::Action::Archive - Old revisions archiving + +=head1 DESCRIPTION + +This action plugin ensures archiving of old package revisions. + +=cut + +use warnings; +use strict; +use Carp; +use base qw/Youri::Submit::Reject/; + +sub _init { + my $self = shift; + my %options = ( + perms => 644, + @_ + ); + + $self->{_perms} = $options{perms}; + + return $self; +} + +sub run { + my ($self, $package, $errors, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + my $file = $package->get_file(); + my $rpm = $package->get_file_name(); + my $dest = $repository->get_reject_dir($package, $target, $define); + + # FIXME remove prefix this should be done by a function + $rpm =~ s/^\d{14}\.\w+\.\w+\.\d+_//; + print "installing file $file to $dest/$rpm\n" ;#if $self->{_verbose}; + + unless ($self->{_test}) { + # create destination dir if needed + system("install -d -m " . ($self->{_perms} + 111) . " $dest/") + unless -d $dest; + + # install file to new location + system("install -m $self->{_perms} $file $dest/$rpm"); + } +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2002-2006, 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/Reject/Clean.pm b/lib/Youri/Submit/Reject/Clean.pm new file mode 100644 index 0000000..9d6d003 --- /dev/null +++ b/lib/Youri/Submit/Reject/Clean.pm @@ -0,0 +1,36 @@ +# $Id: Clean.pm 4747 2007-01-30 10:02:41Z pixel $ +package Youri::Submit::Reject::Clean; + +=head1 NAME + +Youri::Submit::Action::Clean - Old revisions cleanup + +=head1 DESCRIPTION + +This action plugin ensures cleanup of old package revisions. + +=cut + +use warnings; +use strict; +use Carp; +use base qw/Youri::Submit::Reject/; + +sub run { + my ($self, $package, $errors, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + my $file = $package->get_file(); + print "deleting file $file\n" if $self->{_verbose}; + unlink $file unless $self->{_test}; +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2002-2006, 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/Reject/Install.pm b/lib/Youri/Submit/Reject/Install.pm new file mode 100644 index 0000000..f5215d1 --- /dev/null +++ b/lib/Youri/Submit/Reject/Install.pm @@ -0,0 +1,63 @@ +# $Id: Install.pm 4747 2007-01-30 10:02:41Z pixel $ +package Youri::Submit::Reject::Install; + +=head1 NAME + +Youri::Submit::Action::Archive - Old revisions archiving + +=head1 DESCRIPTION + +This action plugin ensures archiving of old package revisions. + +=cut + +use warnings; +use strict; +use Carp; +use base qw/Youri::Submit::Reject/; + +sub _init { + my $self = shift; + my %options = ( + perms => 644, + @_ + ); + + $self->{_perms} = $options{perms}; + $self->{_verbose} = $options{verbose}; +} + +sub run { + my ($self, $package, $errors, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + my $file = $package->get_file(); + my $rpm = $package->get_file_name(); + my $dest = $repository->get_reject_path($package, $target, $define); + + # FIXME remove prefix this should be done by a function + $rpm =~ s/^\d{14}\.\w+\.\w+\.\d+_//; + print "installing file $file to $dest/$rpm\n" if $self->{_verbose}; + + unless ($self->{_test}) { + # create destination dir if needed + system("install -d -m " . ($self->{_perms} + 111) . " $dest/") + unless -d $dest; + + # install file to new location + system("install -m $self->{_perms} $file $dest/$rpm"); + } + $package->{_file} = "$dest/$rpm"; + print "deleting file $file\n" if $self->{_verbose}; + unlink $file unless $self->{_test}; +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2002-2006, 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/Reject/Mail.pm b/lib/Youri/Submit/Reject/Mail.pm new file mode 100644 index 0000000..6fa50f7 --- /dev/null +++ b/lib/Youri/Submit/Reject/Mail.pm @@ -0,0 +1,112 @@ +# $Id: Mail.pm 223952 2007-06-23 13:54:13Z pixel $ +package Youri::Submit::Reject::Mail; + +=head1 NAME + +Youri::Submit::Action::Mail - Mail notification + +=head1 DESCRIPTION + +This action plugin ensures mail notification of new package revisions. + +=cut + +use warnings; +use strict; +use MIME::Entity; +use Encode qw/from_to/; +use Carp; +use Youri::Package; +use base qw/Youri::Submit::Reject/; + +sub _init { + my $self = shift; + my %options = ( + mta => '/usr/sbin/sendmail', + to => '', + from => '', + cc => '', + prefix => '', + encoding => 'quoted-printable', + charset => 'iso-8859-1', + @_ + ); + + croak "undefined mail MTA" unless $options{mta}; + croak "invalid mail MTA $options{mta}" unless -x $options{mta}; + croak "undefined to" unless $options{to}; + if ($options{cc}) { + croak "cc should be an hashref" unless ref $options{cc} eq 'HASH'; + } + croak "invalid charset $options{charset}" + unless Encode::resolve_alias($options{charset}); + + $self->{_mta} = $options{mta}; + $self->{_to} = $options{to}; + $self->{_from} = $options{from}; + $self->{_cc} = $options{cc}; + $self->{_prefix} = $options{prefix}; + $self->{_encoding} = $options{encoding}; + $self->{_charset} = $options{charset}; +} + +sub run { + my ($self, $package, $errors, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + my $section = $repository->_get_section($package, $target, $define); + + my $subject = + ($self->{_prefix} ? '[' . $self->{_prefix} . '] ' : '' ) . ($section ? "$section " : '') . + $package->get_revision_name(); + my $information = $package->get_information(); + my $last_change = $package->get_last_change(); + my $author = $last_change->[Youri::Package::CHANGE_AUTHOR] if $last_change; + my $list = $last_change->[Youri::Package::CHANGE_TEXT] if $last_change; + my $content = + "Errors: \n\n" . join("\n", map { + ( "* $_", (map { " - $_" } @{$errors->{$_}}), "\n"); + } sort(keys %$errors)) . "\n" . + $information . "\n" . + $author . ":\n$list"; + + # ensure proper codeset conversion + # for informations coming from package + my $charset = $repository->get_package_charset(); + from_to($content, $charset, $self->{_charset}); + from_to($subject, $charset, $self->{_charset}); + + my $mail = MIME::Entity->build( + Type => 'text/plain', + Charset => $self->{_charset}, + Encoding => $self->{_encoding}, + From => $self->{_from}, + To => $self->{_to}, + Subject => $subject, + Data => $content, + ); + + if ($self->{_cc}) { + my $cc = $self->{_cc}->{$package->get_name()}; + $mail->head()->add('cc', $cc) if $cc; + } + + if ($self->{_test}) { + $mail->print(\*STDOUT); + } else { + open(MAIL, "| $self->{_mta} -t -oi -oem") or die "Can't open MTA program: $!"; + $mail->print(\*MAIL); + close MAIL; + } + +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2002-2006, YOURI project + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; |