aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Package/RPM.pm
blob: bb87f38c1a0a23eff868aae6ec863b5e3579e175 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# $Id: /local/youri/soft/trunk/lib/Youri/Package/URPM.pm 2257 2006-07-05T09:22:47.088572Z guillaume  $
package Youri::Package::RPM;

=head1 NAME

Youri::Package::RPM - Base class for all RPM-based package implementation

=head1 DESCRIPTION

This bases class factorize code between various RPM-based package
implementation.

=cut

use strict;
use warnings;
use base 'Youri::Package';
use Carp;

sub get_pattern {
    my ($class, $name, $version, $release, $arch) = @_;

    return 
        ($name ? quotemeta($name) : '[\w-]+' ).
        '-' .
        ($version ? quotemeta($version) : '[^-]+' ).
        '-' .
        ($release ? quotemeta($release) : '[^-]+' ). 
        '\.' .
        ($arch ? quotemeta($arch) : '\w+' ).
        '\.rpm';
}

sub as_file {
    my ($self) = @_;
    croak "Not a class method" unless ref $self;

    return $self->{_file};
}

sub is_debug {
    my ($self) = @_;
    croak "Not a class method" unless ref $self;

    return $self->get_name() =~ /-debug$/o;
}

1;