Sunday, April 28, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 5598  / 3 Years ago, tue, june 15, 2021, 7:34:05

How can I determine if a package is a meta-package from the command line, possibly via apt-get, aptitude or apt-cache?



I have tried:



apt-cache show texlive-full
apt-cache showpkg texlive-full


but the only way I can tell this package is meta is by reading the "en-description" field.



Is there a more automatic way of doing this, that will give me a yes/no response, or at least have a field such as then "en-description" dedicated to this?


More From » package-management

 Answers
2

There is no formal definition of a metapackage. The informal definition is that a metapackage is one that is only intended to be installed for its dependencies and contains no useful file of its own.



You can define a metapackage as a package that contains no file. There is no way to determine this from the package database. You can use the file database and check that the package contains only directories (many such packages contain a few directories). In fact, most metapackages contain a few files in /usr/share/doc/<package name>: a copyright file, a changelog, sometimes a few more. Here's an approximation that defines a metapackage as containing only files in /usr/share/doc/<some directory> (not in subdirectories of that) and the leading directories:



if ! apt-file -F list $package | grep -qvE '^/(usr(/share(/doc(/[^/]*(/[^/]*)?)?)?)?)?$'; then
echo "$package looks like a metapackage"
fi


Another approach is to look for a package tag with debtags. There are several tags that are commonly used on metapackages.



debtags tag ls $package | grep -x -e 'role::metapackage' -e 'role::dummy' -e 'special::meta'


Another approach is to look for packages with a small size. Each directory counts as 4 kB, so plan accordingly when picking a threshold (again, this is an approximation).



aptitude -F '%I %p' search "~n^$package$"





Upon reflection, I wonder if you mean virtual packages rather than metapackages. Virtual packages are actually not packages but package names used in Provides: fields. You can list them with aptitude search '~v'. Running apt-cache show on one displays “Can't select versions from package 'zcav' as it is purely virtual”. Running aptitude show lists the packages that provide it. A convenient way to show virtual packages is with apt-cache: this prints one line for a non-virtual package and potentially multiple lines (one for each provider) for a virtual package — you can tell if the package is virtual even if there is a single provider because the name of the provider is different.



apt-cache -n search "^$package$"

[#35303] Wednesday, June 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
farnic

Total Points: 409
Total Questions: 117
Total Answers: 125

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
;