Package Management
Operations for managing packages on Debian/Ubuntu (APT), Fedora/RHEL (DNF), and RPM GPG key management.
APT (Debian/Ubuntu)
Section titled “APT (Debian/Ubuntu)”import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/linux/pkg/apt';getInstalledPackages()
Section titled “getInstalledPackages()”Lists all installed packages using dpkg-query.
const packages = await getInstalledPackages();// [{ name: 'bash' }, { name: 'curl' }, ...]installPackages()
Section titled “installPackages()”Installs packages using apt-get install. Emits change events for newly installed packages. Dry-run aware (-s flag in dry-run mode).
await installPackages({ packages: ['nginx', 'postgresql'] });removePackages()
Section titled “removePackages()”Removes packages using apt-get remove. Preserves configuration files.
await removePackages({ packages: ['apache2'] });DNF (Fedora/RHEL)
Section titled “DNF (Fedora/RHEL)”import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/linux/pkg/dnf';getInstalledPackages()
Section titled “getInstalledPackages()”Lists all installed packages with detailed metadata using dnf repoquery --installed.
const packages = await getInstalledPackages();// [{ name: 'bash', epoch: '0', version: '5.2', release: '1.fc40', arch: 'x86_64' }, ...]installPackages()
Section titled “installPackages()”Installs packages using dnf install. Supports weakDependencies option.
await installPackages({ packages: ['nginx'], weakDependencies: false });removePackages()
Section titled “removePackages()”Removes packages using dnf remove.
await removePackages({ packages: ['httpd'] });import { getRpmVars, getRpmKeys, hasRpmKey, importRpmKey } from '@sysopkit/linux/pkg/rpm';getRpmVars()
Section titled “getRpmVars()”Evaluates RPM macro variables.
const [arch, os] = await getRpmVars(['%_arch', '%_os']);// ['x86_64', 'linux']getRpmKeys()
Section titled “getRpmKeys()”Lists all GPG keys installed in the RPM database.
hasRpmKey()
Section titled “hasRpmKey()”Checks if a specific GPG key is already imported into the RPM database.
importRpmKey()
Section titled “importRpmKey()”Imports a GPG key into the RPM database. Writes the key to /etc/pki/rpm-gpg/ before importing. Idempotent — skips if the key is already installed.
await importRpmKey({ name: 'docker', content: '-----BEGIN PGP PUBLIC KEY BLOCK-----\n...',});