Skip to main content

list_foreign_packages

Function list_foreign_packages 

Source
pub fn list_foreign_packages() -> Result<Vec<(String, String)>, String>
Expand description

What: Run pacman -Qm and parse foreign package names and versions.

Inputs:

  • None (uses host pacman).

Output:

  • Vector of (pkgname, version) or error message. version is the remainder of the line after the package name (typically pkgver-pkgrel from pacman -Qm, but may be empty for name-only lines).

Details:

  • Uses -Qm without -q so each line normally includes pkgver-pkgrel. pacman -Qmq only prints names (see pacman(8) --quiet), which would make overlap detection see zero foreign packages.
  • Returns empty vector when no foreign packages exist.
  • Skips blank lines. Non-blank lines always yield an entry: the first whitespace-separated token is the package name; any further tokens are joined with spaces into version, which is empty when the line contains only a name (no version field to skip—overlap logic still keys on pkgname).

§Errors

  • Returns an error when pacman cannot be executed or exits non-zero.