How do you find the licenses for everything installed on your system?
Solution 1:
Here's what I ended up doing. (results in ~/licenses.txt
with all the licenses that exist in /usr/share/doc
)
$ packages=`dpkg --get-selections | awk '{ print $1 }'`
$ for package in $packages; do echo "$package: "; cat /usr/share/doc/$package/copyright; echo ""; echo ""; done > ~/licenses.txt
Solution 2:
In 2012, Debian released the document Machine-readable debian/copyright which will make licenses readable in the future. Currently, not all packages use this format. The command
grep -h '^License:' /usr/share/doc/*/copyright | sort -i | uniq -ic | sort -n
still returns a lot of garbage. For a better output you probably need a tool which parses each file depending on the Format:
field value.
A completely different way is the file structure in /usr/share/common-licenses/
(thx to https://stackoverflow.com/questions/1884753/license-info-of-a-deb-package#1884785). It lists the main licenses used in debian-based distributions (and contains their license texts). This list is provided by the package base-files
and is not linked to the list of installed packages, but it's probably enough information for the average boss/customer.
ls /usr/share/common-licenses/
Apache-2.0 BSD GFDL-1.2 GPL GPL-2 LGPL LGPL-2.1
Artistic GFDL GFDL-1.3 GPL-1 GPL-3 LGPL-2 LGPL-3
Update I just published a simple command-line solution which extracts the license information from the copyright files with a lot of heuristics. https://github.com/daald/dpkg-licenses. Feel free to try it. Any suggestions are welcome.