LinuxCommandLibrary

expac

Query and extract package information from pacman

TLDR

List the dependencies of a package

$ expac [[-S|--sync]] '%D' [package]
copy

List the optional dependencies of a package
$ expac [[-S|--sync]] "%o" [package]
copy

List the download size of packages in MiB
$ expac [[-S|--sync]] [[-H|--humansize]] M '%k\t%n' [package1 package2 ...]
copy

List packages marked for upgrade with their download size
$ expac [[-S|--sync]] [[-H|--humansize]] M '%k\t%n' $(pacman -Qqu) | sort [[-sh|--sort --human-numeric-sort]]
copy

List explicitly-installed packages with their optional dependencies
$ expac [[-d|--delim]] '\n\n' [[-l|listdelim]] '\n\t' [[-Q|--query]] '%n\n\t%O' $(pacman -Qeq)
copy

SYNOPSIS

expac [options]

PARAMETERS

-h, --help
    Display help message and exit.

-v, --version
    Display version information and exit.

-q, --query
    Query packages matching the given pattern.

-s, --source
    Query source packages only.

-i, --info
    Show information about the packages (same as default format '%{NAME}\n').

-l, --list
    List files contained in the packages.

-F, --file
    Read package names from file. One package name per line.

-x, --exclude
    Exclude packages matching .

-w, --whatprovides
    Query what package provides .

-W, --whatever
    Query what package provides specified field.

--rpmdb
    Specify an alternate RPM database location.

--root
    Specify an alternate root directory.

--nvr
    Print Name-Version-Release string.

--nvra
    Print Name-Version-Release-Architecture string.

--regexp
    Treat package names as regular expressions.

--quiet
    Suppress error messages.

-f, --format
    Specify the output format using a format string with RPM tags (e.g., '%{NAME}\n').

--unsorted
    Do not sort the results.

DESCRIPTION

expac allows users to query the RPM database, providing information about installed packages. It's particularly useful for scripting and automation due to its customizable output formatting. Unlike `rpm -q`, `expac` directly accesses the RPM database files, making it potentially faster. It excels at extracting specific package metadata fields and presenting them in a user-defined format. This command leverages the RPM libraries for efficient data retrieval. Common use cases include generating lists of installed packages with specific properties, auditing package configurations, and creating reports on package dependencies. It provides a wide array of formatting options allowing precise control over how the information is presented. expac focuses on extracting and formatting package metadata, offering powerful filtering capabilities.

CAVEATS

Understanding RPM tag names is crucial for effective use of the `-f` option. Incorrect tag names will result in empty output or errors. Performance can be affected when querying large databases. The output format is highly dependent on the format string provided by the user.
Using wildcards without the `--regexp` flag might not behave as expected.
Requires read access to the RPM database.

FORMAT STRINGS

Format strings utilize RPM tags enclosed in '%{}' to specify which package attributes should be included in the output. For example, '%{NAME}' retrieves the package name, '%{VERSION}' the version, and '%{RELEASE}' the release. Multiple tags can be combined in a single format string separated by delimiters.
Example: `expac -f '%{NAME} - %{VERSION}-%{RELEASE}\n' package_name`

EXAMPLES

List package names: expac -f '%{NAME}\n'
List package names and versions: expac -f '%{NAME}-%{VERSION}\n'
List files in a package: expac -l package_name
Find what provides a specific capability: expac -w 'libc.so.6'

HISTORY

expac was created to address the limitations of `rpm -q` in terms of output formatting and scripting capabilities. It aimed to provide a faster and more flexible tool for querying the RPM database. expac has evolved over time to include more features, such as regular expression support and the ability to specify an alternate RPM database location.

SEE ALSO

rpm(8), rpmquery(8)

Copied to clipboard