[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Distribution installer that defaults to Debian?



> On Fri, Dec 24, 2010 at 05:29:35PM +0200, Damyan Ivanov wrote:
> > Hm, would that be extended to support other distributions than 
> > Debian? If yes, having the generic code (including the detection of 
> > the distribution-specific module to load) in a generic module, and 
> > distribution specific code in corresponding module may be wanted.
> > 
> > CPAN::HybridInstaller - generic code
> > CPAN::HybridInstaller::Debian, CPAN::HybridInstaller::Fedora etc.

This is an appropriate name if the cpan client's methods 
themselves will be pulled in, i.e. 

CPAN::HybridInstaller::CPAN
CPAN::HybridInstaller::CPANPLUS
CPAN::HybridInstaller::CPANMINUS

A less encompassing relationship might leave the 
CPAN stuff separate. In that case, the 
distribution would be better named:

   CPAN::NativeInstaller

I'm advised to start with how the code will be called.

In the CPAN client (or native installer script):

    use CPAN::HybridInstaller;
    
    $nativeinstaller = CPAN::HybridInstaller->new();
	$cpaninstaller   = CPAN::HybridInstaller::CPAN->new();
    
    $pkg_name   = $nativeinstaller->find_perl_module_package('Something::Great')
    $version    = $nativeinstaller->upstream_version('libsomething-great-perl')
    $success    = $nativeinstaller->install('libsomething-great-perl')

	 $nativeinstaller->install('libsomething-great-perl')	
		or cpaninstaller->install('Something::Great')
    
	# native package search functionality
    @choices    = $installer->search(\@keywords,\@criteria);

And the library:
    
    package CPAN::HybridInstaller 

    use Module::Load::Conditional 'can_load';
    
    sub new {
    	my $os = detect_os(); # Debian, Fedora, etc.
    
    	   --and/or--
    
    	my $pkg_system = detect_pkg_system(); # apt, rpm, etc.
    
    	my $class = "CPAN::HybridInstaller::$os";
    	return unless can_load($class);
    	my $installer = $class->new(); 
    	return $installer
    }

As I'm new to a lot of this, I'll especially welcome any 
feedback.

Mele Kalikimaka :-)

-- 
Joel Roth


Reply to: