Alpine Package Keeper: Difference between revisions

From Alpine Linux
No edit summary
Line 13: Line 13:
The '''apk''' tool has the following applets:
The '''apk''' tool has the following applets:


*add - Add new packages to the running system
{|
*del - Delete packages from the running system
| add  
*fix - Attempt to repair or upgrade an installed package  
| Add new packages to the running system
*update - Update the index of available packages
|-
*info - Prints information about installed or available packages
| del
*search - Search for packages or descriptions with wildcard patterns
| Delete packages from the running system
*upgrade - Upgrade the currently installed packages
|-
*cache - Maintenance operations for locally cached package repository
| fix  
*version - Compare version differences between installed and available packages
| Attempt to repair or upgrade an installed package  
*index - create a repository index from a list of packages
|-
*fetch - download (but not install) packages
| update  
*audit - List changes to the file system from pristine package install state
| Update the index of available packages
*verify - Verify a package signature
|-
| info  
| Prints information about installed or available packages
|-
| search  
| Search for packages or descriptions with wildcard patterns
|-
| upgrade  
| Upgrade the currently installed packages
|-
| cache  
| Maintenance operations for locally cached package repository
|-
| version  
| Compare version differences between installed and available packages
|-
| index  
| create a repository index from a list of packages
|-
| fetch  
| download (but not install) packages
|-
| audit  
| List changes to the file system from pristine package install state
|-
| verify  
| Verify a package signature
|}


== Quickstart Guide ==
== Quickstart Guide ==
Line 36: Line 63:


The '''apk''' utility can install packages from multiple repositories.  The list of repositories to check is stored in <tt>/etc/apk/repositories</tt>, one repository per line. If you booted from USB stick (<tt>/media/sda1</tt>) or CD-ROM (<tt>/media/cdrom</tt>), your repository file probably looks like this:
The '''apk''' utility can install packages from multiple repositories.  The list of repositories to check is stored in <tt>/etc/apk/repositories</tt>, one repository per line. If you booted from USB stick (<tt>/media/sda1</tt>) or CD-ROM (<tt>/media/cdrom</tt>), your repository file probably looks like this:
<pre>
<pre>
/media/sda1/apks/
/media/sda1/apks/
Line 41: Line 69:


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:
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:
<pre>
<pre>
/media/sda1/apks
/media/sda1/apks
Line 50: Line 79:
{{note|Currently there are no public https or ftp repositories.  The protocols are available for local repositories}}
{{note|Currently there are no public https or ftp repositories.  The protocols are available for local repositories}}


=== Update the Package list - apk update ===
=== Update the Package list ===


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 APKINDEX.tar.gz from each repository and stores it in the local cache, typically <tt>/var/lib/apk</tt> or <tt>/etc/apk/cache</tt>.
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 APKINDEX.tar.gz from each repository and stores it in the local cache, typically <tt>/var/lib/apk</tt> or <tt>/etc/apk/cache</tt>.


Example:
{{Cmd|apk update}}
 
'''apk update'''
<pre>
<pre>
fetch http://dl-3.alpinelinux.org/alpine/v1.10/packages/main/APKINDEX.tar.gz
fetch http://dl-3.alpinelinux.org/alpine/v1.10/packages/main/APKINDEX.tar.gz
Line 67: Line 94:
{{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}}
{{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}}


=== Add a Package - apk add ===
=== Add a Package ===


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.
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.


Examples:
{{cmd|apk add openssh
apk add openssh openntp vim}}


'''apk add openssh'''
=== Remove a Package  ===
'''apk add openssh openntp vim'''


Use '''del''' to remove a package (and dependencies that are no longer needed.) 


=== Remove a Package -- apk del ===
{{cmd|apk del openssh
apk del openssh openntp vim}}


Use the '''del''' command to remove a package (and dependencies that are no longer needed.) 


=== Upgrade a Running System ===


'''apk del openssh'''
To upgrade ''all'' the packages of a running system, use '''upgrade'''
'''apk del openssh openntp vim'''


{{cmd|apk update
apk upgrade
}}


= Anything below this marker is old =
To upgrade only a few packages, use the '''add''' command with the ''-u'' parameter:


Removing packages is done using:
{{cmd|apk update
% apk_delete openssh
apk add -u busybox
}}


To remove a package plus it's dependencies, use:
{{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]].}}
% apk_delete -R openssh


Even more dangerous is:
=== Search for Packages ===
% apk_delete -r openssl
which will delete openssl plus all packages that depend on it.


Since removing packages (recursively) can seriously damage your system, it is best to use:
The '''search''' command searches the repository Index files for installable packages.  
% apk_delete -n openssh
Which will not really remove the package, but just show what it would do.


== Looking for packages? ==
Examples:
 
* To list all packages available, along with their descriptions: {{cmd|apk search -v}}
To see the packages available in the repository, use:
* To list all packages are part of the ACF system: {{cmd|apk search -v 'acf*' }}
% apk_fetch -l
* To list all packages that list NTP as part of their description: {{cmd|apk search -v -d 'NTP' }}
 
Or you might use:
  % apk_fetch -l -v
