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


Youri-Package documentation Contained in the Youri-Package distribution.

Index


Code Index:

NAME

Top

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

DESCRIPTION

Top

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

get_wrapper_class

Returns the name of a class corresponding to currently available perl RPM bindings:

Youri::Package::RPM::RPM4 if RPM4 is available
Youri::Package::RPM::RPM if RPM is available
Youri::Package::RPM::URPM if URPM is available

This allow to write binding-independant code, by using methods of this class instead of using bindings-specific functions.

set_verbosity
install_srpm
add_macro
expand_macro
new_header
new_spec
new_transaction

set_verbosity

This method calls underlying binding corresponding function.

install_srpm

This method calls underlying binding corresponding function.

add_macro

This method calls underlying binding corresponding function.

expand_macro

This method calls underlying binding corresponding function.

new_header

This method calls the constructor of the underlying binding Header class.

new_spec

This method calls the constructor of the underlying binding Spec class.

new_transaction

This method calls the constructor of the underlying binding Transaction class.


Youri-Package documentation Contained in the Youri-Package distribution.
# $Id: RPM.pm 2306 2011-01-22 12:45:01Z guillomovitch $
package Youri::Package::RPM;

use strict;
use warnings;
use base 'Youri::Package';
use version; our $VERSION = qv('0.2.0');
use Carp;
use UNIVERSAL::require;

sub get_wrapper_class {
    if (RPM4->require()) {
        Youri::Package::RPM::RPM4->require();
        return 'Youri::Package::RPM::RPM4';
    }

    if (RPM->require()) {
        Youri::Package::RPM::RPM->require();
        return 'Youri::Package::RPM::RPM';
    }

    if (URPM->require()) {
        Youri::Package::RPM::URPM->require();
        return 'Youri::Package::RPM::URPM';
    }

    croak "No RPM bindings available";
}

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

    return $class->get_unquoted_pattern(
        $name ? quotemeta($name) : undef,
        $version ? quotemeta($version) : undef,
        $release ? quotemeta($release) : undef,
        $arch ? quotemeta($arch) : undef
    );
}

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

    return 
        ($name ? $name : '[\w-]+' ).
        '-' .
        ($version ? $version : '[^-]+' ).
        '-' .
        ($release ? $release : '[^-]+' ). 
        '\.' .
        ($arch ? $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$/;
}

1;