NAME

Slackware::Slackget - Main library for slack-get package manager 1.X

VERSION

Version 0.17

SYNOPSIS

slack-get (http://slackget.infinityperl.org and now http://www.infinityperl.org/category/slack-get) is an apt-get like tool for Slackware Linux. This bundle is the core library of this program.

The name Slackware::Slackget means slack-get 1.0 because this module is complely new and is for the 1.0 release. It is entierely object oriented, and require some other modules (like XML::Simple, Net::Ftp and LWP::Simple).

This module is still beta development version and I release it on CPAN only for coder which want to see the new architecture. For more informations, have a look on subclasses.

    use Slackware::Slackget;

    my $sgo = Slackware::Slackget->new(
    	-config => '/etc/slack-get/config.xml',
	-name => 'slack-getd',
	-version => '1.0.1228'
    );

CONSTRUCTOR

The constructor ( new() ), is used to instanciate all needed class for a slack-get instance.

new

You have to pass the followings arguments to the constructor :

-config => the name of the configuration file.
-name => ignored : for backward compatibility
-version => ignored : for backward compatibility

-name and -version arguments are passed to the constructor of the Slackware::Slackget::Log object.

slackware_version

Return the host's Slackware version as written in the /etc/slackware-version file.

if ( $sgo->slackware_version >= 12.0.0 ){
	print "Slackware distribution is ok, let's continue.\n";
}

FUNCTIONS

load_plugins

Search for all plugins in the followings directories : <all @INC directories>/lib/Slackware/Slackget/Plugin/, <INSTALLDIR>/lib/Slackware/Slackget/Plugin/, <HOME DIRECTORY>/lib/Slackware/Slackget/Plugin/.

When you call this method, she scan in thoses directory and try to load all files ending by .pm. The loading is in 4 times :

1) scan for plug-in

2) try to "require" all the finded modules.

3) Try to instanciate all modules successfully "require"-ed. To do that, this method call the new() method of the plug-in and passed the current Slackware::Slackget object reference. The internal code is like that :

# Slackware::Slackget::Plugin::MyPlugin is the name of the plug-in
# $self is the reference to the current Slackware::Slackget object.

my $plugin = Slackware::Slackget::Plugin::MyPlugin->new( $self ) ;

The plug-in can internally store this reference, and by the way acces to the instance of this objects : Slackware::Slackget, Slackware::Slackget::Base, Slackware::Slackget::Config, Slackware::Slackget::Network::Auth and Slackware::Slackget::PkgTools.

IN ALL CASE, PLUG-INS ARE NOT ALLOWED TO MODIFY THE Slackware::Slackget OBJECT !

For performance consideration we don't want to clone all accesible objects, so all plug-in developper will have to respect this rule : you never modify object accessible from this object ! At the very least if you have a good idea send me an e-mail to discuss it.

4) dispatch plug-ins' instance by supported HOOK.

Parameters :

1) An ARRAY reference on supported Hooks.

2) the type of plug-in you want to load.

Ex:

$sgo->load_plugins( ['HOOK_COMMAND_LINE_OPTIONS','HOOK_COMMAND_LINE_HELP','HOOK_START_DAEMON','HOOK_RESTART_DAEMON','HOOK_STOP_DAEMON'], 'daemon');

register_plugins

Register all plug-ins by supported calls.

Take a plug-in array reference and a hooks array reference in arguments.

$sgo->register_plugins(\@plugins, \@HOOKS) ;

Please read the code of the load_plugins() method to see how to set the object internal state.

call_plugins

Main method for calling back differents plug-in. This method is quite easy to use : just call it with a hook name in parameter.

call_plugins() will iterate on all plug-ins wich implements the given HOOK.

$sgo->call_plugins( 'HOOK_START_DAEMON' ) ;

Additionaly you can pass all arguments you need to pass to the callback which take care of the HOOK. All extra arguments are passed to the callback.

Since all plug-ins have access to many objects which allow them to perform all needed operations (like logging etc), they have to care about output and user information.

So all call will be eval-ed and juste a little log message will be done on error.

ACCESSORS

base

Return the Slackware::Slackget::Base object of the current instance of the Slackware::Slackget object.

$sgo->base()->compil_package_directory('/var/log/packages/');

pkgtools

Return the Slackware::Slackget::PkgTools object of the current instance of the Slackware::Slackget object.

$sgo->pkgtools()->install( $package_list ) ;

removepkg(<some package>)

Alias for :

$sgo->pkgtools()->remove(<some package>);

installpkg(<some package>)

Alias for :

$sgo->pkgtools()->install(<some package>);

upgradepkg(<some package>)

Alias for :

$sgo->pkgtools()->upgrade(<some package>);

config

Return the Slackware::Slackget::Config object of the current instance of the Slackware::Slackget object.

print $sgo->config()->{common}->{'file-encoding'} ;

get_config_token

A wrapper method to get a configuration key. This method call the Slackware::Slackget::Config->get_token() method.

SO YOU HAVE TO COMPLY WITH THIS SYNTAX !

print "Official media is: ",$sgo->get_config_token('/daemon/official-media'),"\n";

set_config_token

A wrapper method to set a configuration key. This method call the Slackware::Slackget::Config->set_token() method.

SO YOU HAVE TO COMPLY WITH THIS SYNTAX !

$sgo->set_config_token('/daemon/official-media','slackware-12.0');

auth

Return the Slackware::Slackget::Network::Auth object of the current instance of the Slackware::Slackget object.

$sgo->auth()->can_connect($client) or die "Client not allowed to connect here\n";

AUTHOR

DUPUIS Arnaud, <a.dupuis@infinityperl.org>

BUGS

Please report any bugs or feature requests to bug-Slackware-Slackget@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Slackware::Slackget

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.

COPYRIGHT & LICENSE

Copyright 2005 DUPUIS Arnaud, All Rights Reserved.

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