4

我想在我的 Ubuntu 服务器上获取所有已安装的软件包许可证,我可以使用(this 2013 post)将其全部转储:

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

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

package: package_name        licence: licence_name

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

4

1 回答 1

4

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

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.

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

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

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

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

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

于 2016-01-28T03:54:48.543 回答