| 1 | # | ||
| 2 | # This file is part of App-Magpie | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2011 by Jerome Quelin. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | 8 | ▶ | use 5.012; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 8 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | package App::Magpie::URPM; | ||
| 14 | # ABSTRACT: magpie interface to L<URPM> | ||
| 15 | $App::Magpie::URPM::VERSION = '2.010'; | ||
| 16 | 8 | ▶ | use MooseX::Singleton; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 8 | ▶ | use MooseX::Has::Sugar; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 0 | ▶ | use URPM; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 19 | |||
| 20 | with "App::Magpie::Role::Logging"; | ||
| 21 | |||
| 22 | |||
| 23 | # -- private attributes | ||
| 24 | |||
| 25 | |||
| 26 | has _urpm => ( | ||
| 27 | ro, lazy_build, | ||
| 28 | isa => "URPM", | ||
| 29 | handles => { | ||
| 30 | packages => "packages_by_name", | ||
| 31 | }, | ||
| 32 | ); | ||
| 33 | |||
| 34 | |||
| 35 | # -- initialization | ||
| 36 | |||
| 37 | sub _build__urpm { | ||
| 38 | my ($self) = @_; | ||
| 39 | |||
| 40 | my $urpm = URPM->new; | ||
| 41 | my @hdlists = glob "/var/lib/urpmi/*/synthesis.hdlist.cz"; | ||
| 42 | |||
| 43 | foreach my $hdlist ( @hdlists ) { | ||
| 44 | $self->log_debug( "parsing $hdlist" ); | ||
| 45 | $urpm->parse_synthesis( $hdlist ); | ||
| 46 | } | ||
| 47 | |||
| 48 | return $urpm; | ||
| 49 | } | ||
| 50 | |||
| 51 | # -- public methods | ||
| 52 | |||
| 53 | |||
| 54 | sub packages_providing { | ||
| 55 | my ($self, $module) = @_; | ||
| 56 | return $self->_urpm->packages_providing("perl($module)"); | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ | ||