portageq
Query Gentoo Portage package information
TLDR
Display the value of a Portage-specific environment variable
Display a detailed list of repositories configured with Portage
Display a list of repositories sorted by priority (highest first)
Display a specific piece of metadata about an atom (i.e. package name including the version)
SYNOPSIS
portageq [global_options] command [arguments...]
PARAMETERS
-v, --verbose
Enable verbose output. Provides more detailed information, for example, showing a package's full atom (category/package-version:SLOT/REPO).
-q, --quiet
Suppress non-essential output. Useful for scripting where only the requested data is desired.
-r, --root path
Operate on an alternative root filesystem specified by path, useful for chrooted environments or managing multiple installations.
-t, --trees type
Specify which package trees to query. type can be 'installed' (default), 'portdir' (only packages in Portage tree), or 'all' (both).
match atom
This command lists packages that match the specified atom (e.g., 'sys-apps/baselayout', '>=dev-lang/python-3.8').
has_version atom
This command checks if a package matching the specified atom is installed. Exits with 0 if found, 1 otherwise.
contents atom
This command lists all files owned by the specified installed package atom.
list_use atom
This command displays the USE flags applicable to the specified package atom as defined by its ebuild.
list_installed_use atom
This command displays the USE flags with which the specified installed package atom was built.
owners path [path...]
This command identifies which installed packages own the specified path(s) (files or directories).
get_repo atom
This command returns the name of the repository from which the package atom was installed or would be installed.
get_version atom
This command returns the installed version string for the given package atom.
DESCRIPTION
portageq is a powerful utility within the Gentoo Linux distribution's Portage package management system. It provides a robust, command-line interface for querying various aspects of installed packages, available packages in repositories, USE flags, file ownership, and more. Unlike parsing emerge output or directly inspecting the /var/db/pkg directory, portageq offers a structured and efficient way to retrieve package information, making it an invaluable tool for system administrators, developers, and users who need to automate tasks or gain deeper insights into their Gentoo system's package state. It supports a wide range of sub-commands to address specific query needs, from listing installed versions to checking package masks or repository origins.
CAVEATS
portageq is exclusively available on Gentoo Linux and Gentoo-based distributions. Its functionality relies entirely on the presence and configuration of the Portage package manager. The output format can vary slightly between Portage versions and specific sub-commands, so care should be taken when scripting to ensure compatibility, especially with less common queries.
SCRIPTING AND AUTOMATION
portageq is highly valuable for scripting and automation tasks. Its consistent output and wide range of query capabilities allow system administrators to build custom tools for system auditing, dependency checking, package consistency verification, and automated reporting without relying on error-prone parsing of human-readable output from other commands.
UNDERSTANDING PACKAGE STATE
For users and developers, portageq offers unparalleled insight into the state of packages on their system. It helps answer questions like 'Which files belong to this package?', 'What USE flags was this specific version built with?', or 'From which repository did this package come?', aiding in troubleshooting and system understanding.
HISTORY
portageq emerged as part of the evolving Portage package management system in Gentoo Linux. Initially, much of the package query functionality was either built into emerge or required parsing directory structures. As Gentoo grew and the need for programmatic access to package information became more critical for scripting and system introspection, portageq was developed to provide a dedicated, stable, and efficient interface for querying the package database. It has continuously been refined to offer more specific and powerful query capabilities, becoming an indispensable tool for Gentoo system administration.