Skip to content

Package Management

Operations for managing packages on Debian/Ubuntu (APT), Fedora/RHEL (DNF), and RPM GPG key management.

import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/linux/pkg/apt';

Lists all installed packages using dpkg-query.

const packages = await getInstalledPackages();
// [{ name: 'bash' }, { name: 'curl' }, ...]

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'] });

Removes packages using apt-get remove. Preserves configuration files.

await removePackages({ packages: ['apache2'] });
import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/linux/pkg/dnf';

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' }, ...]

Installs packages using dnf install. Supports weakDependencies option.

await installPackages({ packages: ['nginx'], weakDependencies: false });

Removes packages using dnf remove.

await removePackages({ packages: ['httpd'] });
import { getRpmVars, getRpmKeys, hasRpmKey, importRpmKey } from '@sysopkit/linux/pkg/rpm';

Evaluates RPM macro variables.

const [arch, os] = await getRpmVars(['%_arch', '%_os']);
// ['x86_64', 'linux']

Lists all GPG keys installed in the RPM database.

Checks if a specific GPG key is already imported into the RPM database.

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...',
});