knowledge/technology/applications/package managers/alpine/apk.md
2024-01-17 09:00:45 +01:00

133 lines
7.2 KiB
Markdown

---
obj: application
---
# APK
APK is a package manager used on [Alpine Linux](../../../linux/Alpine%20Linux.md).
Software packages for [Alpine Linux](../../../linux/Alpine%20Linux.md) are digitally signed [tar.gz](../../cli/compression/tar.md) archives containing programs, configuration files, and dependency metadata. They have the extension `.apk`, and are often called "a-packs".
The packages are stored in one or more repositories. A repository is simply a directory with a collection of `*.apk` files. The directory must include a special index file, named `APKINDEX.tar.gz` to be considered a repository.
The apk utility can install packages from multiple repositories. The list of repositories to check is stored in `/etc/apk/repositories`, one repository per line.
## Usage
### `apk add`
Add packages to WORLD and commit changes
Usage: `apk add [<OPTIONS>...] PACKAGES...`
#### Options
| Option | Description |
| ------------------------ | ----------------------------------------------------------- |
| `-i, --interactive` | Ask confirmation |
| `-p, --root ROOT` | Manage file system at `ROOT` |
| `-U, --update-cache` | Update package cache |
| `-X, --repository REPO` | Specify additional package repository |
| `--allow-untrusted` | Install packages with untrusted signature or no signature |
| `--arch ARCH` | Temporarily override architecture |
| `--no-cache` | Do not use any local cache path |
| `--no-check-certificate` | Do not validate the HTTPS server certificates |
| `-s, --simulate` | Simulate the requested operation without making any changes |
### `apk del`
Remove packages from WORLD and commit changes
#### Options
| Option | Description |
| ----------------------- | ------------------------------------- |
| `-i, --interactive` | Ask confirmation |
| `-p, --root ROOT` | Manage file system at `ROOT` |
| `-X, --repository REPO` | Specify additional package repository |
| `--arch ARCH` | Temporarily override architecture |
### `apk update`
Update repository indexes
### `apk upgrade`
Install upgrades available from repositories
#### Options
| Option | Description |
| ------------------------ | ----------------------------------------------------------- |
| `-i, --interactive` | Ask confirmation |
| `-p, --root ROOT` | Manage file system at `ROOT` |
| `-U, --update-cache` | Update package cache |
| `-X, --repository REPO` | Specify additional package repository |
| `--allow-untrusted` | Install packages with untrusted signature or no signature |
| `--arch ARCH` | Temporarily override architecture |
| `--no-cache` | Do not use any local cache path |
| `--no-check-certificate` | Do not validate the HTTPS server certificates |
| `-s, --simulate` | Simulate the requested operation without making any changes |
### `apk cache`
Manage local package cache by removing obsolete packages, or downloading missing or newer packages from the repositories.
Usage:
```shell
apk cache [<OPTIONS>...] clean
apk cache [<OPTIONS>...] download [DEPENDENCY...]
apk cache [<OPTIONS>...] purge
apk cache [<OPTIONS>...] sync [DEPENDENCY...]
```
### `apk info`
Give detailed information about packages or repositories
#### Options
| Option | Description |
| ------------------- | ----------------------------------------------------------------------------------------- |
| `-a, --all` | List all information known about the package |
| `-d, --description` | Print the package description |
| `-e, --installed` | Check package installed status |
| `-L, --contents` | List files included in the package |
| `-P, --provides` | List what the package provides |
| `-r, --rdepends` | List reverse dependencies of the package (all other packages which depend on the package) |
| `-R, --depends` | List the dependencies of the package |
| `-s, --size` | Print the package's installed size |
| `-w, --webpage` | Print the [URL](../../../internet/URL.md) for the package's upstream webpage |
### `apk list`
List packages matching a pattern or other criteria
Usage: `apk list [<OPTIONS>...] PATTERN...`
#### Options
| Option | Description |
| --------------------------------- | --------------------------------- |
| `-I, --installed` | Consider only installed packages |
| `-O, --orphaned` | Consider only orphaned packages |
| `-a, --available` | Consider only available packages |
| `-u, --upgradable, --upgradeable` | Consider only upgradable packages |
| `-o, --origin` | List packages by origin |
| `-d, --depends` | List packages by dependency |
| `-P, --providers` | List packages by provider |
### `apk search`
Search for packages by name or description
Usage: `apk search [<OPTIONS>...] PATTERN...`
### `apk fetch`
apk fetch downloads the requested packages from the configured package repositories (see repositories) to a local directory. The current working directory is used as the destination directory unless `-o` is specified.
#### Options
| Option | Description |
| ------------------ | ------------------------------------------------------------------- |
| `-l, --link` | Create hard links if possible |
| `-o, --output DIR` | Write the downloaded file(s) to DIR |
| `-R, --recursive` | Fetch packages and all of their dependencies |
| `-s, --stdout` | Dump the .apk file(s) to stdout |
| `-w, --world` | Download packages needed to satisfy WORLD |
| `--simulate` | Simulate the requested operation without making any changes |
| `--url` | Print the full [URL](../../../internet/URL.md) for downloaded packages |
### `apk manifest`
Show checksums of package contents
### `apk verify`
Verify package integrity and signature
### `apk audit`
Audit system for changes
### `apk stats`
Show statistics about repositories and installations