Differences between revisions 1 and 32 (spanning 31 versions)
Revision 1 as of 2016-06-14 11:12:40
Size: 832
Editor: wookey
Comment:
Revision 32 as of 2019-12-27 12:49:38
Size: 10489
Comment: Add CDBS, demonstrating state of the art of license-miner + licensecheck + licensecheck2dep5 integration
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Reviewing upstream packages to write debian/copyright files is tedious manual work. It tends not to get done again after initial packaging, especially not on every release (when something may have changed).

Making initial copyright file construction, and subsequent review/update easier will improve Debian's software quality.

Stretch (Debian 9) has significantly improved tools over previous releases.

scan-copyrights can update an existing copyright file from rescanning the source. It can also create one from scratch. It uses the underlying licensecheck tool from devscripts

The package needed is cme (and libconfig-model-dpkg-perl v2.074 or later)

updating is as simple as:
## Note on editing: Please use semantic newlines, to ease readability (also of emailed diffs).

<<TableOfContents(2)>>

== Command-line tools in Debian ==

Reviewing upstream packages to write debian/copyright files is tedious but important manual work.
It is done during initial packaging and after every new upstream release.

Making initial copyright file construction and subsequent review/update easier will improve Debian's software quality.

Starting with Stretch (Debian 9) there are significantly improved tools over previous releases to help.

=== licensecheck ===

`licensecheck` from DebianPackage:licensecheck (and older versions of DebianPackage:devscripts) can scan source code
and report found copyright holders and known licenses.
Its approach is to detect licenses with a dataset (medium:~200 regexes) of regex patterns and key phrases (parts)
and to reassemble these in detected licenses based on rules.
In that sense this is somewhat similar to the combined approaches of Fossology/nomos and Ninka (see below for these tools).
It also detects copyright statements.
It output results in plain text (with customizable delimiter) or a Debian copyright file format.
Written in Perl.

{{{
licensecheck --check '.*' --recursive --deb-machine --lines 0 *
}}}

=== scan-copyrights ===

