Files
perl-lib-abs/perl-lib-abs.spec
2025-08-12 18:14:59 +02:00

90 lines
2.7 KiB
RPMSpec

#
# spec file for package perl-lib-abs
#
# 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 lib-abs
Name: perl-lib-abs
Version: 0.950.0
Release: 0
# 0.95 -> normalize -> 0.950.0
%define cpan_version 0.95
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Lib that makes relative path absolute to caller
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/M/MO/MONS/%{cpan_name}-%{cpan_version}.tar.gz
Source1: cpanspec.yml
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(ExtUtils::MakeMaker) >= 6.59
Provides: perl(lib::abs) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
The main reason of this library is transformate relative paths to absolute
at the 'BEGIN' stage, and push transformed to '@INC'. Relative path basis
is not the current working directory, but the location of file, where the
statement is (caller file). When using common 'lib', relative paths stays
relative to curernt working directory,
# For ex:
# script: /opt/scripts/my.pl
use lib::abs '../lib';
# We run `/opt/scripts/my.pl` having cwd /home/mons
# The @INC will contain '/opt/lib';
# We run `./my.pl` having cwd /opt
# The @INC will contain '/opt/lib';
# We run `../my.pl` having cwd /opt/lib
# The @INC will contain '/opt/lib';
Also this module is useful when writing tests, when you want to load
strictly the module from ../lib, respecting the test file.
# t/00-test.t
use lib::abs '../lib';
Also this is useful, when you running under 'mod_perl', use something like
'Apache::StatINC', and your application may change working directory. So in
case of chdir 'StatINC' fails to reload module if the @INC contain relative
paths.
%prep
%autosetup -n %{cpan_name}-%{cpan_version}
%build
PERL_USE_UNSAFE_INC=1 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