# # spec file for package perl-Module-Installed-Tiny # # Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # %define cpan_name Module-Installed-Tiny Name: perl-Module-Installed-Tiny Version: 0.11.0 Release: 0 # 0.011 -> normalize -> 0.11.0 %define cpan_version 0.011 License: Artistic-1.0 OR GPL-1.0-or-later Summary: Check if a module is installed, with as little code as possible URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/P/PE/PERLANCAR/%{cpan_name}-%{cpan_version}.tar.gz Source1: cpanspec.yml Source100: README.md BuildArch: noarch BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(File::Temp) >= 0.2307 BuildRequires: perl(Test::Exception) BuildRequires: perl(Test::More) >= 0.98 BuildRequires: perl(Test::Needs) Provides: perl(Module::Installed::Tiny) = %{version} %undefine __perllib_provides %{perl_requires} %description To check if a module is installed (available), generally the simplest way is to try to 'require()' it: if (eval { require Foo::Bar; 1 }) { # Foo::Bar is available } # or my $mod_pm = "Foo/Bar.pm"; if (eval { require $mod_pm; 1 }) { # Foo::Bar is available } However, this actually loads the module. There are some cases where this is not desirable: 1) we have to check a lot of modules (actually loading the modules will take a lot of CPU time and memory; 2) some of the modules conflict with one another and cannot all be loaded; 3) the module is OS specific and might not load under another OS; 4) we simply do not want to execute the module, for security or other reasons. 'Module::Installed::Tiny' provides a routine 'module_installed()' which works like Perl's 'require' but does not actually load the module. This module does not require any other module except Exporter. %prep %autosetup -n %{cpan_name}-%{cpan_version} %build perl Makefile.PL INSTALLDIRS=vendor %make_build %check make test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %doc Changes README %license LICENSE %changelog