Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How to get all the installed package list with there license, source url? Such as following only shows name of the package only.

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

For example in Fedora/CentOS (RED HAT LINUX BRANCH), you can see that:

$ 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.

Follow up:

/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
share|improve this question
add comment

5 Answers

up vote 2 down vote accepted

dpkg-query is a utility which allows you to query the dpkg database. To print the name and homepage of all installed packages:

$ 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/
...

Note that the homepage is not a required entry in the Debian package control file. I'd say only around 40% of the packages installed on my system have a homepage listed.

There is no simple way to (programatically) determine the license of a package. The Debian control file has no field for a license title. License details for a package foo should be given in the /usr/share/doc/<foo>/copyright file. However, there is no standard format for these files. Some of them are fairly simple and basically say this is released under the GPL v3, see /usr/share/common-licenses/GPL-3 for the full license text. Others have a custom license included in full. Complex packages can have different licenses for different pieces of it (e.g., one for the program and another for graphics). Often, the license of the Debian packaging information is also included.

In short: it is simple to manually get the license for a single package. If you need to do it automatically for all installed packages, it will take a large amount of effort.

share|improve this answer
1  
The package info (that is distributed in one file for all packages for a given server, path, release and section (e.g. main) is found in /var/lib/apt/lists. That information can be queried. Other informaton is package specific. Once installed, there is a common location (mentioned above). for documentation –  Portablejim Dec 17 '11 at 11:23
1  
@Google: Unfortunately, like I said I am not aware of any easy way of automatically getting this information for Debian packages. Homepage is not a required field in the package information so not all packages have it. There is no widely accepted standard format for copyright yet (DEP5 is at the candidate stage and not widely followed yet). You could try writing a parser to scan the copyright files and figure out what license the package is released under, but that will not be a simple task. –  Blair Dec 18 '11 at 3:00
1  
I guess another option would be to save a list of all packages into a text file, then take it to a Fedora machine and write a script to feed the entries into your yum info command, retrieve the license field and save it back to the file. Obviously there will be a number of misses (i.e., packages with different names/versions in their names and those which Fedora doesn't provide) but it could provide a reasonable starting point. If Fedora has a suitable online package list that could be used to get the details instead. –  Blair Dec 18 '11 at 3:03
1  
@Google: Yes, it would be possible. You'd have to find a way of finding packages in different repos (e.g., 6tunnel is in the community repo while a2ps is in the extra repo and linux-firmware is in the core repo), and for different architectures (a2ps is i686 while linux-firmware is any, i.e., architecture-independent). There will still be misses, e.g., ArchLinux doesn't have linux-headers-generic. –  Blair Dec 18 '11 at 10:11
1  
Of course, if you could download an offline package list (à la the lists in /var/lib/apt/lists) you might be able to achieve the same thing without having to scrape the ArchLinux website... –  Blair Dec 18 '11 at 10:14
show 5 more comments

The license and source url (I think you mean here the upstream source url of the tarball) can usually be found in a file called copyright. This file should be in every package, but it has only been recently "standardized" for easier machine/computer reading (see DEP5).

Not all packages have the licenses correctly filled in. Also, not all the packages have machine-readable copyright files. One single file can sometimes require a separate license and can make the debian package a candidate for removal if the license does not allow redistribution (or it's not a free/open source approved license).

share|improve this answer
add comment

The closest thing I can think of that is comparable to yum info would be apt-cache show. I don't know if ever will show the license, but it gives a bunch of details about a package. You can provide multiple package names to get details about more than one package at once.

For example:

matt@eden:~$ apt-cache show python
Package: python
Priority: important
Section: python
Installed-Size: 768
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko@debian.org>
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
share|improve this answer
    
Thanks Matt Layman. The problem is still i have 1759 +/_ packages installed. I am preparing a license page to submit it to my lawyer. Where i need to put which package use which license (example: GPL or LGPL or MPL). Finding one by one manually is too much complicated. But thank you once again. I am stilling looking.... –  YumYumYum Dec 17 '11 at 16:59
add comment

In order to download the debian/copyright file of each package you could use the cupt package manager, like so:

cupt copyright busybox python > all-copyrights.txt

or to get one file per package:

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

In contrast to Fedora, Debian/Ubuntu normally doesn't give a single license for a package but instead lists all the licenses in the source; it's by far more accurate in that sense, but also harder to get an overview. Also, the non-uniform format of older debian/copyright files doesn't help either :)

share|improve this answer
add comment

You might use something like:

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.