Which will also show the version number of the available packages.
 
If the text scrolls by too fast you can use:
% apk_fetch -l | less
 
== Info about your packages ==
 
There are several other commands that give more information about the packages installed on your system.
 
To see the contents of a certain package, use:
% apk_info -L openssh
 
To see the size of a package, use:
% apk_info -s openssh
 
To see all packages that depend on a package, eg zlib:
% apk_glob -r zlib
 
To find out to what package a certain file or directory belongs to, eg /etc/shorewall:
% apk_info -W /etc/shorewall
 
== Upgrading alpine ==
 
The easiest way to upgrade alpine is to safe your settings to floppy or usb-key and reboot using a new CD. But there are several other possibilities a well:
* Change the CD, but do not reboot
* Update over network
 
=== Changing the CD, no reboot ===
 
First update the package list:
% apk_fetch -u
 
Check what packages have changed version numbers
% apk_version -v
 
Next:
% apk_version -v -l '<'
Will show you what packages needs to be updated
 
The first thing to check is whether the apk-tools need to be upgraded, if so, '''always''' do this first:
% apk_add -u apk-tools
 
Now it is time to upgrade the other packages:
% apk_version -q -l '<' | xargs apk_add -u


After your upgrade you might find some apk-new files in /etc,these are upgraded config files. A simple utility to go over these files is:
%  update-conf -l


=== Update over network ===
== Additional apk Commands ==


This is about the same as the previous entry. The key-difference is that we will change the install-source for apk. This can be done in two ways, on the command-line, using ''export'' or changing an /etc file:


% export APK_PATH=http://dev.alpinelinux.org/alpine/v1.4/apks/
In progress...


or edit apk.conf, and add your requested resource.
% vi /etc/apk.conf


You can use sources from:
== Local Cache ==
* cdrom
* http(s)
* ftp
* rsync (remember that rsync has to be installed before you can use this! (''% apk_add rsync''))


After you made this change, continue as the cd-rom upgrade with, etc
Cache info will go here.
% apk_fetch -u

Revision as of 01:26, 30 April 2010

Alpine Linux Package Management

Because Alpine Linux is designed to run from RAM, package management involves two phases:

  • Installing / Upgrading / Deleting packages on a running system
  • Restoring a system to a previously configured state (e.g. after reboot), including all previously installed packages and locally modified configuration files.

apk is the tool used to install, upgrade, or delete software on a running sytem lbu is the tool used to capture the data necessary to restore a system to a previously configured state.

This page documents the apk tool - See the Alpine Local Backup page for the lbu tool.


The apk tool has the following applets:

add Add new packages to the running system
del Delete packages from the running system
fix Attempt to repair or upgrade an installed package
update Update the index of available packages
info Prints information about installed or available packages
search Search for packages or descriptions with wildcard patterns
upgrade Upgrade the currently installed packages
cache Maintenance operations for locally cached package repository
version Compare version differences between installed and available packages
index create a repository index from a list of packages
fetch download (but not install) packages
audit List changes to the file system from pristine package install state
verify Verify a package signature

Quickstart Guide

Packages and Repositories

Software packages for Alpine Linux are digitally signed tar.gz archives containing the 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. If you booted from USB stick (/media/sda1) or CD-ROM (/media/cdrom), your repository file probably looks like this:

/media/sda1/apks/

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:

/media/sda1/apks
http://dl-3.alpinelinux.org/alpine/v1.10/packages/main
https://dl-3.alpinelinux.org/alpine/v1.10/packages/extra
ftp://ftp.alpinelinux.org/edge/packages/main
Note: Currently there are no public https or ftp repositories. The protocols are available for local repositories

Update the Package list

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 APKINDEX.tar.gz from each repository and stores it in the local cache, typically /var/lib/apk or /etc/apk/cache.

apk update

fetch http://dl-3.alpinelinux.org/alpine/v1.10/packages/main/APKINDEX.tar.gz
fetch http://dl-3.alpinelinux.org/alpine/v1.10/packages/testing/APKINDEX.tar.gz
alpine 1.10.1 [/media/sda1/apks]
main v1.10.1-34-g977ff46 [http://dl-3.alpinelinux.org/alpine/v1.10/packages/main]
testing v1.10.0-32-gbf6b6cb [http://dl-3.alpinelinux.org/alpine/v1.10/packages/testing]
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

Add a Package

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.

apk add openssh apk add openssh openntp vim

Remove a Package

Use del to remove a package (and dependencies that are no longer needed.)

apk del openssh apk del openssh openntp vim


Upgrade a Running System

To upgrade all the packages of a running system, use upgrade

apk update apk upgrade

To upgrade only a few packages, use the add command with the -u parameter:

apk update apk add -u busybox

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.

Search for Packages

The search command searches the repository Index files for installable packages.

Examples:

  • To list all packages available, along with their descriptions:

    apk search -v

  • To list all packages are part of the ACF system:

    apk search -v 'acf*'

  • To list all packages that list NTP as part of their description:

    apk search -v -d 'NTP'


Additional apk Commands

In progress...


Local Cache

Cache info will go here.