├── .gitignore ├── MANIFEST.SKIP ├── TODO ├── t ├── coverage.sh ├── pod.t ├── assertos-blah-valid.t ├── assertos-single-valid-OS.t ├── assertos-multi.t ├── lib │ └── Devel │ │ └── AssertOS │ │ ├── AnOperatingSystem.pm │ │ ├── NotAnOperatingSystem.pm │ │ └── AnOperatingSystem │ │ ├── v1.pm │ │ └── v2.pm ├── otherlib │ └── Devel │ │ └── AssertOS │ │ └── AnOperatingSystem.pm ├── assertos-single-invalid-OS.t ├── int-size.t ├── import-bool.t ├── assertos-blah-invalid.t ├── import-fatal.t ├── alias-macos.t ├── multilevel-names.t ├── unknown-debian.t ├── import-all.t ├── os-release.t ├── list_family_members.t ├── expn.t ├── assertos-do-not-want.t ├── case-insensitive.t ├── checkos.t ├── failing-mockery.t ├── mockery.t └── script.t ├── .github ├── dependabot.yml └── workflows │ ├── macos.yml │ ├── coveralls.yml │ ├── arch-linux.yml │ ├── devuan-linux.yml │ ├── real-debian.yml │ ├── install-linux.yml │ ├── windows.yml │ ├── openbsd.yml │ ├── freebsd.yml │ └── linux.yml ├── README ├── lib └── Devel │ ├── AssertOS │ ├── Android.pm │ ├── Alias │ │ └── MacOS.pm │ ├── AIX.pm │ ├── DGUX.pm │ ├── HPUX.pm │ ├── Hurd.pm │ ├── Irix.pm │ ├── NeXT.pm │ ├── OS2.pm │ ├── SCO.pm │ ├── VMS.pm │ ├── VOS.pm │ ├── Amiga.pm │ ├── BSDOS.pm │ ├── Haiku.pm │ ├── MPEiX.pm │ ├── MSDOS.pm │ ├── OS400.pm │ ├── SunOS.pm │ ├── SysVr4.pm │ ├── SysVr5.pm │ ├── VMESA.pm │ ├── Bitrig.pm │ ├── Dynix.pm │ ├── Interix.pm │ ├── MirOSBSD.pm │ ├── NetBSD.pm │ ├── Netware.pm │ ├── OpenBSD.pm │ ├── POSIXBC.pm │ ├── Solaris.pm │ ├── Minix.pm │ ├── Unicos.pm │ ├── FreeBSD.pm │ ├── MacOSclassic.pm │ ├── DragonflyBSD.pm │ ├── GNUkFreeBSD.pm │ ├── MidnightBSD.pm │ ├── OS390.pm │ ├── QNX │ │ ├── v4.pm │ │ └── Neutrino.pm │ ├── iOS.pm │ ├── OSF.pm │ ├── RISCOS.pm │ ├── MacOSX.pm │ ├── Realtime.pm │ ├── Sun.pm │ ├── Apple.pm │ ├── HWCapabilities │ │ ├── Int32.pm │ │ └── Int64.pm │ ├── Linux │ │ ├── Devuan.pm │ │ ├── v2_6.pm │ │ ├── Raspbian.pm │ │ ├── RealDebian.pm │ │ ├── Debian.pm │ │ ├── Ubuntu.pm │ │ └── UnknownDebianLike.pm │ ├── MSWin32.pm │ ├── MicrosoftWindows.pm │ ├── MSYS.pm │ ├── MacOSX │ │ ├── v14.pm │ │ ├── v11.pm │ │ ├── v12.pm │ │ ├── v13.pm │ │ ├── v10_0.pm │ │ ├── v10_1.pm │ │ ├── v10_2.pm │ │ ├── v10_3.pm │ │ ├── v10_4.pm │ │ ├── v10_5.pm │ │ ├── v10_7.pm │ │ ├── v10_6.pm │ │ ├── v10_10.pm │ │ ├── v10_12.pm │ │ ├── v10_14.pm │ │ ├── v10_15.pm │ │ ├── v10_9.pm │ │ ├── v10_11.pm │ │ ├── v10_13.pm │ │ └── v10_8.pm │ ├── Cygwin.pm │ ├── MachTen.pm │ ├── QNX.pm │ ├── DEC.pm │ ├── EBCDIC.pm │ ├── Linux.pm │ ├── OSFeatures │ │ ├── Systemd.pm │ │ ├── POSIXShellRedirection.pm │ │ └── Release.pm │ ├── BeOS.pm │ ├── Unix.pm │ └── Extending.pod │ ├── AssertOS.pm │ ├── CheckOS │ └── Families.pod │ └── CheckOS.pm ├── makefile-expect-driver.pl ├── MANIFEST ├── Makefile.PL ├── bin └── use-devel-assertos ├── ARTISTIC.txt ├── CHANGELOG └── GPL2.txt /.gitignore: -------------------------------------------------------------------------------- 1 | t/XX-* 2 | MYMETA.json 3 | MYMETA.yml 4 | Makefile 5 | Makefile.old 6 | blib/ 7 | pm_to_blib 8 | -------------------------------------------------------------------------------- /MANIFEST.SKIP: -------------------------------------------------------------------------------- 1 | .travis.yml 2 | ^\.git 3 | .appveyor.yml 4 | .cirrus.yml 5 | makefile-expect-driver.pl 6 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Detect different types of MS Windows 2 | 3 | use-devel-assertos should not add itself twice (update, if run a second time) 4 | -------------------------------------------------------------------------------- /t/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cover -delete 4 | HARNESS_PERL_SWITCHES=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine make test 5 | cover 6 | -------------------------------------------------------------------------------- /t/pod.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | 3 | $^W=1; 4 | 5 | use Test::More; 6 | eval "use Test::Pod 1.00"; 7 | plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; 8 | all_pod_files_ok(); 9 | -------------------------------------------------------------------------------- /t/assertos-blah-valid.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | use_ok('Devel::AssertOS::AnOperatingSystem'); 10 | 11 | done_testing; 12 | -------------------------------------------------------------------------------- /t/assertos-single-valid-OS.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | use_ok('Devel::AssertOS', 'AnOperatingSystem'); 10 | 11 | done_testing; 12 | -------------------------------------------------------------------------------- /t/assertos-multi.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | use_ok('Devel::AssertOS', 'NotAnOperatingSystem', 'AnOperatingSystem'); 10 | 11 | done_testing; 12 | -------------------------------------------------------------------------------- /t/lib/Devel/AssertOS/AnOperatingSystem.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::AnOperatingSystem; 2 | 3 | use Devel::CheckOS qw(die_unsupported); 4 | 5 | $VERSION = '1.0'; 6 | 7 | sub os_is { 1; } 8 | 9 | die_unsupported() unless(os_is()); 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/Devel/AssertOS/NotAnOperatingSystem.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::NotAnOperatingSystem; 2 | 3 | use Devel::CheckOS qw(die_unsupported); 4 | 5 | $VERSION = '1.0'; 6 | 7 | sub os_is { 0; } 8 | 9 | die_unsupported() unless(os_is()); 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/otherlib/Devel/AssertOS/AnOperatingSystem.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::AnOperatingSystem; 2 | 3 | use Devel::CheckOS qw(die_unsupported); 4 | 5 | $VERSION = '1.0'; 6 | 7 | sub os_is { 1; } 8 | 9 | die_unsupported() unless(os_is()); 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/assertos-single-invalid-OS.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | eval "use Devel::AssertOS 'NotAnOperatingSystem'"; 10 | 11 | like $@, qr/OS unsupported/i; 12 | 13 | done_testing; 14 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Set update schedule for GitHub Actions 2 | 3 | version: 2 4 | updates: 5 | 6 | - package-ecosystem: "github-actions" 7 | directory: "/" 8 | schedule: 9 | # Check for updates to GitHub Actions every week 10 | interval: "monthly" 11 | -------------------------------------------------------------------------------- /t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::AnOperatingSystem::v1; 2 | 3 | use Devel::CheckOS qw(die_unsupported); 4 | 5 | use Devel::AssertOS::AnOperatingSystem; 6 | 7 | $VERSION = '1.0'; 8 | 9 | sub os_is { 0; } 10 | 11 | die_unsupported() unless(os_is()); 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::AnOperatingSystem::v2; 2 | 3 | use Devel::CheckOS qw(die_unsupported); 4 | 5 | use Devel::AssertOS::AnOperatingSystem; 6 | 7 | $VERSION = '1.0'; 8 | 9 | sub os_is { 1; } 10 | 11 | die_unsupported() unless(os_is()); 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This module provides a nice interface to looking at $^O, and also lets 2 | you ask about OS "families" such as "Unix" (which encompasses Linux, *BSD, 3 | AIX, HPUX, Solaris etc). 4 | 5 | To install, do the usual dance: 6 | 7 | perl Makefile.PL 8 | make 9 | make test 10 | make install 11 | -------------------------------------------------------------------------------- /t/int-size.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | 6 | use Devel::CheckOS qw(os_is); 7 | 8 | if(~0 == 4294967295) { 9 | use_ok('Devel::AssertOS', 'HWCapabilities::Int32'); 10 | } else { 11 | use_ok('Devel::AssertOS', 'HWCapabilities::Int64'); 12 | } 13 | 14 | done_testing; 15 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Android.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Android; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^android$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/import-bool.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | 6 | use Devel::CheckOS ':booleans'; 7 | 8 | use File::Spec; 9 | use lib File::Spec->catdir(qw(t lib)); 10 | 11 | ok(os_is('AnOperatingSystem'), "os_is imported"); 12 | ok(os_isnt('NotAnOperatingSystem'), "os_isnt imported"); 13 | 14 | done_testing; 15 | -------------------------------------------------------------------------------- /t/assertos-blah-invalid.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | eval "use Devel::AssertOS"; 10 | ok($@ =~ /needs at least one param/i, 11 | "'use Devel::AssertOS' needs at least one param"); 12 | 13 | eval "use Devel::AssertOS::NotAnOperatingSystem"; 14 | ok($@ =~ /OS unsupported/i); 15 | 16 | done_testing; 17 | -------------------------------------------------------------------------------- /t/import-fatal.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | 6 | use Devel::CheckOS ':fatal'; 7 | 8 | use File::Spec; 9 | use lib File::Spec->catdir(qw(t lib)); 10 | 11 | eval { die_if_os_isnt('AnOperatingSystem') }; 12 | ok(!$@, "die_if_os_isnt imported"); 13 | eval { die_if_os_is('AnOperatingSystem') }; 14 | ok($@ =~ /OS unsupported/i, "die_if_os_is imported"); 15 | 16 | done_testing; 17 | -------------------------------------------------------------------------------- /t/alias-macos.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Devel::CheckOS qw(os_is os_isnt); 5 | 6 | use Test::More; 7 | 8 | if(os_is('MacOSX')) { 9 | ok(os_is('MacOS'), "the alias works"); 10 | ok(os_is('MACOS'), "... case-insensitively"); 11 | } else { 12 | ok(os_isnt('MacOS'), "the alias doesn't work because you're not on a Mac"); 13 | ok(os_isnt('MACOS'), "... case-insensitively"); 14 | } 15 | 16 | done_testing(); 17 | -------------------------------------------------------------------------------- /t/multilevel-names.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | 6 | use Devel::CheckOS ':booleans'; 7 | 8 | use File::Spec; 9 | use lib File::Spec->catdir(qw(t lib)); 10 | 11 | ok(os_is('AnOperatingSystem::v2'), "os_is works for a multi-level name that exists"); 12 | ok(os_isnt('AnOperatingSystem::v1'), "os_isnt works for a multi-level name that exists"); 13 | 14 | ok(join(' ', Devel::CheckOS::list_platforms()) =~ /\bLinux::v2_6\b/, 15 | "list_platforms supports multi-level names"); 16 | 17 | done_testing; 18 | -------------------------------------------------------------------------------- /t/unknown-debian.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | plan skip_all => "This isn't Debian-ish" unless os_is('Linux::Debian'); 6 | 7 | use Devel::CheckOS qw(os_is list_family_members); 8 | 9 | ok( 10 | (os_is(grep { $_ ne 'Linux::UnknownDebianLike' } list_family_members('Linux::Debian')) ? 1 : 0) + 11 | (os_is('Linux::UnknownDebianLike') ? 1 : 0) == 1, 12 | "OS isn't both UnknownDebianLike and some known Debian variant" 13 | ); 14 | 15 | done_testing(); 16 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: MacOS 3 | 4 | jobs: 5 | build: 6 | strategy: 7 | fail-fast: false 8 | matrix: 9 | runs-on: ['macos-13', 'macos-11', 'macos-12'] 10 | runs-on: ${{ matrix.runs-on }} 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Setup Perl environment 14 | uses: shogo82148/actions-setup-perl@v1 15 | - name: Test and build 16 | run: | 17 | cpanm --installdeps . 18 | perl Makefile.PL 19 | make test 20 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Alias/MacOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Alias::MacOS; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Devel::CheckOS; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | Devel::CheckOS::register_alias(MacOS => 'MacOSX'); 11 | 12 | =head1 COPYRIGHT and LICENCE 13 | 14 | Copyright 2024 David Cantrell 15 | 16 | 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. 17 | 18 | =cut 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/AIX.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::AIX; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^aix$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/DGUX.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::DGUX; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^dgux$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/HPUX.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::HPUX; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^hpux$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Hurd.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Hurd; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { $^O =~ /^gnu$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Irix.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Irix; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^irix$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/NeXT.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::NeXT; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^next$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OS2.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OS2; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.1'; 9 | 10 | sub os_is { $^O =~ /^os2$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/SCO.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::SCO; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^sco_sv$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/VMS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::VMS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^VMS$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/VOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::VOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^vos$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Amiga.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Amiga; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^amigaos$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/BSDOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::BSDOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^bsdos$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Haiku.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Haiku; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.1'; 9 | 10 | sub os_is { $^O =~ /^haiku$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MPEiX.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MPEiX; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^mpeix$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MSDOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MSDOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^dos$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OS400.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OS400; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^os400$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/SunOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::SunOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^sunos$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/SysVr4.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::SysVr4; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^svr4$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/SysVr5.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::SysVr5; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^svr5$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/VMESA.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::VMESA; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^vmesa$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /t/import-all.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | 6 | use Devel::CheckOS ':all'; 7 | 8 | use File::Spec; 9 | use lib File::Spec->catdir(qw(t lib)); 10 | 11 | ok(os_is('AnOperatingSystem'), "os_is imported"); 12 | ok(os_isnt('NotAnOperatingSystem'), "os_isnt imported"); 13 | 14 | eval { die_if_os_isnt('AnOperatingSystem') }; 15 | ok(!$@, "die_if_os_isnt imported"); 16 | eval { die_if_os_is('AnOperatingSystem') }; 17 | ok($@ =~ /OS unsupported/i, "die_if_os_is imported"); 18 | 19 | eval { die_unsupported() }; 20 | ok($@ =~ /OS unsupported/i, "die_unsupported imported"); 21 | 22 | ok((grep { /^AnOperatingSystem$/i } list_platforms()), 23 | "list_platforms imported"); 24 | 25 | done_testing(); 26 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Bitrig.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Bitrig; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { $^O =~ /^BITRIG$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Dynix.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Dynix; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^dynixptx$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Interix.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Interix; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^interix$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MirOSBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MirOSBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^mirbsd$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/NetBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::NetBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^netbsd$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Netware.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Netware; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^netware$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OpenBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OpenBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^openbsd$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/POSIXBC.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::POSIXBC; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^posix-bc$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Solaris.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Solaris; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^solaris$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Minix.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Minix; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | 11 | sub os_is { ( $^O =~ /^minix$/i) ? 1 : 0; } 12 | 13 | Devel::CheckOS::die_unsupported() unless(os_is()); 14 | 15 | =head1 COPYRIGHT and LICENCE 16 | 17 | Copyright 2024 David Cantrell 18 | 19 | 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. 20 | 21 | =cut 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Unicos.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Unicos; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^unicos(mk)?$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /t/os-release.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict; 3 | use Test::More; 4 | use Devel::AssertOS::OSFeatures::Release 'distributor_id'; 5 | 6 | my $total_tests = 3; 7 | plan tests => $total_tests; 8 | 9 | SKIP: { 10 | skip 'Not a Linux distribution', $total_tests unless ( $^O eq 'linux' ); 11 | skip "Your Linux doesn't have an /etc/os-release file", $total_tests unless (-r '/etc/os-release'); 12 | my $id = distributor_id(); 13 | ok( $id, 'can fetch the distribution ID' ) 14 | or BAIL_OUT('No use to keep testing with ID = undef'); 15 | like $id, qr/^[-\w.]+$/, 'ID looks like a string'; 16 | my $copy = ucfirst( lc $id ); 17 | is( $id, $copy, 'ID is returned with first character in uppercase' ); 18 | } 19 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/FreeBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::FreeBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^(gnuk)?freebsd$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSclassic.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSclassic; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^MacOS$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/DragonflyBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::DragonflyBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^dragonfly$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/GNUkFreeBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::GNUkFreeBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.1'; 9 | 10 | sub os_is { $^O =~ /^gnukfreebsd$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MidnightBSD.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MidnightBSD; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.1'; 9 | 10 | sub os_is { $^O =~ /^midnightbsd$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | =head1 COPYRIGHT and LICENCE 15 | 16 | Copyright 2024 David Cantrell 17 | 18 | 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. 19 | 20 | =cut 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /.github/workflows/coveralls.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: Generate Coveralls report 3 | jobs: 4 | build: 5 | runs-on: 'ubuntu-latest' 6 | steps: 7 | - uses: actions/checkout@v4 8 | - uses: shogo82148/actions-setup-perl@v1 9 | with: 10 | perl-version: 5.32 11 | - name: Run with coverage checking 12 | env: 13 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 14 | run: | 15 | cpanm --notest Expect 16 | cpanm --installdeps . 17 | perl makefile-expect-driver.pl Linux::Debian Linux::Ubuntu Linux Unix OSFeatures::Systemd OSFeatures::POSIXShellRedirection HWCapabilities::Int64 18 | cpanm Devel::Cover::Report::Coveralls 19 | cover -test -report Coveralls 20 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OS390.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OS390; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^os390$/i ? 1 : 0; } 11 | 12 | sub expn { "OS390 is also known as z/OS" } 13 | 14 | Devel::CheckOS::die_unsupported() unless(os_is()); 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /t/list_family_members.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | use Test::Warnings qw(warning); 6 | 7 | use Devel::CheckOS; 8 | 9 | eval { Devel::CheckOS::list_family_members() }; 10 | ok($@, 'list_family_members() is fatal'); 11 | 12 | is_deeply( 13 | [(Devel::CheckOS::list_family_members('Cygwin'))], [], 14 | 'list_family_members($not_a_family) gives an empty list' 15 | ); 16 | 17 | is_deeply( 18 | [sort(&Devel::CheckOS::list_family_members('Linux'))], 19 | [sort(qw(Android Linux))], 20 | 'Linux family includes both Linux and Android' 21 | ); 22 | 23 | is_deeply( 24 | [(Devel::CheckOS::list_family_members('DEC'))], 25 | [qw(OSF VMS)], 26 | 'array list_family_members works for DEC family' 27 | ); 28 | 29 | done_testing; 30 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/QNX/v4.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::QNX::v4; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.1'; 9 | 10 | sub os_is { $^O =~ /^qnx$/i ? 1 : 0; } 11 | 12 | sub expn { "The operating system is version 4 of QNX" } 13 | 14 | Devel::CheckOS::die_unsupported() unless(os_is()); 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/iOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::iOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { ( $^O =~ /^iphoneos$/i) ? 1 : 0; } 11 | 12 | sub expn { "Apple's iPhone/iPad OS. *NOT* Cisco IOS!" } 13 | 14 | Devel::CheckOS::die_unsupported() unless(os_is()); 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OSF.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OSF; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^dec_osf$/i ? 1 : 0; } 11 | 12 | sub expn { "OSF is also known as OSF/1, Digital Unix, and Tru64 Unix" } 13 | 14 | Devel::CheckOS::die_unsupported() unless(os_is()); 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /t/expn.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | 6 | use Devel::CheckOS; 7 | 8 | my @families = (); 9 | foreach my $platform (Devel::CheckOS::list_platforms()) { 10 | if(grep { $_ } Devel::CheckOS::list_family_members($platform)) { 11 | ok(eval "Devel::AssertOS::$platform->can('expn') && Devel::AssertOS::${platform}::expn()", 12 | "$platform family has an expn()"); 13 | } elsif(grep { $_ eq $platform } qw( 14 | Cygwin Linux::v2_6 MachTen MacOSX::v10_4 MSWin32 OS390 15 | OSF QNX::Neutrino QNX::v4 RISCOS MacOSX::v10_5 MSYS 16 | )) { 17 | ok(eval "Devel::AssertOS::$platform->can('expn') && Devel::AssertOS::${platform}::expn()", 18 | "non-obvious platform '$platform' has an expn()"); 19 | } 20 | } 21 | 22 | done_testing; 23 | -------------------------------------------------------------------------------- /.github/workflows/arch-linux.yml: -------------------------------------------------------------------------------- 1 | name: Arch Linux 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | container: 8 | image: archlinux:latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Test on Archlinux 12 | run: | 13 | cat /etc/os-release 14 | pacman -Syu --noconfirm make git perl gcc 15 | yes|perl -MCPAN -e 'install App::cpanminus' 16 | yes|perl -MCPAN -e 'install local::lib' 17 | yes|perl -MCPAN -e 'install Expect' 18 | export PERL5OPT=-Mlocal::lib 19 | /usr/bin/site_perl/cpanm --installdeps . 20 | ls -ld /run/systemd/system || true 21 | perl makefile-expect-driver.pl Linux Unix OSFeatures::POSIXShellRedirection HWCapabilities::Int64 22 | make test 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/RISCOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::RISCOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^riscos$/i ? 1 : 0; } 11 | 12 | sub expn { "This is the Acorn operating system, not the MIPS RISC/os system" } 13 | 14 | Devel::CheckOS::die_unsupported() unless(os_is()); 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub os_is { $^O =~ /^darwin$/i ? 1 : 0; } 11 | 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { "Either Mac OS X, or OS X, or MacOS, they're all the same thing really" } 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/QNX/Neutrino.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::QNX::Neutrino; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.1'; 9 | 10 | sub os_is { $^O =~ /^nto$/i ? 1 : 0; } 11 | 12 | sub expn { "The operating system is version 6 of QNX, also known as Neutrino" } 13 | 14 | Devel::CheckOS::die_unsupported() unless(os_is()); 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Realtime.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Realtime; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub matches { return qw(QNX); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { "This is a realtime operating system" } 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Sun.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Sun; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub matches { return qw(SunOS Solaris); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { "The operating system is from Sun Microsystems" } 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Apple.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Apple; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub matches { return qw(iOS MacOSX MacOSclassic); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { "The operating system is from Apple" } 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /.github/workflows/devuan-linux.yml: -------------------------------------------------------------------------------- 1 | name: Devuan Linux 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | container: 8 | image: devuan/devuan:latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Test on Devuan 12 | run: | 13 | cat /etc/os-release 14 | apt-get update 15 | yes|apt-get install perl-base build-essential make gcc lsb-release 16 | yes|perl -MCPAN -e 'install App::cpanminus' 17 | yes|perl -MCPAN -e 'install local::lib' 18 | yes|perl -MCPAN -e 'install Expect' 19 | export PERL5OPT=-Mlocal::lib 20 | /usr/local/bin/cpanm --installdeps . 21 | perl makefile-expect-driver.pl Linux::Debian Linux::Devuan Linux Unix OSFeatures::POSIXShellRedirection HWCapabilities::Int64 22 | make test 23 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/HWCapabilities/Int32.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::HWCapabilities::Int32; 2 | 3 | use strict; 4 | use warnings; 5 | no warnings 'redefine'; 6 | 7 | use Devel::CheckOS; 8 | use Config; 9 | 10 | our $VERSION = '1.0'; 11 | 12 | sub os_is { $Config{ivsize} == 4 } 13 | 14 | sub expn { "Your perl was built with support for 32 bit integers" } 15 | 16 | Devel::CheckOS::die_unsupported() unless(os_is()); 17 | 18 | =head1 COPYRIGHT and LICENCE 19 | 20 | Copyright 2024 David Cantrell 21 | 22 | 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. 23 | 24 | =cut 25 | 26 | 1; 27 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/HWCapabilities/Int64.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::HWCapabilities::Int64; 2 | 3 | use strict; 4 | use warnings; 5 | no warnings 'redefine'; 6 | 7 | use Devel::CheckOS; 8 | use Config; 9 | 10 | our $VERSION = '1.0'; 11 | 12 | sub os_is { $Config{ivsize} == 8 } 13 | 14 | sub expn { "Your perl was built with support for 64 bit integers" } 15 | 16 | Devel::CheckOS::die_unsupported() unless(os_is()); 17 | 18 | =head1 COPYRIGHT and LICENCE 19 | 20 | Copyright 2024 David Cantrell 21 | 22 | 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. 23 | 24 | =cut 25 | 26 | 1; 27 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/Devuan.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::Devuan; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('Linux') && 12 | `lsb_release -i 2>/dev/null` =~ /Devuan/ 13 | } 14 | 15 | sub expn { "The operating system is Devuan" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/v2_6.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::v2_6; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('Linux') && 12 | `uname -r` =~ /^2\.6\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system has a Linux 2.6.x series kernel" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MSWin32.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MSWin32; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub os_is { $^O =~ /^MSWin32$/i ? 1 : 0; } 11 | 12 | sub expn { 13 | join("\n", 14 | "The operating system is Microsoft Windows, and perl was built using", 15 | "the Win32 API" 16 | ) 17 | } 18 | 19 | Devel::CheckOS::die_unsupported() unless(os_is()); 20 | 21 | =head1 COPYRIGHT and LICENCE 22 | 23 | Copyright 2024 David Cantrell 24 | 25 | 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. 26 | 27 | =cut 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MicrosoftWindows.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MicrosoftWindows; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.4'; 9 | 10 | sub matches { return qw(Cygwin MSWin32 MSYS); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { "The operating system is some version of Microsoft Windows" } 15 | 16 | =head1 COPYRIGHT and LICENCE 17 | 18 | Copyright 2024 David Cantrell 19 | 20 | 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. 21 | 22 | =cut 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MSYS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MSYS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { $^O =~ /^msys2?$/i ? 1 : 0; } 11 | 12 | sub expn { 13 | join("\n", 14 | "The operating system is Microsoft Windows, but this perl", 15 | "is part of MSYS (or MSYS2), part of MinGW" 16 | ) 17 | } 18 | 19 | Devel::CheckOS::die_unsupported() unless(os_is()); 20 | 21 | =head1 COPYRIGHT and LICENCE 22 | 23 | Copyright 2024 David Cantrell 24 | 25 | 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. 26 | 27 | =cut 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v14.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v14; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^14/ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of Mac OS Sonoma" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Cygwin.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Cygwin; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub os_is { $^O =~ /^cygwin$/i ? 1 : 0; } 11 | 12 | sub expn { 13 | join("\n", 14 | "The operating system is Microsoft Windows, but perl was built using", 15 | "the POSIXish API provided by Cygwin" 16 | ) 17 | } 18 | 19 | Devel::CheckOS::die_unsupported() unless(os_is()); 20 | 21 | =head1 COPYRIGHT and LICENCE 22 | 23 | Copyright 2024 David Cantrell 24 | 25 | 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. 26 | 27 | =cut 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/Raspbian.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::Raspbian; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('Linux') && 12 | `lsb_release -i 2>/dev/null` =~ /Raspbian/ 13 | } 14 | 15 | sub expn { "The operating system is some version of Raspbian" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v11.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v11; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^11/ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of Mac OS Big Sur" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v12.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v12; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^12/ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of Mac OS Monterey" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v13.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v13; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^13/ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of Mac OS Ventura" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_0.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_0; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.0\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Cheetah (10.0)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_1.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_1; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.1\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Puma (10.1)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_2.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_2; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.2\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Jaguar (10.2)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_3.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_3; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.3\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Panther (10.3)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_4.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_4; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.4'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.4\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Tiger (10.4)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_5.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_5; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.5\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Leopard (10.5)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_7.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_7; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.7\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Lion (10.7)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_6.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_6; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.6\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Snow Leopard (10.6)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_10.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_10; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.10\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Yosemite (10.10)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_12.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_12; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.12\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Sierra (10.12)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_14.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_14; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.14\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Mojave (10.14)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_15.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_15; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.15\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Catalina (10.15)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_9.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_9; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.9\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Mavericks (10.9)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MachTen.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MachTen; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub os_is { $^O =~ /^machten$/i ? 1 : 0; } 11 | 12 | sub expn { 13 | join("\n", 14 | "You're using the Mach Ten BSD-compatible environment on top of", 15 | "Mac OS 'Classic' - ie, a pre-OS-X version of Mac OS.", 16 | ) 17 | } 18 | 19 | Devel::CheckOS::die_unsupported() unless(os_is()); 20 | 21 | =head1 COPYRIGHT and LICENCE 22 | 23 | Copyright 2024 David Cantrell 24 | 25 | 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. 26 | 27 | =cut 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/QNX.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::QNX; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub matches { return qw(QNX::v4 QNX::Neutrino); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | sub expn { 13 | join("\n", 14 | "All versions of QNX match this, as well as (possibly) a more specific", 15 | "match" 16 | ) 17 | } 18 | Devel::CheckOS::die_unsupported() unless(os_is()); 19 | 20 | =head1 COPYRIGHT and LICENCE 21 | 22 | Copyright 2024 David Cantrell 23 | 24 | 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. 25 | 26 | =cut 27 | 28 | 1; 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_11.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_11; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.11\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X El Capitan (10.11)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_13.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_13; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.13\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X High Sierra (10.13)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/MacOSX/v10_8.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::MacOSX::v10_8; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('MacOSX') && 12 | `sw_vers -productVersion` =~ /^10\.8\./ ? 1 : 0; 13 | } 14 | 15 | sub expn { "The operating system is some version of OS X Mountain Lion (10.8)" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/real-debian.yml: -------------------------------------------------------------------------------- 1 | name: Real Debian Linux 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | container: 8 | image: debian:stable 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Test on real Debian 12 | run: | 13 | cat /etc/os-release 14 | mkdir -p /run/systemd/system 15 | apt-get update 16 | yes|apt-get install perl-base build-essential make gcc lsb-release 17 | lsb_release -i 18 | yes|perl -MCPAN -e 'install App::cpanminus' 19 | yes|perl -MCPAN -e 'install local::lib' 20 | yes|perl -MCPAN -e 'install Expect' 21 | export PERL5OPT=-Mlocal::lib 22 | /usr/local/bin/cpanm --installdeps . 23 | perl makefile-expect-driver.pl Linux::Debian Linux::RealDebian Linux Unix OSFeatures::Systemd OSFeatures::POSIXShellRedirection HWCapabilities::Int64 24 | make test 25 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/RealDebian.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::RealDebian; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | sub os_is { 11 | Devel::CheckOS::os_is('Linux') && 12 | `lsb_release -i 2>/dev/null` =~ /Debian/ 13 | } 14 | 15 | sub expn { "The operating system is real Debian, recent enough to have \`lsb_release\`, and not some Debian derivative" } 16 | 17 | Devel::CheckOS::die_unsupported() unless(os_is()); 18 | 19 | =head1 COPYRIGHT and LICENCE 20 | 21 | Copyright 2024 David Cantrell 22 | 23 | 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. 24 | 25 | =cut 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/DEC.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::DEC; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.4'; 9 | 10 | sub matches { return qw(OSF VMS); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { 15 | join("\n", 16 | "The operating system is from Digital Equipment Corporation, or was", 17 | "originally written by DEC before they were taken over by Compaq/HP" 18 | ) 19 | } 20 | 21 | =head1 COPYRIGHT and LICENCE 22 | 23 | Copyright 2024 David Cantrell 24 | 25 | 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. 26 | 27 | =cut 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /.github/workflows/install-linux.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: Linux install 3 | 4 | jobs: 5 | build: 6 | runs-on: 'macos-12' 7 | steps: 8 | - uses: actions/checkout@v4 9 | - name: Setup Perl environment 10 | uses: shogo82148/actions-setup-perl@v1 11 | - name: Test and build 12 | run: | 13 | cpanm --installdeps . 14 | perl Makefile.PL 15 | make test 16 | make dist 17 | - uses: actions/upload-artifact@v4 18 | with: 19 | name: dist-for-linux-install 20 | path: '*.tar.gz' 21 | retention-days: 1 22 | install-linux: 23 | runs-on: 'ubuntu-latest' 24 | needs: build 25 | container: 26 | image: perl:5.34 27 | steps: 28 | - uses: actions/download-artifact@v4 29 | with: 30 | name: dist-for-linux-install 31 | - name: Install on Linux 32 | run: | 33 | cpanm *.tar.gz 34 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/EBCDIC.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::EBCDIC; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | # list of OSes lifted from Module::Build 0.2808 11 | # 12 | sub matches { 13 | return qw( 14 | OS390 OS400 POSIXBC VMESA 15 | ); 16 | } 17 | sub os_is { Devel::CheckOS::os_is(matches()); } 18 | Devel::CheckOS::die_unsupported() unless(os_is()); 19 | 20 | sub expn { 21 | "The OS uses some variant of EBCDIC instead of ASCII." 22 | } 23 | 24 | =head1 COPYRIGHT and LICENCE 25 | 26 | Copyright 2024 David Cantrell 27 | 28 | 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. 29 | 30 | =cut 31 | 32 | 1; 33 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/Debian.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::Debian; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.2'; 9 | 10 | sub matches { map { "Linux::$_" } qw(Raspbian Ubuntu RealDebian UnknownDebianLike Devuan) } 11 | 12 | sub os_is { Devel::CheckOS::os_is(matches()) } 13 | 14 | sub expn { "The operating system is some derivative of Debian Linux (see Linux::RealDebian for *actual* Debian Linux)" } 15 | 16 | Devel::CheckOS::die_unsupported() unless(os_is()); 17 | 18 | =head1 COPYRIGHT and LICENCE 19 | 20 | Copyright 2024 David Cantrell 21 | 22 | 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. 23 | 24 | =cut 25 | 26 | 1; 27 | 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/Ubuntu.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::Ubuntu; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | 7 | use Devel::AssertOS::OSFeatures::Release 'distributor_id'; 8 | 9 | no warnings 'redefine'; 10 | 11 | our $VERSION = '1.1'; 12 | 13 | sub os_is { 14 | my $id = distributor_id; 15 | Devel::CheckOS::os_is('Linux') && defined($id) && $id =~ /Ubuntu/; 16 | } 17 | 18 | sub expn { "The operating system is some version of Ubuntu" } 19 | 20 | Devel::CheckOS::die_unsupported() unless ( os_is() ); 21 | 22 | =head1 COPYRIGHT and LICENCE 23 | 24 | Copyright 2024 David Cantrell 25 | 26 | 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. 27 | 28 | =cut 29 | 30 | 1; 31 | 32 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.3'; 9 | 10 | sub subtypes { qw(Android) } 11 | sub matches { ('Linux', subtypes()) } 12 | 13 | sub os_is { 14 | ( 15 | # order is important 16 | Devel::CheckOS::os_is(subtypes()) || 17 | $^O =~ /^linux$/i 18 | ) ? 1 : 0; 19 | } 20 | 21 | Devel::CheckOS::die_unsupported() unless(os_is()); 22 | 23 | sub expn { 24 | "The operating system has a Linux kernel" 25 | } 26 | 27 | =head1 COPYRIGHT and LICENCE 28 | 29 | Copyright 2024 David Cantrell 30 | 31 | 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. 32 | 33 | =cut 34 | 35 | 1; 36 | -------------------------------------------------------------------------------- /t/assertos-do-not-want.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | eval "use Devel::AssertOS qw/ -NotAnOperatingSystem /"; 10 | is $@ => '', "do not want, not our OS, all is good"; 11 | 12 | eval "use Devel::AssertOS qw/ -notanoperatingsystem /"; 13 | is $@ => '', "do not want, not our OS, case-insensitively, all is good"; 14 | 15 | eval "use Devel::AssertOS qw/ -AnOperatingSystem /"; 16 | like $@ => qr/OS unsupported/, "do not want our OS => dying"; 17 | 18 | eval "use Devel::AssertOS qw/ -anoperatingsystem /"; 19 | like $@ => qr/OS unsupported/, "do not want our OS case-insensitively => dying"; 20 | 21 | eval "use Devel::AssertOS qw/ -NotAnOperatingSystem AnOperatingSystem /"; 22 | is $@ => '', 'negative + positive assertions successful'; 23 | 24 | eval "use Devel::AssertOS qw/ NotAnOperatingSystem -AnOperatingSystem /"; 25 | like $@ => qr/OS unsupported/, 'negative + positive assertions failing'; 26 | 27 | done_testing; 28 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OSFeatures/Systemd.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OSFeatures::Systemd; 2 | 3 | our $VERSION = '1.0'; 4 | 5 | use Devel::CheckOS; 6 | use strict; 7 | use warnings; 8 | no warnings 'redefine'; 9 | 10 | sub os_is { -d '/run/systemd/system' } 11 | Devel::CheckOS::die_unsupported() unless(os_is()); 12 | 13 | sub expn { 14 | "The operating system uses systemd as init instead of something more sensible" 15 | } 16 | 17 | =head1 NAME 18 | 19 | Devel::AssertOS::OSFeatures::Systemd - check whether 20 | the OS we're running on uses systemd instead of a sensible init. 21 | 22 | =head1 SYNOPSIS 23 | 24 | See L and L 25 | 26 | =head1 COPYRIGHT and LICENCE 27 | 28 | Copyright 2024 David Cantrell 29 | 30 | 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. 31 | 32 | =cut 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | --- 2 | jobs: 3 | build: 4 | runs-on: windows-latest 5 | steps: 6 | - uses: actions/checkout@v4 7 | - name: Set up perl 8 | uses: shogo82148/actions-setup-perl@v1 9 | with: 10 | distribution: strawberry 11 | perl-version: ${{ matrix.perl-version }} 12 | - name: perl -V 13 | run: perl -V 14 | - name: Install Dependencies 15 | run: | 16 | cpanm ExtUtils::MakeMaker Test::Pod Test::Pod::Coverage || cat $HOME/.cpanm/work/*/build.log 17 | cpanm --installdeps . || cat $HOME/.cpanm/work/*/build.log 18 | - name: Run Tests 19 | run: | 20 | perl Makefile.PL 21 | if( "${{ matrix.perl-version }}" -lt "5.26" ) { dmake test TEST_VERBOSE=1 } else { gmake test TEST_VERBOSE=1 } 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | perl-version: 26 | - '5.20' 27 | - '5.22' 28 | - '5.24' 29 | - '5.26' 30 | - '5.28' 31 | - '5.30' 32 | - '5.32' 33 | - latest 34 | name: Windows 35 | on: 36 | - push 37 | - pull_request 38 | -------------------------------------------------------------------------------- /t/case-insensitive.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use File::Spec; 5 | use lib; # no import yet! 6 | 7 | use Test::More; 8 | 9 | use Devel::CheckOS qw(list_platforms list_family_members os_is os_isnt); 10 | 11 | my $platform = find_platform(); 12 | 13 | # some platforms have all-upper names, so check the lower-case version as well 14 | ok(os_is(uc($platform)), "os_is('".uc($platform)."')"); 15 | ok(os_is(lc($platform)), "os_is('".lc($platform)."')"); 16 | 17 | lib->import(File::Spec->catdir(qw(t lib))); 18 | 19 | ok( 20 | os_is( 21 | 'anoperatingsystem', 22 | os_is('Linux') ? 'Irix' : 'Linux' 23 | ), 24 | "case-insensitive works for multiple targets" 25 | ); 26 | ok( 27 | os_is( 28 | (os_is('Linux') ? 'Irix' : 'Linux'), 29 | 'anoperatingsystem' 30 | ), 31 | "... regardless of order" 32 | ); 33 | ok( 34 | !os_isnt( 35 | (os_is('Linux') ? 'Irix' : 'Linux'), 36 | 'anoperatingsystem' 37 | ), 38 | "os_isnt is also case-insensitive" 39 | ); 40 | 41 | done_testing; 42 | 43 | sub find_platform { 44 | foreach my $platform (list_platforms()) { 45 | if(os_is($platform)) { 46 | return $platform; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Linux/UnknownDebianLike.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Linux::UnknownDebianLike; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.0'; 9 | 10 | # Can't use() this because that would make an infinite loop at BEGIN-time 11 | if(!exists($INC{'Devel/AssertOS/Linux/Debian.pm'})) { 12 | require Devel::AssertOS::Linux::Debian; 13 | } 14 | 15 | sub os_is { 16 | Devel::CheckOS::os_is('Linux') && 17 | -f '/etc/debian_version' && 18 | Devel::CheckOS::os_isnt(grep { $_ !~ /UnknownDebianLike/ } Devel::AssertOS::Linux::Debian::matches()) 19 | } 20 | 21 | sub expn { "The operating system is some derivative of Debian, or possibly a very old version of real Debian" } 22 | 23 | Devel::CheckOS::die_unsupported() unless(os_is()); 24 | 25 | =head1 COPYRIGHT and LICENCE 26 | 27 | Copyright 2024 David Cantrell 28 | 29 | 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. 30 | 31 | =cut 32 | 33 | 1; 34 | 35 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/BeOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::BeOS; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.4'; 9 | 10 | # weird special case, not quite like other OS modules, as this is both 11 | # an OS *and* a family - maybe this should be fixed at some point 12 | sub matches { return qw(Haiku) } 13 | sub os_is { 14 | return 1 if( 15 | $^O =~ /^beos$/i || 16 | Devel::CheckOS::os_is('Haiku') 17 | ); 18 | return 0; 19 | } 20 | 21 | sub expn { 22 | join("\n", 23 | "This matches both Be Inc's original BeOS, as well as Haiku, an open-", 24 | "source BeOS-compatible project. This is because Haiku is intended", 25 | "to be able to run BeOS software, while also having its own extra features." 26 | ) 27 | } 28 | 29 | Devel::CheckOS::die_unsupported() unless(os_is()); 30 | 31 | =head1 COPYRIGHT and LICENCE 32 | 33 | Copyright 2024 David Cantrell 34 | 35 | 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. 36 | 37 | =cut 38 | 39 | 1; 40 | -------------------------------------------------------------------------------- /.github/workflows/openbsd.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: OpenBSD 3 | 4 | jobs: 5 | build: 6 | runs-on: 'macos-12' 7 | steps: 8 | - uses: actions/checkout@v4 9 | - name: Setup Perl environment 10 | uses: shogo82148/actions-setup-perl@v1 11 | - name: Test and build 12 | run: | 13 | cpanm --installdeps . 14 | perl Makefile.PL 15 | make test 16 | make dist 17 | - uses: actions/upload-artifact@v4 18 | with: 19 | name: dist-for-openbsd-install 20 | path: '*.tar.gz' 21 | retention-days: 1 22 | install-openbsd: 23 | runs-on: macos-12 24 | needs: build 25 | steps: 26 | - uses: actions/download-artifact@v4 27 | with: 28 | name: dist-for-openbsd-install 29 | - name: Install on OpenBSD 30 | uses: cross-platform-actions/action@v0.24.0 31 | with: 32 | operating_system: openbsd 33 | version: 6.9 34 | shell: bash 35 | run: | 36 | mkdir dist-for-test && 37 | tar -C dist-for-test -xzf *.tar.gz && 38 | cd dist-for-test/* && 39 | cpan App::cpanminus && 40 | /home/runner/perl5/bin/cpanm --quiet --notest --installdeps . && 41 | /home/runner/perl5/bin/cpanm -v . 42 | 43 | -------------------------------------------------------------------------------- /.github/workflows/freebsd.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: FreeBSD 3 | 4 | jobs: 5 | build: 6 | runs-on: 'macos-12' 7 | steps: 8 | - uses: actions/checkout@v4 9 | - name: Setup Perl environment 10 | uses: shogo82148/actions-setup-perl@v1 11 | - name: Test and build 12 | run: | 13 | cpanm --installdeps . 14 | perl Makefile.PL 15 | make test 16 | make dist 17 | - uses: actions/upload-artifact@v4 18 | with: 19 | name: dist-for-freebsd-install 20 | path: '*.tar.gz' 21 | retention-days: 1 22 | install-freebsd: 23 | runs-on: macos-12 24 | needs: build 25 | steps: 26 | - uses: actions/download-artifact@v4 27 | with: 28 | name: dist-for-freebsd-install 29 | - name: Install on FreeBSD 30 | uses: cross-platform-actions/action@v0.24.0 31 | with: 32 | operating_system: freebsd 33 | version: 13.1 34 | shell: bash 35 | run: | 36 | mkdir dist-for-test && 37 | tar -C dist-for-test -xzf *.tar.gz && 38 | cd dist-for-test/* && 39 | sudo pkg install -y perl5 && 40 | cpan App::cpanminus && 41 | /home/runner/perl5/bin/cpanm --installdeps . && 42 | /home/runner/perl5/bin/cpanm -v . 43 | 44 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OSFeatures::POSIXShellRedirection; 2 | 3 | our $VERSION = '1.4'; 4 | 5 | use Devel::CheckOS; 6 | use strict; 7 | use warnings; 8 | no warnings 'redefine'; 9 | 10 | sub matches { return qw(Unix Cygwin BeOS VOS); } 11 | sub os_is { Devel::CheckOS::os_is(matches()); } 12 | Devel::CheckOS::die_unsupported() unless(os_is()); 13 | 14 | sub expn { 15 | join("\n", 16 | "The operating system's normal shell(s) support POSIX-style redirection", 17 | "such as:", 18 | " foo | more (piping from one command to another)", 19 | " foo > file (redirection of STDOUT to a file)", 20 | " foo 2> file (redirection of STDERR to a file)", 21 | " foo < file (redirection of STDIN from a file)", 22 | "and so on" 23 | ) 24 | } 25 | 26 | =head1 NAME 27 | 28 | Devel::AssertOS::OSFeatures::POSIXShellRedirection - check whether 29 | the OS we're running on can be expected to support POSIX shell 30 | redirection. 31 | 32 | =head1 SYNOPSIS 33 | 34 | See L and L 35 | 36 | =head1 COPYRIGHT and LICENCE 37 | 38 | Copyright 2024 David Cantrell 39 | 40 | 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. 41 | 42 | =cut 43 | 44 | 1; 45 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Unix.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::Unix; 2 | 3 | use Devel::CheckOS; 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; 7 | 8 | our $VERSION = '1.6'; 9 | 10 | # list of OSes originally lifted from Module::Build 0.2808 11 | # 12 | sub matches { 13 | return qw( 14 | AIX Android Bitrig BSDOS DGUX DragonflyBSD Dynix FreeBSD HPUX Hurd 15 | Interix iOS Irix Linux MachTen MacOSX Minix MirOSBSD NetBSD OpenBSD OSF 16 | QNX SCO Solaris SunOS SysVr4 SysVr5 Unicos MidnightBSD 17 | ); 18 | } 19 | sub os_is { Devel::CheckOS::os_is(matches()); } 20 | Devel::CheckOS::die_unsupported() unless(os_is()); 21 | 22 | sub expn { 23 | join("\n", 24 | "The OS supports multiple concurrent users, devices are represented as", 25 | "pseudo-files in /dev, there is a single root to the filesystem, users", 26 | "are protected from interference from other users, and the API is POSIXy.", 27 | "It should be reasonably easy to port a simple text-mode C program", 28 | "between Unixes.\n", 29 | "In some cases (eg Android, iOS) this might not be obvious or be exposed", 30 | "to users." 31 | ) 32 | } 33 | 34 | =head1 COPYRIGHT and LICENCE 35 | 36 | Copyright 2024 David Cantrell 37 | 38 | 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. 39 | 40 | =cut 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: Linux 3 | 4 | jobs: 5 | list: 6 | name: list available perl versions 7 | runs-on: 'ubuntu-latest' 8 | steps: 9 | - uses: shogo82148/actions-setup-perl@v1 10 | - id: set-matrix 11 | name: list available perl versions 12 | shell: perl {0} 13 | run: | 14 | use Actions::Core; 15 | set_output(matrix => {perl => [grep { $_ !~ /^5\.6/ } perl_versions()]}); 16 | outputs: 17 | matrix: ${{ steps.set-matrix.outputs.matrix }} 18 | 19 | build: 20 | runs-on: 'ubuntu-latest' 21 | needs: list 22 | strategy: 23 | fail-fast: false 24 | matrix: ${{fromJson(needs.list.outputs.matrix)}} 25 | name: Perl ${{ matrix.perl }} 26 | steps: 27 | - name: check out code 28 | uses: actions/checkout@v4 29 | 30 | - name: switch to perl ${{ matrix.perl }} 31 | uses: shogo82148/actions-setup-perl@v1 32 | with: 33 | perl-version: ${{ matrix.perl }} 34 | 35 | - name: run tests 36 | env: 37 | PERL_USE_UNSAFE_INC: 0 38 | run: | 39 | perl -v 40 | cpanm Expect ExtUtils::MakeMaker Test::Pod Test::Pod::Coverage || cat /home/runner/.cpanm/work/*/build.log 41 | perl -Mparent -e0 || cpanm parent 42 | rm -rf /home/runner/.cpanm/work/* 43 | cpanm --installdeps . || cat /home/runner/.cpanm/work/*/build.log 44 | perl makefile-expect-driver.pl Linux::Debian Linux::Ubuntu Linux Unix OSFeatures::Systemd OSFeatures::POSIXShellRedirection HWCapabilities::Int64 45 | make test TEST_VERBOSE=1 46 | -------------------------------------------------------------------------------- /t/checkos.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | use Test::Warnings qw(warning); 6 | 7 | BEGIN { use_ok('Devel::CheckOS'); } 8 | 9 | use File::Spec; 10 | use lib File::Spec->catdir(qw(t lib)); 11 | 12 | eval 'Devel::CheckOS::os_is("[broken]")'; 13 | ok($@ =~ /isn't a legal OS name/, "os_is whines about illegal names"); 14 | 15 | ok(Devel::CheckOS::os_is('AnOperatingSystem'), 16 | "a single valid OS detected by os_is"); 17 | ok(!Devel::CheckOS::os_is('NotAnOperatingSystem'), 18 | "a single invalid OS detected by os_is"); 19 | ok(Devel::CheckOS::os_isnt('NotAnOperatingSystem'), 20 | "a single invalid OS detectedby os_isnt"); 21 | ok(!Devel::CheckOS::os_isnt('AnOperatingSystem'), 22 | "a single valid OS detectedby os_isnt"); 23 | 24 | eval { Devel::CheckOS::die_if_os_isnt('AnOperatingSystem') }; 25 | ok(!$@, "a single valid OS detected using die_if_os_isnt"); 26 | eval { Devel::CheckOS::die_if_os_is('AnOperatingSystem') }; 27 | ok($@ =~ /OS unsupported/i, "a single valid OS detected using die_if_os_is"); 28 | 29 | eval { Devel::CheckOS::die_if_os_is('NotAnOperatingSystem') }; 30 | ok(!$@, "a single invalid OS detected using die_if_os_is"); 31 | eval { Devel::CheckOS::die_if_os_isnt('NotAnOperatingSystem') }; 32 | ok($@ =~ /OS unsupported/i, "a single invalid OS detected using die_if_os_isnt"); 33 | 34 | eval { Devel::CheckOS::die_unsupported() }; 35 | ok($@ =~ /OS unsupported/i, "die_unsupported works"); 36 | 37 | ok((grep { /^AnOperatingSystem$/i } Devel::CheckOS::list_platforms()) && 38 | (grep { /^NotAnOperatingSystem$/i } Devel::CheckOS::list_platforms()), 39 | "list_platforms works"); 40 | 41 | ok(!(grep { /^Alias::MacOS$/i } Devel::CheckOS::list_platforms()), 42 | "list_platforms excludes Aliases"); 43 | 44 | eval "use lib File::Spec->catdir(qw(t otherlib))"; 45 | 46 | is(1, (grep { /^AnOperatingSystem$/i } Devel::CheckOS::list_platforms()), 47 | "A platform is listed only once"); 48 | 49 | done_testing; 50 | -------------------------------------------------------------------------------- /makefile-expect-driver.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Expect; 5 | use File::Spec; 6 | 7 | (my @platforms_wanted = @ARGV) || 8 | die("You need to tell me what platforms to expect\n"); 9 | my $platforms_regex = '^Are you using ('.join('|', @platforms_wanted).')\\?'; 10 | my @platforms_found; 11 | my $e = Expect->new(); 12 | 13 | $ENV{AUTOMATED_TESTING} = 1; 14 | $e->spawn($^X, 'Makefile.PL'); 15 | 16 | my($eof, $timeout) = (0, 0); 17 | while(!$eof && !$timeout) { 18 | my $pattern_index = $e->expect( 19 | 50, 20 | [ eof => sub { $eof++; } ], 21 | [ timeout => sub { $timeout++; } ], 22 | -re => qr/(Are you using (.*)\?)/, 23 | ); 24 | if($pattern_index && $pattern_index == 3) { 25 | my $matched = $e->match(); 26 | (my $os_detected = $matched) =~ s/^Are you using (.*?)\?.*/$1/; 27 | push @platforms_found, $os_detected; 28 | 29 | if($matched =~ /$platforms_regex/) { 30 | $e->send("\n"); 31 | } else { 32 | $e->send("n\n"); 33 | } 34 | } 35 | } 36 | 37 | my @errors = (); 38 | foreach my $wanted_platform (@platforms_wanted) { 39 | if(!grep { $_ eq $wanted_platform } @platforms_found) { 40 | push @errors, "Wanted $wanted_platform, but not detected"; 41 | (my $filename_os = $wanted_platform) =~ s/::/-/g; 42 | my $test_file = File::Spec->catfile('t', "XX-no-autodetect-$^O-as-$filename_os.t"); 43 | open(my $fh, '>', $test_file) || die("Couldn't write $test_file: $!\n"); 44 | print $fh 'print "1..1\\nnot ok 1\\n"'; 45 | close($fh); 46 | } 47 | } 48 | foreach my $got_platform (@platforms_found) { 49 | if(!grep { $_ eq $got_platform } @platforms_wanted) { 50 | push @errors, "Got $got_platform, unexpectedly"; 51 | } 52 | } 53 | die( 54 | "Didn't match all (and only!) expected platforms:\n". 55 | join("\n", map { " $_" } @errors). 56 | "\n" 57 | ) if(@errors); 58 | -------------------------------------------------------------------------------- /t/failing-mockery.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | use Devel::CheckOS; 10 | 11 | my %platforms = ( 12 | aix => 'AIX', 13 | amigaos => 'Amiga', 14 | beos => 'BeOS', 15 | bsdos => 'BSDOS', 16 | cygwin => 'Cygwin', 17 | dgux => 'DGUX', 18 | dragonfly => 'DragonflyBSD', 19 | dynixptx => 'Dynix', 20 | freebsd => 'FreeBSD', 21 | gnukfreebsd => 'GNUkFreeBSD', 22 | haiku => 'Haiku', 23 | hpux => 'HPUX', 24 | interix => 'Interix', 25 | irix => 'Irix', 26 | linux => 'Linux', 27 | machten => 'MachTen', 28 | MacOS => 'MacOSclassic', 29 | darwin => 'MacOSX', 30 | midnightbsd => 'MidnightBSD', 31 | mirbsd => 'MirOSBSD', 32 | mpeix => 'MPEiX', 33 | msys => 'MSYS', 34 | msys2 => 'MSYS', 35 | dos => 'MSDOS', 36 | MSWin32 => 'MSWin32', 37 | netbsd => 'NetBSD', 38 | netware => 'Netware', 39 | next => 'NeXT', 40 | openbsd => 'OpenBSD', 41 | dec_osf => 'OSF', 42 | os2 => 'OS2', 43 | os390 => 'OS390', 44 | os400 => 'OS400', 45 | 'posix-bc' => 'POSIXBC', 46 | nto => 'QNX::Neutrino', 47 | qnx => 'QNX::v4', 48 | riscos => 'RISCOS', 49 | sco_sv => 'SCO', 50 | svr4 => 'SysVr4', 51 | svr5 => 'SysVr5', 52 | solaris => 'Solaris', 53 | sunos => 'SunOS', 54 | unicosmk => 'Unicos', 55 | unicos => 'Unicos', 56 | vmesa => 'VMESA', 57 | VMS => 'VMS', 58 | VOS => 'VOS', 59 | 60 | ); 61 | 62 | # see if all the platform-specific modules fail OK with the wrong $^O 63 | foreach my $o (sort { lc($platforms{$a}) cmp lc($platforms{$b}) } keys %platforms) { 64 | my $platform = $platforms{$o}; 65 | local $^O = ($platform eq 'Linux') ? 'irix' : 'linux'; 66 | # eval "use Devel::AssertOS::$platform"; 67 | ok(Devel::CheckOS::os_is($platform) == 0, "unsupported: $platform when \t\$^O = $^O"); 68 | } 69 | 70 | done_testing; 71 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/OSFeatures/Release.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS::OSFeatures::Release; 2 | 3 | use strict; 4 | use warnings; 5 | use File::Spec; 6 | use parent 'Exporter'; 7 | 8 | our $VERSION = '1.0'; 9 | our @EXPORT_OK = qw(distributor_id); 10 | 11 | =pod 12 | 13 | =head1 NAME 14 | 15 | Devel::AssertOS::OSFeatures::Release - functions to manipulate os-release file 16 | 17 | =head1 SYNOPSIS 18 | 19 | use Devel::AssertOS::OSFeatures::Release 'distributor_id'; 20 | my $id = distributor_id; 21 | 22 | =head1 DESCRIPTION 23 | 24 | This module exports functions to handle text files related to Debian-like 25 | distributions. 26 | 27 | =head1 EXPORTED 28 | 29 | The following subs are exported. 30 | 31 | =head2 distributor_id 32 | 33 | Retrieves and returns the distributor ID from the F file. 34 | 35 | It is expected that the file exists, it is readable and have the following 36 | (minimum) content format: 37 | 38 | NAME="Ubuntu" 39 | VERSION_ID="22.04" 40 | VERSION="22.04.4 LTS (Jammy Jellyfish)" 41 | VERSION_CODENAME=jammy 42 | ID=ubuntu 43 | ID_LIKE=debian 44 | HOME_URL="https://www.ubuntu.com/" 45 | 46 | This excerpt is from Ubuntu 22.04, but other distributions might have fewer, 47 | more or different fields and values. 48 | 49 | It returns the value of C or C, if the conditions are not those 50 | specified above. 51 | 52 | =cut 53 | 54 | sub distributor_id { 55 | my $filename = 'os-release'; 56 | my $file_path = File::Spec->catfile( ( '', 'etc' ), $filename ); 57 | my $regex = qr/^ID=(['"]?)([-\w.]+)\1\s*$/; 58 | my $dist_id = undef; 59 | 60 | if ( -r $file_path ) { 61 | open my $in, '<', $file_path or die "Cannot read $file_path: $!"; 62 | while (<$in>) { 63 | chomp; 64 | if ( $_ =~ $regex ) { 65 | $dist_id = ucfirst(lc $2) if (defined($2)); 66 | last; 67 | } 68 | } 69 | close($in) or die "Cannot close $file_path: $!"; 70 | } 71 | 72 | return $dist_id; 73 | } 74 | 75 | =head1 COPYRIGHT and LICENCE 76 | 77 | Copyright 2024 David Cantrell 78 | 79 | 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. 80 | 81 | =cut 82 | 83 | 1; 84 | -------------------------------------------------------------------------------- /t/mockery.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use File::Spec; 5 | use lib File::Spec->catdir(qw(t lib)); 6 | 7 | use Test::More; 8 | 9 | my %platforms = ( 10 | # $^O => platform name 11 | aix => 'AIX', 12 | amigaos => 'Amiga', 13 | android => 'Android', 14 | beos => 'BeOS', 15 | BITRIG => 'Bitrig', 16 | bsdos => 'BSDOS', 17 | cygwin => 'Cygwin', 18 | dgux => 'DGUX', 19 | dragonfly => 'DragonflyBSD', 20 | dynixptx => 'Dynix', 21 | freebsd => 'FreeBSD', 22 | gnu => 'Hurd', 23 | gnukfreebsd => 'GNUkFreeBSD', 24 | haiku => 'Haiku', 25 | hpux => 'HPUX', 26 | interix => 'Interix', 27 | irix => 'Irix', 28 | linux => 'Linux', 29 | machten => 'MachTen', 30 | MacOS => 'MacOSclassic', 31 | darwin => 'MacOSX', 32 | midnightbsd => 'MidnightBSD', 33 | mirbsd => 'MirOSBSD', 34 | mpeix => 'MPEiX', 35 | msys => 'MSYS', 36 | msys2 => 'MSYS', 37 | dos => 'MSDOS', 38 | minix => 'Minix', 39 | MSWin32 => 'MSWin32', 40 | netbsd => 'NetBSD', 41 | netware => 'Netware', 42 | next => 'NeXT', 43 | openbsd => 'OpenBSD', 44 | dec_osf => 'OSF', 45 | os2 => 'OS2', 46 | os390 => 'OS390', 47 | os400 => 'OS400', 48 | 'posix-bc' => 'POSIXBC', 49 | nto => 'QNX::Neutrino', 50 | qnx => 'QNX::v4', 51 | riscos => 'RISCOS', 52 | sco_sv => 'SCO', 53 | svr4 => 'SysVr4', 54 | svr5 => 'SysVr5', 55 | solaris => 'Solaris', 56 | sunos => 'SunOS', 57 | unicosmk => 'Unicos', 58 | unicos => 'Unicos', 59 | vmesa => 'VMESA', 60 | VMS => 'VMS', 61 | VOS => 'VOS', 62 | 63 | ); 64 | 65 | # see if all the platform-specific modules load OK with the right $^O 66 | foreach my $o (sort { lc($platforms{$a}) cmp lc($platforms{$b}) }keys %platforms) { 67 | my $platform = $platforms{$o}; 68 | eval qq{ local \$^O = '$o'; eval 'use Devel::AssertOS::$platform'; }; 69 | ok(!$@, "\$^O = $o\t=> $platform". ($@ ? ": $@" : '')); 70 | } 71 | 72 | { 73 | local $^O = 'haiku'; 74 | ok(Devel::CheckOS::os_is('BeOS'), "Haiku is also BeOS"); 75 | } 76 | 77 | { 78 | local $^O = 'android'; 79 | ok(Devel::CheckOS::os_is('Linux'), "Android is also Linux"); 80 | ok(Devel::CheckOS::os_is('Unix'), "Android is also Unix"); 81 | } 82 | 83 | done_testing; 84 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::AssertOS; 2 | 3 | use Devel::CheckOS; 4 | 5 | use strict; 6 | use warnings; 7 | 8 | our $VERSION = '1.21'; 9 | 10 | =head1 NAME 11 | 12 | Devel::AssertOS - require that we are running on a particular OS 13 | 14 | =head1 DESCRIPTION 15 | 16 | Devel::AssertOS is a utility module for Devel::CheckOS and 17 | Devel::AssertOS::*. It is nothing but a magic C that lets you 18 | do this: 19 | 20 | use Devel::AssertOS qw(Linux FreeBSD Cygwin); 21 | 22 | which will die unless the platform the code is running on is Linux, FreeBSD 23 | or Cygwin. 24 | 25 | To assert that the OS is B a specific platform, prepend the platform name 26 | with a minus sign. For example, to run on anything but Amiga, do: 27 | 28 | use Devel::AssertOS qw(-Amiga); 29 | 30 | 31 | =cut 32 | 33 | sub import { 34 | shift; 35 | die("Devel::AssertOS needs at least one parameter\n") unless(@_); 36 | 37 | my @oses = @_; 38 | 39 | my ( @must, @must_not ); 40 | 41 | for my $os ( @oses ) { 42 | if ( $os =~ s/^-// ) { 43 | push @must_not, $os; 44 | } 45 | else { 46 | push @must, $os; 47 | } 48 | } 49 | 50 | Devel::CheckOS::die_if_os_is(@must_not) if @must_not; 51 | Devel::CheckOS::die_if_os_isnt(@must) if @must; 52 | } 53 | 54 | =head1 BUGS and FEEDBACK 55 | 56 | I welcome feedback about my code, including constructive criticism. 57 | Bug reports should be made using L. 58 | 59 | You will need to include in your bug report the exact value of $^O, what 60 | the OS is called (eg Windows Vista 64 bit Ultimate Home Edition), and, 61 | if relevant, what "OS family" it should be in and who wrote it. 62 | 63 | If you are feeling particularly generous you can encourage me in my 64 | open source endeavours by buying me something from my wishlist: 65 | L 66 | 67 | =head1 SEE ALSO 68 | 69 | $^O in L 70 | 71 | L 72 | 73 | L 74 | 75 | L 76 | 77 | The use-devel-assertos script 78 | 79 | L 80 | 81 | =head1 AUTHOR 82 | 83 | David Cantrell EFE 84 | 85 | Thanks to David Golden for suggesting that I add this utility module. 86 | 87 | =head1 COPYRIGHT and LICENCE 88 | 89 | Copyright 2024 David Cantrell 90 | 91 | 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. 92 | 93 | =head1 CONSPIRACY 94 | 95 | This module is also free-as-in-mason software. 96 | 97 | =cut 98 | 99 | $^O; 100 | -------------------------------------------------------------------------------- /lib/Devel/CheckOS/Families.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | Devel::CheckOS::Families - what OS "families" are supported "out of the 4 | box" by Devel::CheckOS and Devel::AssertOS? 5 | 6 | =head1 WHAT IS AN OS FAMILY 7 | 8 | Computing platforms fall into several categories. For example, there is 9 | the category of Unix-a-likes. Each of these categories is a "family". 10 | A platform can fall into several families. 11 | 12 | =head1 THE Unix FAMILY 13 | 14 | Broadly speaking, these are platforms where: 15 | 16 | =over 17 | 18 | =item Devices are represented as pseudo-files in the filesystem 19 | 20 | =item Symlinks and hardlinks are supported in at least some filesystems 21 | 22 | =item "Unix-style" permissions are supported 23 | 24 | That is, there are seperate read/write/execute permissions for file owner, 25 | group and anyone. This implies the presence of multiple user accounts 26 | and user groups. Permissions may not be supported on all filesystems. 27 | 28 | =item The filesystem has a single root 29 | 30 | =item The C API for the operating system is largely POSIX-compatible 31 | 32 | =back 33 | 34 | =head1 THE Linux FAMILY 35 | 36 | This includes both ordinary Linux and Android. Plain old Linux will 37 | match 'Linux'. Android will match both that and 'Android'. 38 | 39 | =head1 THE Linux::Debian FAMILY 40 | 41 | Up until version 1.84 this wasn't a family, and would match any platform 42 | which claimed to be Debian via C or on which a file called 43 | C existed. That meant that as well as matching real 44 | Debian, it would also match Ubuntu, Raspbian, and so on. As of version 1.85 45 | C has become a family of all the Debian-based Linuxes. If 46 | you want to test which particular family member you're on then look at 47 | C to see what's available. 48 | 49 | NB the difference between C (which uses C 50 | for identification) and C (which uses the 51 | existence of C for identification). In particular 52 | beware that some *very* old Debians don't have C available 53 | and so will be detected as C. 54 | 55 | =head1 THE MicrosoftWindows FAMILY 56 | 57 | This includes any version of Windows and also includes things like 58 | Cygwin which run on top of it. 59 | 60 | =head1 THE DEC, Sun, and Apple FAMILIES 61 | 62 | These include any OS written by, respectively, DEC, Sun, and Apple. 63 | They exist because, while, eg, Mac OS Classic and Mac OS X are very 64 | different platforms, they do support some unique features - such as 65 | AppleScript. 66 | 67 | =head1 THE Realtime FAMILY 68 | 69 | This is for all real-time OSes. So far, it only includes QNX. 70 | 71 | =head1 THE EBCDIC FAMILY 72 | 73 | OSes which use EBCDIC instead of ASCII. 74 | 75 | =head1 AUTHOR, COPYRIGHT and LICENCE 76 | 77 | Copyright 2024 David Cantrell EFE 78 | 79 | This documentation is free-as-in-speech. It may be used, 80 | distributed and modified under the terms of the Creative Commons 81 | Attribution-Share Alike 2.0 UK: England & Wales License, whose 82 | text you may read at 83 | L. 84 | 85 | =head1 CONSPIRACY 86 | 87 | This documentation is also free-as-in-mason. 88 | 89 | =cut 90 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | lib/Devel/AssertOS/AIX.pm 2 | lib/Devel/AssertOS/Amiga.pm 3 | lib/Devel/AssertOS/Apple.pm 4 | lib/Devel/AssertOS/BeOS.pm 5 | lib/Devel/AssertOS/Haiku.pm 6 | lib/Devel/AssertOS/BSDOS.pm 7 | lib/Devel/AssertOS/Cygwin.pm 8 | lib/Devel/AssertOS/DEC.pm 9 | lib/Devel/AssertOS/DGUX.pm 10 | lib/Devel/AssertOS/DragonflyBSD.pm 11 | lib/Devel/AssertOS/Dynix.pm 12 | lib/Devel/AssertOS/Extending.pod 13 | lib/Devel/AssertOS/FreeBSD.pm 14 | lib/Devel/AssertOS/HPUX.pm 15 | lib/Devel/AssertOS/Interix.pm 16 | lib/Devel/AssertOS/Irix.pm 17 | lib/Devel/AssertOS/Linux.pm 18 | lib/Devel/AssertOS/Linux/v2_6.pm 19 | lib/Devel/AssertOS/MachTen.pm 20 | lib/Devel/AssertOS/MacOSclassic.pm 21 | lib/Devel/AssertOS/MacOSX.pm 22 | lib/Devel/AssertOS/MacOSX/v10_0.pm 23 | lib/Devel/AssertOS/MacOSX/v10_1.pm 24 | lib/Devel/AssertOS/MacOSX/v10_2.pm 25 | lib/Devel/AssertOS/MacOSX/v10_3.pm 26 | lib/Devel/AssertOS/MacOSX/v10_4.pm 27 | lib/Devel/AssertOS/MacOSX/v10_5.pm 28 | lib/Devel/AssertOS/MacOSX/v10_6.pm 29 | lib/Devel/AssertOS/MacOSX/v10_7.pm 30 | lib/Devel/AssertOS/MacOSX/v10_8.pm 31 | lib/Devel/AssertOS/MacOSX/v10_9.pm 32 | lib/Devel/AssertOS/MacOSX/v10_10.pm 33 | lib/Devel/AssertOS/MicrosoftWindows.pm 34 | lib/Devel/AssertOS/MPEiX.pm 35 | lib/Devel/AssertOS/MSDOS.pm 36 | lib/Devel/AssertOS/MSWin32.pm 37 | lib/Devel/AssertOS/NetBSD.pm 38 | lib/Devel/AssertOS/Netware.pm 39 | lib/Devel/AssertOS/NeXT.pm 40 | lib/Devel/AssertOS/OpenBSD.pm 41 | lib/Devel/AssertOS/OS2.pm 42 | lib/Devel/AssertOS/OS390.pm 43 | lib/Devel/AssertOS/OS400.pm 44 | lib/Devel/AssertOS/OSF.pm 45 | lib/Devel/AssertOS/POSIXBC.pm 46 | lib/Devel/AssertOS/RISCOS.pm 47 | lib/Devel/AssertOS/SCO.pm 48 | lib/Devel/AssertOS/Solaris.pm 49 | lib/Devel/AssertOS/Sun.pm 50 | lib/Devel/AssertOS/SunOS.pm 51 | lib/Devel/AssertOS/SysVr4.pm 52 | lib/Devel/AssertOS/SysVr5.pm 53 | lib/Devel/AssertOS/Unicos.pm 54 | lib/Devel/AssertOS/Unix.pm 55 | lib/Devel/AssertOS/VMESA.pm 56 | lib/Devel/AssertOS/VMS.pm 57 | lib/Devel/AssertOS/VOS.pm 58 | lib/Devel/AssertOS.pm 59 | lib/Devel/CheckOS.pm 60 | lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm 61 | Makefile.PL 62 | t/lib/Devel/AssertOS/AnOperatingSystem.pm 63 | t/lib/Devel/AssertOS/NotAnOperatingSystem.pm 64 | t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm 65 | t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm 66 | bin/use-devel-assertos 67 | TODO 68 | MANIFEST 69 | README 70 | CHANGELOG 71 | t/otherlib/Devel/AssertOS/AnOperatingSystem.pm 72 | lib/Devel/AssertOS/MirOSBSD.pm 73 | lib/Devel/AssertOS/Realtime.pm 74 | lib/Devel/AssertOS/QNX.pm 75 | lib/Devel/AssertOS/QNX/Neutrino.pm 76 | lib/Devel/AssertOS/QNX/v4.pm 77 | ARTISTIC.txt 78 | GPL2.txt 79 | lib/Devel/CheckOS/Families.pod 80 | lib/Devel/AssertOS/MidnightBSD.pm 81 | t/coverage.sh 82 | lib/Devel/AssertOS/EBCDIC.pm 83 | lib/Devel/AssertOS/GNUkFreeBSD.pm 84 | lib/Devel/AssertOS/Bitrig.pm 85 | lib/Devel/AssertOS/Android.pm 86 | MANIFEST.SKIP 87 | lib/Devel/AssertOS/Linux/Debian.pm 88 | lib/Devel/AssertOS/Minix.pm 89 | lib/Devel/AssertOS/iOS.pm 90 | lib/Devel/AssertOS/Hurd.pm 91 | lib/Devel/AssertOS/MacOSX/v10_11.pm 92 | lib/Devel/AssertOS/MacOSX/v10_12.pm 93 | lib/Devel/AssertOS/MacOSX/v10_13.pm 94 | lib/Devel/AssertOS/MacOSX/v10_14.pm 95 | lib/Devel/AssertOS/MacOSX/v10_15.pm 96 | lib/Devel/AssertOS/MSYS.pm 97 | lib/Devel/AssertOS/Linux/Raspbian.pm 98 | lib/Devel/AssertOS/Linux/RealDebian.pm 99 | lib/Devel/AssertOS/Linux/Ubuntu.pm 100 | lib/Devel/AssertOS/Linux/UnknownDebianLike.pm 101 | t/assertos-blah-invalid.t 102 | t/assertos-blah-valid.t 103 | t/assertos-do-not-want.t 104 | t/assertos-multi.t 105 | t/assertos-single-invalid-OS.t 106 | t/assertos-single-valid-OS.t 107 | t/checkos.t 108 | t/expn.t 109 | t/failing-mockery.t 110 | t/import-all.t 111 | t/import-bool.t 112 | t/import-fatal.t 113 | t/list_family_members.t 114 | t/mockery.t 115 | t/multilevel-names.t 116 | t/pod.t 117 | t/script.t 118 | t/unknown-debian.t 119 | lib/Devel/AssertOS/MacOSX/v11.pm 120 | lib/Devel/AssertOS/Linux/Devuan.pm 121 | t/case-insensitive.t 122 | lib/Devel/AssertOS/Alias/MacOS.pm 123 | t/alias-macos.t 124 | lib/Devel/AssertOS/MacOSX/v12.pm 125 | lib/Devel/AssertOS/HWCapabilities/Int64.pm 126 | t/int-size.t 127 | lib/Devel/AssertOS/HWCapabilities/Int32.pm 128 | lib/Devel/AssertOS/MacOSX/v13.pm 129 | lib/Devel/AssertOS/OSFeatures/Systemd.pm 130 | lib/Devel/AssertOS/MacOSX/v14.pm 131 | lib/Devel/AssertOS/OSFeatures/Release.pm 132 | t/os-release.t 133 | -------------------------------------------------------------------------------- /Makefile.PL: -------------------------------------------------------------------------------- 1 | #!perl 2 | require 5.006; 3 | use ExtUtils::MakeMaker; 4 | 5 | use File::Spec; 6 | 7 | use strict; 8 | use warnings; 9 | 10 | use lib 'lib'; 11 | 12 | # one of these is not like the other 13 | # this is really a sanity check that loading bogus modules doesn't Fuck Shit Up 14 | use Devel::CheckOS; 15 | my @dont_care = Devel::CheckOS::list_family_members('Unix'); 16 | @dont_care = Devel::CheckOS::list_family_members('MicrosoftWindows'); 17 | 18 | my(@OSes, @notOSes) = (); 19 | if($ENV{AUTOMATED_TESTING}) { 20 | print "I will now ask you some questions to make sure I've detected your\n"; 21 | print "system correctly. Most platforms will be detected several times.\n"; 22 | print "This is deliberate. To see an explanation of some of the more\n"; 23 | print "obscure options, hit the question mark key.\n\n"; 24 | findOSes(File::Spec->catdir(qw(lib Devel AssertOS))); 25 | opendir(T, 't'); 26 | unlink File::Spec->catfile('t', $_) foreach(grep { /^XX/ } readdir(T)); 27 | close(T); 28 | 29 | if(@notOSes) { # user told us we got it wrong 30 | foreach my $os (@notOSes) { 31 | (my $filename_os = $os) =~ s/::/-/g; 32 | my $test_file = File::Spec->catfile('t', "XX-autodetected-$^O-as-$filename_os.t"); 33 | open(my $fh, '>', $test_file) || die("Couldn't write ".$test_file.": $!\n"); 34 | print $fh 'print "1..1\\nnot ok 1\\n"'; 35 | close($fh); 36 | } 37 | } 38 | if(!@notOSes && !@OSes) { # didn't detect anything! 39 | my $test_file = File::Spec->catfile('t', "XX-autodetected-$^O-as-nothing.t"); 40 | open(my $fh, '>', $test_file) || die("Couldn't write ".$test_file.": $!\n"); 41 | print $fh 'print "1..1\\nnot ok 1\\n"'; 42 | close($fh); 43 | } 44 | if(@OSes) { 45 | foreach my $os (@OSes) { 46 | (my $filename_os = $os) =~ s/::/-/g; 47 | my $test_file = File::Spec->catfile('t', "XX-autodetected-$^O-as-$filename_os.t"); 48 | open(my $fh, '>', $test_file) || die("Couldn't write ".$test_file.": $!\n"); 49 | print $fh qq{ 50 | use Devel::AssertOS::$os; 51 | print "1..1\\n";print "ok 1\\n"; 52 | }; 53 | close($fh); 54 | } 55 | } 56 | } 57 | 58 | WriteMakefile( 59 | NAME => 'Devel::CheckOS', 60 | META_MERGE => { 61 | license => ["artistic_1", "artistic_2"], 62 | resources => { 63 | repository => 'https://github.com/DrHyde/perl-modules-Devel-CheckOS', 64 | bugtracker => 'https://github.com/DrHyde/perl-modules-Devel-CheckOS/issues' 65 | }, 66 | }, 67 | LICENSE => "gpl_2", 68 | MIN_PERL_VERSION => "5.6.0", 69 | VERSION_FROM => 'lib/Devel/CheckOS.pm', 70 | CONFIGURE_REQUIRES => { 71 | 'ExtUtils::MakeMaker' => 6.64, # TEST_REQUIRES (CONFIGURE_REQUIRES is in 6.52; BUILD_REQUIRES in 6.56) 72 | }, 73 | PREREQ_PM => { 74 | 'File::Find::Rule' => 0.28, 75 | 'File::Temp' => 0.19, 76 | 'Test::More' => 0.88, # done_testing 77 | 'Test::Warnings' => 0, # listed here as well as in TEST_REQUIRES in case we've got a Ye Olde Toolchaine 78 | # and not even the CONFIGURE_REQUIRES above is understood 79 | }, 80 | TEST_REQUIRES => { 81 | 'Test::More' => 0.88, 82 | 'Test::Warnings' => 0, 83 | }, 84 | EXE_FILES => [qw( 85 | bin/use-devel-assertos 86 | )], 87 | clean => { FILES => 't/XX*' } 88 | ); 89 | 90 | sub findOSes { 91 | my $dir = shift; 92 | opendir(LIBS, $dir) || 93 | die("Can't read $dir. Your distribution is broken\n"); 94 | my @dirents = File::Spec->no_upwards(readdir(LIBS)); 95 | closedir(LIBS); 96 | foreach (grep { -d File::Spec->catdir($dir, $_) } @dirents) { 97 | findOSes(File::Spec->catdir($dir, $_)); 98 | } 99 | foreach (map { s/\.pm$//; $_ } grep { /\.pm$/ } @dirents) { 100 | my $modname = join('::', File::Spec->splitdir($dir), $_); 101 | (my $classname = $modname) =~ s/^lib:://; 102 | (my $prompt_modname = $modname) =~ s/.*AssertOS:://; 103 | if (!eval "use $classname; ${classname}::os_is()") { 104 | next; 105 | } 106 | my $hasexpn = $classname->can('expn') ? '/?' : ''; 107 | ASK: my $answer = prompt( 108 | "Are you using $prompt_modname? [Y/n$hasexpn]", 109 | "Y" 110 | ); 111 | if($answer =~ /^y/i) { 112 | push @OSes, $prompt_modname; 113 | } elsif($answer =~ /^\?/) { 114 | if($hasexpn) { 115 | print "\n".$classname->expn()."\n\n"; 116 | } else { 117 | print "\nYou need help for that!?!?\n\n"; 118 | } 119 | goto ASK; 120 | } else { 121 | push @notOSes, $prompt_modname; 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /lib/Devel/AssertOS/Extending.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | Devel::AssertOS::Extending - how to write Devel::AssertOS::* modules that 4 | check what platform they're running on 5 | 6 | =head1 DESCRIPTION 7 | 8 | Devel::AssertOS::* modules are used by Devel::CheckOS to figure out what 9 | OS it is running on. A set of modules are provided which should correctly 10 | detect all platforms that perl *currently* runs on, as well as detecting 11 | OS 'families' like 'Unix' and 'Windows'. 12 | 13 | You can also use Devel::AssertOS::* modules on their own to quickly check 14 | whether you're running on the right platform. 15 | 16 | If you try to C a Devel::AssertOS module on the wrong platform, it 17 | will C by calling C. This 18 | conveniently spits out the text that CPAN-testers look for to see if 19 | your code failed simply because they're doing something as silly as 20 | testing your Solaris-only code on HPUX. 21 | 22 | =head1 HOW TO WRITE YOUR OWN MODULES 23 | 24 | If you want to add support for new platforms, you need to write a module 25 | called Devel::AssertOS::PlatformName which looks like: 26 | 27 | package Devel::AssertOS::Linux; 28 | use Devel::CheckOS; 29 | use strict; 30 | use warnings; 31 | no warnings 'redefine'; 32 | our $VERSION = '1.0'; 33 | sub os_is { $^O =~ /^linux$/i ? 1 : 0; } 34 | Devel::CheckOS::die_unsupported() unless(os_is()); 35 | 1; 36 | 37 | And that's it. The subroutine B be called C and loading the 38 | module B die in precisely that manner if your code is running on 39 | the wrong platform. It's a good idea to check $^O case-insensitively 40 | as it's not consistent. Note that it is an error to say: 41 | 42 | sub os_is { 1; } 43 | 44 | and assume "well, on the wrong platform that'll never get reached because 45 | the module can't load". Because the module *can* load, and indeed *does 46 | get loaded* - some functions in Devel::CheckOS do things like: 47 | 48 | eval "use Devel::AssertOS::$os"; 49 | 50 | to suppress the error. 51 | 52 | If you want to support a 'family' of OSes, then instead of matching against 53 | C<$^O>, instead use C to check that we're running on 54 | any of the OSes in your family, like this: 55 | 56 | package Devel::AssertOS::FreeSoftware; 57 | use Devel::CheckOS; 58 | use strict; 59 | use warnings; 60 | our $VERSION = '1.0'; 61 | sub matches { return qw(Linux FreeBSD NetBSD OpenBSD DragonflyBSD); } 62 | sub os_is { Devel::CheckOS::os_is(matches()); } 63 | sub expn { "The operating system is free-as-in-beer" } 64 | Devel::CheckOS::die_unsupported() unless(os_is()); 65 | 66 | You may also add a subroutine called C which should return a small 67 | snippet of explanatory text. Again, see Devel::AssertOS::Unix for an 68 | example. This is particularly useful for 'family' modules. 69 | 70 | Note the C subroutine - this is so that people can query your 71 | module and see what OSes are in your family. 72 | 73 | =head1 VERSIONS OF AN OS 74 | 75 | Two levels of name are supported. So C is 76 | legal. More than two levels are not supported. Be careful to pick names 77 | that are both legal perl package names and legal filenames on all platforms. 78 | In general, this means anything that matches C. 79 | 80 | =head1 OS FEATURES 81 | 82 | I would like to reserve the namespace C. 83 | If you want to release a module that tells the user whether a particular 84 | OS feature is available (eg, whether POSIX shell redirection can be 85 | expected to work) then please discuss it with me first. 86 | 87 | =head1 HARDWARE CAPABILITIES 88 | 89 | I would like to reserve the namespace C. 90 | If you want to release a module that tells the user whether a particular 91 | hardware feature is available (eg, whether you have 64 bit integers) then 92 | please discuss it with me first. 93 | 94 | =head1 ALIASES 95 | 96 | I would like to reserve the namespace C for use 97 | by OS aliases. If you want to release a module that provides an alternative 98 | name for an OS please discuss it with me first. 99 | 100 | Alias modules are simpler than normal extensions, they just need to call 101 | C when loaded, with the name of the alias 102 | as its first argument and the real name of the OS as the second. See 103 | L for an example. 104 | 105 | =head1 BUGS and FEEDBACK 106 | 107 | I welcome feedback about my code, including constructive criticism. 108 | Bug reports should be made using L. 109 | 110 | If you are feeling particularly generous you can encourage me in my 111 | open source endeavours by buying me something from my wishlist: 112 | L 113 | 114 | =head1 SEE ALSO 115 | 116 | L 117 | 118 | $^O in L 119 | 120 | L 121 | 122 | =head1 AUTHOR 123 | 124 | David Cantrell EFE 125 | 126 | Thanks to David Golden for the name and ideas about the interface, and 127 | for the cpan-testers-discuss mailing list for prompting me to write it 128 | in the first place. 129 | 130 | =head1 COPYRIGHT and LICENCE 131 | 132 | Copyright 2024 David Cantrell 133 | 134 | This documentation is free-as-in-speech. It may be used, 135 | distributed and modified under the terms of the Creative Commons 136 | Attribution-Share Alike 2.0 UK: England & Wales License, whose 137 | text you may read at 138 | L. 139 | 140 | =head1 CONSPIRACY 141 | 142 | This documentation is also free-as-in-mason. 143 | 144 | =cut 145 | -------------------------------------------------------------------------------- /bin/use-devel-assertos: -------------------------------------------------------------------------------- 1 | #!perl 2 | 3 | use strict; 4 | # NB no warnings because of "implicit split to @_" 5 | 6 | $/ = undef; 7 | 8 | use File::Spec; 9 | 10 | my @files = grep { -f $_ } qw(Makefile.PL Build.PL); 11 | 12 | (my @oses = @ARGV) || die("You must specify at least one OS\n"); 13 | 14 | eval "use Devel::AssertOS"; # to load AssertOS and CheckOS 15 | 16 | my $verbose = 1; 17 | if($oses[0] eq '-q') { # mostly to make tests shut the hell up 18 | $verbose = 0; 19 | shift @oses; 20 | } 21 | 22 | if($oses[0] eq '-l') { 23 | print join(', ', Devel::CheckOS::list_platforms())."\n"; 24 | exit(0); 25 | } 26 | 27 | 28 | if(!-e 'MANIFEST') { 29 | open(MANIFEST, '>>MANIFEST') || die("Can't update MANIFEST\n"); 30 | print MANIFEST "MANIFEST\n"; 31 | close(MANIFEST); 32 | } 33 | if(!@files) { # neither Makefile.PL no Build.PL exists, so create Makefile.PL 34 | open(MANIFEST, '>>MANIFEST') || die("Can't update MANIFEST\n"); 35 | print MANIFEST "Makefile.PL\n"; 36 | close(MANIFEST); 37 | } 38 | 39 | push @files, 'Makefile.PL' unless(@files); 40 | 41 | # NB can't just use scalar list_platforms cos that won't tell us that, 42 | # eg, Linux::v2_6 also uses Linux 43 | foreach my $os (@oses) { 44 | my %oldinc = %INC; 45 | eval "use Devel::AssertOS qw($os)"; 46 | if( 47 | join(':', map { $_ => $oldinc{$_} } sort keys %oldinc) eq 48 | join(':', map { $_ => $INC{$_} } sort keys %INC) 49 | ) { 50 | print STDERR "Couldn't find a module for $os\n"; 51 | exit(1); 52 | } 53 | } 54 | my @modulefiles = keys %{{ 55 | map { $_ => $INC{$_} } 56 | grep { 57 | /\bDevel\b/i && 58 | /\b(Check|Assert)OS\b/i && 59 | $_ !~ /\bAlias\b/i 60 | } 61 | keys %INC 62 | }}; 63 | 64 | mkdir 'inc'; 65 | mkdir 'inc/Devel'; 66 | mkdir 'inc/Devel/AssertOS'; 67 | print "Extra directories created under inc/\n" if($verbose); 68 | 69 | open(MANIFEST, '>>MANIFEST') || die("Can't update MANIFEST\n"); 70 | use Data::Dumper; 71 | foreach my $modulefile (@modulefiles) { 72 | my $fullfilename = ''; 73 | SEARCHINC: foreach (@INC) { 74 | if(-e File::Spec->catfile($_, $modulefile)) { 75 | $fullfilename = File::Spec->catfile($_, $modulefile); 76 | last SEARCHINC; 77 | } 78 | } 79 | die("Can't find a file for $modulefile\n") unless(-e $fullfilename); 80 | 81 | (my $module = join('::', split(/\W+/, $modulefile))) =~ s/::pm/.pm/; 82 | my @dircomponents = ('inc', (split(/::/, $module))); 83 | my $file = pop @dircomponents; 84 | 85 | mkdir File::Spec->catdir(@dircomponents); 86 | 87 | open(PM, $fullfilename) || 88 | die("Can't read $fullfilename: $!"); 89 | (my $pm = ) =~ s/package Devel::/package #\nDevel::/; 90 | close(PM); 91 | open(PM, '>'.File::Spec->catfile(@dircomponents, $file)) || 92 | die("Can't write ".File::Spec->catfile(@dircomponents, $file).": $!"); 93 | print PM $pm; 94 | print "Copied $fullfilename to\n ".File::Spec->catfile(@dircomponents, $file)."\n" if($verbose); 95 | close(PM); 96 | 97 | print MANIFEST join('/', @dircomponents, $file)."\n"; 98 | } 99 | close(MANIFEST); 100 | print "Added necessary modules\n" if($verbose); 101 | print "Updated MANIFEST\n" if($verbose); 102 | 103 | foreach my $file (@files) { 104 | my $contents = ''; 105 | if(open(FILE, $file)) { $contents = ; close(FILE); } 106 | open(FILE, ">$file") || die("Can't write $file\n"); 107 | print FILE 'use lib qw(inc); use Devel::AssertOS qw('. 108 | join(' ', 109 | sort { $a cmp $b } map { 110 | exists($Devel::CheckOS::OS_ALIASES{$_}) 111 | ? $Devel::CheckOS::OS_ALIASES{$_} 112 | : $_ 113 | } @oses 114 | ). 115 | ");\n\n"; 116 | print FILE $contents; 117 | close(FILE); 118 | print "Modified $file\n" if($verbose); 119 | } 120 | 121 | =head1 NAME 122 | 123 | use-devel-assertos - a script to package Devel::AssertOS modules 124 | with your code. 125 | 126 | =head1 DESCRIPTION 127 | 128 | This script, when run in the directory in which your shiny new module 129 | lives, will bundle whichever Devel::AssertOS modules you ask it to 130 | in the C directory, and update your Makefile.PL (or Build.PL) 131 | appropriately. If neither exists, it will create a Makefile.PL. 132 | The MANIFEST file is updated if any files are created. 133 | 134 | =head1 SYNOPSIS 135 | 136 | use-devel-assertos NetBSD OpenBSD FreeBSD 137 | 138 | But note that if you use C you are encouraged to use 139 | C instead. 140 | 141 | =head1 USAGE 142 | 143 | In the example above, this will insert code to make your module 144 | depend on one of the specified OSes, as well as update Makefile.PL / 145 | Build.PL / MANIFEST. By default it's rather noisy, but you can 146 | suppress that by passing -q as the first parameter. 147 | 148 | =head1 SUPPORTED PLATFORMS 149 | 150 | To get a list of supported platforms, do this: 151 | 152 | use-devel-assertos -l 153 | 154 | =head1 WARNINGS, BUGS and FEEDBACK 155 | 156 | This script has not been thoroughly tested. You should check by 157 | hand that it has done what you expected after running it. 158 | 159 | If you use Module::Build::Compat to write a Makefile.PL, then you 160 | will need to re-run this script whenever you have generated a new 161 | Makefile.PL. 162 | 163 | I welcome feedback about my code, including constructive criticism. 164 | Bug reports should be made using L. 165 | 166 | =head1 SEE ALSO 167 | 168 | L 169 | 170 | L 171 | 172 | L 173 | 174 | =head1 AUTHOR 175 | 176 | David Cantrell EFE 177 | 178 | =head1 COPYRIGHT and LICENCE 179 | 180 | Copyright 2024 David Cantrell 181 | 182 | 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. 183 | 184 | =head1 CONSPIRACY 185 | 186 | This software is also free-as-in-mason. 187 | 188 | =cut 189 | -------------------------------------------------------------------------------- /ARTISTIC.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | The "Artistic License" 6 | 7 | Preamble 8 | 9 | The intent of this document is to state the conditions under which a 10 | Package may be copied, such that the Copyright Holder maintains some 11 | semblance of artistic control over the development of the package, 12 | while giving the users of the package the right to use and distribute 13 | the Package in a more-or-less customary fashion, plus the right to make 14 | reasonable modifications. 15 | 16 | Definitions: 17 | 18 | "Package" refers to the collection of files distributed by the 19 | Copyright Holder, and derivatives of that collection of files 20 | created through textual modification. 21 | 22 | "Standard Version" refers to such a Package if it has not been 23 | modified, or has been modified in accordance with the wishes 24 | of the Copyright Holder as specified below. 25 | 26 | "Copyright Holder" is whoever is named in the copyright or 27 | copyrights for the package. 28 | 29 | "You" is you, if you're thinking about copying or distributing 30 | this Package. 31 | 32 | "Reasonable copying fee" is whatever you can justify on the 33 | basis of media cost, duplication charges, time of people involved, 34 | and so on. (You will not be required to justify it to the 35 | Copyright Holder, but only to the computing community at large 36 | as a market that must bear the fee.) 37 | 38 | "Freely Available" means that no fee is charged for the item 39 | itself, though there may be fees involved in handling the item. 40 | It also means that recipients of the item may redistribute it 41 | under the same conditions they received it. 42 | 43 | 1. You may make and give away verbatim copies of the source form of the 44 | Standard Version of this Package without restriction, provided that you 45 | duplicate all of the original copyright notices and associated disclaimers. 46 | 47 | 2. You may apply bug fixes, portability fixes and other modifications 48 | derived from the Public Domain or from the Copyright Holder. A Package 49 | modified in such a way shall still be considered the Standard Version. 50 | 51 | 3. You may otherwise modify your copy of this Package in any way, provided 52 | that you insert a prominent notice in each changed file stating how and 53 | when you changed that file, and provided that you do at least ONE of the 54 | following: 55 | 56 | a) place your modifications in the Public Domain or otherwise make them 57 | Freely Available, such as by posting said modifications to Usenet or 58 | an equivalent medium, or placing the modifications on a major archive 59 | site such as uunet.uu.net, or by allowing the Copyright Holder to include 60 | your modifications in the Standard Version of the Package. 61 | 62 | b) use the modified Package only within your corporation or organization. 63 | 64 | c) rename any non-standard executables so the names do not conflict 65 | with standard executables, which must also be provided, and provide 66 | a separate manual page for each non-standard executable that clearly 67 | documents how it differs from the Standard Version. 68 | 69 | d) make other distribution arrangements with the Copyright Holder. 70 | 71 | 4. You may distribute the programs of this Package in object code or 72 | executable form, provided that you do at least ONE of the following: 73 | 74 | a) distribute a Standard Version of the executables and library files, 75 | together with instructions (in the manual page or equivalent) on where 76 | to get the Standard Version. 77 | 78 | b) accompany the distribution with the machine-readable source of 79 | the Package with your modifications. 80 | 81 | c) give non-standard executables non-standard names, and clearly 82 | document the differences in manual pages (or equivalent), together 83 | with instructions on where to get the Standard Version. 84 | 85 | d) make other distribution arrangements with the Copyright Holder. 86 | 87 | 5. You may charge a reasonable copying fee for any distribution of this 88 | Package. You may charge any fee you choose for support of this 89 | Package. You may not charge a fee for this Package itself. However, 90 | you may distribute this Package in aggregate with other (possibly 91 | commercial) programs as part of a larger (possibly commercial) software 92 | distribution provided that you do not advertise this Package as a 93 | product of your own. You may embed this Package's interpreter within 94 | an executable of yours (by linking); this shall be construed as a mere 95 | form of aggregation, provided that the complete Standard Version of the 96 | interpreter is so embedded. 97 | 98 | 6. The scripts and library files supplied as input to or produced as 99 | output from the programs of this Package do not automatically fall 100 | under the copyright of this Package, but belong to whoever generated 101 | them, and may be sold commercially, and may be aggregated with this 102 | Package. If such scripts or library files are aggregated with this 103 | Package via the so-called "undump" or "unexec" methods of producing a 104 | binary executable image, then distribution of such an image shall 105 | neither be construed as a distribution of this Package nor shall it 106 | fall under the restrictions of Paragraphs 3 and 4, provided that you do 107 | not represent such an executable image as a Standard Version of this 108 | Package. 109 | 110 | 7. C subroutines (or comparably compiled subroutines in other 111 | languages) supplied by you and linked into this Package in order to 112 | emulate subroutines and variables of the language defined by this 113 | Package shall not be considered part of this Package, but are the 114 | equivalent of input as in Paragraph 6, provided these subroutines do 115 | not change the language in any way that would cause it to fail the 116 | regression tests for the language. 117 | 118 | 8. Aggregation of this Package with a commercial distribution is always 119 | permitted provided that the use of this Package is embedded; that is, 120 | when no overt attempt is made to make this Package's interfaces visible 121 | to the end user of the commercial distribution. Such use shall not be 122 | construed as a distribution of this Package. 123 | 124 | 9. The name of the Copyright Holder may not be used to endorse or promote 125 | products derived from this software without specific prior written permission. 126 | 127 | 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR 128 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 129 | WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 130 | 131 | The End 132 | -------------------------------------------------------------------------------- /t/script.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | $^W = 1; 3 | 4 | use Test::More; 5 | use File::Temp; 6 | use File::Spec; 7 | use Devel::CheckOS; 8 | use Cwd; 9 | 10 | my $cwd = getcwd(); 11 | 12 | use Config (); 13 | our $Inc = join $Config::Config{path_sep}, @INC; 14 | 15 | emptydir(); 16 | MakefilePLexists(); 17 | BuildPLexists(); 18 | BuildPLandMakefilePLexist(); 19 | checkCopyCorrectModulesLinux26MicrosoftWindows(); 20 | checkCopyCorrectModulesPOSIXRedir(); 21 | checkDashl(); 22 | 23 | sub checkDashl { 24 | my $projectdir = File::Temp->newdir(); 25 | chdir($projectdir); 26 | my $cmd = join(' ', map { qq{"$_"} } ( 27 | $^X, $cwd.'/bin/use-devel-assertos', '-l' 28 | )); 29 | do { local $ENV{PERL5LIB} = $Inc; $cmd = `$cmd` }; 30 | chomp($cmd); 31 | is_deeply( 32 | [sort { $a cmp $b } (Devel::CheckOS::list_platforms())], 33 | [sort { $a cmp $b } split(/, /, $cmd)], 34 | '-l spews the right stuff' 35 | ); 36 | chdir($cwd); 37 | ok(!-e File::Spec->catfile($projectdir, 'MANIFEST'), 38 | "... and doesn't write a MANIFEST"); 39 | ok(!-e File::Spec->catfile($projectdir, 'Makefile.PL'), 40 | "... or a Makefile.PL"); 41 | ok(!-e File::Spec->catdir($projectdir, 'inc'), 42 | "... or create directories"); 43 | } 44 | 45 | # a big family - make sure all are copied! 46 | sub checkCopyCorrectModulesPOSIXRedir { 47 | my $projectdir = File::Temp->newdir(); 48 | 49 | _run_script($projectdir, qw(OSFeatures::POSIXShellRedirection)); 50 | print "# use-devel-assertos OSFeatures::POSIXShellRedirection\n"; 51 | my @modules = ( 52 | 'OSFeatures::POSIXShellRedirection', 53 | Devel::CheckOS::list_family_members('OSFeatures::POSIXShellRedirection'), 54 | Devel::CheckOS::list_family_members('Unix'), 55 | Devel::CheckOS::list_family_members('BeOS'), 56 | Devel::CheckOS::list_family_members('QNX'), 57 | ); 58 | foreach(@modules) { 59 | ok(-e File::Spec->catfile( 60 | $projectdir, qw(inc Devel AssertOS), split('::', "$_.pm")), 61 | join('/', "inc/Devel/AssertOS", split('::', "$_.pm"))." exists"); 62 | } 63 | is_deeply( 64 | [sort {$a cmp $b} split("\n", _getfile(File::Spec->catfile($projectdir, 'MANIFEST')))], 65 | [sort {$a cmp $b} ( 66 | qw( 67 | inc/Devel/CheckOS.pm inc/Devel/AssertOS.pm 68 | MANIFEST Makefile.PL 69 | ), 70 | (map { 71 | join('/', "inc/Devel/AssertOS", split('::', "$_.pm")) 72 | } @modules) 73 | )], 74 | '... and update MANIFEST correctly' 75 | ); 76 | } 77 | 78 | # a family plus a specific module plus its parents 79 | sub checkCopyCorrectModulesLinux26MicrosoftWindows { 80 | my $projectdir = File::Temp->newdir(); 81 | 82 | _run_script($projectdir, qw(Linux::v2_6 MicrosoftWindows)); 83 | print "# use-devel-assertos Linux::v2_6 MicrosoftWindows\n"; 84 | ok(-e File::Spec->catfile( 85 | $projectdir, qw(inc Devel AssertOS Linux v2_6.pm)), 86 | "inc/Devel/AssertOS/Linux/v2_6.pm exists"); 87 | ok(-e File::Spec->catfile( 88 | $projectdir, qw(inc Devel AssertOS Linux.pm)), 89 | "inc/Devel/AssertOS/Linux.pm exists"); 90 | ok(-e File::Spec->catfile( 91 | $projectdir, qw(inc Devel AssertOS MSWin32.pm)), 92 | "inc/Devel/AssertOS/MSWin32.pm exists"); 93 | ok(-e File::Spec->catfile( 94 | $projectdir, qw(inc Devel AssertOS Cygwin.pm)), 95 | "inc/Devel/AssertOS/Cygwin.pm exists"); 96 | ok(-e File::Spec->catfile( 97 | $projectdir, qw(inc Devel AssertOS MicrosoftWindows.pm)), 98 | "inc/Devel/AssertOS/MicrosoftWindows.pm exists"); 99 | ok(-e File::Spec->catfile( 100 | $projectdir, qw(inc Devel AssertOS MSYS.pm)), 101 | "inc/Devel/AssertOS/MSYS.pm exists"); 102 | ok(-e File::Spec->catfile( 103 | $projectdir, qw(inc Devel AssertOS.pm)), 104 | "inc/Devel/AssertOS.pm exists"); 105 | ok(-e File::Spec->catfile( 106 | $projectdir, qw(inc Devel CheckOS.pm)), 107 | "inc/Devel/CheckOS.pm exists"); 108 | is_deeply( 109 | [sort split("\n", _getfile(File::Spec->catfile($projectdir, 'MANIFEST')))], 110 | [sort qw( inc/Devel/AssertOS/Android.pm 111 | inc/Devel/AssertOS/Linux/v2_6.pm inc/Devel/AssertOS/Linux.pm 112 | inc/Devel/AssertOS/MSWin32.pm inc/Devel/AssertOS/Cygwin.pm 113 | inc/Devel/AssertOS/MicrosoftWindows.pm 114 | inc/Devel/AssertOS/MSYS.pm 115 | inc/Devel/CheckOS.pm inc/Devel/AssertOS.pm 116 | MANIFEST Makefile.PL 117 | )], 118 | '... and update MANIFEST correctly' 119 | ); 120 | } 121 | 122 | sub BuildPLandMakefilePLexist { 123 | my $projectdir = File::Temp->newdir(); 124 | _writefile(File::Spec->catfile($projectdir, 'Build.PL'), 125 | "build stuff"); 126 | _writefile(File::Spec->catfile($projectdir, 'Makefile.PL'), 127 | "makefile stuff"); 128 | 129 | _run_script($projectdir, qw(Linux MSWin32)); 130 | is_deeply( 131 | _getfile(File::Spec->catfile($projectdir, 'Makefile.PL')), 132 | 'use lib qw(inc); use Devel::AssertOS qw(Linux MSWin32); 133 | 134 | makefile stuff', # mmm, significant whitespace 135 | 'if both exist, edit Makefile.PL' 136 | ); 137 | is_deeply( 138 | _getfile(File::Spec->catfile($projectdir, 'Build.PL')), 139 | 'use lib qw(inc); use Devel::AssertOS qw(Linux MSWin32); 140 | 141 | build stuff', # mmm, significant whitespace 142 | '... and Build.PL' 143 | ); 144 | } 145 | sub BuildPLexists { 146 | my $projectdir = File::Temp->newdir(); 147 | _writefile(File::Spec->catfile($projectdir, 'Build.PL'), 148 | "wibblywobblywoo"); 149 | _writefile(File::Spec->catfile($projectdir, 'MANIFEST'), 150 | "HLAGH\n"); 151 | 152 | _run_script($projectdir, qw(Linux MSWin32)); 153 | ok(!-e File::Spec->catfile($projectdir, 'Makefile.PL'), 154 | 'Makefile.PL not created'); 155 | is_deeply( 156 | _getfile(File::Spec->catfile($projectdir, 'Build.PL')), 157 | 'use lib qw(inc); use Devel::AssertOS qw(Linux MSWin32); 158 | 159 | wibblywobblywoo', # mmm, significant whitespace 160 | 'if Build.PL exists, edit it' 161 | ); 162 | is_deeply( 163 | [sort split("\n", _getfile(File::Spec->catfile($projectdir, 'MANIFEST')))], 164 | [sort qw( inc/Devel/AssertOS/Android.pm 165 | inc/Devel/AssertOS/Linux.pm inc/Devel/AssertOS/MSWin32.pm 166 | inc/Devel/CheckOS.pm inc/Devel/AssertOS.pm 167 | HLAGH 168 | )], 169 | '... and update MANIFEST correctly' 170 | ); 171 | } 172 | 173 | sub MakefilePLexists { 174 | my $projectdir = File::Temp->newdir(); 175 | _writefile(File::Spec->catfile($projectdir, 'Makefile.PL'), 176 | "wibblywobblywoo"); 177 | _writefile(File::Spec->catfile($projectdir, 'MANIFEST'), 178 | "HLAGH\n"); 179 | 180 | _run_script($projectdir, qw(Linux MSWin32)); 181 | ok(!-e File::Spec->catfile($projectdir, 'Build.PL'), 182 | 'Build.PL not created'); 183 | is_deeply( 184 | _getfile(File::Spec->catfile($projectdir, 'Makefile.PL')), 185 | 'use lib qw(inc); use Devel::AssertOS qw(Linux MSWin32); 186 | 187 | wibblywobblywoo', # mmm, significant whitespace 188 | 'if Makefile.PL exists, edit it' 189 | ); 190 | is_deeply( 191 | [sort split("\n", _getfile(File::Spec->catfile($projectdir, 'MANIFEST')))], 192 | [sort qw( inc/Devel/AssertOS/Android.pm 193 | inc/Devel/AssertOS/Linux.pm inc/Devel/AssertOS/MSWin32.pm 194 | inc/Devel/CheckOS.pm inc/Devel/AssertOS.pm 195 | HLAGH 196 | )], 197 | '... and update MANIFEST correctly' 198 | ); 199 | } 200 | 201 | sub emptydir { 202 | my $projectdir = File::Temp->newdir(); 203 | _run_script($projectdir, qw(MacOS Linux MSWin32)); 204 | ok(-e File::Spec->catfile($projectdir, 'Makefile.PL'), 205 | "create Makefile.PL if there's neither Makefile.PL nor Build.PL"); 206 | is_deeply( 207 | _getfile(File::Spec->catfile($projectdir, 'Makefile.PL')), 208 | 'use lib qw(inc); use Devel::AssertOS qw(Linux MSWin32 MacOSX); 209 | 210 | ', # mmm, significant whitespace 211 | '... and created it correctly' 212 | ); 213 | is_deeply( 214 | [sort split("\n", _getfile(File::Spec->catfile($projectdir, 'MANIFEST')))], 215 | [sort qw( 216 | inc/Devel/AssertOS/Android.pm 217 | inc/Devel/AssertOS/Linux.pm inc/Devel/AssertOS/MSWin32.pm 218 | inc/Devel/AssertOS/MacOSX.pm 219 | inc/Devel/CheckOS.pm inc/Devel/AssertOS.pm 220 | MANIFEST Makefile.PL 221 | )], 222 | '... and MANIFEST created OK where there wasn\'t one' 223 | ); 224 | } 225 | 226 | sub _getfile { open(my $fh, $_[0]) || return ''; local $/; return <$fh>; } 227 | sub _writefile { open(my $fh, '>', shift()) || return ''; print $fh @_; } 228 | sub _run_script { 229 | chdir(shift()); 230 | require Config; 231 | local $ENV{PERL5LIB} = $Inc; 232 | system($^X, $cwd.'/bin/use-devel-assertos', '-q', @_); 233 | chdir($cwd); 234 | } 235 | 236 | done_testing(); 237 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 2.03 2024-05-?? 2 | 3 | - OS ID's are not always \w+ 4 | 5 | 2.02 2024-05-15 6 | 7 | - Read /etc/os-release to detect Ubuntu instead of shelling out to `lsb_release` 8 | there will be further updates in the future to do the same on other Linux distros 9 | 10 | 2.01 2024-05-02 11 | 12 | - Fix typos in docoumentation 13 | 14 | 2.00 2024-05-01 15 | 16 | - list_* no longer have special behaviour when called in scalar context. This has 17 | been deprecated since version 1.90; 18 | 19 | - Add Devel::AssertOS::MacOSX::v14 (Sonoma) 20 | 21 | 1.96 2023-02-04 22 | 23 | - Add Devel::AssertOS::MacOSX::v13 (Ventura) 24 | 25 | - Add Devel::AssertOS::OSFeatures::Systemd 26 | 27 | 1.95 2022-10-29 28 | 29 | - Add Devel::AssertOS::HWCapabilities::Int{32,64} 30 | 31 | 1.94 2022-07-27 32 | 33 | - Add Mac OS 12 (Monterey) 34 | 35 | 1.93 2022-04-25 36 | 37 | - No functional changes, just changes to where dependencies are declared 38 | https://github.com/DrHyde/perl-modules-Devel-CheckOS/issues/27 39 | 40 | 1.92 2022-04-24 41 | 42 | - Fix bugs in new alias and case-insensitivity features which meant everything 43 | broke in taint-mode. The new features now no longer work in taint-mode but 44 | everything else should. 45 | 46 | 1.91 2022-04-21 47 | 48 | - Fix tests for platforms where the OS is detected as something that is 49 | a family, but not as anything more specific, such as Fedora Linux 50 | 51 | 1.90 2022-04-20 52 | 53 | - Matches are now case-insensitive 54 | 55 | - Add support for OS aliases 56 | 57 | - Deprecated the list_* functions being context sensitive, they now warn 58 | when called inappropriately. They will stop being context-sensitive some 59 | time after April 2024. 60 | 61 | 1.87 2021-05-25 62 | 63 | - Add support for Devuan Linux 64 | 65 | 1.86 2021-05-20 66 | 67 | - Belatedly add doco on Debian family to Families.pod 68 | 69 | - Add Mac OS 11 (Big Sur) 70 | 71 | 1.85 2020-10-15 Add Linux::Raspbian and Linux::Ubuntu; 72 | Add Linux::RealDebian for *actual* Debian Linux; 73 | Add Linux::UnknownDebianLike for anything else that's like Debian; 74 | Linux::Debian has become a family that includes all the above 75 | 76 | 1.84 2020-10-05 Add some more versions of MacOS; 77 | Note change of name Mac OS X -> MacOS, but don't 78 | change the module name for backward compatibility; 79 | Add MSYS (reported by perl in MinGW environments) 80 | 81 | 1.83 2020-02-15 Remove dependency on Data::Compare, which in turn 82 | depends on non-pure-perl XS in Clone.pm 83 | 84 | 1.82 2020-02-15 Fix build bug affecting perl 5.8 when AUTOMATED_TESTING 85 | is set (https://github.com/DrHyde/perl-modules-Devel-CheckOS/pull/23) 86 | 87 | 1.81 2018-01-23 Restore 5.6 and 5.8 compatibility; 88 | Cope better in tests when @INC is humungous 89 | 90 | 1.80 2017-05-24 Fix bug where tests would fail if 91 | AUTOMATED_TESTING=1 on perl 5.26 and higher; 92 | For some reason that made it break on 5.8.9, 93 | but I don't really care 94 | 95 | 1.79 2016-10-30 Fix another minor bug 96 | (https://github.com/DrHyde/perl-modules-Devel-CheckOS/issues/17) 97 | 98 | 1.78 2016-10-30 Fix an isue that made it uninstallable on some 99 | systems (https://github.com/DrHyde/perl-modules-Devel-CheckOS/issues/16) 100 | 101 | 1.77 2016-10-21 Add MacOSX:v10_11 and ..._12 102 | 103 | 1.76 2015-03-13 Add GNU Hurd 104 | 105 | 1.75 2015-03-08 Add Minix and iOS; 106 | Correct ancient typo in Apple family that no-one 107 | has ever noticed because no-one uses 'classic' 108 | Mac OS; 109 | Various 'kwalitee' improvements from Dale Evans 110 | 111 | 1.74 2015-03-04 Add Linux::Debian; 112 | Add MacOSX::v10_* (up to 10_10); 113 | Add perl 5.6.2 support 114 | all the above thanks to Dale Evans 115 | 116 | 1.73 2014-08-01 Add support for Android 117 | 118 | 1.72 2014-04-16 Add support for Bitrig, an OpenBSD fork; 119 | Check $^O case-insensitively as some OSes 120 | aren't particularly consistent 121 | 122 | 1.71 2013-01-27 Bugfix, better tests for negative assertions, 123 | also from Yanick 124 | 125 | 1.7 2012-11-20 Add support for negative assertions in 126 | Devel::AssertOS, thanks to Yanick Champoux 127 | 128 | 1.64 2011-04-25 Add support for GNU/kFreeBSD 129 | 130 | 1.63 2010-05-29 $^O for VOS is sometimes VOS, sometimes vos; 131 | VOS supports POSIX shell redirections 132 | 133 | 1.62 2010-05-21 Add OS X 10.5 platform and EBCDIC family 134 | 135 | 1.61 2009-04-25 Better code coverage in tests; 136 | Fix bug in script - not copying all members of 137 | a family, only those it checked up until the 138 | OS it's running on 139 | 140 | 1.6 2009-04-21 Only ask to confirm what this platform is in 141 | Makefile.PL if AUTOMATED_TESTING is set; 142 | Add MidnightBSD 143 | 144 | 1.55 2009-04-16 This time with the damned changes - really 145 | shouldn't be doing releases at 1 am :-) 146 | 147 | 1.54 2009-04-16 And more irritating little changes, this time 148 | to make tests pass on 5.6.2 149 | 150 | 1.53 2009-04-15 Grargh! 5.10.0 doesn't fully populate %INC 151 | if a module dies when we use() it. HATE. 152 | So need another way to find the files in the 153 | scripts. Grr. Hate. Kill. 154 | 155 | 1.52 2009-04-15 Scalar context bug fixed in script, thanks to 156 | Mike Kelly 157 | Tests and misc fixes for script 158 | 159 | 1.51 2009-04-14 OS "families" can tell you what their members are; 160 | Update Extending.pod to explain that 161 | 162 | 1.50 2008-11-11 No bugs found in 1.49_01, bumping to 1.50 163 | The "shrill demented choirs of wailing shells" 164 | release 165 | 166 | 1.49_01 2008-11-05 add Haiku (thanks to Ingo Weinhold) 167 | BeOS has a POSIXish shell 168 | Makefile.PL can now explain what some of the 169 | OSes and OS families are (thanks to Michael 170 | Schwern for suggesting it) 171 | The "only honest man to ever enter parliament" 172 | release 173 | 174 | 1.46 2008-10-27 fix bug on Windows 175 | 176 | 1.45 2008-10-22 add QNX, QNX::v4, QNX::Neutrino 177 | (thanks to Matt Kraai) 178 | add Realtime family 179 | doco about families 180 | add licence text files 181 | families now use documented interface instead 182 | of embedding $^O values all over the place 183 | 184 | 1.44 2008-09-26 add D::A::MirOSBSD ($^O eq 'mirbsd') 185 | 186 | 1.43 2008-03-12 use-devel-assertos now prints some status updates; 187 | Break up 'package Devel::CheckLib' in inc/ so 188 | distributions including it don't get marked 189 | as 'unauthorised' 190 | 191 | 1.42 2007-11-20 Applied Seth Blumberg's patch to make 192 | list_platforms work on not-Unix; 193 | Documented that ...::OSFeatures::* is reserved; 194 | Added D::A::OSFeatures::POSIXShellRedirection 195 | 196 | 1.41 2007-11-07 Aaargh, fixed broken Makefile.PL 197 | 198 | 1.4 2007-11-07 Fix use-devel-assertos to update MANIFEST 199 | 200 | 1.3 2007-11-07 Support multi-level OSnames 201 | 202 | 1.2 2007-10-14 Made prompts in Makefile.PL clearer; 203 | Added use-devel-assertos script; 204 | Makefile.PL now requires 5.005 instead of use 205 | 206 | 1.1 2007-10-04 Oops, forgot to 'use Exporter'! 207 | 208 | 1.0 2007-10-02 Remove File::Spec::Functions; 209 | Test that we can load the OSes we detected. 210 | This is totally paranoid cos we already 211 | did it in Makefile.PL to detect them, but 212 | mumble mumble case insensitve mumble 213 | 214 | 0.92 2007-10-01 More portability fixes 215 | 216 | 0.91 2007-10-01 Fix filesystem portability stuff using 'catdir' 217 | 218 | 0.9 2007-09-30 First release candidate 219 | -------------------------------------------------------------------------------- /lib/Devel/CheckOS.pm: -------------------------------------------------------------------------------- 1 | package Devel::CheckOS; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Exporter; 7 | # if we're loading this from Makefile.PL, FFR might not yet be installed 8 | eval 'use File::Find::Rule'; 9 | use File::Spec; 10 | 11 | use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS %OS_ALIASES); 12 | 13 | our $VERSION = '2.02'; 14 | 15 | @ISA = qw(Exporter); 16 | @EXPORT_OK = qw( 17 | os_is os_isnt die_if_os_is die_if_os_isnt die_unsupported 18 | list_platforms list_family_members register_alias 19 | ); 20 | %EXPORT_TAGS = ( 21 | all => \@EXPORT_OK, 22 | booleans => [qw(os_is os_isnt die_unsupported)], 23 | fatal => [qw(die_if_os_is die_if_os_isnt)] 24 | ); 25 | 26 | # get a list of the .pm files under a list of dirs, or the empty list 27 | # in taint mode 28 | sub _find_pm_files_in_dirs { 29 | my @files; 30 | eval { @files = File::Find::Rule->file()->name('*.pm')->in(@_) }; 31 | return @files; 32 | } 33 | 34 | if(exists($INC{'File/Find/Rule.pm'})) { 35 | foreach my $alias_module ( 36 | _find_pm_files_in_dirs( 37 | grep { -d } 38 | map { File::Spec->catdir($_, qw(Devel AssertOS Alias)) } 39 | @INC 40 | ) 41 | ) { 42 | my(undef, undef, $file_part) = File::Spec->splitpath($alias_module); 43 | $file_part =~ s/\.pm$//; 44 | eval "use Devel::AssertOS::Alias::$file_part"; 45 | warn("Bad alias module 'Devel::AssertOS::Alias::$file_part' ignored\n") if($@); 46 | } 47 | } 48 | 49 | =head1 NAME 50 | 51 | Devel::CheckOS - check what OS we're running on 52 | 53 | =head1 DESCRIPTION 54 | 55 | A learned sage once wrote on IRC: 56 | 57 | $^O is stupid and ugly, it wears its pants as a hat 58 | 59 | Devel::CheckOS provides a more friendly interface to $^O, and also lets 60 | you check for various OS "families" such as "Unix", which includes things 61 | like Linux, Solaris, AIX etc. 62 | 63 | It spares perl the embarrassment of wearing its pants on its head by 64 | covering them with a splendid Fedora. 65 | 66 | =head1 SYNOPSIS 67 | 68 | use Devel::CheckOS qw(os_is); 69 | print "Hey, I know this, it's a Unix system\n" if(os_is('Unix')); 70 | 71 | print "You've got Linux 2.6\n" if(os_is('Linux::v2_6')); 72 | 73 | =head1 USING IT IN Makefile.PL or Build.PL 74 | 75 | If you want to use this from Makefile.PL or Build.PL, do 76 | not simply copy the module into your distribution as this may cause 77 | problems when PAUSE and search.cpan.org index the distro. Instead, use 78 | the use-devel-assertos script. 79 | 80 | =head1 FUNCTIONS 81 | 82 | Devel::CheckOS implements the following functions, which load subsidiary 83 | OS-specific modules on demand to do the real work. They can all be exported 84 | by listing their names after C. You can also export 85 | groups of functions thus: 86 | 87 | use Devel::CheckOS qw(:booleans); # export the boolean functions 88 | # and 'die_unsupported' 89 | 90 | use Devel::CheckOS qw(:fatal); # export those that die on no match 91 | 92 | use Devel::CheckOS qw(:all); # export everything exportable 93 | 94 | =head2 Boolean functions 95 | 96 | =head3 os_is 97 | 98 | Takes a list of OS names. If the current platform matches any of them, 99 | it returns true, otherwise it returns false. The names can be a mixture 100 | of OSes and OS families, eg ... 101 | 102 | os_is(qw(Unix VMS)); # Unix is a family, VMS is an OS 103 | 104 | Matching is case-insensitive provided that Taint-mode is not enabled, so the 105 | above could also be written: 106 | 107 | os_is(qw(unix vms)); 108 | 109 | =cut 110 | 111 | sub os_is { 112 | my @targets = @_; 113 | my $rval = 0; 114 | 115 | TARGET: foreach my $target (@targets) { 116 | # resolve aliases 117 | ALIAS: foreach my $alias (keys %OS_ALIASES) { 118 | if($target =~ /^$alias$/i) { 119 | $target = $OS_ALIASES{$alias}; 120 | last ALIAS; 121 | } 122 | } 123 | 124 | # resolve case-insensitive names (no-op in taint-mode as list_platforms 125 | # won't work) 126 | my @available_platforms = list_platforms(); 127 | CANDIDATE: foreach my $candidate (@available_platforms) { 128 | if($target =~ /^\Q$candidate\E$/i) { 129 | $target = $candidate; 130 | last CANDIDATE; 131 | } 132 | } 133 | 134 | die("Devel::CheckOS: $target isn't a legal OS name\n") 135 | unless($target =~ /^\w+(::\w+)*$/); 136 | eval "use Devel::AssertOS::$target"; 137 | if(!$@) { 138 | no strict 'refs'; 139 | $rval = 1 if(&{"Devel::AssertOS::${target}::os_is"}()); 140 | } 141 | } 142 | return $rval; 143 | } 144 | 145 | =head3 os_isnt 146 | 147 | If the current platform matches (case-insensitively) any of the parameters it 148 | returns false, otherwise it returns true. 149 | 150 | =cut 151 | 152 | sub os_isnt { 153 | my @targets = @_; 154 | my $rval = 1; 155 | foreach my $target (@targets) { 156 | $rval = 0 if(os_is($target)); 157 | } 158 | return $rval; 159 | } 160 | 161 | =head2 Fatal functions 162 | 163 | =head3 die_if_os_isnt 164 | 165 | As C, except that it dies instead of returning false. The die() 166 | message matches what the CPAN-testers look for to determine if a module 167 | doesn't support a particular platform. 168 | 169 | =cut 170 | 171 | sub die_if_os_isnt { 172 | os_is(@_) ? 1 : die_unsupported(); 173 | } 174 | 175 | =head3 die_if_os_is 176 | 177 | As C, except that it dies instead of returning false. 178 | 179 | =cut 180 | 181 | sub die_if_os_is { 182 | os_isnt(@_) ? 1 : die_unsupported(); 183 | } 184 | 185 | =head2 And some utility functions ... 186 | 187 | =head3 die_unsupported 188 | 189 | This function simply dies with the message "OS unsupported", which is what 190 | the CPAN testers look for to figure out whether a platform is supported or 191 | not. 192 | 193 | =cut 194 | 195 | sub die_unsupported { die("OS unsupported\n"); } 196 | 197 | =head3 list_platforms 198 | 199 | Return a list of all the platforms for which the corresponding 200 | Devel::AssertOS::* module is available. This includes both OSes and OS 201 | families, and both those bundled with this module and any third-party 202 | add-ons you have installed. 203 | 204 | Unfortunately, on some platforms this list may have platform names' 205 | case broken, eg you might see 'freebsd' instead of 'FreeBSD'. 206 | This is because they have case-insensitive filesystems so things 207 | should Just Work anyway. 208 | 209 | This function does not work in taint-mode. 210 | 211 | =cut 212 | 213 | my $case_flag = File::Spec->case_tolerant ? '(?i)' : ''; 214 | my $re_Devel = qr/$case_flag ^Devel$/x; 215 | my $re_AssertOS = qr/$case_flag ^AssertOS$/x; 216 | my $re_Alias = qr/$case_flag ^Alias\b/x; 217 | 218 | sub list_platforms { 219 | my @modules = sort keys %{ {map { $_ => 1 } grep { 220 | $_ !~ $re_Alias 221 | } map { 222 | my (undef, $dir_part, $file_part) = File::Spec->splitpath($_); 223 | $file_part =~ s/\.pm$//; 224 | my (@dirs) = grep {+length} File::Spec->splitdir($dir_part); 225 | foreach my $i (reverse 1..$#dirs) { 226 | next unless( 227 | $dirs[$i] =~ $re_AssertOS && 228 | $dirs[$i - 1] =~ $re_Devel 229 | );; 230 | splice @dirs, 0, $i + 1; 231 | last; 232 | } 233 | join('::', @dirs, $file_part); 234 | } _find_pm_files_in_dirs( 235 | grep { -d } 236 | map { File::Spec->catdir($_, qw(Devel AssertOS)) } 237 | @INC 238 | )}}; 239 | 240 | return @modules; 241 | } 242 | 243 | =head3 list_family_members 244 | 245 | Takes the name of an OS 'family' and returns a list of all its members. 246 | 247 | If called on something that isn't a family, you get an empty list. 248 | 249 | =cut 250 | 251 | sub list_family_members { 252 | my $family = shift() || 253 | die(__PACKAGE__."::list_family_members needs a parameter\n"); 254 | 255 | # this will die if it's the wrong OS, but the module is loaded ... 256 | eval qq{use Devel::AssertOS::$family}; 257 | # ... so we can now query it 258 | return eval qq{ 259 | no strict 'refs'; 260 | &{"Devel::AssertOS::${family}::matches"}() 261 | }; 262 | } 263 | 264 | =head3 register_alias 265 | 266 | It takes two arguments, the first being an alias name, the second being the 267 | name of an OS. After the alias has been registered, any queries about the 268 | alias will return the appropriate result for the named OS. 269 | 270 | It returns true unless you invoke it incorrectly or you attempt to change 271 | an existing alias. 272 | 273 | Aliases don't work under taint-mode. 274 | 275 | See L. 276 | 277 | =cut 278 | 279 | sub register_alias { 280 | my($alias, $os) = @_; 281 | ($alias && $os) || return 0; 282 | if(!exists($OS_ALIASES{$alias}) || $OS_ALIASES{$alias} eq $os) { 283 | return $OS_ALIASES{$alias} = $os; 284 | } else { 285 | return 0 286 | } 287 | } 288 | 289 | =head1 PLATFORMS SUPPORTED 290 | 291 | To see the list of platforms for which information is available, run this: 292 | 293 | perl -MDevel::CheckOS -e 'print join(", ", Devel::CheckOS::list_platforms())' 294 | 295 | These are the names of the underlying Devel::AssertOS::* modules 296 | which do the actual platform detection, so they have to 297 | be 'legal' filenames and module names, which unfortunately precludes 298 | funny characters, so platforms like OS/2 are mis-spelt deliberately. 299 | Sorry. 300 | 301 | Also be aware that not all of them have been properly tested. I don't 302 | have access to most of them and have had to work from information 303 | gleaned from L and a few other places. For a complete list of 304 | OS families, see L. 305 | 306 | If you want to add your own OSes or families, see L 307 | and please feel free to upload the results to the CPAN. 308 | 309 | =head1 BUGS and FEEDBACK 310 | 311 | I welcome feedback about my code, including constructive criticism. 312 | Bug reports should be made using L. 313 | 314 | You will need to include in your bug report the exact value of $^O, what 315 | the OS is called (eg Windows Vista 64 bit Ultimate Home Edition), and, 316 | if relevant, what "OS family" it should be in and who wrote it. 317 | 318 | If you are feeling particularly generous you can encourage me in my 319 | open source endeavours by buying me something from my wishlist: 320 | L 321 | 322 | =head1 COMPATIBILITY 323 | 324 | Version 1.90 made all matches case-insensitive. This is a change in behaviour, but 325 | if it breaks your code then your code was already broken, you just didn't know it. 326 | 327 | As of version 2.00 the list_* functions always return plain old lists. Calling them 328 | in scalar context was deprecated and has emitted warnings for over 2 years, since 329 | version 1.90. 330 | 331 | =head1 SEE ALSO 332 | 333 | $^O in L 334 | 335 | L 336 | 337 | L 338 | 339 | L 340 | 341 | L 342 | 343 | The use-devel-assertos script 344 | 345 | L 346 | 347 | =head1 AUTHOR 348 | 349 | David Cantrell EFE 350 | 351 | Thanks to David Golden for the name and ideas about the interface, and 352 | to the cpan-testers-discuss mailing list for prompting me to write it 353 | in the first place. 354 | 355 | Thanks to Ken Williams, from whose L I lifted some of the 356 | information about what should be in the Unix family. 357 | 358 | Thanks to Billy Abbott for finding some bugs for me on VMS. 359 | 360 | Thanks to Matt Kraai for information about QNX. 361 | 362 | Thanks to Kenichi Ishigaki and Gabor Szabo for reporting a bug on Windows, 363 | and to the former for providing a patch. 364 | 365 | Thanks to Paul Green for some information about VOS. 366 | 367 | Thanks to Yanick Champoux for a patch to let Devel::AssertOS support 368 | negative assertions. 369 | 370 | Thanks to Brian Fraser for adding Android support. 371 | 372 | Thanks to Dale Evans for Debian detection, a bunch of Mac OS X specific version 373 | detection modules, and perl 5.6 support. 374 | 375 | Thanks to Graham Knop for fixing a build bug on perl 5.8. 376 | 377 | Thanks to Alceu Rodrigues de Freitas Junior for improving Ubuntu detection 378 | and providing a way to detect a lot more Linux variants. 379 | 380 | =head1 SOURCE CODE REPOSITORY 381 | 382 | L 383 | 384 | =head1 COPYRIGHT and LICENCE 385 | 386 | Copyright 2024 David Cantrell 387 | 388 | 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. 389 | 390 | =head1 HATS 391 | 392 | I recommend buying a Fedora from L. 393 | 394 | =head1 CONSPIRACY 395 | 396 | This module is also free-as-in-mason software. 397 | 398 | =cut 399 | 400 | 1; 401 | -------------------------------------------------------------------------------- /GPL2.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------