https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Alfred-landrum&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T14:59:22ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&diff=12930Alpine Package Keeper2016-09-01T14:47:42Z<p>Alfred-landrum: Fixed some preposition and article usage, and removed a few extraneous spaces.</p>
<hr />
<div><!--For searching: apk, APK--><br />
<br />
Because Alpine Linux is designed to run from RAM, package management involves two phases:<br />
* Installing / Upgrading / Deleting packages on a running system.<br />
* Restoring a system to a previously configured state (e.g. after reboot), including all previously installed packages and locally modified configuration files. '''(RAM-Based Installs Only)'''<br />
<br /><br />
'''apk''' is the tool used to install, upgrade, or delete software on a running sytem.<br /><br />
'''lbu''' is the tool used to capture the data necessary to restore a system to a previously configured state.<br />
<br />
This page documents the [http://git.alpinelinux.org/cgit/apk-tools.git apk tool] - See the [[Alpine_local_backup|Alpine Local Backup page]] for the lbu tool.<br />
<br />
= Overview =<br />
<br />
The '''apk''' tool has the following applets:<br />
<br />
{|<br />
| [[#Add a Package|add]] <br />
| Add new packages to the running system<br />
|-<br />
| [[#Remove a Package|del]]<br />
| Delete packages from the running system<br />
|-<br />
| fix <br />
| Attempt to repair or upgrade an installed package <br />
|-<br />
| [[#Update the Package list|update]] <br />
| Update the index of available packages<br />
|-<br />
| [[#Info on Packages|info]]<br />
| Prints information about installed or available packages<br />
|-<br />
| [[#Search for Packages|search]] <br />
| Search for packages or descriptions with wildcard patterns<br />
|-<br />
| [[#Upgrade a Running System|upgrade]]<br />
| Upgrade the currently installed packages<br />
|-<br />
| [[#Cache Maintenance|cache]]<br />
| Maintenance operations for locally cached package repository<br />
|-<br />
| version <br />
| Compare version differences between installed and available packages<br />
|-<br />
| index <br />
| create a repository index from a list of packages<br />
|-<br />
| fetch <br />
| download (but not install) packages<br />
|-<br />
| audit <br />
| List changes to the file system from pristine package install state<br />
|-<br />
| verify <br />
| Verify a package signature<br />
|}<br />
<br />
= Packages and Repositories =<br />
<br />
Software packages for Alpine Linux are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. They have the extension <code>.apk</code>, and are often called "a-packs".<br />
<br />
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 {{Path|APKINDEX.tar.gz}} to be considered a repository.<br />
<br />
The '''apk''' utility can install packages from multiple repositories. The list of repositories to check is stored in {{Path|/etc/apk/repositories}}, one repository per line. If you booted from a USB stick ({{Path|/media/sda1}}) or CD-ROM ({{Path|/media/cdrom}}), your repository file probably looks something like this:<br />
<br />
{{Cat|/etc/apk/repositories|/media/sda1/apks/}}<br />
<br />
In addition to local repositories, the '''apk''' utility uses '''busybox wget''' to fetch packages using ''http:'', ''https:'' or ''ftp:'' protocols. The following is a valid repository file:<br />
<br />
{{Cat|/etc/apk/repositories|<br />
/media/sda1/apks<br />
http://dl-3.alpinelinux.org/alpine/v2.6/main<br />
https://dl-3.alpinelinux.org/alpine/v2.6/main<br />
ftp://dl-3.alpinelinux.org/alpine/v2.6/main<br />
}}<br />
<br />
{{Note|Currently there are no public https or ftp repositories. The protocols are available for local repositories.}}<br />
<br />
== Repository pinning ==<br />
<br />
You can specify additional "tagged" repositories in {{Path|/etc/apk/repositories}}:<br />
<br />
{{Cat|/etc/apk/repositories|<br />
http://nl.alpinelinux.org/alpine/v2.6/main<br />
@edge http://nl.alpinelinux.org/alpine/edge/main<br />
@testing http://nl.alpinelinux.org/alpine/edge/testing<br />
}}<br />
<br />
After which you can "pin" dependencies to these tags using:<br />
<br />
{{cmd|apk add stableapp newapp@edge bleedingapp@testing}}<br />
<br />
Apk will now by default only use the untagged repositories, but adding a tag to specific package:<br />
<br />
1. will prefer the repository with that tag for the named package, even if a later version of the package is available in another repository<br />
<br />
2. ''allows'' pulling in dependencies for the tagged package from the tagged repository (though it ''prefers'' to use untagged repositories to satisfy dependencies if possible)<br />
<br />
= Update the Package list =<br />
<br />
Remote repositories change as packages are added and upgraded. To get the latest list of available packages, use the ''update'' command. The command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}.<br />
<br />
{{Cmd|apk update}}<br />
<br />
<!--<br />
fetch http://dl-3.alpinelinux.org/alpine/v2.1/main/APKINDEX.tar.gz<br />
--><br />
<br />
{{Tip|If using remote repositories, it is a good idea to do an '''update''' just before doing an '''add''' or '''upgrade''' command. That way you know you are using the latest software available.}}<br />
<br />
= Add a Package =<br />
<br />
Use '''add''' to install packages from a repository. Any necessary dependencies are also installed. If you have multiple repositories, the '''add''' command installs the newest package.<br />
<br />
{{Cmd|apk add openssh<br />
apk add openssh openntp vim}}<br />
<br />
If you only have the main repository enabled in your configuration, apk will not include packages from the other repositories. To install a package from the edge/testing repository without changing your repository configuration file, use the command below. This will tell apk to use that particular repository.<br />
<br />
{{cmd|apk add cherokee --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}<br />
<br />
{{Note|Be careful when using third-party or the testing repository. Your system can go down.}}<br />
<br />
= Remove a Package =<br />
Use '''del''' to remove a package (and dependencies that are no longer needed.) <br />
<br />
{{cmd|apk del openssh<br />
apk del openssh openntp vim}}<br />
<br />
= Upgrade a Running System =<br />
<br />
To upgrade ''all'' the packages of a running system, use '''upgrade''':<br />
<br />
{{cmd|apk update<br />
apk upgrade<br />
}}<br />
<br />
To upgrade ''only a few'' packages, use the '''add''' command with the ''-u'' or ''--upgrade'' option:<br />
<br />
{{cmd|apk update<br />
apk add --upgrade busybox <br />
}}<br />
<br />
{{Note|Remember that when you reboot your machine, the remote repository will not be available until after networking is started. This means packages newer than your local boot media will likely not be installed after a reboot. To make an "upgrade" persist over a reboot, use a [[#Local Cache|local cache]].}}<br />
<br />
= Search for Packages =<br />
The '''search''' command searches the repository Index files for installable packages. <br />
<br />
Examples:<br />
* To list all packages available, along with their descriptions: {{cmd|apk search -v}}<br />
* To list all packages are part of the ACF system: {{cmd|apk search -v 'acf*' }}<br />
* To list all packages that list NTP as part of their description, use the ''-d'' or ''--description'' option: {{cmd|apk search -v --description 'NTP' }}<br />
<br />
= Info on Packages =<br />
<br />
The '''info''' command provides information on the contents of packages, their dependencies, and which files belong to a package.<br />
<br />
For a given package, each element can be chosen (for example, ''-w'' to show just the webpage information), or all information displayed with the ''-a'' command.<br />
<br />
Example: {{cmd|apk info -a zlib}}<br />
<br />
'''zlib-1.2.5-r1 description:'''<br />
A compression/decompression Library<br />
<br />
'''zlib-1.2.5-r1 webpage:'''<br />
<nowiki>http://zlib.net</nowiki><br />
<br />
'''zlib-1.2.5-r1 installed size:'''<br />
94208<br />
<br />
'''zlib-1.2.5-r1 depends on:'''<br />
libc0.9.32<br />
<br />
'''zlib-1.2.5-r1 is required by:'''<br />
libcrypto1.0-1.0.0-r0<br />
apk-tools-2.0.2-r4<br />
openssh-client-5.4_p1-r2<br />
openssh-5.4_p1-r2<br />
libssl1.0-1.0.0-r0<br />
freeswitch-1.0.6-r6<br />
atop-1.25-r0 <br />
<br />
'''zlib-1.2.5-r1 contains:'''<br />
lib/libz.so.1.2.5<br />
lib/libz.so.1<br />
lib/libz.so <br />
<br />
'''zlib-1.2.5-r1 triggers:'''<br />
<br />
As shown in the example you can determine<br />
* The '''description''' of the package (''-d'' or ''--description'')<br />
* The '''webpage''' where the application is hosted (''-w'' or ''--webpage'')<br />
* The '''size''' the package will require once installed (in bytes) (''-s'' or ''--size'')<br />
* What packages are required to use this one ('''depends''') (''-R'' or ''--depends'')<br />
* What packages require this one to be installed ('''required by''') (''-r'' or ''--rdepends'')<br />
* The '''contents''' of the package, that is, which files it installs (''-L'' or ''--contents'')<br />
* Any '''triggers''' this package sets. (''-t'' or ''--triggers'') Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.<br />
<br />
{{Tip|The '''info''' command is also useful to determine which package a file belongs to. For example: {{cmd|apk info --who-owns /sbin/lbu}} will display<br />
<br />
/sbin/lbu is owned by alpine-conf-x.x-rx<br />
}}<br />
<br />
== Listing installed packages ==<br />
<br />
To list all installed packages, use:<br />
<br />
<pre>apk info</pre><br />
<br />
To list all installed packages in alphabetical order, with a description of each, do:<br />
<br />
<pre>apk -vv info|sort</pre><br />
<br />
= Additional apk Commands =<br />
In progress...<br />
<br />
= Local Cache =<br />
<br />
{{:Local_APK_cache}}<br />
<br />
= Advanced APK Usage =<br />
<br />
== Holding a specific package back ==<br />
<br />
In certain cases, you may want to upgrade a system, but keep a specific package at a back level. It is possible to add "sticky" or versioned dependencies. For instance, to hold the ''asterisk'' package to the 1.6.2 level or lower:<br />
{{cmd|1=apk add asterisk=1.6.0.21-r0}}<br />
or<br />
{{cmd|apk add 'asterisk<1.6.1'}}<br />
<br />
after which a {{cmd|apk upgrade}}<br />
<br />
will upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level<br />
<br />
To later upgrade to the current version,<br />
<br />
{{cmd|apk add 'asterisk>1.6.1'}}<br />
<br />
[[Category:Package Manager]]</div>Alfred-landrum