2 # This file is part of App::CPAN2Pkg.
3 # Copyright (c) 2009 Jerome Quelin, all rights reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the same terms as Perl itself.
10 package App
::CPAN2Pkg
;
15 use App
::CPAN2Pkg
::Module
;
17 constructor
=> '_new',
19 _complete
=> '_complete',
20 _missing
=> '_missing',
26 our $VERSION = '0.2.2';
29 my ($class, $opts) = @_;
31 my $obj = App
::CPAN2Pkg
->_new(
37 my $session = POE
::Session
->create(
40 upstream_status
=> \
&upstream_status
,
41 install_status
=> \
&install_status
,
42 module_spawned
=> \
&module_spawned
,
45 upstream_install
=> \
&upstream_install
,
48 _stop
=> sub { warn "stop"; },
62 # if ( not available in cooker ) is_in_dist
64 # compute dependencies find_prereqs
65 # repeat with each dep
67 # install local install_from_local
68 # while ( not available locally ) is_installed
70 # prompt user to fix manually
72 # import import_local_to_dist
73 # submit (included above)
74 # ack available (manual?)
77 # urpmi --auto perl(module::to::install) install_from_dist
83 my ($k, $module, $is_installed) = @_[KERNEL
, ARG0
, ARG1
];
85 if ( not $is_installed ) {
86 $k->post($module, 'is_in_dist');
90 $k->post('ui', 'module_available', $module);
95 my ($k, $h, $module) = @_[KERNEL
, HEAP
, ARG0
];
96 my $name = $module->name;
97 $h->_module->{$name} = $module;
98 $k->post($module, 'is_installed');
102 my ($k, $h, $module) = @_[KERNEL
, HEAP
, ARG0
];
103 App
::CPAN2Pkg
::Module
->spawn($module);
107 my ($k, $h, $module, @prereqs) = @_[KERNEL
, HEAP
, ARG0
..$#_];
110 foreach my $m ( @prereqs ) {
111 # check if module is new. in which case, let's treat it.
112 $k->yield('package', $m) unless exists $h->_module->{$m};
114 # store missing module.
115 push @missing, $m unless exists $h->_complete->{$m};
119 # module misses some prereqs - wait for them.
120 my $name = $module->name;
121 $h->_missing->{$name}{$_} = 1 for @missing;
122 $h->_prereq->{$_}{$name} = 1 for @missing;
125 # no prereqs, move on
126 $k->yield('prereqs_completed', $module);
131 sub upstream_install
{
132 my ($k, $module, $success) = @_[KERNEL
, ARG0
, ARG1
];
136 sub upstream_status
{
137 my ($k, $module, $is_available) = @_[KERNEL
, ARG0
, ARG1
];
138 my $event = $is_available ?
'install_from_dist' : 'find_prereqs';
139 $k->post($module, $event);
143 # -- poe inline states
146 my ($k, $opts) = @_[KERNEL
, ARG0
];
147 $k->alias_set('app');
149 # start packaging some modules
150 my $modules = $opts->{modules
};
151 $k->yield('package', $_) for @
$modules;
160 App::CPAN2Pkg - generating native linux packages from cpan
167 $ cpan2pkg Module::Foo Module::Bar ...
173 Don't use this module directly, refer to the C<cpan2pkg> script instead.
175 C<App::CPAN2Pkg> is the controller for the C<cpan2pkg> application. It
176 implements a POE session, responsible to schedule and advance module
179 It is spawned by the poe session responsible for the user interface.
183 =head1 PUBLIC PACKAGE METHODS
185 =head2 my $id = App::CPAN2Pkg->spawn( \%params )
187 This method will create a POE session responsible for coordinating the
190 It will return the POE id of the session newly created.
192 You can tune the session by passing some arguments as a hash
193 reference, where the hash keys are:
197 =item * modules => \@list_of_modules
199 A list of modules to start packaging.
206 =head1 PUBLIC EVENTS ACCEPTED
208 The following events are the module's API.
211 =head2 install_status( $module, $is_installed )
213 Sent when C<$module> knows whether it is installed locally (C<$is_installed>
217 =head2 module_spawned( $module )
219 Sent when C<$module> has been spawned successfully.
222 =head2 package( $module )
224 Request the application to package (if needed) the perl C<$module>. Note
225 that the module can be either the top-most module of a distribution or
226 deep inside said distribution.
229 =head2 prereqs( $module, @prereqs )
231 Inform main application that C<$module> needs some C<@prereqs> (possibly
235 =head2 upstream_install( $module, $success )
237 Sent after trying to install C<$module> from upstream dist. Result is passed
238 along with C<$success>.
241 =head2 upstream_status( $module, $is_available )
243 Sent when C<$module> knows whether it is available upstream (C<$is_available>
250 Please report any bugs or feature requests to C<app-cpan2pkg at
251 rt.cpan.org>, or through the web interface at
252 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-CPAN2Pkg>. I will
253 be notified, and then you'll automatically be notified of progress on
254 your bug as I make changes.
260 Our git repository is located at L<git://repo.or.cz/app-cpan2pkg.git>,
261 and can be browsed at L<http://repo.or.cz/w/app-cpan2pkg.git>.
264 You can also look for information on this module at:
268 =item * AnnoCPAN: Annotated CPAN documentation
270 L<http://annocpan.org/dist/App-CPAN2Pkg>
274 L<http://cpanratings.perl.org/d/App-CPAN2Pkg>
278 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-CPAN2Pkg>
286 Jerome Quelin, C<< <jquelin@cpan.org> >>
290 =head1 COPYRIGHT & LICENSE
292 Copyright (c) 2009 Jerome Quelin, all rights reserved.
294 This program is free software; you can redistribute it and/or modify
295 it under the same terms as Perl itself.