Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 27265  / 1 Year ago, tue, january 17, 2023, 8:13:59

I want to write a script that outputs the license for every software package installed on my system.



Using dpkg --get-selections I am able to get list of everything installed. However, I don't see a way to get the license information for each package. For example, I can use aptitude show to get the properties of each package, but that does not include the license:



$ aptitude show apache2
Package: apache2
State: installed
Automatically installed: no
Version: 2.2.14-5ubuntu8.6
Priority: optional
Section: httpd
Maintainer: Ubuntu Developers <[email protected]>
Uncompressed Size: 36.9k
Depends: apache2-mpm-worker (= 2.2.14-5ubuntu8.6) | apache2-mpm-prefork (= 2.2.14-5ubuntu8.6) | apache2-mpm-event (= 2.2.14-5ubuntu8.6) | apache2-mpm-itk (= 2.2.14-5ubuntu8.6),
apache2.2-common (= 2.2.14-5ubuntu8.6)
Provided by: apache2-mpm-event, apache2-mpm-itk, apache2-mpm-prefork, apache2-mpm-worker
Description: Apache HTTP Server metapackage
The Apache Software Foundation's goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the
number one web server on the Internet.

It features support for HTTPS, virtual hosting, CGI, SSI, IPv6, easy scripting and database integration, request/response filtering, many flexible authentication schemes, and
more.
Homepage: http://httpd.apache.org/


Is there a third-party repository that correlates the license to each package?



It sounds painful to download every source package and inspect it for licensing information, but maybe that's the best way.


More From » apt

 Answers
0

Here's what I ended up doing. (results in ~/licenses.txt with all the licenses that exist in /usr/share/doc)



$ packages=`dpkg --get-selections | awk '{ print $1 }'`
$ for package in $packages; do echo "$package: "; cat /usr/share/doc/$package/copyright; echo ""; echo ""; done > ~/licenses.txt

[#33004] Wednesday, January 18, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
naldis

Total Points: 257
Total Questions: 101
Total Answers: 111

Location: Kenya
Member since Sat, Feb 25, 2023
1 Year ago
naldis questions
;