Fedora::RPM::Spec::License - Class for handle Fedora license string.
use Fedora::RPM::Spec::License; my $obj = Fedora::RPM::Spec::License->new(%params); my @exceptions = $obj->exceptions; my $fedora_license_format = $obj->format; my @licenses = $obj->licenses; $obj->parse($fedora_license_string); $obj->reset;
Fedora license string is used in Fedora RPM spec files in License field. There are two versions of this string. One is old version and new one with SPDX identifiers.
new
my $obj = Fedora::RPM::Spec::License->new(%params);
Constructor.
Returns instance of object.
exceptions
my @exceptions = $obj->exceptions;
Get exceptions used in the Fedora license string sorted alphabetically.
Returns array of strings.
format
my $fedora_license_format = $obj->format;
Get Fedora license string format. Possible values:
1 - Old RPM Fedora format. 2 - New RPM Fedora format with SPDX license ids.
Returns number.
licenses
my @licenses = $obj->licenses;
Get licenses used in the Fedora license string sorted alphabetically.
parse
$obj->parse($fedora_license_string);
Parse Fedora license string and set object internal structures. If string is valid for format 1 and 2 as well, format 2 is preferred. Example is 'MIT' license string.
Returns undef.
reset
$obj->reset;
Reset object.
new(): From Class::Utils::set_params(): Unknown parameter '%s'. format(): No Fedora license string processed. licenses(): No Fedora license string processed. parse(): License '%s' isn't SPDX license. License '%s' isn't SPDX license exception.
use strict; use warnings; use Fedora::RPM::Spec::License; if (@ARGV < 1) { print STDERR "Usage: $0 fedora_license_string\n"; exit 1; } my $fedora_license_string = $ARGV[0]; # Object. my $obj = Fedora::RPM::Spec::License->new; # Parse license. $obj->parse($fedora_license_string); # Print out. print "Fedora license string: $fedora_license_string\n"; print 'Format: '.$obj->format."\n"; print "Contain licenses:\n"; print join "\n", map { '- '. $_ } $obj->licenses; print "\n"; if ($obj->exceptions) { print "Contain exceptions:\n"; print join "\n", map { '- '. $_ } $obj->exceptions; print "\n"; } # Output with 'MIT' input: # Fedora license string: MIT # Format: 2 # Contain licenses: # - MIT # Output with 'MIT AND FSFAP' input: # Fedora license string: MIT AND FSFAP # Format: 2 # Contain licenses: # - FSFAP # - MIT # Output with '(GPL+ or Artistic) and Artistic 2.0 and (MIT or GPLv2)' input: # Fedora license string: (GPL+ or Artistic) and Artistic 2.0 and (MIT or GPLv2) # Format: 1 # Contain licenses: # - Artistic # - Artistic 2.0 # - GPL+ # - GPLv2 # - MIT # Output with 'LGPL-3.0-only WITH LGPL-3.0-linking-exception' input: # Fedora license string: LGPL-3.0-only WITH LGPL-3.0-linking-exception # Format: 2 # Contain licenses: # - LGPL-3.0-only # Contain exceptions: # - LGPL-3.0-linking-exception
Class::Utils, English, Error::Pure, License::SPDX, List::Util, Parse::RecDescent, Readonly.
Tool for working with RPM spec file licenses.
https://github.com/michal-josef-spacek/Fedora-RPM-Spec-License
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2023 Michal Josef Špaček
BSD 2-Clause License
0.03
To install Fedora::RPM::Spec::License, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fedora::RPM::Spec::License
CPAN shell
perl -MCPAN -e shell install Fedora::RPM::Spec::License
For more information on module installation, please visit the detailed CPAN module installation guide.