pax_global_header00006660000000000000000000000064130014334140014503gustar00rootroot0000000000000052 comment=802b9a3299f2100a53310c73d7e4e208282e912c libtest-debian-perl-0.06/000077500000000000000000000000001300143341400152565ustar00rootroot00000000000000libtest-debian-perl-0.06/.travis.yml000066400000000000000000000021441300143341400173700ustar00rootroot00000000000000sudo: required services: - docker env: - TRAVIS_DEBIAN_DISTRIBUTION=wheezy before_install: - set -e - sudo apt-get -qq --yes install devscripts dpkg-dev - dch --newversion `git describe|sed -E 's#.*/##'|sed -E 's/-([0-9]+)-(.{8})$/+\1.\2/'`~$TRAVIS_DEBIAN_DISTRIBUTION --force-distribution --distribution nowtaxi 'Autobuilt by git commit' - git commit -m 'update changelog' debian/changelog - dpkg-parsechangelog script: - set -e - wget -O- http://travis.debian.net/script.sh | sh - - echo $UPLOAD_SSH_KEY | base64 -d > ../issh - chmod 0600 ../issh - echo '[nowtaxi]' > ../dput.cf - echo login = gitlabuploader >> ../dput.cf - echo fqdn = debian.nowtaxi.ru >> ../dput.cf - echo method = scp >> ../dput.cf - echo incoming = /srv/debian.incomming >> ../dput.cf - echo ssh_config_options = UserKnownHostsFile=/dev/null >> ../dput.cf - echo ' StrictHostKeyChecking=no' >> ../dput.cf - echo ' IdentityFile=../issh' >> ../dput.cf - if test "$DPUT" -eq 1; then dput --debug -u -c ../dput.cf nowtaxi ../*.changes; fi - cat ../*.changes branches: only: - master libtest-debian-perl-0.06/Changes000066400000000000000000000002571300143341400165550ustar00rootroot00000000000000Revision 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.06/MANIFEST000066400000000000000000000002701300143341400164060ustar00rootroot00000000000000debian/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 libtest-debian-perl-0.06/Makefile.PL000066400000000000000000000015441300143341400172340ustar00rootroot00000000000000use 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/dr-co/test-debian-perl', repository => 'https://github.com/dr-co/test-debian-perl', bugtracker => 'https://github.com/dr-co/test-debian-perl/issues' } } ); libtest-debian-perl-0.06/README000066400000000000000000000006371300143341400161440ustar00rootroot00000000000000Test-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.06/debian/000077500000000000000000000000001300143341400165005ustar00rootroot00000000000000libtest-debian-perl-0.06/debian/changelog000066400000000000000000000012061300143341400203510ustar00rootroot00000000000000libtest-debian-perl (0.06-1) unstable; urgency=medium * Extends package test syntax. -- Dmitry E. Oboukhov Tue, 18 Oct 2016 17:20:08 +0300 libtest-debian-perl (0.03-1) unstable; urgency=low * Fix ok error. -- Dmitry E. Oboukhov Sat, 08 Dec 2012 21:12:42 +0400 libtest-debian-perl (0.02-1) unstable; urgency=low * Test for several package names. -- Dmitry E. Oboukhov Sat, 08 Dec 2012 19:55:37 +0400 libtest-debian-perl (0.01-1) unstable; urgency=low * Debian first commit, closes: #680178 -- Dmitry E. Oboukhov Wed, 04 Jul 2012 13:54:53 +0400 libtest-debian-perl-0.06/debian/compat000066400000000000000000000000021300143341400176760ustar00rootroot000000000000007 libtest-debian-perl-0.06/debian/control000066400000000000000000000011031300143341400200760ustar00rootroot00000000000000Source: libtest-debian-perl Section: perl Homepage: http://search.cpan.org/dist/Test-Debian/ Maintainer: Dmitry E. Oboukhov Build-Depends: debhelper (>= 7), cdbs Standards-Version: 3.9.6 Priority: extra VCS-Browser: https://github.com/unera/test-debian-perl Package: libtest-debian-perl Depends: ${perl:Depends}, ${misc:Depends} Architecture: all Description: perl tests for debian The module provides some perl tests for debian system: - system_is_debian - package_is_installed - package_isnt_installed You can use them inside Your perl tests. libtest-debian-perl-0.06/debian/copyright000066400000000000000000000016751300143341400204440ustar00rootroot00000000000000Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 Maintainer: Dmitry E. Oboukhov Source: http://search.cpan.org/dist/Test-Debian/ Name: Test::Debian Files: * Copyright: 2011-2012 Dmitry E. Oboukhov License: Artistic or GPL-1+ License: Artistic This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, which comes with Perl. . On Debian systems, the complete text of the Artistic License can be found in `/usr/share/common-licenses/Artistic'. License: GPL-1+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. . On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-1' libtest-debian-perl-0.06/debian/rules000077500000000000000000000012511300143341400175570ustar00rootroot00000000000000#!/usr/bin/make -f include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/perl-makemaker.mk MAIN_MODULE = lib/Test/Debian.pm DEBVERSION = $(shell dpkg-parsechangelog \ |grep ^Version|awk '{print $$2}'|sed 's/-.*//' ) PERLVERSION = $(shell grep '^our[[:space:]]\+$$VERSION' $(MAIN_MODULE) \ |head -n 1 \ |awk '{print $$4}'|sed "s/[';']//g" ) install/libtest-debian-perl:: test $(DEBVERSION) = $(PERLVERSION) make tardist clean:: rm -f Makefile.old rm -fr .pc rm -f Test-Debian-*.tar.gz* tarball: cd .. && tar \ --exclude=debian \ --exclude=.git \ -czf libtest-debian-perl_$(DEBVERSION).orig.tar.gz \ libtest-debian-perl-$(DEBVERSION) libtest-debian-perl-0.06/debian/source/000077500000000000000000000000001300143341400200005ustar00rootroot00000000000000libtest-debian-perl-0.06/debian/source/format000066400000000000000000000000141300143341400212060ustar00rootroot000000000000003.0 (quilt) libtest-debian-perl-0.06/debian/source/options000066400000000000000000000000631300143341400214150ustar00rootroot00000000000000extend-diff-ignore = "^\.(travis|gitlab-ci)\.yml$" libtest-debian-perl-0.06/debian/watch000066400000000000000000000001211300143341400175230ustar00rootroot00000000000000version=3 http://search.cpan.org/dist/Test-Debian/ .*-(\d+(?:\.\d+)+).tar.gz libtest-debian-perl-0.06/lib/000077500000000000000000000000001300143341400160245ustar00rootroot00000000000000libtest-debian-perl-0.06/lib/Test/000077500000000000000000000000001300143341400167435ustar00rootroot00000000000000libtest-debian-perl-0.06/lib/Test/Debian.pm000066400000000000000000000105771300143341400204750ustar00rootroot00000000000000package 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.06'; my $DPKG = '/usr/bin/dpkg'; 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 $DPKG) { Test::More->builder->ok( 0, $name ); diag "$DPKG 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 ($pkgs, $name) = @_; my $list = _pkg_list($name) or return 0; my $tb = Test::More->builder; $name ||= "package(s) '$pkgs' is/are installed"; for ( split /\s*\|\s*/, $pkgs ) { my ($pkg, $op, $ver) = _parse_pkg($_); next unless $pkg; next unless exists $list->{ $pkg }; next unless $list->{ $pkg } eq 'install'; return $tb->ok( 1, $name ) unless $op; my $ok = _compare_versions_ok($pkg, $op, $ver); return $tb->ok(1, $name) if $ok; } return $tb->ok( 0, $name ); } sub package_isnt_installed($;$) { my ($pkg_spec, $name) = @_; $name ||= "$pkg_spec is not installed"; my $list = _pkg_list($name) or return 0; my $tb = Test::More->builder; my ($pkg, $op, $ver) = _parse_pkg($pkg_spec); return $tb->ok( 0, $name) unless $pkg; return $tb->ok( 1, $name ) unless exists $list->{ $pkg }; return $tb->cmp_ok($list->{ $pkg }, 'ne', 'install', $name) unless $op; my $res = _compare_versions($pkg, $op, $ver); return $tb->ok( $res ? 1 : 0, $name); } my %ops = ( '>' => 'gt', '>=' => 'ge', '=' => 'eq', '!=' => 'ne', '<' => 'lt', '<=' => 'le', ); sub _parse_pkg { my ($str) = @_; $str =~ s/\s+//g; my ($pkg, $op, $ver) = $str =~ /^([^(]+) (?:\( ([^\d]+) ([^)]+) \))?$/x; my $err; if ($op) { $op = $ops{$op}; $err = 1 unless $op && $ver =~ /^[\d._-]+/; } else { $err = 1 unless $pkg && length $str == length $pkg; } if ($err) { diag "invalid syntax for package '$_[0]'"; return; } return ($pkg, $op, $ver); } sub _compare_versions_ok { my ($pkg, $op, $req_ver) = @_; my $pid = open my $fh, '-|', $DPKG, '-s', $pkg; unless ($pid) { diag "exec: $!"; return undef; } my @info = <$fh>; waitpid $pid, 0; if ($?) { diag "$DPKG error: ", $? >> 8; return undef; } my $inst_ver; for (@info) { $inst_ver = $1 and last if /^Version:\s+(.+)$/; } unless ($inst_ver) { diag "Can`t define version $pkg"; return undef; } $inst_ver =~ s/(^[\d.]+).+$/$1/; my $r = system($DPKG, '--compare-versions', $inst_ver, $op, $req_ver); $r = $r >> 8; if ($r > 1) { diag "dpkg error: $r"; return undef; } return $r == 0; } 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_variant [, $test_name ]) Passes if package is installed L understands the following syntax: package1 | package2 package1 (< 1.23) | package2 (> 1.3) =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.06/t/000077500000000000000000000000001300143341400155215ustar00rootroot00000000000000libtest-debian-perl-0.06/t/01-test-debian.t000066400000000000000000000020171300143341400203230ustar00rootroot00000000000000#!/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 => 16; 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'; (my $perl = $^V) =~ s/^v//; (my $prev = $perl) =~ s/(\d\d)/$1 - 1/e; (my $next = $perl) =~ s/(\d\d)/$1 + 1/e; package_is_installed "perl (< $perl) | perl"; package_is_installed "perl ( = $perl )"; package_is_installed "perl ( >= $perl )"; package_is_installed "perl ( <= $perl )"; package_is_installed "perl ( != $prev )"; package_is_installed "perl ( != $next )"; package_is_installed "perl ( > $prev )"; package_is_installed "perl ( < $next )"; package_is_installed "perl ( < $next )|perl (= $perl)"; package_is_installed "perl ( > $prev )|perl";