`scan-copyrights` from DebianPackage:libconfig-model-dpkg-perl can update an existing copyright file from rescanning the source.
It can also create one from scratch.
Written in Perl, using [[#licensecheck|licensecheck]].

=== cme ===

Config::Model can update Debian copyright files using the `cme` command
(from DebianPackage:cme or DebianPackage:libconfig-model-dpkg-perl less than 2.063).
Written in Perl, using [[#licensecheck|licensecheck]].

{{{
Line 13: Line 43:

More details here:
https://github.com/dod38fr/config-model/wiki/Updating-debian-copyright-file-with-cme
}}}

Usage is detailed in [[https://github.com/dod38fr/config-model/wiki/Updating-debian-copyright-file-with-cme|Config::Model wiki]]

=== licensecheck2dep5 ===

A script from DebianPackage:cdbs can create a copyright file by tidying output from `licensecheck`.
Written in Perl, using [[#licensecheck]].

{{{
licensecheck --check '.*' --recursive --copyright --deb-fmt --lines 0 * | /usr/lib/cdbs/licensecheck2dep5
}}}

=== license-miner ===

A script from DebianPackage:cdbs can extract structured metadata embedded in binary content,
for subsequent parsing by [[#licensecheck]] and suffix stripping by [[#licensecheck2dep5]].
Written in Perl, using `Image::ExifTool` and `Font::TTF`.

{{{
find -type f -name '*.png' -print0 | perl -0 /usr/lib/cdbs/license-miner
licensecheck --check '.*' --ignore '.+\.png$' --recursive --copyright --deb-fmt --lines 0 * | /usr/lib/cdbs/licensecheck2dep5
find -type f -name '*.png.metadata' -delete
}}}

=== CDBS ===

A makefile from DebianPackage:cdbs can automate selection, mining, parsing, and cleanup,
comparing previously autogenerated file `debian/copyright_hints` included with source package
with freshly autogenerated instance and warning about newly introduced (but not disappearing) changes to discovered hints,
using [[#license-miner]] and [[#licensecheck]] and [[#licensecheck2dep5]] under the hood.
Written in make.

Typical use is by shipping a package-specific script `debian/copyright-check with source package
and executing that script manually (not as part of normal build) when sources change:

{{{
#!/bin/sh

export DEB_COPYRIGHT_EXTRACT_EXTS="icc pdf png ttf"
export DEB_COPYRIGHT_EXTRACT_PATHS_EXIF="Resource/Font/"
export DEB_COPYRIGHT_CHECK_IGNORE_EXTS="cat ico xls pcl xps"
export DEB_COPYRIGHT_CHECK_IGNORE_PATHS="doc/.*\.htm"
export DEB_COPYRIGHT_CHECK_MERGE_SAME_LICENSE=yes

make -f /usr/share/cdbs/1/rules/utils.mk pre-build || true
make -f /usr/share/cdbs/1/rules/utils.mk clean DEB_COPYRIGHT_CHECK_STRICT=1
}}}

=== license-reconcile ===

`license-reconcile` compares the existing copyright with the source code and reports discrepancies.
Written in Perl, using [[#licensecheck|licensecheck]].

=== debmake ===

`debmake -k` also compares the existing copyright with the source code and reports discrepancies.

`debmake -cc` generates a new copyright file from the source code.

=== decopy ===

[[https://anonscm.debian.org/git/collab-maint/decopy.git/|decopy]] is a tool that "automates creating and updating the debian/copyright files."
It also "aims to detects as many licenses as possible" which makes it a tool for license detection too.
It uses `python-debian` to handle Debian machine readable copyright files.
Its approach to detect licenses is the same as `license-checker`.
Written in Python, using [[#python-debian|python-debian]].

=== licensee ===

`licensee` from DebianPackage:ruby-licensee checks LICENSE files and returns known license names.
This is the [[https://github.com/benbalter/licensee| tool used by Github]] to provide a summary license indication on a repository main page.
Its approach is to search for typical LICENSE file names or some package manifest (NPM, Bower, Gemfile, etc)
and perform an exact or approximate license text matching against the set of common licenses texts
as published at [[https://choosealicense.com]] (small: ~20).
It output results in YAML format.
Written in Ruby.

=== check-all-the-things ===

Wrapper for some of the other tools listed here.

{{{
check-all-the-things -f copyright
}}}

=== cargo-lichking ===

Automated license checking for rust. cargo lichking is a Cargo subcommand that checks licensing information for dependencies,
based on [[http://www.dwheeler.com/essays/floss-license-slide.html|David A. Wheeler's compatibility graph]].

{{{
cargo lichking check
}}}

== Libraries in Debian ==

=== python-debian ===

[[https://packages.qa.debian.org/p/python-debian.html|python-debian]] has support parsing and creating copyright files (and any Debian-style files such as description, control, Sources, Packages, etc.)
Written in Python.

== Command-line tools not in Debian ==

=== license_finder ===

[[https://github.com/pivotal/LicenseFinder|LicenseFinder]] is a tool that "Find licenses for your project's dependencies."
It does so by running application-specific package management tools
and detecting package manifests to collect license-related metadata (e.g. Gemfile, etc)
and detect licensing using regex against a set of common license texts (small: ~20).
It output results in CSV, HTML and other report format.
Written in Ruby.

=== licensed ===

[[https://github.com/github/licensed|licensed]] has been recently released by GitHub to check the licenses of the dependencies of a project. Modern language package managers (bower, bundler, cabal, go, npm, stack) are used to pull the dependency chain of a specific project. Licenses can be configured to be either accepted or rejected, easing the developer task of identifying problematic dependencies when importing a new third-party library.


=== ninka ===

[[https://github.com/dmgerman/ninka|Ninka]] is a "license identification tool for Source Code".
Its approach is to detect licenses from text sentences using a dataset of key license sentences (large: ~600)
and assemble the results based on the matched sentences.
It output results in CSV format.
Written in Perl.

=== scancode ===

[[https://github.com/nexB/scancode-toolkit/|ScanCode]] is a tool "to scan code and detect licenses, copyrights and more".
Its approach is to detect licenses using a dataset of plain license texts (large:~1000 texts)
and plain text notices (large:~2500 notices and mentions)
and finds exact and approximate matches in source and binaries using full text alignments.
It also detects copyright statements and collect license metadata from package manifests (e.g Maven, Pypi, etc.).
It output results in JSON, HTML or SPDX format.
Written in Python.

=== dlt ===

[[https://github.com/agustinhenze/dlt/|dlt]] has support for parsing and creating Debian machine readable copyright files.
Written in Python.

=== deb-pkg-tools ===

[[https://github.com/xolox/python-deb-pkg-tools|Debian packaging tools]] is "a collection of functions to work with Debian packages and repositories.
Written in Python, using [[#python-debian|python-debian]].

=== jninka ===

[[https://github.com/whitesource/jninka/|jninka]] is a port from Perl to Java of `ninka`.
Written in Java.

=== apache-rat ===

[[https://github.com/apache/creadur-rat/| Apache Creadur rat]] is a "tool to improve accuracy and efficiency when checking releases." .
Its goal is to help Apache Foundation projects to comply with the release policy including detecting licenses.
Its approach is to use a key sentences dataset (small: ~20).
Written in Java.

== metaframeworks ==

=== fossology ===

[[https://www.fossology.org/|FOSSology]] is a open source license compliance software system and toolkit
that [[https://debconf16.debconf.org/talks/100/|can]] (in version 3.1) generate DEP5 copyright files.
Its approach is to detect licenses with a either large (large:~2500 regexes) dataset of regex patterns (nomos)
or a full string comparison against license full texts (large: ~400 text) (monk).
It also detects copyright statements and does also integrate with Ninka (see below).
This is a complete database-backed web application with some command line support written in C/C++ with a PHP frontend.

== Obsolete code ==

[[https://forge.ow2.org/projects/oslcv3/|OSLCv3]] Open Source License Checker 3.0 is a "risk management tool for analyzing open source software licenses."
It detects licenses using key sentences and diffs using a dataset of license texts (small: ~50).
It is developed in Java and seems no longer under development since 2009.

== See also ==

 * [[https://github.com/dod38fr/config-model/wiki/Updating-debian-copyright-file-with-cme|Updating debian copyright file with cme]] by Dominique Dumont
 * [[http://people.skolelinux.org/pere/blog/Creating__updating_and_checking_debian_copyright_semi_automatically.html|Creating, updating and checking debian/copyright semi-automatically]] by Petter Reinholdtsen
 * Bachelor Thesis: [[https://osr.cs.fau.de/2019/08/07/final-thesis-a-comparison-study-of-open-source-license-crawler/|A Comparison Study of Open Source License Crawlers]] ([[https://osr.cs.fau.de/wp-content/uploads/2019/08/wolter_2019.pdf|PDF]]) by Thomas Wolter
 * [[CopyrightReview|Peer review for copyright files]]

Command-line tools in Debian

Reviewing upstream packages to write debian/copyright files is tedious but important manual work. It is done during initial packaging and after every new upstream release.

Making initial copyright file construction and subsequent review/update easier will improve Debian's software quality.

Starting with Stretch (Debian 9) there are significantly improved tools over previous releases to help.

licensecheck

licensecheck from licensecheck (and older versions of devscripts) can scan source code and report found copyright holders and known licenses. Its approach is to detect licenses with a dataset (medium:~200 regexes) of regex patterns and key phrases (parts) and to reassemble these in detected licenses based on rules. In that sense this is somewhat similar to the combined approaches of Fossology/nomos and Ninka (see below for these tools). It also detects copyright statements. It output results in plain text (with customizable delimiter) or a Debian copyright file format. Written in Perl.

licensecheck --check '.*' --recursive --deb-machine --lines 0 *

scan-copyrights

scan-copyrights from libconfig-model-dpkg-perl can update an existing copyright file from rescanning the source. It can also create one from scratch. Written in Perl, using licensecheck.

cme

Config::Model can update Debian copyright files using the cme command (from cme or libconfig-model-dpkg-perl less than 2.063). Written in Perl, using licensecheck.

cme update dpkg-copyright

Usage is detailed in Config::Model wiki

licensecheck2dep5

A script from cdbs can create a copyright file by tidying output from licensecheck. Written in Perl, using #licensecheck.

licensecheck --check '.*' --recursive --copyright --deb-fmt --lines 0 * | /usr/lib/cdbs/licensecheck2dep5

license-miner

A script from cdbs can extract structured metadata embedded in binary content, for subsequent parsing by #licensecheck and suffix stripping by #licensecheck2dep5. Written in Perl, using Image::ExifTool and Font::TTF.

find -type f -name '*.png' -print0 | perl -0 /usr/lib/cdbs/license-miner
licensecheck --check '.*' --ignore '.+\.png$' --recursive --copyright --deb-fmt --lines 0 * | /usr/lib/cdbs/licensecheck2dep5
find -type f -name '*.png.metadata' -delete

CDBS

A makefile from cdbs can automate selection, mining, parsing, and cleanup, comparing previously autogenerated file debian/copyright_hints included with source package with freshly autogenerated instance and warning about newly introduced (but not disappearing) changes to discovered hints, using #license-miner and #licensecheck and #licensecheck2dep5 under the hood. Written in make.

Typical use is by shipping a package-specific script `debian/copyright-check with source package and executing that script manually (not as part of normal build) when sources change:

export DEB_COPYRIGHT_EXTRACT_EXTS="icc pdf png ttf"
export DEB_COPYRIGHT_EXTRACT_PATHS_EXIF="Resource/Font/"
export DEB_COPYRIGHT_CHECK_IGNORE_EXTS="cat ico xls pcl xps"
export DEB_COPYRIGHT_CHECK_IGNORE_PATHS="doc/.*\.htm"
export DEB_COPYRIGHT_CHECK_MERGE_SAME_LICENSE=yes

make -f /usr/share/cdbs/1/rules/utils.mk pre-build || true
make -f /usr/share/cdbs/1/rules/utils.mk clean DEB_COPYRIGHT_CHECK_STRICT=1

license-reconcile

license-reconcile compares the existing copyright with the source code and reports discrepancies. Written in Perl, using licensecheck.

debmake

debmake -k also compares the existing copyright with the source code and reports discrepancies.

debmake -cc generates a new copyright file from the source code.

decopy

decopy is a tool that "automates creating and updating the debian/copyright files." It also "aims to detects as many licenses as possible" which makes it a tool for license detection too. It uses python-debian to handle Debian machine readable copyright files. Its approach to detect licenses is the same as license-checker. Written in Python, using python-debian.

licensee

licensee from ruby-licensee checks LICENSE files and returns known license names. This is the tool used by Github to provide a summary license indication on a repository main page. Its approach is to search for typical LICENSE file names or some package manifest (NPM, Bower, Gemfile, etc) and perform an exact or approximate license text matching against the set of common licenses texts as published at https://choosealicense.com (small: ~20). It output results in YAML format. Written in Ruby.

check-all-the-things

Wrapper for some of the other tools listed here.

check-all-the-things -f copyright

cargo-lichking

Automated license checking for rust. cargo lichking is a Cargo subcommand that checks licensing information for dependencies, based on David A. Wheeler's compatibility graph.

cargo lichking check

Libraries in Debian

python-debian

python-debian has support parsing and creating copyright files (and any Debian-style files such as description, control, Sources, Packages, etc.) Written in Python.

Command-line tools not in Debian

license_finder

LicenseFinder is a tool that "Find licenses for your project's dependencies." It does so by running application-specific package management tools and detecting package manifests to collect license-related metadata (e.g. Gemfile, etc) and detect licensing using regex against a set of common license texts (small: ~20). It output results in CSV, HTML and other report format. Written in Ruby.

licensed

licensed has been recently released by ?GitHub to check the licenses of the dependencies of a project. Modern language package managers (bower, bundler, cabal, go, npm, stack) are used to pull the dependency chain of a specific project. Licenses can be configured to be either accepted or rejected, easing the developer task of identifying problematic dependencies when importing a new third-party library.

ninka

Ninka is a "license identification tool for Source Code". Its approach is to detect licenses from text sentences using a dataset of key license sentences (large: ~600) and assemble the results based on the matched sentences. It output results in CSV format. Written in Perl.

scancode

ScanCode is a tool "to scan code and detect licenses, copyrights and more". Its approach is to detect licenses using a dataset of plain license texts (large:~1000 texts) and plain text notices (large:~2500 notices and mentions) and finds exact and approximate matches in source and binaries using full text alignments. It also detects copyright statements and collect license metadata from package manifests (e.g Maven, Pypi, etc.). It output results in JSON, HTML or SPDX format. Written in Python.

dlt

dlt has support for parsing and creating Debian machine readable copyright files. Written in Python.

deb-pkg-tools

Debian packaging tools is "a collection of functions to work with Debian packages and repositories. Written in Python, using python-debian.

jninka

jninka is a port from Perl to Java of ninka. Written in Java.

apache-rat

Apache Creadur rat is a "tool to improve accuracy and efficiency when checking releases." . Its goal is to help Apache Foundation projects to comply with the release policy including detecting licenses. Its approach is to use a key sentences dataset (small: ~20). Written in Java.

metaframeworks

fossology

FOSSology is a open source license compliance software system and toolkit that can (in version 3.1) generate DEP5 copyright files. Its approach is to detect licenses with a either large (large:~2500 regexes) dataset of regex patterns (nomos) or a full string comparison against license full texts (large: ~400 text) (monk). It also detects copyright statements and does also integrate with Ninka (see below). This is a complete database-backed web application with some command line support written in C/C++ with a PHP frontend.

Obsolete code

OSLCv3 Open Source License Checker 3.0 is a "risk management tool for analyzing open source software licenses." It detects licenses using key sentences and diffs using a dataset of license texts (small: ~50). It is developed in Java and seems no longer under development since 2009.

See also