| 1 | package Module::Install::Debian; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Module::Install::Base; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use English; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 2 | ▶ | use vars qw{$VERSION @ISA}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 2 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | $VERSION = '0.030'; | |||||||||||
| 11 | 2 | @ISA = qw{Module::Install::Base}; | |||||||||||
| 12 | } | ||||||||||||
| 13 | |||||||||||||
| 14 | 0 | ▶ | sub dpkg_requires { | ||||||||||
|
Subroutine
dpkg_requires: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||
| 15 | 0 | my $self = shift; | |||||||||||
| 16 | |||||||||||||
| 17 | 0 | ▶ | if ( !$self->can_run('dpkg') ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 0 | warn 'No dpkg installed.'; | |||||||||||
| 19 | 0 | return; | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | 0 | ▶ | while (@_) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | 0 | ▶ | my $package = shift or last; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 0 | ▶ | my $version = shift || 0; | ||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 25 | 0 | push @{ $self->{values}{dpkg_requires} }, [ $package, $version ]; | |||||||||||
| 26 | |||||||||||||
| 27 | # Check for package | ||||||||||||
| 28 | 0 | print "Checking dpkg $package status...\n"; | |||||||||||
| 29 | 0 | my $dpkg_status = `dpkg -s $package`; | |||||||||||
| 30 | 0 | my $installed = ( $dpkg_status =~ /^Status\:.*installed/m ); | |||||||||||
| 31 | 0 | my ($installed_version) = ( $dpkg_status =~ /^Version\: (.*)$/m ); | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | if ($installed) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | 0 | print "$package $version ... $installed_version\n"; | |||||||||||
| 35 | |||||||||||||
| 36 | # Check version | ||||||||||||
| 37 | 0 | return; | |||||||||||
| 38 | } | ||||||||||||
| 39 | else { | ||||||||||||
| 40 | 0 | print "$package $version ... missing\n"; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | # Check for apt-get | ||||||||||||
| 44 | 0 | ▶ | if ( !$self->can_run('apt-get') ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | 0 | warn "No apt-get installed. Needs to but cannot install $package"; | |||||||||||
| 46 | 0 | return; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | # Check for root? | ||||||||||||
| 50 | |||||||||||||
| 51 | # Install package | ||||||||||||
| 52 | 0 | `apt-get install $package`; | |||||||||||
| 53 | |||||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | 0 | $self->{values}{dpkg_requires}; | |||||||||||
| 57 | } | ||||||||||||
| 58 | |||||||||||||
| 59 | 2 | 1; | |||||||||||
| 60 | |||||||||||||
| 61 | =head1 NAME | ||||||||||||
| 62 | |||||||||||||
| 63 | Module::Install::Debian - Require debian packages to be installed on the system | ||||||||||||
| 64 | |||||||||||||
| 65 | =head1 SYNOPSIS | ||||||||||||
| 66 | |||||||||||||
| 67 | Have your Makefile.PL read as follows: | ||||||||||||
| 68 | |||||||||||||
| 69 | use inc::Module::Install; | ||||||||||||
| 70 | |||||||||||||
| 71 | name 'Foo-Bar'; | ||||||||||||
| 72 | all_from 'lib/Foo/Bar.pm'; | ||||||||||||
| 73 | |||||||||||||
| 74 | dpkg_requires '' => 'bar'; # require .deb file | ||||||||||||
| 75 | |||||||||||||
| 76 | WriteAll; | ||||||||||||
| 77 | |||||||||||||
| 78 | |||||||||||||
| 79 | =head1 DESCRIPTION | ||||||||||||
| 80 | |||||||||||||
| 81 | Module::Install::Debian allows you to require .deb packages to be installed | ||||||||||||
| 82 | on the system. | ||||||||||||
| 83 | |||||||||||||
| 84 | =head1 METHODS | ||||||||||||
| 85 | |||||||||||||
| 86 | =over 1 | ||||||||||||
| 87 | |||||||||||||
| 88 | =item * dpkg_requires() | ||||||||||||
| 89 | |||||||||||||
| 90 | Takes a list of key/value pairs specifying a debian package name and version | ||||||||||||
| 91 | number. This will install the package in the system if it is not there allready. | ||||||||||||
| 92 | |||||||||||||
| 93 | =back | ||||||||||||
| 94 | |||||||||||||
| 95 | =head1 BUGS | ||||||||||||
| 96 | |||||||||||||
| 97 | This module will not honour the version requirement yet. | ||||||||||||
| 98 | |||||||||||||
| 99 | Please report any bugs to (patches welcome): | ||||||||||||
| 100 | |||||||||||||
| 101 | http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Install-Debian | ||||||||||||
| 102 | |||||||||||||
| 103 | |||||||||||||
| 104 | =head1 SEE ALSO | ||||||||||||
| 105 | |||||||||||||
| 106 | L<Module::Install> | ||||||||||||
| 107 | |||||||||||||
| 108 | =head1 AUTHOR | ||||||||||||
| 109 | |||||||||||||
| 110 | Bjørn-Olav Strand E<lt>bo@startsiden.noE<gt> | ||||||||||||
| 111 | |||||||||||||
| 112 | =head1 LICENSE | ||||||||||||
| 113 | |||||||||||||
| 114 | Copyright 2009 by ABC Startsiden AS, Bjørn-Olav Strand <bo@startsiden.no>. | ||||||||||||
| 115 | |||||||||||||
| 116 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||
| 117 | |||||||||||||
| 118 | =cut | ||||||||||||