Module::Install::Debian - Require debian packages to be installed on the system


Module-Install-Debian documentation Contained in the Module-Install-Debian distribution.

Index


Code Index:

NAME

Top

Module::Install::Debian - Require debian packages to be installed on the system

SYNOPSIS

Top

Have your Makefile.PL read as follows:

  use inc::Module::Install;

  name      'Foo-Bar';
  all_from  'lib/Foo/Bar.pm';

  dpkg_requires '' => 'bar'; # require .deb file

  WriteAll;




DESCRIPTION

Top

Module::Install::Debian allows you to require .deb packages to be installed on the system.

METHODS

Top

* dpkg_requires()

Takes a list of key/value pairs specifying a debian package name and version number. This will install the package in the system if it is not there allready.

BUGS

Top

This module will not honour the version requirement yet.

Please report any bugs to (patches welcome):

    http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Install-Debian




SEE ALSO

Top

Module::Install

AUTHOR

Top

Bjørn-Olav Strand <bo@startsiden.no>

LICENSE

Top

Copyright 2009 by ABC Startsiden AS, Bjørn-Olav Strand <bo@startsiden.no>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Module-Install-Debian documentation Contained in the Module-Install-Debian distribution.

package Module::Install::Debian;

use strict;
use Module::Install::Base;
use English;

use vars qw{$VERSION @ISA};

BEGIN {
    $VERSION = '0.030';
    @ISA     = qw{Module::Install::Base};
}

sub dpkg_requires {
    my $self = shift;

    if ( !$self->can_run('dpkg') ) {
        warn 'No dpkg installed.';
        return;
    }

    while (@_) {
        my $package = shift or last;
        my $version = shift || 0;
        push @{ $self->{values}{dpkg_requires} }, [ $package, $version ];

        # Check for package
        print "Checking dpkg $package status...\n";
        my $dpkg_status  = `dpkg -s $package`;
        my $installed = ( $dpkg_status =~ /^Status\:.*installed/m );
        my ($installed_version) = ( $dpkg_status =~ /^Version\: (.*)$/m );

        if ($installed) {
            print "$package $version ... $installed_version\n";

            # Check version
            return;
        }
        else {
            print "$package $version ... missing\n";
        }

        # Check for apt-get
        if ( !$self->can_run('apt-get') ) {
            warn "No apt-get installed. Needs to but cannot install $package";
            return;
        }

        # Check for root?

        # Install package
        `apt-get install $package`;

    }

    $self->{values}{dpkg_requires};
}

1;