slackget10::Package - This class is the internal representation of a package for slack-get 1.0
Version 1.0.1
This module is used to represent a package for slack-get
use slackget10::Package; my $package = slackget10::Package->new('package-1.0.0-noarch-1'); $package->setValue('description',"This is a test of the slackget10::Package object"); $package->fill_object_from_package_name();
This class inheritate from slackget10::MD5, so you can use :
$sgo->installpkg($package) if($package->verify_md5);
Isn't it great ?
The constructor take two parameters : a package name, and an id (the namespace of the package like 'slackware' or 'linuxpackages')
my $package = new slackget10::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 slackget10::Package ('aaa_base-10.0.0-noarch-1', 'package-object-version' => '1.0.0');
The constructor return undef if the id is not defined.
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.
This method overwrite existing value.
$package->merge($another_package);
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]));
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.
This method take another slackget10::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.
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 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 slackget10::SpecialFiles::PACKAGES class, and automatically call the clean_description() method.
remove the "<package_name>: " string in front of each line of the description. Remove extra tabulation (for identation).
$package->clean_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();
return the package as an XML encoded string.
$xml = $package->to_XML();
Alias for to_XML()
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 ;-)
Print a part of package information.
$package->print_restricted_info();
Print all informations found in the package.
$package->print_full_info();
Same as print_restricted_info, but output in HTML
$package->fprint_restricted_info();
Same as print_full_info, but output in HTML
$package->fprint_full_info();
Set the value of a named key to the value passed in argument.
$package->setValue($key,$value);
Return the value of a key :
$string = $package->getValue($key);
Return the current status of the package object as a slackget10::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 slackget10::Status object, to this method.
$package->status($status_object);
This method return 1 if all goes well and undef else.
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');
return the package id (full name, like aaa_base-10.0.0-noarch-1).
$string = $package->get_id();
return the description of the package.
$string = $package->description();
return the list of files in the package. WARNING: by default this list is not included !
$string = $package->filelist();
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();
return the compressed size of the package
$number = $package->compressed_size();
return the uncompressed size of the package
$number = $package->uncompressed_size();
return the location of the installed package.
$string = $package->location();
return the list of conflicting pakage.
$string = $package->conflict();
return the suggested package related to the current package.
$string = $package->suggest();
return the required packages for installing the current package
$string = $package->required();
return the architecture the package is compiled for.
$string = $package->architecture();
return the package version.
$string = $package->version();
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" ) ; }
DUPUIS Arnaud, <a.dupuis@infinityperl.org>
<a.dupuis@infinityperl.org>
Please report any bugs or feature requests to bug-slackget10-Package@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=slackget10. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-slackget10-Package@rt.cpan.org
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.
To install slackget10, copy and paste the appropriate command in to your terminal.
cpanm
cpanm slackget10
CPAN shell
perl -MCPAN -e shell install slackget10
For more information on module installation, please visit the detailed CPAN module installation guide.