Apero.Pkg (Apero v1.0.0)

Copy Markdown View Source

Cross-platform package manager abstraction.

Detects the available system package manager and provides a consistent interface for installing, updating, querying, searching, removing, and getting info about packages.

Supported managers: apt, apt-get, dnf, yum, pacman, brew, apk, zypper, choco (Chocolatey), winget, pkg (FreeBSD), emerge (Gentoo).

Summary

Functions

Detects the first available package manager on the system.

Gets detailed info about an installed package.

Installs a package using the detected package manager. Runs non-interactively.

Returns true if the package is installed.

Removes/uninstalls a package.

Searches for a package by name or keyword.

Updates the package index/cache.

Types

package_manager()

@type package_manager() ::
  :apt
  | :apt_get
  | :dnf
  | :yum
  | :pacman
  | :brew
  | :apk
  | :zypper
  | :choco
  | :winget
  | :pkg
  | :emerge
  | :unknown

Functions

detect()

@spec detect() :: package_manager()

Detects the first available package manager on the system.

info(package, opts \\ [])

@spec info(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Gets detailed info about an installed package.

Options

  • :manager — override detected package manager

install(package, opts \\ [])

@spec install(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Installs a package using the detected package manager. Runs non-interactively.

Options

  • :manager — override detected package manager

installed?(package, opts \\ [])

@spec installed?(
  binary(),
  keyword()
) :: boolean()

Returns true if the package is installed.

remove(package, opts \\ [])

@spec remove(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Removes/uninstalls a package.

Options

  • :manager — override detected package manager
  • :purge — remove config files too (apt only)

search(query, opts \\ [])

@spec search(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Searches for a package by name or keyword.

Options

  • :manager — override detected package manager
  • :exact — exact name match (apt-cache show vs apt-cache search)

update(opts \\ [])

@spec update(keyword()) :: {:ok, binary()} | {:error, binary()}

Updates the package index/cache.