CPANPLUS-Dist-SUSE

 view release on metacpan or  search on metacpan

lib/CPANPLUS/Dist/SUSE.pm  view on Meta::CPAN

Checks if /etc/SuSE-release file exists

=cut

sub format_available {

    # Check SUSE release file
    if ( !-f '/etc/SuSE-release' ) {
        error('Not on a SUSE system');
        return 0;
    }

    return super;
}

# my $bool = $self->_has_been_built;
#
# Returns true if there's already a package built for this module.
#
sub _has_been_built {
    my ( $self, $name, $vers ) = @_;

    # FIXME this entire method should be overridden to first check the local
    # rpmdb, then check the yum repos via repoquery.  As is we're pretty
    # broken right now
    #
    # For now, just call super
    return super;
}

sub _is_module_build_compat {
    my $self = shift @_;
    my $module = shift @_ || $self->parent;

    my $makefile = $module->_status->extract . '/Makefile.PL';

    #my $buildfile = $module->_status->extract . '/Build.PL';
    if ( !-f $makefile ) {
        return 0;
    }
    $makefile = file $makefile;
    my $content = $makefile->slurp;

    return $content =~ /Module::Build::Compat/;
}

=head2 install

Overrides the install method of RPM allowing for extra
rpm install arguments in dist-opts, be aware that you
need to specify it as

cpan2dist ... --dist-opts="--aid= --allfiles= --relocate=/a=/b"

        --aid --allfiles --badreloc
        --excludedocs --force -h,--hash
        --ignoresize --ignorearch --ignoreos
        --includedocs --justdb --nodeps
        --nodigest --nosignature --nosuggest
        --noorder --noscripts --notriggers
        --oldpackage --percent
        --repackage --replacefiles --replacepkgs
        --test

=cut

sub install {
    my $self                = shift @_;
    my %opts                = $self->_parse_args(@_);
    my @valid_singleoptions = (
        "--aid",       "--allfiles",     "--badreloc",    "--excludedocs",
        "--force",     "--hash",         "--ignoresize",  "--ignorearch",
        "--ignoreos",  "--includedocs",  "--justdb",      "--nodeps",
        "--nodigest",  "--nosignature",  "--nosuggest",   "--noorder",
        "--noscripts", "--notriggers",   "--oldpackage",  "--percent",
        "--repackage", "--replacefiles", "--replacepkgs", "--test"
    );

    #my $rpm = $self->status->rpm;

    my $otheropts = '';

    foreach my $o (@valid_singleoptions) {
        $otheropts .= $o if ( exists( $opts{$o} ) );
    }

    my $rpmcmd = 'rpm -Uvh ' . $otheropts . ' ' . $self->status->rpmpath;

    if ( $EUID != 0 ) {

        msg 'trying to invoke rpm via sudo';

        $rpmcmd = "sudo $rpmcmd";
    }

    my $buffer;

    my $success = run(
        command => $rpmcmd,
        verbose => $opts{verbose},
        buffer  => \$buffer,
    );

    if ( !( defined($success) ) || not $success ) {
        error "error installing! ($success)";
        printf STDERR $buffer;

        #die;
        return $self->status->installed(0);
    }

    return $self->status->installed(1);
}
1;

__DATA__
__[ spec ]__
#
# spec file for package [% status.rpmname %] (Version [% status.distvers %])
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
 
# norootforbuild

Name:           [% status.rpmname %]
Version:        [% status.distvers %]
Release:        [% status.rpmvers %]%{?dist}
License:        [% status.license %]
Group:          Development/Libraries/Perl
Summary:        [% status.summary %]



( run in 2.044 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )