#55 Filter dependencies using the cfg language and translate license tags
Merged 5 years ago by ignatenkobrain. Opened 5 years ago by zbyszek.
fedora-rust/ zbyszek/rust2rpm cfg-filtering  into  master

file modified
+1
@@ -1,3 +1,4 @@ 

  include LICENSE

  include data/*

+ include rust2rpm/spdx_to_fedora.csv

  include rust2rpm/templates/*

file modified
+1
@@ -2,3 +2,4 @@ 

  requests

  semantic_version

  tqdm

+ rustcfg

file modified
+1
@@ -1,1 +1,2 @@ 

  from .metadata import *

+ from . import licensing

file modified
+18 -2
@@ -7,6 +7,7 @@ 

  import os

  import shlex

  import shutil

+ import sys

  import tarfile

  import tempfile

  import time
@@ -16,7 +17,7 @@ 

  import requests

  import tqdm

  

- from . import Metadata

+ from . import Metadata, licensing

  

  DEFAULT_EDITOR = "vi"

  XDG_CACHE_HOME = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))
@@ -185,6 +186,8 @@ 

  def main():

      parser = argparse.ArgumentParser("rust2rpm",

                                       formatter_class=argparse.RawTextHelpFormatter)

+     parser.add_argument("--show-license-map", action="store_true",

+                         help="Print license mappings and exit")

      parser.add_argument("-", "--stdout", action="store_true",

                          help="Print spec and patches into stdout")

      parser.add_argument("-t", "--target", action="store",
@@ -196,10 +199,18 @@ 

                          help="Store crate in current directory")

      parser.add_argument("crate", help="crates.io name\n"

                                        "path/to/local.crate\n"

-                                       "path/to/project/")

+                                       "path/to/project/",

+                         nargs="?")

      parser.add_argument("version", nargs="?", help="crates.io version")

      args = parser.parse_args()

  

+     if args.show_license_map:

+         licensing.dump_sdpx_to_fedora_map(sys.stdout)

+         return

+ 

+     if args.crate is None:

+         parser.error('required crate/path argument missing')

+ 

      crate, diff, metadata = make_diff_metadata(args.crate, args.version,

                                                 patch=args.patch,

                                                 store=args.store_crate)
@@ -253,6 +264,11 @@ 

          kwargs["date"] = time.strftime("%a %b %d %Y")

      kwargs["packager"] = detect_packager()

  

+     if metadata.license is not None:

+         license, comments = licensing.translate_license(args.target, metadata.license)

+         kwargs["license"] = license

+         kwargs["license_comments"] = comments

+ 

      spec_file = "rust-{}.spec".format(crate)

      spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs)

      if args.stdout:

@@ -0,0 +1,57 @@ 

+ import os as _os

+ import sys as _sys

+ import csv as _csv

+ import functools as _functools

+ 

+ SPDX_TO_FEDORA_CSV = _os.path.dirname(__file__) + '/spdx_to_fedora.csv'

+ 

+ def translate_slashes(license):

+     "Replace all slashes with OR, emit warning"

+     split = [l.strip() for l in license.split("/")]

+     if len(split) > 1:

+         print('Upstream uses deprecated "/" syntax. Replacing with "OR"',

+               file=_sys.stderr)

+     return ' OR '.join(split)

+ 

+ @_functools.lru_cache()

+ def spdx_to_fedora_map():

+     with open(SPDX_TO_FEDORA_CSV, newline='') as f:

+         reader = _csv.DictReader(f)

+         return {line['SPDX License Identifier'] : line['Fedora Short Name']

+                 for line in reader

+                 if line['SPDX License Identifier']}

+ 

+ def dump_sdpx_to_fedora_map(file):

+     for k,v in spdx_to_fedora_map().items():

+         print(f"{k} → {v}", file=file)

+ 

+ def translate_license_fedora(license):

+     comments = ''

+     final = []

+     for tag in license.split():

+         # We accept all variant cases, but output lowercase which is what Fedora LicensingGuidelines specify

+         if tag.upper() == 'OR':

+             final.append('or')

+         elif tag.upper() == 'AND':

+             final.append('and')

+         else:

+             mapped = spdx_to_fedora_map().get(tag, None)

+             if mapped is None:

+                 comments += f'# FIXME: Upstream uses unknown SPDX tag {tag}!'

+                 final.append(tag)

+             elif mapped is '':

+                 comments += f"# FIXME: Upstream SPDX tag {tag} not listed in Fedora's good licenses list.\n"

+                 comments += "# FIXME: This package might not be allowed in Fedora!\n"

+                 final.append(tag)

+             else:

+                 final.append(mapped)

+                 if mapped != tag:

+                     print(f'Upstream license tag {tag} translated to {mapped}',

+                           file=_sys.stderr)

+     return (' '.join(final), comments or None)

+ 

+ def translate_license(target, license):

+     license = translate_slashes(license)

+     if target in {"fedora", "epel", "mageia"}:

+         return translate_license_fedora(license)

+     return license, None

file modified
+20 -5
@@ -6,6 +6,7 @@ 

  import sys

  

  import semantic_version as semver

+ import rustcfg

  

  class Target(object):

      def __init__(self, kind, name):
@@ -163,23 +164,37 @@ 

          self.targets = [Target(tgt["kind"][0], tgt["name"]) for tgt in md["targets"]]

  

          # Provides

-         # All optional depdencies are also features

+         # All optional dependencies are also features

          # https://github.com/rust-lang/cargo/issues/4911

          features = itertools.chain((x["name"] for x in md["dependencies"] if x["optional"]),

                                     md["features"])

          provides = Dependency(self.name, version, features=features, provides=True)

          self.provides = str(provides).split(" and ")

  

+         ev = rustcfg.Evaluator.platform()

+ 

          # Dependencies

          for dep in md["dependencies"]:

-             if dep["kind"] is None:

+             kind = dep["kind"]

+             if kind is None:

                  requires = self.requires

-             elif dep["kind"] == "build":

+             elif kind == "build":

                  requires = self.build_requires

-             elif dep["kind"] == "dev":

+             elif kind == "dev":

                  requires = self.test_requires

              else:

-                 raise ValueError("Unknown kind: {!r}, please report bug.".format(dep["kind"]))

+                 raise ValueError("Unknown kind: {!r}, please report bug.".format(kind))

+ 

+             target = dep["target"]

+             if target is None:

+                 pass

+             else:

+                 cond = ev.parse_and_eval(target)

+                 if not cond:

+                     print(f'Dependency {dep["name"]} for target {target!r} is not needed, ignoring.',

+                           file=sys.stderr)

+                     continue

+ 

              requires.append(Dependency(dep["name"], dep["req"], features=dep["features"]))

  

          return self

@@ -0,0 +1,372 @@ 

+ SPDX Full name of License,SPDX License Identifier,Fedora Short Name,Fedora Fullname (if different),Notes,Other Fedora Licenses (full name) that use same short identifier and are SPDX License List equivalent (as per SPDX Matching Guidelines)

+ 3dfx Glide License,Glide,Glide,,,

+ Abstyles License,Abstyles,Abstyles,,,

+ Academic Free License v1.1,AFL-1.1,,,not on Fedora list,

+ Academic Free License v1.2,AFL-1.2,,,not on Fedora list,

+ Academic Free License v2.0,AFL-2.0,,,not on Fedora list,

+ Academic Free License v2.1,AFL-2.1,,,not on Fedora list,

+ Academic Free License v3.0,AFL-3.0,AFL,Academic Free License,,

+ Academy of Motion Picture Arts and Sciences BSD,AMPAS,AMPAS BSD,,,

+ Adaptive Public License 1.0,APL-1.0,,,Fedora bad list,

+ Adobe Glyph List License,Adobe-Glyph,MIT,,,

+ Adobe Postscript AFM License,APAFML,APAFML,,,

+ Adobe Systems Incorporated Source Code License Agreement,Adobe-2006,Adobe,,,

+ Affero General Public License v1.0,AGPL-1.0,AGPLv1,,,

+ Afmparse License,Afmparse,Afmparse,,,

+ Aladdin Free Public License,Aladdin,,,not on Fedora list,

+ Amazon Digital Services License,ADSL,ADSL,,,

+ AMD's plpa_map.c License,AMDPLPA,AMDPLPA,,,

+ ANTLR Software Rights Notice,ANTLR-PD,,,not on Fedora list,

+ Apache License 1.0,Apache-1.0,ASL 1.0,Apache Software License 1.0,,

+ Apache License 1.1,Apache-1.1,ASL 1.1,Apache Software License 1.1,,"4Suite Copyright License

+ MX4J License

+ Neotonic Clearsilver License

+ Phorum License

+ Sequence Library License

+ QuickFix License"

+ Apache License 2.0,Apache-2.0,ASL 2.0,Apache Software License 2.0,,

+ Apple MIT License,AML,AML,,,

+ Apple Public Source License 1.0,APSL-1.0,,,Fedora bad list,

+ Apple Public Source License 1.1,APSL-1.1,,,Fedora bad list,

+ Apple Public Source License 1.2,APSL-1.2,,,Fedora bad list,

+ Apple Public Source License 2.0,APSL-2.0,APSL 2.0,,,

+ Artistic License 1.0,Artistic-1.0,,,not on Fedora list,

+ Artistic License 1.0 (Perl),Artistic-1.0-Perl,,,Fedora bad list,

+ Artistic License 1.0 w/clause 8,Artistic-1.0-cl8,,,not on Fedora list,

+ Artistic License 2.0,Artistic-2.0,Artistic 2.0,Artistic 2.0,,

+ Attribution Assurance License,AAL,AAL,,,

+ Bahyph License,Bahyph,Bahyph,,,

+ Barr License,Barr,Barr,,,

+ Beerware License,Beerware,Beerware,,,

+ BitTorrent Open Source License v1.0,BitTorrent-1.0,,,This specific version not on Fedora list,

+ BitTorrent Open Source License v1.1,BitTorrent-1.1,BitTorrent,BitTorrent License,,

+ Boost Software License 1.0,BSL-1.0,Boost,Boost Software License,,

+ Borceux license,Borceux,Borceux,,,

+ "BSD 2-clause ""Simplified"" License",BSD-2-Clause,BSD,BSD License (two clause),,Cryptix General License

+ BSD 2-clause FreeBSD License,BSD-2-Clause-FreeBSD,,,not on Fedora list,

+ BSD 2-clause NetBSD License,BSD-2-Clause-NetBSD,,,not on Fedora list,

+ "BSD 3-clause ""New"" or ""Revised"" License",BSD-3-Clause,BSD,BSD License (no advertising),,Eclipse Distribution License 1.0

+ BSD 3-clause Clear License,BSD-3-Clause-Clear,,,not on Fedora list,

+ "BSD 4-clause ""Original"" or ""Old"" License",BSD-4-Clause,BSD with advertising,,See note re: BSD-4-Clause-UC (need to confirm w/Fedora),

+ BSD Protection License,BSD-Protection,BSD Protection,,,

+ BSD with attribution,BSD-3-Clause-Attribution,BSD with attribution,,,

+ BSD-4-Clause (University of California-Specific),BSD-4-Clause-UC,BSD,,"Due to U. of CA 1999 retroactive deletion of the advertising clause, this is effectively 'BSD'-3-clause. Hence, Fedora would classify as “BSD” and not “BSD with advertising”? (need to confirm with Fedora)",

+ bzip2 and libbzip2 License v1.0.5,bzip2-1.0.5,,,not on Fedora list,

+ bzip2 and libbzip2 License v1.0.6,bzip2-1.0.6,,,not on Fedora list,

+ Caldera License,Caldera,,,not on Fedora list,

+ CeCILL Free Software License Agreement v1.0,CECILL-1.0,,,This specific version not on Fedora list,

+ CeCILL Free Software License Agreement v1.1,CECILL-1.1,CeCILL,CeCILL License v1.1,,

+ CeCILL Free Software License Agreement v2.0,CECILL-2.0,CeCILL,CeCILL License v2,,

+ CeCILL-B Free Software License Agreement,CECILL-B,CeCILL-B,CeCILL-B License,,

+ CeCILL-C Free Software License Agreement,CECILL-C,CeCILL-C,CeCILL-C License,,

+ Clarified Artistic License,ClArtistic,Artistic clarified,Artistic (clarified),,

+ CMU License,MIT-CMU,MIT,CMU License (BSD like),,

+ CNRI Jython License,CNRI-Jython,Jpython,Jpython License (old),,

+ CNRI Python License,CNRI-Python,CNRI,CNRI License (Old Python),Check – may not be exact match as per SPDX Matching Guidelines,

+ CNRI Python Open Source GPL Compatible License Agreement,CNRI-Python-GPL-Compatible,,,not on Fedora list,

+ Code Project Open License 1.02,CPOL-1.02,,,Fedora bad list,

+ Common Development and Distribution License 1.0,CDDL-1.0,CDDL,Common Development Distribution License,,

+ Common Development and Distribution License 1.1,CDDL-1.1,CDDL,,"This specific version not on Fedora list. Same as 1.0, but changes name from Sun to Oracle in section 4.1 and adds patent infringement termination clause (section 6.3) – would Fedora also consider “CDDL”?",

+ Common Public Attribution License 1.0,CPAL-1.0,CPAL,CPAL License 1.0,,

+ Common Public License 1.0,CPL-1.0,CPL,Common Public License,,

+ Computer Associates Trusted Open Source License 1.1,CATOSL-1.1,CATOSL,,,

+ Condor Public License v1.1,Condor-1.1,Condor,Condor Public License,,

+ Creative Commons Attribution 1.0,CC-BY-1.0,,,This specific version not on Fedora list,

+ Creative Commons Attribution 2.0,CC-BY-2.0,,,This specific version not on Fedora list,

+ Creative Commons Attribution 2.5,CC-BY-2.5,,,This specific version not on Fedora list,

+ Creative Commons Attribution 3.0,CC-BY-3.0,CC-BY,,,

+ Creative Commons Attribution 4.0,CC-BY-4.0,,,This specific version not on Fedora list,

+ Creative Commons Attribution No Derivatives 1.0,CC-BY-ND-1.0,,,not on Fedora list,

+ Creative Commons Attribution No Derivatives 2.0,CC-BY-ND-2.0,,,not on Fedora list,

+ Creative Commons Attribution No Derivatives 2.5,CC-BY-ND-2.5,,,not on Fedora list,

+ Creative Commons Attribution No Derivatives 3.0,CC-BY-ND-3.0,,,not on Fedora list,

+ Creative Commons Attribution No Derivatives 4.0,CC-BY-ND-4.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial 1.0,CC-BY-NC-1.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial 2.0,CC-BY-NC-2.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial 2.5,CC-BY-NC-2.5,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial 3.0,CC-BY-NC-3.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial 4.0,CC-BY-NC-4.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial No Derivatives 1.0,CC-BY-NC-ND-1.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial No Derivatives 2.0,CC-BY-NC-ND-2.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial No Derivatives 2.5,CC-BY-NC-ND-2.5,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial No Derivatives 3.0,CC-BY-NC-ND-3.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial No Derivatives 4.0,CC-BY-NC-ND-4.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial Share Alike 1.0,CC-BY-NC-SA-1.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial Share Alike 2.0,CC-BY-NC-SA-2.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial Share Alike 2.5,CC-BY-NC-SA-2.5,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial Share Alike 3.0,CC-BY-NC-SA-3.0,,,not on Fedora list,

+ Creative Commons Attribution Non Commercial Share Alike 4.0,CC-BY-NC-SA-4.0,,,not on Fedora list,

+ Creative Commons Attribution Share Alike 1.0,CC-BY-SA-1.0,,,This specific version not on Fedora list,

+ Creative Commons Attribution Share Alike 2.0,CC-BY-SA-2.0,,,This specific version not on Fedora list,

+ Creative Commons Attribution Share Alike 2.5,CC-BY-SA-2.5,,,This specific version not on Fedora list,

+ Creative Commons Attribution Share Alike 3.0,CC-BY-SA-3.0,CC-BY-SA,,,

+ Creative Commons Attribution Share Alike 4.0,CC-BY-SA-4.0,,,This specific version not on Fedora list,

+ Creative Commons Zero v1.0 Universal,CC0-1.0,CC0,,,

+ Crossword License,Crossword,Crossword,,,

+ CUA Office Public License v1.0,CUA-OPL-1.0,MPLv1.1,,,

+ Cube License,Cube,Cube,,,

+ Deutsche Freie Software Lizenz,D-FSL-1.0,,,not on Fedora list,

+ diffmark license,diffmark,diffmark,,,

+ Do What The F*ck You Want To Public License,WTFPL,WTFPL,,,

+ DOC License,DOC,DOC,,,

+ Dotseqn License,Dotseqn,Dotseqn,,,

+ DSDP License,DSDP,DSDP,,,

+ dvipdfm License,dvipdfm,dvipdfm,,,

+ Eclipse Public License 1.0,EPL-1.0,EPL,,,

+ Educational Community License v1.0,ECL-1.0,ECL 1.0,,,

+ Educational Community License v2.0,ECL-2.0,ECL 2.0,,,

+ eGenix.com Public License 1.1.0,eGenix,eGenix,,,

+ Eiffel Forum License v1.0,EFL-1.0,,,Fedora bad list,

+ Eiffel Forum License v2.0,EFL-2.0,EFL 2.0,,,

+ Enlightenment License (e16),MIT-advertising,MIT with advertising,,,

+ enna License,MIT-enna,MIT,,,

+ Entessa Public License v1.0,Entessa,Entessa,Entessa Public License,,

+ Erlang Public License v1.1,ErlPL-1.1,ERPL,,,

+ EU DataGrid Software License,EUDatagrid,EU Datagrid,,,

+ European Union Public License 1.0,EUPL-1.0,,,Fedora bad list,

+ European Union Public License 1.1,EUPL-1.1,EUPL 1.1,,,

+ Eurosym License,Eurosym,Eurosym,,,

+ Fair License,Fair,Fair,,,

+ feh License,MIT-feh,MIT,,,

+ Frameworx Open License 1.0,Frameworx-1.0,,,Fedora bad list,

+ FreeImage Public License v1.0,FreeImage,MPLv1.0,FreeImage Public License,,

+ Freetype Project License,FTL,FTL,Freetype License,,

+ FSF Unlimited License,FSFUL,FSFUL,,,

+ FSF Unlimited License (with License Retention),FSFULLR,FSFULLR,,,

+ Giftware License,Giftware,Giftware,,,

+ GL2PS License,GL2PS,GL2PS,,,

+ Glulxe License,Glulxe,Glulxe,,,

+ GNU Affero General Public License v3.0,AGPL-3.0,AGPLv3,Affero General Public License 3.0,,

+ GNU Free Documentation License v1.1,GFDL-1.1,,,This specific version not on Fedora list,

+ GNU Free Documentation License v1.2,GFDL-1.2,,,This specific version not on Fedora list,

+ GNU Free Documentation License v1.3,GFDL-1.3,GFDL,,,

+ GNU General Public License v1.0 only,GPL-1.0,GPLv1,,"For “or later” add + to SPDX or Fedora short identifier: 

+ SPDX: GPL-1.0+ 

+ Fedora: GPLv1+ or GPL+",

+ GNU General Public License v2.0 only,GPL-2.0,GPLv2,,"For “or later” add + to SPDX or Fedora short identifier: 

+ SPDX: GPL-2.0+ 

+ Fedora: GPLv2+",

+ GNU General Public License v3.0 only,GPL-3.0,GPLv3,,"For “or later” add + to SPDX or Fedora short identifier: 

+ SPDX: GPL-3.0+ 

+ Fedora: GPLv3+",

+ GNU Lesser General Public License v2.1 only,LGPL-2.1,LGPLv2,,,

+ GNU Lesser General Public License v3.0 only,LGPL-3.0,LGPLv3,,,

+ GNU Library General Public License v2 only,LGPL-2.0,LGPLv2,,,

+ gnuplot License,gnuplot,gnuplot,,,

+ gSOAP Public License v1.3b,gSOAP-1.3b,,,not on Fedora list,

+ Haskell Language Report License,HaskellReport,HaskellReport,,,

+ Historic Permission Notice and Disclaimer,HPND,MIT,,,

+ IBM PowerPC Initialization and Boot Software,IBM-pibs,,,not on Fedora list,

+ IBM Public License v1.0,IPL-1.0,IBM,IBM Public License,,

+ ICU License,ICU,,,not on Fedora list,

+ ImageMagick License,ImageMagick,ImageMagick,,,

+ iMatix Standard Function Library Agreement,iMatix,iMatix,,,

+ Imlib2 License,Imlib2,Imlib2,,,

+ Independent JPEG Group License,IJG,IJG,,,

+ Intel ACPI Software License Agreement,Intel-ACPI,Intel ACPI,,,

+ Intel Open Source License,Intel,,,Fedora bad list,

+ IPA Font License,IPA,,,not on Fedora list,

+ ISC License,ISC,ISC,,,

+ JasPer License,JasPer-2.0,JasPer,,,

+ JSON License,JSON,,,Fedora bad list,

+ LaTeX Project Public License 1.3a,LPPL-1.3a,LPPL,,,

+ LaTeX Project Public License v1.0,LPPL-1.0,,,This specific version not on Fedora list,

+ LaTeX Project Public License v1.1,LPPL-1.1,,,This specific version not on Fedora list,

+ LaTeX Project Public License v1.2,LPPL-1.2,,,This specific version not on Fedora list,

+ LaTeX Project Public License v1.3c,LPPL-1.3c,,,This specific version not on Fedora list,

+ Latex2e License,Latex2e,Latex2e,,,

+ Lawrence Berkeley National Labs BSD variant license,BSD-3-Clause-LBNL,LBNL BSD,,,

+ Leptonica License,Leptonica,Leptonica,,,

+ Lesser General Public License For Linguistic Resources,LGPLLR,,,,

+ libpng License,Libpng,,,not on Fedora list,

+ libtiff License,libtiff,libtiff,,,

+ Lucent Public License v1.02,LPL-1.02,LPL,Lucent Public License (Plan9),,

+ Lucent Public License Version 1.0,LPL-1.0,,,This specific version not on Fedora list,

+ MakeIndex License,MakeIndex,MakeIndex,,,

+ Matrix Template Library License,MTLL,MTLL,,,

+ Microsoft Public License,MS-PL,MS-PL,,,

+ Microsoft Reciprocal License,MS-RL,MS-RL,,,

+ MirOS Licence,MirOS,MirOS,,,

+ MIT +no-false-attribs license,MITNFA,MITNFA,,,

+ MIT License,MIT,MIT,,,

+ Motosoto License,Motosoto,Motosoto,,,

+ Mozilla Public License 1.0,MPL-1.0,MPLv1.0,Mozilla Public License v1.0,,

+ Mozilla Public License 1.1,MPL-1.1,MPLv1.1,Mozilla Public License v1.1,,

+ Mozilla Public License 2.0,MPL-2.0,MPLv2.0,Mozilla Public License v2.0,,

+ Mozilla Public License 2.0 (no copyleft exception),MPL-2.0-no-copyleft-exception,,,This variant not included on Fedora list (confirm this is correct statement),

+ mpich2 License,mpich2,MIT,,,

+ Multics License,Multics,,,not on Fedora list,

+ Mup License,Mup,Mup,,,

+ NASA Open Source Agreement 1.3,NASA-1.3,,,Fedora bad list,

+ Naumen Public License,Naumen,Naumen,,,

+ Net Boolean Public License v1,NBPL-1.0,,,not on Fedora list,

+ NetCDF license,NetCDF,NetCDF,,,

+ Nethack General Public License,NGPL,NGPL,,,

+ Netizen Open Source License,NOSL,NOSL,,,

+ Netscape Public License v1.0,NPL-1.0,Netscape,Netscape Public License,,

+ Netscape Public License v1.1,NPL-1.1,,,This specific version not on Fedora list,

+ Newsletr License,Newsletr,Newsletr,,,

+ No Limit Public License,NLPL,NLPL,,,

+ Nokia Open Source License,Nokia,Nokia,,,

+ Non-Profit Open Software License 3.0,NPOSL-3.0,,,not on Fedora list,

+ Noweb License,Noweb,Noweb,,,

+ NRL License,NRL,BSD with advertising,,,

+ NTP License,NTP,,,not on Fedora list,

+ Nunit License,Nunit,MIT with advertising,,,

+ OCLC Research Public License 2.0,OCLC-2.0,,,Fedora bad list,

+ ODC Open Database License v1.0,ODbL-1.0,,,not on Fedora list,

+ ODC Public Domain Dedication & License 1.0,PDDL-1.0,,,not on Fedora list,

+ Open Group Test Suite License,OGTSL,,,Fedora bad list,

+ Open LDAP Public License 2.2.2,OLDAP-2.2.2,,,This specific version not on Fedora list,

+ Open LDAP Public License v1.1,OLDAP-1.1,,,This specific version not on Fedora list,

+ Open LDAP Public License v1.2,OLDAP-1.2,,,This specific version not on Fedora list,

+ Open LDAP Public License v1.3,OLDAP-1.3,,,This specific version not on Fedora list,

+ Open LDAP Public License v1.4,OLDAP-1.4,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B),OLDAP-2.0,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.0.1,OLDAP-2.0.1,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.1,OLDAP-2.1,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.2,OLDAP-2.2,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.2.1,OLDAP-2.2.1,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.3,OLDAP-2.3,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.4,OLDAP-2.4,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.5,OLDAP-2.5,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.6,OLDAP-2.6,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.7,OLDAP-2.7,,,This specific version not on Fedora list,

+ Open LDAP Public License v2.8,OLDAP-2.8,OpenLDAP,,,

+ Open Market License,OML,OML,,,

+ Open Public License v1.0,OPL-1.0,,,Fedora bad list,

+ Open Software License 1.0,OSL-1.0,OSL 1.0,,,

+ Open Software License 1.1,OSL-1.1,OSL 1.1,,,

+ Open Software License 2.0,OSL-2.0,OSL 2.0,,,

+ Open Software License 2.1,OSL-2.1,OSL 2.1,,,

+ Open Software License 3.0,OSL-3.0,OSL 3.0,,,

+ OpenSSL License,OpenSSL,OpenSSL,,,

+ PHP License v3.0,PHP-3.0,PHP,,,

+ PHP License v3.01,PHP-3.01,,,This specific version not on Fedora list,

+ Plexus Classworlds License,Plexus,Plexus,,,

+ PostgreSQL License,PostgreSQL,PostgreSQL,,,

+ psfrag License,psfrag,psfrag,,,

+ psutils License,psutils,psutils,,,

+ Python License 2.0,Python-2.0,,,"Stack of 4 licenses. SPDX version matches what is on OSI site. Fedora version looks to be more current version from Python website. May match, but need to check against SPDX matching guidelines (and possibly create template). SPDX could consider breaking indivicual licenses apart.",

+ Q Public License 1.0,QPL-1.0,QPL,Q Public License,,

+ Qhull License,Qhull,Qhull,,,

+ Rdisc License,Rdisc,Rdisc,,,

+ RealNetworks Public Source License v1.0,RPSL-1.0,RPSL,,,

+ Reciprocal Public License 1.1,RPL-1.1,,,Fedora bad list,

+ Reciprocal Public License 1.5,RPL-1.5,,,Fedora bad list,

+ Red Hat eCos Public License v1.1,RHeCos-1.1,,,not on Fedora list,

+ Ricoh Source Code Public License,RSCPL,,,Fedora bad list,

+ RSA Message-Digest License ,RSA-MD,,,not on Fedora list,

+ Ruby License,Ruby,Ruby,,,

+ Sax Public Domain Notice,SAX-PD,,,not on Fedora list,

+ Saxpath License,Saxpath,Saxpath,,,

+ SCEA Shared Source License,SCEA,SCEA,,,

+ Scheme Widget Library (SWL) Software License Agreement,SWL,SWL,,,

+ SGI Free Software License B v1.0,SGI-B-1.0,,,This specific version not on Fedora list,

+ SGI Free Software License B v1.1,SGI-B-1.1,,,Fedora bad list,

+ SGI Free Software License B v2.0,SGI-B-2.0,MIT,SGI Free Software License B 2.0,,

+ SIL Open Font License 1.0,OFL-1.0,,,not on Fedora list,

+ SIL Open Font License 1.1,OFL-1.1,,,not on Fedora list,

+ Simple Public License 2.0,SimPL-2.0,,,not on Fedora list,

+ Sleepycat License,Sleepycat,Sleepycat,,,

+ SNIA Public License 1.1,SNIA,SNIA,,,

+ Spencer License 86,Spencer-86,HSRL,Henry Spencer Reg-Ex Library License,,

+ Spencer License 94,Spencer-94,HSRL,Henry Spencer Reg-Ex Library License,,

+ Spencer License 99,Spencer-99,,,This specific version not on Fedora list,

+ Standard ML of New Jersey License,SMLNJ,MIT,,,

+ SugarCRM Public License v1.1.3,SugarCRM-1.1.3,,,not on Fedora list,

+ Sun Industry Standards Source License v1.1,SISSL,SISSL,,,

+ Sun Industry Standards Source License v1.2,SISSL-1.2,,,This specific version not on Fedora list,

+ Sun Public License v1.0,SPL-1.0,SPL,,,

+ Sybase Open Watcom Public License 1.0,Watcom-1.0,,,Fedora bad list,

+ TCL/TK License,TCL,TCL,,,

+ The Unlicense,Unlicense,Unlicense,Unlicense,,

+ TMate Open Source License,TMate,TMate,,,

+ TORQUE v2.5+ Software License v1.1,TORQUE-1.1,TORQUEv1.1,,,

+ Trusster Open Source License,TOSL,TOSL,,,

+ Unicode Terms of Use,Unicode-TOU,,,not on Fedora list,

+ Universal Permissive License v1.0,UPL-1.0,,,not on Fedora list,

+ University of Illinois/NCSA Open Source License,NCSA,NCSA,NCSA/University of Illinois Open Source License,,

+ Vim License,Vim,Vim,,,

+ VOSTROM Public License for Open Source,VOSTROM,VOSTROM,,,

+ Vovida Software License v1.0,VSL-1.0,VSL,,,

+ W3C Software Notice and License (1998-07-20),W3C-19980720,,,not on Fedora list,

+ W3C Software Notice and License (2002-12-31),W3C,W3C,,,

+ Wsuipa License,Wsuipa,Wsuipa,,,

+ X.Net License,Xnet,,,not on Fedora list,

+ X11 License,X11,MIT,,,

+ Xerox License,Xerox,Xerox,,,

+ XFree86 License 1.1,XFree86-1.1,,,not on Fedora list,

+ xinetd License,xinetd,xinetd,,,

+ XPP License,xpp,xpp,,,

+ XSkat License,XSkat,XSkat,,,

+ Yahoo! Public License v1.0,YPL-1.0,,,Fedora bad list,

+ Yahoo! Public License v1.1,YPL-1.1,YPLv1.1,,,

+ Zed License,Zed,Zed,,,

+ Zend License v2.0,Zend-2.0,Zend,,,

+ Zimbra Public License v1.3,Zimbra-1.3,,,Fedora bad list,

+ Zimbra Public License v1.4,Zimbra-1.4,,,not on Fedora list,

+ zlib License,Zlib,"zlib

+ Teeworlds",,,Teeworlds License

+ zlib/libpng License with Acknowledgement,zlib-acknowledgement,zlib with acknowledgement,,,

+ Zope Public License 1.1,ZPL-1.1,,,This specific version not on Fedora list,

+ Zope Public License 2.0,ZPL-2.0,ZPLv2.0,,,

+ Zope Public License 2.1,ZPL-2.1,ZPLv2.1,,,

+ BSD Zero Clause License,0BSD,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ CeCILL Free Software License Agreement v2.1,CECILL-2.1,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ CrystalStacker License,CrystalStacker,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ Interbase Public License v1.0,Interbase-1.0,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ Sendmail License,Sendmail,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ curl License,curl,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list",

+ Info-ZIP License,Info-ZIP,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list",

+ Open CASCADE Technology Public License,OCCT-PL,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list",

+ Open Government Licence v3.0,OGL-3.0,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list",

+ Norwegian Licence for Open Government Data,NLOD-1.0,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ FSF All Permissive License,FSFAP,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ Secure Messaging Protocol Public License,SMPPL,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ Licence Libre du Québec – Permissive version 1.1,LiLiQ-P-1.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ Licence Libre du Québec – Réciprocité forte version 1.1,LiLiQ-Rplus-1.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ Licence Libre du Québec – Réciprocité version 1.1,LiLiQ-R-1.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ OSET Public License version 2.1,OSET-PL-2.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ Free Art License 1.3,FAL-1.3,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ Free Art License 1.2,FAL-1.2,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list",

+ BSD 3-Clause No Nuclear License,BSD-3-Clause-No-Nuclear-License,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list",

+ BSD 3-Clause No Nuclear License 2014,BSD-3-Clause-No-Nuclear-License-2014,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list",

+ BSD 3-Clause No Nuclear Warranty,BSD-3-Clause-No-Nuclear-Warranty,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list",

+ BSD Source Code Attribution,BSD-Source-Code,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list",

+ ,,,,,

+ ,,,,,

+ ,,,,,

+ ,,,,,

+ "License Exceptions: As per SPDX specification – these exceptions would use the short identifier for the main license, the “with” operator, and then the short identifier for the exception (shown here). See SPDX spec 2.0, Appendix IV",,,,,

+ "389 Directory Server

+ Exception",389-exception,GPLv2 with exceptions,Fedora Directory Server License,,

+ Autoconf exception 2.0,Autoconf-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Autoconf exception 3.0,Autoconf-exception-3.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Bison exception 2.2,Bison-exception-2.2,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Classpath exception 2.0,Classpath-exception-2.0,[identifier] with exceptions,"On Fedora List as ""GNU General Public License (no version), with Classpath exception"" and ""GNU General Public License v2.0 only, with Classpath exception"" and ""GNU General Public License v2.0 or later, with Classpath exception"" and ""GNU General Public License v3.0 only, with Classpath exception"" and ""GNU General Public License v3.0 or later, with Classpath exception""","Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” ",

+ CLISP exception 2.0 ,CLISP-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ eCos exception 2.0,eCos-exception-2.0,eCos,eCos License v2.0,,

+ FLTK exception,FLTK-exception,LGPLv2 with exceptions,FTLK License,,

+ Font exception 2.0,Font-exception-2.0,[identifier] with exceptions,"On Fedora list as 

+ ""GNU General Public License v2.0 only, with font embedding exception"" and 

+ ""GNU General Public License v2.0 or later, with font embedding exception"" and 

+ ""GNU General Public License v3.0 only, with font embedding exception"" and 

+ ""GNU General Public License v3.0 or later, with font embedding exception"" and 

+ ""GNU General Public License (no version), with font embedding exception"".","Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ FreeRTOS Exception 2.0,freertos-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ GCC Runtime Library exception 2.0,GCC-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ GCC Runtime Library exception 3.1,GCC-exception-3.1,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ GNU JavaMail exception,gnu-javamail-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ i2p GPL+Java Exception,i2p-gpl-java-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Libtool Exception,Libtool-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ LZMA exception,LZMA-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Macros and Inline Functions Exception,mif-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Nokia Qt LGPL exception 1.1,Nokia-Qt-exception-1.1,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ Qwt exception 1.0,Qwt-exception-1.0,LGPLv2+ with exceptions,Qwt License 1.0,,

+ U-Boot exception 2.0,u-boot-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ WxWindows Library Exception 3.1,WxWindows-exception-3.1,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)",

+ DigiRule FOSS License Exception,DigiRule-FOSS-exception,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ Fawkes Runtime Exception,Fawkes-Runtime-exception,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ OpenVPN OpenSSL Exception,openvpn-openssl-exception,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list",

+ Open CASCADE Exception 1.0,OCCT-exception-1.0,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list", 

\ No newline at end of file

file modified
+7 -1
@@ -20,7 +20,13 @@ 

  Group:          {{ rust_group }}

  {% endif %}

  

- License:        {{ md.license|default("# FIXME") }}

+ {% if md.license != license %}

+ # Upstream license specification: {{ md.license|default("(missing)") }}

+ {% endif %}

+ License:        {{ license|default("# FIXME") }}

+ {% if license_comments is not none %}

+ {{ license_comments }}

+ {% endif %}

  URL:            https://crates.io/crates/{{ md.name }}

  Source0:        https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate

  {% if patch_file is not none %}

file modified
+4
@@ -10,6 +10,7 @@ 

      packages=["rust2rpm"],

      package_data={

          "rust2rpm": [

+             "spdx_to_fedora.csv",

              "templates/*.spec",

              "templates/*.spec.inc",

          ],
@@ -28,6 +29,9 @@ 

          "jinja2",

          "requests",

          "tqdm",

+ 

+         # Rust cfg language parser

+         "rustcfg",

      ],

  

      author="Igor Gnatenko",

This is just a POC for now, using the new cfg parser. See https://pagure.io/python-rustcfg/ and https://bugzilla.redhat.com/show_bug.cgi?id=1615629.

Some outstanding issues:

  • the cfg language is documented (approximately), but the specific fields that can be used are not. I looked at the list of Cargo.toml files packages for Fedora and added support for stuff that is found there.

  • multiarch tuples may be used. But I don't see how this can ever work, at least without globs. But the packages I saw did not use globs. So it would be necessary to list all possible tuples, for all possible vendors and such. This seems to be a legacy feature only, so I think it's fine to just ignore any dependencies listed by multiarch tuple. In Fedora only /usr/share/cargo/registry/net2-0.2.32/Cargo.toml uses them, and only as fallback.

  • I did not implement passing of options to the evaluator. This certainly should be added. I didn't see any examples though in the toml files I looked at.

  • Various files use syntax like target.'cfg(foo)'.dependencies.something. The .something part is not documented in the rust docs from what I saw. And cargo read-manifest seems to ignore it too. Not sure what to make of this.

Example:

$ PYTHONPATH=~/python/rust2rpm:~/python/python-rustcfg python3 -m rust2rpm --stdout /var/tmp/rust-native-tls/Cargo.toml             
Dependency lazy_static for target 'cfg(any(target_os = "macos", target_os = "ios"))' is not needed, ignoring.
Dependency libc for target 'cfg(any(target_os = "macos", target_os = "ios"))' is not needed, ignoring.
Dependency security-framework for target 'cfg(any(target_os = "macos", target_os = "ios"))' is not needed, ignoring.
Dependency security-framework-sys for target 'cfg(any(target_os = "macos", target_os = "ios"))' is not needed, ignoring.
Dependency tempfile for target 'cfg(any(target_os = "macos", target_os = "ios"))' is not needed, ignoring.
Dependency schannel for target 'cfg(target_os = "windows")' is not needed, ignoring.
# rust-native-tls.spec
# Generated by rust2rpm
%bcond_without check
%global debug_package %{nil}

%global crate native-tls

Name:           rust-%{crate}
Version:        0.2.1
Release:        1%{?dist}
Summary:        A wrapper over a platform's native TLS implementation

License:        MIT/Apache-2.0
URL:            https://crates.io/crates/native-tls
Source0:        https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate

ExclusiveArch:  %{rust_arches}

BuildRequires:  rust-packaging
# [dependencies]
BuildRequires:  (crate(openssl) >= 0.10.11 with crate(openssl) < 0.11.0)
BuildRequires:  (crate(openssl-probe) >= 0.1.0 with crate(openssl-probe) < 0.2.0)
BuildRequires:  (crate(openssl-sys) >= 0.9.30 with crate(openssl-sys) < 0.10.0)
%if %{with check}
# [dev-dependencies]
BuildRequires:  (crate(hex) >= 0.3.0 with crate(hex) < 0.4.0)
%endif
...

@zbyszek the .something is name of dependency, isn't it?

I would prefer double quotes.

add one line to setup.py as well (once you publish rustcfg to pypi).

1 new commit added

  • Translate SPDX licenses to Fedora license tags
5 years ago

I would prefer double quotes.

All things equal, I generally prefer single quotes, because they are visually lighter.
But here double quotes are already used to refer to fields (e.g. dep["name"]), so using single quotes for the whole string is natural.

add one line to setup.py as well (once you publish rustcfg to pypi).

Right. I'll leave that for later when the pypi registration is done.

I added one more patch: this does translation of spdx license tags to our Fedora tags. It does not implement the full spdx language (no parentheses, no "+"). It turns out that most crates use very simple licensing, so this should be good enough for now. We can always add a full parser later on as more use cases come up.

The license part from the example above now looks like this:

# Upstream license specification: MIT/Apache-2.0
License:        MIT or ASL 2.0
# FIXME: Upstream uses deprecated "/" syntax. Assuming that OR was meant. Needs to be verified.

FIXME: Upstream uses deprecated "/" syntax. Assuming that OR was meant. Needs to be verified.

I would put this just to stderr/stdout. I haven't encounter any crate where it meant AND.

@zbyzek, is the swapping of / to or happening regardless of tags? SUSE distributions use SPDX identifiers as-is, but the / is invalid.

@ngompa: it's not. I'll update the patch to do that in that case too.

Updated:
- use double quotes in one more place to match surrounding code
- always apply "/" replacement, not just on Fedora and EPEL

I think this looks good now. Once the rustcfg part is done, I don't see why it shouldn't be merged.

rebased onto 1fea7d2915185a478a48ae891e7cf1cdab11fdfe

5 years ago

Mageia also uses Fedora license tags.

1 new commit added

  • Use fedora tags also for megeia
5 years ago

@zbyszek Can you rebase against current master?

rebased onto e022a1562877e93f27275f8021dc269ca8b14e70

5 years ago

python-rustcfg is now Fedora. This can be merged, and I'll work on the follow-up functionality (#1, #2, #4) in a separate PR.

I will review it today and merge.

Metadata Update from @ignatenkobrain:
- Request assigned

5 years ago

still need entry in requirements.txt and setup.py

would be nice to know how it is generated.

you can use DictReader instead.

if I understand correctly, this is the only API function, so add __all__ = [translate_license] and replace from . import license by from .license import *

Updated with the following changes:
- rustcfg added to setup.py and requires.txt
- with open and csv.DictReader is used to read the file
- empty keys (spdx tag) in the license list are filtered out
- I added rust2rpm --show-license-map to dump the license list

would be nice to know how it is generated.

This is documented in the commit message. The list is from spdx upstream.

if I understand correctly, this is the only API function, so add __all__ = [translate_license] and replace from . import license by from .license import *

I think __all__ is exceptionally ugly. I like the leading-underscore convention much more so I'll stick to it. And star imports are terrible, in particular for the reader of the code. I very much won't use them.

rebased onto 9b64a6f

5 years ago

Pull-Request has been merged by ignatenkobrain

5 years ago