Slackware::Slackget::Package - This class is the internal representation of a package for slack-get 1.0


Slackware-Slackget documentation  | view source Contained in the Slackware-Slackget distribution.

Index


NAME

Top

Slackware::Slackget::Package - This class is the internal representation of a package for slack-get 1.0

VERSION

Top

Version 1.0.3

SYNOPSIS

Top

This module is used to represent a package for slack-get

    use Slackware::Slackget::Package;

    my $package = Slackware::Slackget::Package->new('package-1.0.0-noarch-1');
    $package->set_value('description',"This is a test of the Slackware::Slackget::Package object");
    $package->fill_object_from_package_name();

This class inheritate from Slackware::Slackget::MD5, so you can use :

	$sgo->installpkg($package) if($package->verify_md5);

Isn't it great ?

CONSTRUCTOR

Top

new

The constructor take two parameters : a package name, and an id (the namespace of the package like 'slackware' or 'linuxpackages')

	my $package = new Slackware::Slackget::Package ('aaa_base-10.0.0-noarch-1','slackware');

The constructor automatically call the fill_object_from_package_name() method.

You also can pass some extra arguments like that :

	my $package = new Slackware::Slackget::Package ('aaa_base-10.0.0-noarch-1', 'package-object-version' => '1.0.0');

The constructor return undef if the id is not defined.

FUNCTIONS

Top

merge

This method merge $another_package with $package.

** WARNING ** : $another_package will be destroy in the operation (this is a collateral damage ;-), for some dark preocupation of memory.

** WARNING 2 ** : the merge keep the id from $package, this mean that an inconsistency can be found between the id and the version number.

This method overwrite existing value.

	$package->merge($another_package);

is_heavy_word

This method return true (1) if the first argument is an "heavy word" and return false (0) otherwise.

	print "heavy word found !\n" if($package->is_heavy_word($request[$i]));

get_statistic

Return a given statistic about the description of the package. Currently available are : dwc (description words count) and hw (heavy words, a list of important words).

Those are for the optimisation of the search speed.

compare_version

This method take another Slackware::Slackget::Package as argument and compare it's version to the current object.

	if( $package->compare_version( $another_package ) == -1 )
	{
		print $another_package->get_id," is newer than ",$package->get_id ,"\n";
	}

Returned code :

	-1 => $package version is lesser than $another_package's one
	0 => $package version is equal to $another_package's one
	1 => $package version is greater than $another_package's one
	undef => an error occured.

fill_object_from_package_name

Try to extract the maximum informations from the name of the package. The constructor automatically call this method.

	$package->fill_object_from_package_name();

extract_informations

Extract informations about a package from a string. This string must be a line of the description of a package.

	$package->extract_informations($data);

This method is designe to be called by the Slackware::Slackget::SpecialFiles::PACKAGES class, and automatically call the clean_description() method.

clean_description

remove the "<package_name>: " string in front of each line of the description. Remove extra tabulation (for identation).

	$package->clean_description();

grab_info_from_description

Try to find some informations in the description. For example, packages from linuxpackages.net contain a line starting by Packager: ..., this method will extract this information and re-set the package-maintener tag.

The supported tags are: package-maintener, info-destination-slackware, info-packager-mail, info-homepage, info-packager-tool, info-packager-tool-version

	$package->grab_info_from_description();

to_XML (deprecated)

Same as to_xml(), provided for backward compatibility.

to_xml

return the package as an XML encoded string.

	$xml = $package->to_xml();

to_string

Return a string describing the package using the official Slackware text based semantic.

	my $text = $package->to_string();

In this case, $text contains something like that :

	PACKAGE NAME:  test_package-1.0-i486-1.tgz 
	PACKAGE LOCATION:  ./path/to/test_package/
	PACKAGE SIZE (compressed):  677 K
	PACKAGE SIZE (uncompressed):  1250 K
	PACKAGE REQUIRED:  acl >= 2.2.47_1-i486-1,attr >= 2.4.41_1-i486-1,cxxlibs >= 6.0.9-i486-1 | gcc-g++ >= 4.2.3-i486-1,expat >= 2.0.1-i486-1,fontconfig >= 2.4.2-i486-2,freetype >= 2.3.5-i486-1,
	PACKAGE CONFLICTS:  
	PACKAGE SUGGESTS:  
	PACKAGE DESCRIPTION:
	test_package: Test Package
	test_package:
	test_package: Test Package is a package for testing
	test_package: the slack-get API.
	test_package:

WARNING: This method behavior have changed compare to previous versions.

to_HTML (deprecated)

Same as to_html(), provided for backward compatibility.

to_html

return the package as an HTML string

	my $html = $package->to_html ;

Note: I have design this method for 2 reasons. First for an easy integration of the search result in a GUI, second for my website search engine. So this HTML may not satisfy you. In this case just generate new HTML from accessors ;-)

PRINTING METHODS

Top

fprint_restricted_info

Same as print_restricted_info, but output in HTML

	$package->fprint_restricted_info();

fprint_full_info

Same as print_full_info, but output in HTML

	$package->fprint_full_info();

ACCESSORS

Top

set_value

Set the value of a named key to the value passed in argument.

	$package->set_value($key,$value);

Return $value (for integrity check).

setValue (deprecated)

Same as set_value(), provided for backward compatibility.

getValue (deprecated)

Same as get_value(), provided for backward compatibility.

get_value

Return the value of a key :

	$string = $package->get_value($key);

status

Return the current status of the package object as a Slackware::Slackget::Status object. This object is set by other class, and in most case you don't have to set it by yourself.

	print "The current status for ",$package->name," is ",$package->status()->to_string,"\n";

You also can set the status, by passing a Slackware::Slackget::Status object, to this method.

	$package->status($status_object);

This method return 1 if all goes well and undef else.

add_dependency

Add a dependency to the package. Parameters are :

* the type of dependency between : required, suggested, conflicts * the dependency as a hashref containing the following keys : pkg_name (mandatory), comparison_type and required_version (optional).

	$package->add_dependency('required',{pkg_name => 'gcc', comparison_type => '>=', required_version => '4.2'}) ;

If you want to let a choice between 2 or more dependencies (like between cxxlibs and gcc-g++), use an arrayref which contains as mush hashref as needed :

	$package->add_dependency('required',[{pkg_name => 'gcc-g++', comparison_type => '>=', required_version => '4.2.3'},{pkg_name => 'cxxlibs', comparison_type => '>=', required_version => '6.0.9'}]) ;

_setId [PRIVATE]

set the package ID (normally the package complete name, like aaa_base-10.0.0-noarch-1). In normal use you don't need to use this method

	$package->_setId('aaa_base-10.0.0-noarch-1');

get_id

return the package id (full name, like aaa_base-10.0.0-noarch-1).

	$string = $package->get_id();

description

return the description of the package.

	$string = $package->description();

filelist

return the list of files in the package. WARNING: by default this list is not included !

	$string = $package->filelist();

name

return the name of the package. Ex: for the package aaa_base-10.0.0-noarch-1 name() will return aaa_base

	my $string = $package->name();

compressed_size

return the compressed size of the package

	$number = $package->compressed_size();

uncompressed_size

return the uncompressed size of the package

	$number = $package->uncompressed_size();

location

return the location of the installed package.

	$string = $package->location();

conflicts

return the list of conflicting pakage.

	$string = $package->conflicts();

suggested

return the suggested package related to the current package.

	$string = $package->suggested();

required

return the required packages for installing the current package

	$string = $package->required();

architecture

return the architecture the package is compiled for.

	$string = $package->architecture();

version

return the package version.

	$string = $package->version();

get_fields_list

return a list of all fields of the package. This method is suitable for example in GUI for displaying informations on packages.

	foreach my $field ( $package->get_fields_list )
	{
		qt_textbrowser->append( "<b>$field</b> : ".$package->getValue( $field )."<br/>\n" ) ;
	}

AUTHOR

Top

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

BUGS

Top

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

Top

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

    perldoc Slackware::Slackget::Package




You can also look for information at:

* Infinity Perl website

http://www.infinityperl.org/category/slack-get

* slack-get specific website

http://slackget.infinityperl.org

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Slackware-Slackget

* CPAN Ratings

http://cpanratings.perl.org/d/Slackware-Slackget

* Search CPAN

http://search.cpan.org/dist/Slackware-Slackget

ACKNOWLEDGEMENTS

Top

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

SEE ALSO

Top

COPYRIGHT & LICENSE

Top


Slackware-Slackget documentation  | view source Contained in the Slackware-Slackget distribution.