130 lines
3.8 KiB
RPMSpec
130 lines
3.8 KiB
RPMSpec
#
|
|
# spec file for package perl-Shell-Config-Generate
|
|
#
|
|
# 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 Shell-Config-Generate
|
|
Name: perl-Shell-Config-Generate
|
|
Version: 0.340.0
|
|
Release: 0
|
|
# 0.34 -> normalize -> 0.340.0
|
|
%define cpan_version 0.34
|
|
License: Artistic-1.0 OR GPL-1.0-or-later
|
|
Summary: Portably generate config for any shell
|
|
URL: https://metacpan.org/release/%{cpan_name}
|
|
Source0: https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/%{cpan_name}-%{cpan_version}.tar.gz
|
|
Source1: cpanspec.yml
|
|
Source100: README.md
|
|
BuildArch: noarch
|
|
BuildRequires: perl
|
|
BuildRequires: perl-macros
|
|
BuildRequires: perl(Shell::Guess) >= 0.20.0
|
|
BuildRequires: perl(Test2::API) >= 1.302015
|
|
BuildRequires: perl(Test2::Mock) >= 0.000060
|
|
BuildRequires: perl(Test2::V0) >= 0.000060
|
|
Requires: perl(Shell::Guess) >= 0.20.0
|
|
Provides: perl(Shell::Config::Generate) = %{version}
|
|
%undefine __perllib_provides
|
|
%{perl_requires}
|
|
|
|
%description
|
|
This module provides an interface for specifying shell configurations for
|
|
different shell environments without having to worry about the arcane
|
|
differences between shells such as csh, sh, cmd.exe and command.com.
|
|
|
|
It does not modify the current environment, but it can be used to create
|
|
shell configurations which do modify the environment.
|
|
|
|
This module uses Shell::Guess to represent the different types of shells
|
|
that are supported. In this way you can statically specify just one or more
|
|
shells:
|
|
|
|
#!/usr/bin/perl
|
|
use Shell::Guess;
|
|
use Shell::Config::Generate;
|
|
my $config = Shell::Config::Generate->new;
|
|
# ... config config ...
|
|
$config->generate_file(Shell::Guess->bourne_shell, 'foo.sh' );
|
|
$config->generate_file(Shell::Guess->c_shell, 'foo.csh');
|
|
$config->generate_file(Shell::Guess->cmd_shell, 'foo.cmd');
|
|
$config->generate_file(Shell::Guess->command_shell, 'foo.bat');
|
|
|
|
This will create foo.sh and foo.csh versions of the configurations, which
|
|
can be sourced like so:
|
|
|
|
#!/bin/sh
|
|
. ./foo.sh
|
|
|
|
or
|
|
|
|
#!/bin/csh
|
|
source foo.csh
|
|
|
|
It also creates '.cmd' and '.bat' files with the same configuration which
|
|
can be used in Windows. The configuration can be imported back into your
|
|
shell by simply executing these files:
|
|
|
|
C:\> foo.cmd
|
|
|
|
or
|
|
|
|
C:\> foo.bat
|
|
|
|
Alternatively you can use the shell that called your Perl script using
|
|
Shell::Guess's 'running_shell' method, and write the output to standard
|
|
out.
|
|
|
|
#!/usr/bin/perl
|
|
use Shell::Guess;
|
|
use Shell::Config::Generate;
|
|
my $config = Shell::Config::Generate->new;
|
|
# ... config config ...
|
|
print $config->generate(Shell::Guess->running_shell);
|
|
|
|
If you use this pattern, you can eval the output of your script using your
|
|
shell's back ticks to import the configuration into the shell.
|
|
|
|
#!/bin/sh
|
|
eval `script.pl`
|
|
|
|
or
|
|
|
|
#!/bin/csh
|
|
eval `script.pl`
|
|
|
|
%prep
|
|
%autosetup -n %{cpan_name}-%{cpan_version}
|
|
|
|
find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644
|
|
|
|
%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 example README
|
|
%license LICENSE
|
|
|
|
%changelog
|