如何列出基于 Debian 的发行版中所有已安装软件包的许可证?

6 ubuntu copyright-display

我想获得 Ubuntu 服务器上所有已安装的软件包许可证,我可以使用(这篇 2013 年的帖子)转储所有内容:

packages=$( dpkg --get-selections | awk '{ print $1 }' )
for package in $packages; do
  echo "$package: "
  cat /usr/share/doc/$package/copyright
  echo; echo
done > /tmp/licenses.txt
less /tmp/licenses.txt
Run Code Online (Sandbox Code Playgroud)

但输出是一个巨大的无用文件,其中包含每个包的所有版权数据。我需要类似的东西:

package: package_name        licence: licence_name
Run Code Online (Sandbox Code Playgroud)

是否有解析器或其他工具可以获取这样的数据?

tri*_*eee 4

尽管正在努力在文件/usr/share/doc/*/copyrightfiles 中提供机器可读的信息,但目前您所尝试的支持很差。例如,请参阅此摘录

Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: at
Source: git://anonscm.debian.org/collab-maint/at.git
Comment: This package was debianized by its author Thomas Koenig
 <ig25@rz.uni-karlsruhe.de>, taken over and re-packaged first by Martin
 Schulze <joey@debian.org> and then by Siggy Brentrup <bsb@winnegan.de>,
 and then taken over by Ryan Murray <rmurray@debian.org>.
 .
 In August 2009 the upstream development and Debian packaging were taken over
 by Ansgar Burchardt <ansgar@debian.org> and Cyril Brulebois <kibi@debian.org>.
 .
 This may be considered the experimental upstream source, and since there
 doesn't seem to be any other upstream source, the only upstream source.

Files: *
Copyright: 1993-1997,  Thomas Koenig <ig25@rz.uni-karlsruhe.de>
           1993,       David Parsons
           2002, 2005, Ryan Murray <rmurray@debian.org>
License: GPL-2+

Files: getloadavg.c
Copyright: 1985-1995, Free Software Foundation Inc
License: GPL-2+

Files: posixtm.*
Copyright: 1989-2007, Free Software Foundation Inc
License: GPL-3+

Files: parsetime.pl
Copyright: 2009, Ansgar Burchardt <ansgar@debian.org>
License: ISC 

License: GPL-2+
 This program is free software; you can redistribute it
 and/or modify it under the terms of the GNU General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later
 version.
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/中的规范(上面链接) 。

正如您所看到的,每个包必然有一个许可证的基本假设是错误的。每个文件可能有多个许可证- 取决于您要解决的问题,当然可以忽略其中许多许可证(例如,如果您想调查您是否拥有 Apache 许可证下的内容,对于已经转换为这种新格式的包来说,这应该很容易做到)。

这是 Debian Jessie 的新功能,于 2015 年发布;旧版本的 Debian 没有这样的东西。如果您需要审核具有较旧软件包的系统,您能做的最好的事情可能是 grep 文件中是否copyright存在类似于 GPL、BSD、MIT 等的片段,然后希望您不会丢失太多;但希望在一些脆弱的 grepping 之上似乎对任何适当的法律工作都是令人厌恶的,我认为我们可以假设这就是你尝试这样做的原因。更好的方法可能是找到copyright您正在审核的软件包的当前文件,以及大致机器可读的信息,并希望(再次出现这个词)它们也适合您安装的旧版本。

(为了进行比较,旧版本也可以在http://metadata.ftp-master.debian.org/changelogs/main/a/at/上供您检查。)

我不再密切关注 Ubuntu,但假设他们从几个版本开始就接受了这一变化。事实上,http://packages.ubuntu.com/xenial/at似乎有相同的copyright文件。