如何从命令行列出所有软件包,其中可以显示软件包名称、许可证、源 URL 等?

如何从命令行列出所有软件包,其中可以显示软件包名称、许可证、源 URL 等?

如何获取所有已安装软件包列表license, source url?例如,下面仅显示软件包名称。

$ dpkg --get-selections
acpi-support                    install
acpid                       install
adduser                     install
adium-theme-ubuntu              install
aisleriot                   install
alacarte                    install

例如在 Fedora/CentOS (RED HAT LINUX BRANCH) 中,您可以看到:

$ yum info busybox
Loaded plugins: auto-update-debuginfo, langpacks, presto, refresh-packagekit
Available Packages
Name        : busybox
Arch        : i686
Epoch       : 1
Version     : 1.18.2
Release     : 5.fc15
Size        : 615 k
Repo        : updates
Summary     : Statically linked binary providing simplified versions of system commands
URL         : http://www.busybox.net
License     : GPLv2
Description : Busybox is a single binary which includes versions of a large number
            : of system commands, including a shell.  This package can be very
            : useful for recovering from certain types of system failures,
            : particularly those involving broken shared libraries.

跟进:

/var/lib/apt/lists$ ls
extras.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages
extras.ubuntu.com_ubuntu_dists_natty_main_source_Sources
extras.ubuntu.com_ubuntu_dists_natty_Release
extras.ubuntu.com_ubuntu_dists_natty_Release.gpg
lock
partial
security.ubuntu.com_ubuntu_dists_natty-security_main_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_main_source_Sources
security.ubuntu.com_ubuntu_dists_natty-security_multiverse_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_multiverse_source_Sources
security.ubuntu.com_ubuntu_dists_natty-security_Release
security.ubuntu.com_ubuntu_dists_natty-security_Release.gpg
security.ubuntu.com_ubuntu_dists_natty-security_restricted_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_restricted_source_Sources
security.ubuntu.com_ubuntu_dists_natty-security_universe_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_universe_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_main_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_multiverse_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_multiverse_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_Release
us.archive.ubuntu.com_ubuntu_dists_natty_Release.gpg
us.archive.ubuntu.com_ubuntu_dists_natty_restricted_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_restricted_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_universe_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_universe_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_main_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_main_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_multiverse_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_multiverse_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_Release
us.archive.ubuntu.com_ubuntu_dists_natty-updates_Release.gpg
us.archive.ubuntu.com_ubuntu_dists_natty-updates_restricted_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_restricted_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_universe_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_universe_source_Sources

答案1

dpkg-query是一个允许您查询 dpkg 数据库的实用程序。要打印所有已安装软件包的名称和主页:

$ dpkg-query -f='${PackageSpec;-30}\t${Homepage}\n' -W "*"
a2ps                            
aalib1                          
abrowser                        
abrowser-branding               
accountsservice                 http://cgit.freedesktop.org/accountsservice/
acl                             http://savannah.nongnu.org/projects/acl/
acpi-support                    
acpid                           http://www.tedfelix.com/linux/acpid-netlink.html
adbbs                           
adduser                         http://alioth.debian.org/projects/adduser/
...

请注意,主页不是 Debian 软件包控制文件中的必需条目。我认为我的系统上安装的软件包中只有大约 40% 列出了主页。

没有简单的方法(以编程方式)确定软件包的许可证。Debian 控制文件没有许可证标题字段。软件包的许可证详细信息文件中应给出/usr/share/doc/<foo>/copyright。但是,这些文件没有标准格式。其中一些相当简单,基本上就是说这是根据 GPL v3 发布的,请参阅 /usr/share/common-licenses/GPL-3 了解完整的许可证文本。其他软件包则包含完整的自定义许可证。复杂软件包的不同部分可能有不同的许可证(例如,一个用于程序,另一个用于图形)。通常,Debian 打包信息的许可证也包含在内。

简而言之:手动获取单个软件包的许可证很简单。如果您需要自动为所有已安装的软件包执行此操作,则需要付出大量努力。

答案2

基于@crysman 的回答:这适用于 ubuntu 14.04 上的许多软件包,并且部分${packages:amd64}是根据我的处理器导航到正确的文件夹。

for package in `dpkg -l | grep ^ii | awk '{print $2}'`; do echo -e $package"\t"`grep License /usr/share/doc/${package%:amd64}/copyright`; done > ~/dpkg.txt

答案3

许可证和源 URL(我想你指的是 tarball 的上游源 URL)通常可以在名为 copyright 的文件中查找。此文件应该在每个软件包中都有,但最近才被“标准化”,以便于机器/计算机读取(请参阅DEP5)。

并非所有软件包都正确填写了许可证。此外,并非所有软件包都有机器可读的版权文件。一个文件有时可能需要单独的许可证,如果许可证不允许重新分发(或它不是自由/开源批准的许可证),则可能导致 debian 软件包被删除。

答案4

我能想到的最接近的类似的东西yum infoapt-cache show。我不知道它是否会显示许可证,但它提供了有关软件包的大量详细信息。您可以提供多个软件包名称以一次获取有关多个软件包的详细信息。

例如:

matt@eden:~$ apt-cache show python
Package: python
Priority: important
Section: python
Installed-Size: 768
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Matthias Klose <[email protected]>
Architecture: all
Source: python-defaults
Version: 2.7.2-7ubuntu2
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.2-3~), python-minimal (= 2.7.2-7ubuntu2)
Suggests: python-doc (= 2.7.2-7ubuntu2), python-tk (= 2.7.2-7ubuntu2)
Conflicts: python-central (<< 0.5.5)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager (<= 0.200.5-1)
Filename: pool/main/p/python-defaults/python_2.7.2-7ubuntu2_all.deb
Size: 165792
MD5sum: a4b881e98e39f213bc8bbcfac566dd21
SHA1: 8a85fd4e62d1bad26a03ceef4313a12521e8a1dc
SHA256: ba95771b54aa4a1211486651fea1ecbac9e2dbbb4f66435e8a4dd0cb3e86bf4b
Description-en: interactive high-level object-oriented language (default version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python version (currently v2.7).
Homepage: http://www.python.org/
Description-md5: d1ea97f755d8153fe116080f2352859b
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 18m
Task: minimal

相关内容