如何从命令行列出我的所有包,可以显示包名,许可证,源URL等?

如何使用license, source 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 

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控制文件没有许可证标题的字段。 软件包foo的许可证详细信息应在/usr/share/doc//copyright文件中给出。 但是,这些文件没有标准格式。 其中一些相当简单,基本上说这是根据GPL v3发布的,请参阅/ usr / share / common-licenses / GPL-3获取完整的许可文本 。 其他人则包含完整的自定义许可证。 复杂包可以针对其不同部分具有不同的许可(例如,一个用于程序而另一个用于图形)。 通常,还包括Debian包装信息的许可。

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

许可证和源URL(我认为你的意思是tarball的上游源URL)通常可以在名为copyright的文件中找到。 这个文件应该放在每个包中,但它最近才“标准化”,以便于机器/计算机读取(参见DEP5 )。

并非所有软件包都已正确填写许可证。此外,并非所有软件包都具有机器可读的版权文件。 一个单独的文件有时可能需要单独的许可证,如果许可证不允许再分发(或者它不是免费/开源批准的许可证),可以使debian软件包成为删除的候选者。

为了下载每个软件包的debian / copyright文件,您可以使用cupt包管理器,如下所示:

 cupt copyright busybox python > all-copyrights.txt 

或者每包获得一个文件:

 for i in busybox python; do cupt copyright "$i" >"$i"_copyright.txt; done 

与Fedora相比,Debian / Ubuntu通常不会为包提供单一许可,而是列出源中的所有许可; 从这个意义上来说,它更准确,但也更难以概述。 此外,旧的debian /版权文件的非统一格式也无济于事:)

建立@ 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 

我能想到的最接近yum info就是apt-cache show 。 我不知道是否会显示许可证,但它提供了一些关于包的详细信息。 您可以提供多个包名称,以一次获取有关多个包的详细信息。

例如:

 matt@eden:~$ apt-cache show python Package: python Priority: important Section: python Installed-Size: 768 Maintainer: Ubuntu Developers  Original-Maintainer: Matthias Klose  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 

您可能会使用以下内容:

 for package in `dpkg -l | grep ^ii | awk '{print $2}'`; do apt-cache policy $package; done | grep -iv "version table" | grep -i -e :$ -e multiverse -e restricted