an 'apt-cache'-like cli tool, that is designed for batch queries and extracting as much information from apt as possible
  • C++ 97.2%
  • CMake 2.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-30 13:44:18 +04:00
.gear 0.1.0-alt1 2026-06-30 13:44:18 +04:00
src fix: add a check for empty cache 2026-06-30 12:55:27 +04:00
.clang-format init 2026-06-19 18:10:25 +04:00
.gitignore init 2026-06-19 18:10:25 +04:00
CMakeLists.txt 0.1.0-alt1 2026-06-30 13:44:18 +04:00
README.md change: rework all commands 2026-06-30 12:52:52 +04:00

'apt-query' cli tool

This tool allows to list and query all the packages, known to apt, including not installed ones.

Usage:

apt-query [global-options] <command> [command args]

Global options:

  • -0: use \0 instead of \n to separate different groups (package's versions, package's records, etc).
  • --help: show help.

Commands:

list-repos

Prints a list of active repositories, decomposed into raw urls.

Example:

rpm [alt] ftp://mirror.yandex.ru/altlinux/Sisyphus x86_64 classic
	ftp://mirror.yandex.ru/altlinux/Sisyphus/x86_64/RPMS.classic/
	ftp://mirror.yandex.ru/altlinux/Sisyphus/noarch/RPMS.classic/

list-versions <repo_set>

Prints package names, each followed by a list of versions. Respects the --packages filter of the system repo_set.

Format:

  • if -0 is set, versions are delimited by newlines and packages — with a zero-byte.
  • otherwise human-readable format is used: each package on a new line, followed by a space-separated list of versions.

Example:

vlc-plugin-bittorrent 2.16-alt1:sisyphus+414646.100.1.1@1775695751
gst-plugins-bad1.0-debuginfo 1.28.4-alt1:sisyphus+421340.400.1.2@1781373661

repos-inspect <packages|provides> <repo_set>

Prints a list of strings for the desired <repo_set>, depending on <what_to_inspect>:

  • packages — real package names (packages with versions).
  • provides — virtual package names.

repos-conflicts <packages|provides> -a <repo_set> -b <repo_set>

Checks if any of the strings produced by <what_to_inspect> getter for repo set A are also present in repo set B. Prints the intersected entries.

packages-info [--entries=key1,key2,...] <repo_set> -p <package list>

Prints all available information about the requested package versions.

Supports both versioned and versionless form, e.g.: package or package=version. NOTE: versioned form only accepts full package version, as returned from list-versions command: <version>-<release>[:dist_tag]<@timestamp>.

If version is not specified, the following priority applies:

  1. local version, if package is actually installed
  2. "candidate" - selected by apt (usually, with the highest timestamp) as if apt-get install was executed

If --entries is defined, output is restricted to the specified keys (a comma-separated list). Otherwise all available keys are printed.

Package information consists of a set of key-value pairs, each from new line. If value is a multiline string (e.g. LongDesc, Changelog), C-style escaping is applied.

If -0 is set, each version will be delimited with a zero-byte, otherwise — with an extra new line.

The following data is currently returned:

  • Name - package name
  • VerStr - full package version string, provided manually, or selected automatically.
  • RelStr - repository release file information. For 3rd-party repositories may be empty or "Unknown".
  • Filename - package file name, relative to its repository, e.g. RPMS.classic/alt-packages-0.4.0-alt1.x86_64.rpm
  • Installed - is installed, "True" or "False"
  • Downloadable - is available, "True" or "False"
  • Candidate - is a "candidate" (apt's install selection), "True" or "False"
  • Automatic - True if this version is selectable for automatic installation (any of the versions files are not NotAutomatic).
  • PriorityType - priority type from pkgpriorities
  • ShortDesc - short description
  • LongDesc - long description
  • SourcePkg - source package name
  • Arch - target architecture, or noarch
  • Section - rpm "Group"
  • Maintainer - name and email of package maintainer
  • Repo - repository URI, this package version belongs to, with "section" dir appended, e.g. rsync://mirror.yandex.ru/altlinux/Sisyphus/x86_64/RPMS.debuginfo, file:///home/user/.hasher/repo/x86_64/RPMS.hasher/. NOTE: When installed package version is outdated, or the original repository was removed from sources.list - it is empty.
  • Size - size of downloaded package
  • InstallSize - size of installed package
  • Changelog - full changelog. NOTE: may be empty, for an example git.altlinux.org task repos.
  • Provides, Depends, Obsoletes, ... - a list of package dependencies. Each entry contains one package name, so there may be multiple entries of the same key. Virtual package names placed in angles. Each name may also contain a version, e.g.:
Provides: alt-packages = 0.4.0-alt1:sisyphus+409454.2050.28.1 
Provides: <alterator-application-packages> = 0.4.0-alt1  
Depends: alterator-entry >= 0.4.13-alt1
...
Obsoletes: <alterator-application-packages> < 0.3.3

repo_set

A set of repositories to work with. Supported forms:

system

Use active sources.list entries via local apt cache.

Options:

  • --missing=<exit|get|skip> — what to do if a repository is missing indexes (apt-get update was not performed yet):
    • skip — ignore missing indexes (default).
    • get — prepare a temporary cache for them, like for remote ones (never affects the system cache).
    • exit — expect all indexes to be present; exit with error if not.
  • --packages=<all|local|remote> — what packages to take into account:
    • remote — any packages available in remote repos (default).
    • local — only packages that are installed (no matter if remote version exists or not).
    • all — both local and remote packages.

<entry_list>

A space-separated list of sources.list entries and/or raw urls.

Options:

  • --with-local — prefer local indexes so no unnecessary temp cache updates are performed. Also allows specifying raw urls (otherwise raw urls are rejected).