|
|
<?xml version="1.0" encoding="utf-8"?>
<chapter label="3" id="packages">
<title>Package Management</title>
<highlights><para>In this chapter, we will discuss package management in the Adélie Linux operating environment, including the APK package manager.</para></highlights>
<section id="introduction3">
<title>Introduction</title>
<para>We'll start off by learning what a package is, and about the package manager used by Adélie Linux.</para>
<section>
<title>What is a "package"?</title>
<para>All software in Adélie Linux is provided to you in the form of <firstterm>packages</firstterm>. A "software package" is a single distribution of computer software that fulfils a purpose. For example, AbiWord, a word processor, is provided in the "abiword" package. When you want to install or uninstall software from your computer, you add (to install) or delete (to uninstall) packages.</para>
<para>Some packages have what are termed <firstterm>subpackages</firstterm>, which can provide related files such as translations of the software, documentation, or accessories.</para>
<para>There are also <firstterm>metapackages</firstterm>, which provide no software themselves, but refer to a collective, related group of software. For instance, the <package>kde-games</package> metapackage allows you to quickly install or uninstall the entire set of KDE Games.</para>
</section>
<section>
<title>An introduction to APK</title>
<para>Adélie Linux uses the APK package manager. The APK package manager is very fast, and performs well even on computers with limited resources. APK allows you to add and remove packages, ensure the integrity of installed packages, and perform system updates.</para>
<para>APK refers the entire set of packages you have chosen to install on your computer as a "<firstterm>world</firstterm>". When you install a package, you are adding it to the "world". When you uninstall a package, you are removing it from the "world". The world file exists at <filename>/etc/apk/world</filename> and is a text file with each package you have chosen to install on a single line.</para>
</section>
</section>
<section id="install_uninstall">
<title>Installing and uninstalling packages</title>
<para>When you want to install a package on your Adélie Linux system, you may use the command <command>apk add <userinput>PACKAGE</userinput></command>, where <userinput>PACKAGE</userinput> is the name of the package you want to install. You may install multiple packages at the same time by separating them with spaces. For example, <command>apk add firefox thunderbird</command> will install the Firefox web browser and Thunderbird email client.</para>
<para>To uninstall a package on your Adélie Linux system, you may use the command <command>apk del <userinput>PACKAGE</userinput></command>, where <userinput>PACKAGE</userinput> is the name of the package you want to uninstall. As with package installation, you may uninstall multiple packages at the same time by separating them with spaces.</para>
<para>When you install a package, APK will determine what additional libraries are required for your desired package(s) to run, and install those dependencies as well. These dependencies are not added to your "world" file, because you did not explicitly install them. They are kept only as long as the software that requires them is installed. Attempting to uninstall a dependency that is currently required by another package will result in a message similar to the following:</para>
<screen>
workstation01 ~ # apk del fts
World updated, but the following packages are not removed due to:
fts: dracut
</screen>
<para>This indicates that the <package>fts</package> package was removed from your "world" file (if it was listed there), but it is still required by the <package>dracut</package> package that is currently installed on your computer.</para>
</section>
<section id="integrity">
<title>Ensuring package integrity</title>
<para>The APK package manager can help you ensure continuing system integrity, and can also help you correct some issues as they arise. Every file installed on your computer by APK has a cryptographic signature and checksum. You may use the command <command>apk audit</command> to audit your entire system for integrity, or <command>apk audit <userinput>PATH</userinput></command> to audit a specific file or directory on your system. Note that <userinput>PATH</userinput> must be an <firstterm>absolute path</firstterm>; it must be the entire path beginning with a /. For example, the command <command>apk audit /usr/bin/vim</command> is valid; the command <command>apk audit vim</command>, even if it is run from inside the /usr/bin directory, is not.</para>
<para>The typical output of an <command>apk audit</command> run will look something like the following:</para>
<screen>
gwyn ~ # apk audit
A etc/init.d/net.eth1
A etc/conf.d/net
A etc/machine-id
A etc/fstab
U etc/shadow
U etc/group
A etc/hostname
A etc/resolv.conf
A etc/localtime
D etc/lvm/cache
U etc/passwd
</screen>
<para>Files marked with an 'A' are files <firstterm>added</firstterm> by a process other than APK. In this example, the <filename>/etc/resolv.conf</filename> was created when networking was configured on this computer. Files marked with a 'U' are files <firstterm>updated</firstterm> by a process other than APK. In this example, the <filename>/etc/passwd</filename> file was updated by changing the root password. Files marked with a 'D' are files <firstterm>deleted</firstterm> by a process other than APK. In this example, the <filename>/etc/lvm/cache</filename> directory was removed by a LVM process.</para>
<para>If you do find a file has been corrupted, incorrectly manipulated, or otherwise damaged, you may determine what package owns it by using the <command>apk info -W <userinput>FILE</userinput></command> command, where <userinput>FILE</userinput> is the absolute path to the file that is damaged. For example, if the file <filename>/etc/os-release</filename> was corrupted, you may run <command>apk info -W /etc/os-release</command> to determine which package owns it. You may then run <command>apk fix <userinput>PACKAGE</userinput></command> to reinstall the package, where <userinput>PACKAGE</userinput> is the name of the owning package.</para>
<para>There are a few additional options you may pass to <command>apk fix</command>, including:</para>
<itemizedlist>
<listitem><para><parameter>-d</parameter>, which will additionally reinstall all dependencies of the package;</para></listitem>
<listitem><para><parameter>-x</parameter>, which will repair extended attributes (or <firstterm>xattr</firstterm>s); and</para></listitem>
<listitem><para><parameter>--directory-permissions</parameter>, which will repair all directory permissions.</para></listitem>
</itemizedlist>
</section>
<section id="apk_repos">
<title>Package repositories</title>
<para>A <firstterm>package repository</firstterm> is a collection of packages that you may install on your computer. The Adélie Linux project runs two official package repositories: <literal>system</literal>, which contains essential packages that are necessary for the operation of computers running the Adélie Linux system, and <literal>user</literal>, which contains packages that can be installed and uninstalled by users and administrators.</para>
<para>You may run your own package repository using the information contained in our Developer's Handbook. There are also external package repositories on the Internet. Some of these may contain experimental software ports or software that could not be included in the Adélie Linux system. They may also contain <firstterm>malware</firstterm>, software that can harm your computer or cause security issues. Please always ensure that repositories that you add to your system are authored by people or organisations you trust.</para>
<para>Management of package repositories is accomplished via the <filename>/etc/apk/repositories</filename> configuration file. Refer to <xref linkend="e-a-r" /> for more information on the <filename>/etc/apk/repositories</filename> configuration file.</para>
</section>
</chapter>
|