libtest-debian-perl-0.03/0000755000000000000000000000000012060673555013771 5ustar rootrootlibtest-debian-perl-0.03/Makefile.PL0000644000000000000000000000143412060660653015740 0ustar rootrootuse 5.008008; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Test::Debian', VERSION_FROM => 'lib/Test/Debian.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Test/Debian.pm', # retrieve abstract from module AUTHOR => 'Dmitry E. Oboukhov ') : ()), LICENSE => 'perl', META_MERGE => { resources => { homepage => 'https://github.com/unera/test-debian-perl', bugtracker => 'https://github.com/unera/test-debian-perl/issues' } } ); libtest-debian-perl-0.03/t/0000775000000000000000000000000012060661351014225 5ustar rootrootlibtest-debian-perl-0.03/t/01-test-debian.t0000644000000000000000000000072112060661351017025 0ustar rootroot#!/usr/bin/perl use warnings; use strict; use utf8; use open qw(:std :utf8); use lib qw(lib ../lib); BEGIN { use Test::More; plan skip_all => 'Current system is not Debian' unless -r '/etc/debian_version'; plan tests => 6; use_ok 'Test::Debian'; } system_is_debian; package_is_installed 'dpkg'; package_isnt_installed('unknown_package_name'); package_is_installed 'dpkg|abcccc'; package_is_installed 'dddddddddddddddd|dpkg|abcccc'; libtest-debian-perl-0.03/Changes0000644000000000000000000000025712060660653015263 0ustar rootrootRevision history for Perl extension Test::DebIsInstalled. 0.01 Wed Jul 4 12:52:58 2012 - original version; created by h2xs 1.23 with options -X -n Test::DebIsInstalled libtest-debian-perl-0.03/lib/0000775000000000000000000000000012060660653014534 5ustar rootrootlibtest-debian-perl-0.03/lib/Test/0000775000000000000000000000000012060672405015451 5ustar rootrootlibtest-debian-perl-0.03/lib/Test/Debian.pm0000644000000000000000000000510712060672405017172 0ustar rootrootpackage Test::Debian; use 5.008008; use strict; use warnings; use Test::More; use base 'Exporter'; our @EXPORT = qw( system_is_debian package_is_installed package_isnt_installed ); our $VERSION = '0.03'; sub system_is_debian(;$) { my $name = shift || 'System is debian'; Test::More->builder->ok( -r '/etc/debian_version', $name ); } sub _pkg_list($) { my ($name) = @_; our %dpkg_list; unless(-x '/usr/bin/dpkg') { Test::More->builder->ok( 0, $name ); diag '/usr/bin/dpkg is not found or executable'; return 0; } unless(%dpkg_list) { my $pid = open my $fh, '-|', '/usr/bin/dpkg', '--get-selections'; unless($pid) { my $err = $!; Test::More->builder->ok( 0, $name ); diag $!; return 0; } %dpkg_list = map { ( @$_[0, 1] ) } map { [ split /\s+/, $_, 3 ] } <$fh>; } return \%dpkg_list; } sub package_is_installed($;$) { my ($pkg, $name) = @_; $name ||= "$pkg is installed"; my $list = _pkg_list($_) or return 0; my $tb = Test::More->builder; my @names = split /\|/, $pkg; for (@names) { next unless exists $list->{ $_ }; next unless $list->{ $_ } eq 'install'; return $tb->ok( 1, $name ); } return $tb->ok( 0, $name ); } sub package_isnt_installed($;$) { my ($pkg, $name) = @_; $name ||= "$pkg is not installed"; my $list = _pkg_list($name) or return 0; my $tb = Test::More->builder; return $tb->ok( 1, $name ) unless exists $list->{ $pkg }; return $tb->cmp_ok($list->{ $pkg }, 'ne', 'install', $name); } 1; =head1 NAME Test::Debian - some tests for debian system =head1 SYNOPSIS use Test::More; use Test::Debian; ok($value, 'test name'); system_is_debian; package_is_installed 'dpkg'; package_is_installed 'dpkg', 'dpkg is installed'; package_isnt_installed 'kde-base'; =head1 DESCRIPTION The module provides some perl tests for debian system: =head2 system_is_debian([ $test_name ]) Passes if current OS is debian =head2 package_is_installed($pkg_name [, $test_name ]) Passes if package is installed =head2 package_isnt_installed($pkg_name [, $test_name ]) Passes if package isn't installed =head1 AUTHOR Dmitry E. Oboukhov, Eunera@debian.org =head1 COPYRIGHT AND LICENSE Copyright (C) 2012 by Dmitry E. Oboukhov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. =cut libtest-debian-perl-0.03/README0000644000000000000000000000063712060660653014652 0ustar rootrootTest-Debian =========== INSTALLATION To install this module type the following: perl Makefile.PL make make test make install COPYRIGHT AND LICENCE Copyright (C) 2012 by Dmitry E. Oboukhov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. libtest-debian-perl-0.03/MANIFEST0000664000000000000000000000027012060660653015116 0ustar rootrootdebian/source/format debian/rules debian/changelog debian/control debian/compat debian/watch debian/copyright lib/Test/Debian.pm MANIFEST t/01-test-debian.t Changes README Makefile.PL