NAME Fedora::RPM::Spec::License - Class for handle Fedora license string. SYNOPSIS use Fedora::RPM::Spec::License; my $obj = Fedora::RPM::Spec::License->new(%params); my $fedora_license_format = $obj->format; my @licenses = $obj->licenses; $obj->parse($fedora_license_string); $obj->reset; DESCRIPTION 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. METHODS "new" my $obj = Fedora::RPM::Spec::License->new(%params); Constructor. Returns instance of object. "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. Returns array of strings. "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. Returns undef. ERRORS new(): From Class::Utils::set_params(): Unknown parameter '%s'. format(): No Fedora license string processed. licenses(): No Fedora license string processed. EXAMPLE 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; # 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 DEPENDENCIES Class::Utils, English, Error::Pure, License::SPDX, List::Util, Parse::RecDescent, Readonly. SEE ALSO rpm-spec-license Tool for working with RPM spec file licenses. REPOSITORY <https://github.com/michal-josef-spacek/Fedora-RPM-Spec-License> AUTHOR Michal Josef Špaček <mailto:skim@cpan.org> <http://skim.cz> LICENSE AND COPYRIGHT © 2023 Michal Josef Špaček BSD 2-Clause License VERSION 0.02