02 Package management - sylirre/vmConsole Wiki

Overview

Alpine Linux uses apk utility as a package manager. It is very simple to use:

  • apk add package_name

    Install specified package. Requires execution as root.

  • apk del package_name

    Uninstall specified package. Requires execution as root.

  • apk search query

    Search for packages with specified query. Query could be a wildcard pattern or a key word matching the package name or its description.

  • apk upgrade

    Upgrade all packages. Requires execution as root.

As this distribution intends to be lightweight, it does excessive splitting of software on multiple packages, even more than done by Debian. Usually you will find packages having these name suffixes:

  • -dev: development-related part of library packages, usually contain C/C++ header files.
  • -doc: documentation part of packages, typically manual pages.
  • -lang: localization for packages.
  • -static: static libraries and sometimes statically-linked binaries.
  • -progs, -tools or -utils: less common, usually these packages contain utilities or demos that come with library packages.

Not every package has splits. Be prepared that some packages even do not have documentation.

Repository configuration

File /etc/apk/repositories is responsible for providing a list of active repositories to the package manager. Each repository is defined either through local directory path (local repository, e.g. in CD-ROM) or HTTP(S) URL.

Default configuration:

/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
#http://dl-cdn.alpinelinux.org/alpine/edge/testing

Symbol # (hash) indicates the beginning of comment. Such lines are ignored. If line starts with @ immediately followed by keyword, then repository will be pinned (tagged). Example of pinned testing repository:

@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing

apk will not use pinned repositories by default. Instead, you need to manually specify whether package version must be picked from it. For example:

apk add [email protected]

Offline cache

Offline cache lets you to store installation files of downloaded packages for later use, e.g. reinstallation or downgrading. By default offline cache is disabled to avoid wasting disk space.

You can enable it by running the next command (as root):

setup-apkcache

A prompt will appear with default value /var/cache/apk which is sufficient for on-disk Alpine installations. If using diskless installation variant, a path of directory on persistent storage mount point should be provided there.

Cache can be populated by running command apk cache download as root.

Installing man pages

By default neither utility man nor even a single manual page are available. If you need the man pages, install them manually for specific packages. There is no way to tell package manager to install them automatically.

Install mandoc (using man-db is not recommended in vmConsole) and look for packages suffixed by -doc.

Example of installing coreutils package with documentation:

apk add coreutils coreutils-doc