From fcd6cfb7689b8f6b3c6e81861847314a6ec74aea Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Mon, 24 May 2021 22:47:52 +0100 Subject: [PATCH] add support for Devuan --- CHANGELOG | 4 ++++ MANIFEST | 1 + lib/Devel/AssertOS/Linux/Debian.pm | 6 +++--- lib/Devel/AssertOS/Linux/Devuan.pm | 28 ++++++++++++++++++++++++++++ lib/Devel/CheckOS.pm | 2 +- t/unknown-debian.t | 16 +++++++--------- 6 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 lib/Devel/AssertOS/Linux/Devuan.pm diff --git a/CHANGELOG b/CHANGELOG index 6c86227..5e7ecd6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +1.87 2021-XX-XX + +- Add support for Devuan Linux + 1.86 2021-05-20 - Belatedly add doco on Debian family to Families.pod diff --git a/MANIFEST b/MANIFEST index 6ed8b91..095468f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -117,3 +117,4 @@ t/pod.t t/script.t t/unknown-debian.t lib/Devel/AssertOS/MacOSX/v11.pm +lib/Devel/AssertOS/Linux/Devuan.pm diff --git a/lib/Devel/AssertOS/Linux/Debian.pm b/lib/Devel/AssertOS/Linux/Debian.pm index 7692208..a22c026 100644 --- a/lib/Devel/AssertOS/Linux/Debian.pm +++ b/lib/Devel/AssertOS/Linux/Debian.pm @@ -5,9 +5,9 @@ use strict; use warnings; no warnings 'redefine'; -our $VERSION = '1.1'; +our $VERSION = '1.2'; -sub matches { map { "Linux::$_" } qw(Raspbian Ubuntu RealDebian UnknownDebianLike) } +sub matches { map { "Linux::$_" } qw(Raspbian Ubuntu RealDebian UnknownDebianLike Devuan) } sub os_is { Devel::CheckOS::os_is(matches()) } @@ -17,7 +17,7 @@ Devel::CheckOS::die_unsupported() unless(os_is()); =head1 COPYRIGHT and LICENCE -Copyright 2007 - 2020 David Cantrell +Copyright 2007 - 2021 David Cantrell This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively. diff --git a/lib/Devel/AssertOS/Linux/Devuan.pm b/lib/Devel/AssertOS/Linux/Devuan.pm new file mode 100644 index 0000000..4c5cb0a --- /dev/null +++ b/lib/Devel/AssertOS/Linux/Devuan.pm @@ -0,0 +1,28 @@ +package Devel::AssertOS::Linux::Devuan; + +use Devel::CheckOS; +use strict; +use warnings; +no warnings 'redefine'; + +our $VERSION = '1.0'; + +sub os_is { + Devel::CheckOS::os_is('Linux') && + `lsb_release -i 2>/dev/null` =~ /Devuan/ +} + +sub expn { "The operating system is Devuan" } + +Devel::CheckOS::die_unsupported() unless(os_is()); + +=head1 COPYRIGHT and LICENCE + +Copyright 2007 - 2021 David Cantrell + +This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively. + +=cut + +1; + diff --git a/lib/Devel/CheckOS.pm b/lib/Devel/CheckOS.pm index 7e8dbe0..b5e03d3 100644 --- a/lib/Devel/CheckOS.pm +++ b/lib/Devel/CheckOS.pm @@ -6,7 +6,7 @@ use Exporter; use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); -our $VERSION = '1.86'; +our $VERSION = '1.87'; @ISA = qw(Exporter); @EXPORT_OK = qw(os_is os_isnt die_if_os_is die_if_os_isnt die_unsupported list_platforms list_family_members); diff --git a/t/unknown-debian.t b/t/unknown-debian.t index dfd36d9..736dfaf 100644 --- a/t/unknown-debian.t +++ b/t/unknown-debian.t @@ -2,16 +2,14 @@ use strict; use warnings; use Test::More; +plan skip_all => "This isn't Debian-ish" unless os_is('Linux::Debian'); -use Devel::CheckOS qw(os_is); +use Devel::CheckOS qw(os_is list_family_members); -SKIP: { - skip "This isn't Debian-ish", 1 unless os_is('Debian'); - ok( - (os_is(map { "Linux::$_" } qw(Raspbian Ubuntu RealDebian)) ? 1 : 0) + - (os_is('Linux::UnknownDebianLike') ? 1 : 0) == 1, - "OS isn't both UnknownDebianLike and some known Debian variant" - ); -} +ok( + (os_is(grep { $_ ne 'Linux::UnknownDebianLike' } list_family_members('Linux::Debian')) ? 1 : 0) + + (os_is('Linux::UnknownDebianLike') ? 1 : 0) == 1, + "OS isn't both UnknownDebianLike and some known Debian variant" +); done_testing();