App-CPAN2Pkg

 view release on metacpan or  search on metacpan

lib/App/CPAN2Pkg/Worker/Mageia.pm  view on Meta::CPAN

    };
}

{   # install_from_upstream
    override install_from_upstream => sub {
        super();
        $K->yield( get_rpm_lock => "_install_from_upstream_with_rpm_lock" );
    };

    #
    # _install_from_upstream_with_rpm_lock( )
    #
    # really install module from distribution, now that we have a lock
    # on rpm operations.
    #
    event _install_from_upstream_with_rpm_lock => sub {
        my $self = shift;
        my $modname = $self->module->name;
        my $cmd = "sudo urpmi --auto 'perl($modname)'";
        $self->run_command( $cmd => "_install_from_upstream_result" );
    };
}

{ # upstream_import_package
    override upstream_import_package => sub {
        super();
        my $self = shift;
        my $srpm = $self->srpm;
        my $cmd = "mgarepo import $srpm";
        $self->run_command( $cmd => "_upstream_import_package_result" );
    };
}

{ # upstream_build_package
    override upstream_build_package => sub {
        super();
        my $self = shift;
        my $pkgname = $self->pkgname;
        my $cmd = "mgarepo submit $pkgname";
        $self->run_command( $cmd => "_upstream_build_package_result" );
    };

    override _upstream_build_wait => sub {
        my $self = shift;
        $self->yield( "_upstream_build_wait_request" );
    };

    event _upstream_build_wait_request => sub {
        my $self = shift;
        my $pkgname = $self->pkgname;
        my $url = "http://pkgsubmit.mageia.org/?package=$pkgname&last";
        my $request = HTTP::Request->new(HEAD => $url);
        $K->post( $self->_ua => request => _upstream_build_wait_answer => $request );
    };

    event _upstream_build_wait_answer => sub {
        my ($self, $requests, $answers) = @_[OBJECT, ARG0, ARG1];
        my $answer = $answers->[0];
        my $status = $answer->header( 'x-bs-package-status' ) // "?";
        my $modname = $self->module->name;
        if ($status eq "uploaded") {
            # nice, we finally made it!
            my $min = 1;
            $K->post( main => log_comment => $modname =>
                "module successfully built, waiting $min minutes to index it" );
            # wait some time to be sure package has been indexed
            $K->delay( _upstream_build_package_ready => $min * 60 );
        }
        elsif ($status eq "failure" ) {
            my $url = "http://pkgsubmit.mageia.org/";
            $self->yield( _upstream_build_package_failed => $url );
        }
        else {
            # no definitive result, wait a bit before checking again
            $K->post( main => log_comment => $modname =>
                "still not ready (current status: $status), waiting 1 more minute" );
            $K->delay( _upstream_build_wait_request => 60 );
        }

    };
}


no Moose;
__PACKAGE__->meta->make_immutable;
1;

__END__

=pod

=head1 NAME

App::CPAN2Pkg::Worker::Mageia - worker dedicated to Mageia distribution

=head1 VERSION

version 3.004

=head1 DESCRIPTION

This class implements Mageia specificities that a general worker doesn't
know how to handle. It inherits from L<App::CPAN2Pkg::Worker::RPM>.

=head1 AUTHOR

Jerome Quelin <jquelin@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2009 by Jerome Quelin.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 2.391 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )