# $Id$ package Youri::Package; =head1 NAME Youri::Package - Abstract package class =head1 DESCRIPTION This abstract class defines Youri::Package interface. =cut use Carp; use strict; use warnings; use constant DEPENDENCY_NAME => 0; use constant DEPENDENCY_RANGE => 1; use constant FILE_NAME => 0; use constant FILE_MODE => 1; use constant FILE_MD5SUM => 2; use constant CHANGE_AUTHOR => 0; use constant CHANGE_TIME => 1; use constant CHANGE_TEXT => 2; =head1 CLASS METHODS =head2 new(%args) Creates and returns a new Youri::Package object. Warning: do not call directly, call subclass constructor instead. =cut sub new { my $class = shift; croak "Abstract class" if $class eq __PACKAGE__; my %options = ( @_ ); my $self = bless { }, $class; $self->_init(%options); return $self; } sub _init { # do nothing } =head2 get_pattern($name, $version, $release, $arch) Returns a pattern matching a file for a package, using available informations. =head2 compare_revisions($revision1, $revision2) Compares two revision tokens, and returns a numeric value: =over =item positive if first revision is higher =item null if both revisions are equal =item negative if first revision is lower =back =head2 check_ranges_compatibility($range1, $range2) Returns a true value if given revision ranges are compatible. =head1 INSTANCE METHODS =head2 as_file() Returns the file corresponding to this package. =head2 as_string() Returns a string representation of this package. =head2 as_formated_string(I) Returns a string representation of this package, formated according to I. Format is a string, where each %{foo} token will get replaced by equivalent tag value. =head2 get_name() Returns the name of this package. =head2 get_version() Returns the version of this package. =head2 get_release() Returns the release of this package. =head2 get_revision() Returns the revision of this package. =head2 get_arch() Returns the architecture of this package. =head2 get_file_name() Returns the file name of this package (name-version-release.arch.extension). =head2 is_source() Returns true if this package is a source package. =head2 is_binary() Returns true if this package is a binary package. =head2 is_debug() Returns true if this package is a debug package. =head2 get_type() Returns the type (binary/source) of this package. =head2 get_age() Returns the age of this package =head2 get_url() Returns the URL of this package =head2 get_summary() Returns the summary of this package =head2 get_description() Returns the description of this package =head2 get_packager() Returns the packager of this package. =head2 get_source_package() Returns the name of the source package of this package. =head2 get_tag($tag) Returns the value of tag $tag of this package. =head2 get_canonical_name() Returns the canonical name of this package, shared by its multiple components, usually the one from the source package. =head2 get_requires() Returns the list of dependencies required by this package, each dependency being represented as an array reference, with the following informations: =over =item B Name of the dependency (index DEPENDENCY_NAME) =item B Range of the dependency (index DEPENDENCY_RANGE) =back For more conveniency, fields index are available as constant in this package. =head2 get_provides() Returns the list of dependencies provided by this package, each dependency being represented as an array reference, using the same structure as previous method. =head2 get_obsoletes() Returns the list of other packages obsoleted by this one, each one being represented as an array reference, using the same structure as previous method. =head2 get_conflicts() Returns the list of other packages conflicting with this one. =head2 get_files() Returns the list of files contained in this package, each file being represented as an array reference, with the following informations: =over =item B Name of the file (index FILE_NAME). =item B Mode of the file (index FILE_MODE). =item B Md5sum of the file (index FILE_MD5SUM). =back For more conveniency, fields index are available as constant in this package. =head2 get_gpg_key() Returns the gpg key id of package signature. =head2 get_information() Returns formated informations about the package. =head2 get_changes() Returns the list of changes for this package, each change being represented as an array reference, with the following informations: =over =item B Author of the change (index CHANGE_AUTHOR). =item B