apk - Man Page
Alpine Package Keeper
Examples (TL;DR)
- Update repository indexes from all remote repositories:
apk update
- Install a new package:
apk add package
- Remove a package:
apk del package
- Repair a package or upgrade it without modifying main dependencies:
apk fix package
- Search for a package via keywords:
apk search keywords
- Display information about a specific package:
apk info package
Synopsis
apk [<options>...] command [<arguments>...]
Description
apk manages packages installed on the system. The set of top level packages to install is called the world (see apk-world(5)). apk supports various sub-commands to query and manipulate world and local & remote package repositories.
Commands
Each command is documented in detail on its manual page.
Package Installation and Removal
apk-add(8) | Add packages to world and commit changes |
apk-del(8) | Remove packages from world and commit changes |
System Maintenance
apk-fix(8) | Fix, reinstall or upgrade packages without modifying world |
apk-update(8) | Update repository indexes |
apk-upgrade(8) | Install upgrades available from repositories |
apk-cache(8) | Manage the local package cache |
Querying Package Information
apk-info(8) | Give detailed information about packages or repositories |
apk-list(8) | List packages matching a pattern or other criteria |
apk-dot(8) | Render dependencies as graphviz graphs |
apk-policy(8) | Show repository policy for packages |
apk-search(8) | Search for packages by name or description |
Repository Maintenance
apk-index(8) | Create repository index file from packages |
apk-fetch(8) | Download packages from global repositories to a local directory |
apk-manifest(8) | Show checksums of package contents |
apk-verify(8) | Verify package integrity and signature |
Miscellaneous
apk-audit(8) | Audit system for changes |
apk-stats(8) | Show statistics about repositories and installations |
apk-version(8) | Compare package versions or perform tests on version strings |
Global Options
The following options are available for all commands.
- -f, --force
Enable selected --force-* options (deprecated).
- -i, --interactive
Ask confirmation before performing certain operations.
- -p, --root <ROOT>
Manage file system at ROOT.
- -q, --quiet
Print less information.
- -U, --update-cache
Alias for '--cache-max-age 1'.
- -v, --verbose
Print more information (can be specified twice).
- -V, --version
Print program version and exit.
- -X, --repository <REPO>
Specify additional package repository. This option can be specified multiple times.
- --allow-untrusted
Install packages with untrusted signature or no signature.
- --arch ARCH
Temporarily override architecture, to be combined with --root.
- --cache-dir CACHEDIR
Temporarily override the cache directory. CACHEDIR is treated relative to the ROOT.
- --cache-max-age AGE
Maximum AGE (in minutes) for index in cache before it's refreshed.
- --force-binary-stdout
Continue even if binary data will be printed to the terminal.
- --force-broken-world
Continue even if world cannot be satisfied.
- --force-non-repository
Continue even if packages may be lost on reboot. This can happen when running in run-from-tmpfs mode, and installing non-repository package.
- --force-old-apk
Continue even if packages use unsupported features.
- --force-overwrite
Overwrite files in other packages.
- --force-refresh
Do not use cached files (local or from proxy).
- --keys-dir KEYSDIR
Override directory of trusted keys. This is treated relative to ROOT.
- --no-cache
Do not use any local cache path.
- --no-network
Do not use the network. The cache is still used when possible.
- --no-progress
Disable progress bar even for TTYs.
- --print-arch
Print default arch and exit.
- --progress
Show progress.
- --progress-fd FD
Write progress to the specified file descriptor.
- --purge
Delete modified configuration files on package removal and uninstalled packages from cache on cache clean.
- --repositories-file REPOFILE
Override system repositories, see apk-repositories(8). Specifying this option overrides the normal repositories file and repositories.d directory processing. The given REPOFILE is relative to the startup directory since apk 2.12.0_rc2.
- --wait TIME
Wait for TIME seconds to get an exclusive repository lock before failing.
Commit Options
The following options are available for all commands which commit the database.
- -s, --simulate
Simulate the requested operation without making any changes.
- --clean-protected
Do not create .apk-new files in configuration directories.
- --overlay-from-stdin
Read list of overlay files from stdin. Normally this is used only during initramfs when booting run-from-tmpfs installation.
- --no-scripts
Do not execute any scripts. Useful for extracting a system image for different architecture on alternative ROOT.
- --no-commit-hooks
Skip pre/post hook scripts (but not other scripts).
- --initramfs-diskless-boot
Used by initramfs when it's recreating root tmpfs. This enables selected force options to minimize failure, and disables commit hooks, among other features.
apk-add - Man Page
add packages to world and commit changes
Synopsis
apk add [<options>...] packages...
Description
apk add adds the requested packages to world and installs (or upgrades) them if not already present, ensuring all dependencies are met.
To upgrade individual packages without modifying world use apk-fix(8).
By default apk tries to select a set of packages so that all dependencies are satisfied. This means that some packages can be held back in an older version if there is direct or implicit dependencies to the older version.
Options
apk add supports the commit options described in apk(8), as well as the following options:
- --initdb
Initialize a new package database.
- -l, --latest
Always choose the latest package by version. However, the versions considered are based on the package pinning. Primarily this overrides the default heuristic and will cause an error to displayed if all dependencies cannot be satisfied.
- -u, --upgrade
Upgrade packages and it's dependencies. Normally apk add will avoid changing installed package unless it is required by the newly added packages or their dependencies. This changes the default preference to upgrading the package to the latest installable version.
- -t, --virtual NAME
Create virtual package NAME with given dependencies. This new package will get the packages as dependencies instead of world. Finally the NAME is added to world.
One can use this to ensure that selected set of packages are installed, and later the temporary modification be undone with apk-del(8) NAME without removing packages that were installed earlier.
- --no-chown
Do not change file owner or group. By default apk will manage the file ownership when running as root. However, this option is turned on when running as non-root user, as changing file ownership is not permitted by the system then.
apk-del - Man Page
remove packages from world and commit changes
Synopsis
apk del [<options>...] packages...
Description
apk del removes packages from world and uninstalls them if no longer required by any other packages.
Options
apk del supports the commit options described in apk(8), as well as the following options:
- -r, --rdepends
Recursively delete all top-level reverse dependencies, too.
apk-fix - Man Page
repair packages or system
Synopsis
apk fix [<options>...] [packages...]
Description
apk fix applies repair strategies to correct errors in the installation of the specified packages, or all installed packages if none are specified.
Options
apk fix supports the commit options described in apk(8), as well as the following options:
- -d, --depends
Also fix dependencies of specified packages.
- -r, --reinstall
Reinstall packages (default).
- -u, --upgrade
Upgrade name PACKAGE if an upgrade exists and does not break dependencies.
- -x, --xattr
Fix packages with broken xattrs.
- --directory-permissions
Reset all directory permissions.
apk-update - Man Page
update repository indexes
Synopsis
apk update
Description
apk update forces updating of the indexes from all configured package repositories. This command is not needed in normal operation as all applets requiring indexes will automatically refresh them after caching time expires.
See apk-repositories(5) for more information on configuring package repositories.
Options
apk update does not support any specific options. See apk(8) for global options.
apk-upgrade - Man Page
upgrade installed packages
Synopsis
apk upgrade [<options>...] [<packages>...]
Description
apk upgrade upgrades installed packages to the latest version available from configured package repositories (see apk-repositories(5)). When no packages are specified, all packages are upgraded if possible. If list of packages is provided, only those packages are upgraded along with needed dependencies.
Options
apk upgrade supports the commit options described in apk(8), as well as the following options:
- -a, --available
Reset all packages to versions available from current repositories. This resets all versioned dependencies in world (see apk-world(5)). Additionally, packages are selected from active repositories if possible even if it means replacing or downgrading the package.
This is useful to reset system against new set of packages after updating repositories.
- --ignore
Upgrade all other packages than the ones listed. This inverts the given package name list to mean packages that should not be upgraded.
- -l, --latest
Always choose the latest package by version. However, the versions considered are based on the package pinning. Primarily this overrides the default heuristic and will cause an error to displayed if all dependencies cannot be satisfied.
- --no-self-upgrade
Do not do an early upgrade of the 'apk-tools' package.
- --prune
Prune the world by removing packages which are no longer available from any configured repository.
- --self-upgrade-only
Only perform a self-upgrade of the 'apk-tools' package.
apk-cache - Man Page
manage a local cache of package files
Synopsis
apk cache [<options>...] clean
apk cache [<options>...] download
apk cache [<options>...] sync
Description
Manage local package cache by removing obsolete packages, or downloading missing or newer packages from the repositories.
apk cache download will fetch package files from the repositories and store them in the cache, which must be enabled upfront (see apk-cache(5)).
apk cache clean will remove package files which are no longer necessary, having been made obsolete by new versions or no longer being transitively depended on by packages in world.
apk cache sync performs both operations.
Options
- -l, --latest
Always choose the latest package by version. However, the versions considered are based on the package pinning. Primarily this overrides the default heuristic and will cause an error to displayed if all dependencies cannot be satisfied.
- -u, --upgrade
Upgrade packages and it's dependencies. Normally apk add will avoid changing installed package unless it is required by the newly added packages or their dependencies. This changes the default preference to upgrading the package to the latest installable version.
apk-info - Man Page
print detailed information about packages
Synopsis
apk info [<options>...] packages...
apk info -W file
Description
apk info prints information known about the listed packages. By default, it prints the description, webpage, and installed size of the package (equivalent to apk info -dws).
Each field printed is prefaced by the name of the package and its package version, then the field to be displayed, and a newline. The following lines display the appropriate information, then an empty line terminates that field.
apk info -W file prints the package which owns the specified file.
Options
- -a, --all
List all information known about the package.
- -d, --description
Print the package description.
- -e, --installed
Check package installed status. For each installed package, print it's name. The exit status is the number of given packages not installed. Thus, zero (or success) is returned if all named packages are installed.
- -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 for the package's upstream webpage.
- -W, --who-owns
Print the package which owns the specified file.
- --install-if
List the package's install_if rule. When the dependencies in this list are satisfied, the package will be installed automatically.
- --license
Print the package SPDX license identifier.
- --replaces
List the other packages for which this package is marked as a replacement.
- --rinstall-if
List other packages whose install_if rules refer to this package.
- --triggers
Print active triggers for the package.
apk-list - Man Page
list packages matching a pattern or other criteria
Synopsis
apk list [<options>...] pattern...
Description
apk list searches package indicies for packages matching the given patterns and prints any matching packages.
The patterns are matched with fnmatch(3), which behaves similarly to shell globbing.
Options
- -I, --installed
Consider only installed packages.
- -O, --orphaned
Consider only orphaned packages.
- -a, --available
Consider only available packages.
- -u, --upgradable
Consider only upgradable packages.
- -o, --origin
List packages by origin.
- -d, --depends
List packages by dependency.
- -P, --providers
List packages by provider.
apk-dot - Man Page
generate graphviz graphs
Synopsis
apk dot [<options>...] [pkgmask...]
Description
apk dot renders package dependencies as graphviz graphs.
The graph is generated for the packages matching the masks given, or for every known package if unspecified (this will generate a large and unwieldy graph).
Options
- --errors
Consider only packages with errors. This is useful for visually reporting e.g. cyclic dependencies and missing packages.
- --installed
Consider only installed packages.
apk-policy - Man Page
show repository policy for packages
Synopsis
apk policy [<options>...] packages...
Description
apk policy shows apk's repository policy for the specified packages. It prints matching packages and their versions available from configured repositories (see apk-repositories(5)), in order of installation preference.
Options
apk policy does not support any specific options. See apk(8) for global options.
apk-search - Man Page
search for packages by name or description
Synopsis
apk search [<options>...] pattern...
Description
apk search searches all repositories for packages matching at least one pattern. If no pattern is given, it lists all packages in the repository. A pattern matches if it is a case-sensitive substring of the package name.
Options
In addition to the global options (see apk(8)), apk search supports the following options:
- -a, --all
Print all matching package versions. By default, apk only shows the latest version.
- -d, --description
Also search for pattern in the package description. By default, apk does not search package descriptions.
- -e, -x, --exact
Match package names exactly.
- --has-origin
Match by package origin. Shows all packages whose base package name matches pattern exactly. Implies --all and --exact.
- -o, --origin
Print base package name.
- -r, --rdepends
Print reverse dependencies (other packages which depend on the package).
apk-index - Man Page
create repository index file from packages
Synopsis
apk index [<options>...] packages...
Description
apk index creates a repository index from a list of package files. See apk-repositories(8) for more information on repository indicies.
Generally, the resulting index must be cryptographically signed before apk will accept it. See abuild-sign(1) for details.
Options
- -d, --description TEXT
Add a description to the index. Upstream, this is used to add version information based on the git commit SHA of aports HEAD at the time of index generation.
- -o, --output FILE
Output generated index to FILE.
- -x, --index INDEX
Read an existing index from INDEX to speed up the creation of the new index by reusing data when possible.
- --no-warnings
Disable the warning about missing dependencies. This happens when A, depends on package B, that does not have a provider in the indexed repository.
- --rewrite-arch ARCH
Set all package's architecture to ARCH.
apk-fetch - Man Page
download packages from global repositories to a local directory
Synopsis
apk fetch [<options>...] packages...
Description
apk fetch downloads the requested packages from the configured package repositories (see apk-repositories(5)) to a local directory. The current working directory is used as the destination directory unless -o is specified.
Options
- -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.
Note: this option is incompatible with -o, -R, and the global --progress option.
- --simulate
Simulate the requested operation without making any changes.
Note: this option is unreliable if needed indexes are not up-to-date as this omits refresing or downloading of missing indexes.
apk-manifest - Man Page
Show checksums of package contents
Synopsis
apk manifest [<options>...] packages...
Description
apk manifest prints the checksums of files in the listed packages. One file is printed per line, the checksum first, followed by a space, and then the path to the file.
The checksum itself is printed in the format algorithm:hash. Supported algorithms are:
- md5
- sha1
sha1 is used for new packages.
Options
apk manifest does not support any specific options. See apk(8) for global options.
apk-verify - Man Page
verify package integrity and signature
Synopsis
apk verify [<options>...] files...
Description
apk verify verifies the integrity of the package files specified, validating the checksums and cryptographic signature.
apk verify prints a summary of the results on stdout, and exits with status code zero if all packages were successfully verified. If any failed, apk verify exits with a nonzero status.
Options
apk verify does not support any specific options. See apk(8) for global options.
apk-audit - Man Page
audit directories for changes
Synopsis
apk audit [<options>...] directories...
Description
apk audit audits the system or specified directories for changes compared to the package database.
The audit can be done against configuration files only (--backup) to generate list of files needed to be stored in the overlay in run-from-tmps configuration. Alternatively, it can audit all installed files (--system) to e.g. detect unauthorized modifications of system files.
By default, the output format is one file per line, for each modified file. A character is printed indicating the change detected, followed by a space, then the affected path. The changes detected are:
A | File added |
d | Directory added |
D | Directory added (with non-listed files/subdirs) |
M | File metadata changed (uid, gid, or mode) |
m | Directory metadata changed |
U | File contents modified |
X | File deleted |
x | xattrs changed |
Options
- --backup
Audit configuration files only (default). The list of files to be audited is generated from the masks in protected_paths.d.
- --check-permissions
Check file permissions too. Namely, the uid, gid and file mode will be checked in addition to the file content.
- --packages
Print only the packages with changed files. Instead of the full output each modification, the set of packages with at least one modified file is printed.
To repair all packages with modified files, one could use:
apk audit --packages -q | xargs apk fix
- --system
Audit all system files. All files provided by packages are verified for integrity with the exception of configuration files (listed in protected_paths.d). This is useful detecting unauthorized file changes.
- -r, --recursive
Descend into directories and audit them as well.
apk-stats - Man Page
show statistics about repositories and installations
Synopsis
apk stats
Description
apk stats prints statistics about installed packages, package repositories, and other information.
Options
apk stats does not support any specific options. See apk(8) for global options.
apk-version - Man Page
compare package versions
Synopsis
apk version [<options>...] [packages...]
apk version -c versions...
apk version -t version1 version2
apk version -I
Description
apk version compares the versions of installed packages against package versions available from repositories (see apk-repositories(5)). It can also be used to validate and compare version strings.
In default mode, if no packages are specified, all installed packages are considered. Otherwise, the comparison is limited to the explicitly listed packages. A summary is printed on stdout, with the difference between package versions being represented as >, =, or <.
Options
These options only apply when checking installed package versions against packages available from the repositories (when neither -c, -t, nor -I are specified).
- -a, --all
Consider packages from all repository tags.
- -c, --check versions...
Check versions for validity. If a given version is invalid, it is printed. Exits with status code zero if all versions are valid, and non-zero otherwise.
- -I, --indexes
Print the version and description for each repository's index. See apk-repositories(5) for more information.
- -l, --limit operand
Limit to packages with output matching given operand. The operand can be specified as any combination of >, =, and <.
- -t, --test version1 version2
Compare two version strings. Does not consult the database. Prints one of >, =, or <, if version1 is, respectively, greater than, equal to, or lesser than version2.
src
https://www.mankier.com/8/apk#
https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper
Comments
Post a Comment