[4122007] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
[3d760b6] | 8 | <sect1 id="intro-important-pkgmgt">
|
---|
[a0f03b0] | 9 | <sect1info>
|
---|
[5cd0959d] | 10 | <othername>$LastChangedBy$</othername>
|
---|
| 11 | <date>$Date$</date>
|
---|
[a0f03b0] | 12 | </sect1info>
|
---|
[71e06e23] | 13 | <?dbhtml filename="pkgmgt.html"?>
|
---|
[3d760b6] | 14 | <title>Package Management</title>
|
---|
| 15 |
|
---|
[511570b] | 16 | <para>Package Management is an often requested addition
|
---|
[3d760b6] | 17 | to the <acronym>LFS</acronym> Book. A Package Manager allows tracking
|
---|
| 18 | the installation of files making it easy to remove and upgrade packages.
|
---|
[20828163] | 19 | And before you begin to wonder, NO—this section does not talk about any
|
---|
[3d760b6] | 20 | particular package manager, nor does it recommend one. What it provides is
|
---|
| 21 | a roundup of the more popular techniques and how they work. The perfect
|
---|
| 22 | package manager for you may be among these techniques or may be a combination
|
---|
[511570b] | 23 | of two or more of these techniques. This section briefly mentions
|
---|
| 24 | issues that may arise when upgrading packages.</para>
|
---|
[3d760b6] | 25 |
|
---|
| 26 | <para>Some reasons why no package manager is mentioned in <acronym>LFS</acronym>
|
---|
| 27 | or <acronym>BLFS</acronym>:</para>
|
---|
| 28 |
|
---|
| 29 | <itemizedlist>
|
---|
| 30 | <listitem><para>Dealing with package management takes the focus away from
|
---|
[20828163] | 31 | the goals of these books—teaching how a Linux system is built.</para></listitem>
|
---|
[3d760b6] | 32 | <listitem><para>There are multiple solutions for package management, each having
|
---|
[1f629e3] | 33 | its strengths and drawbacks. Including one that satifies all audiences is
|
---|
| 34 | difficult.</para></listitem>
|
---|
[3d760b6] | 35 | </itemizedlist>
|
---|
| 36 |
|
---|
| 37 | <para>There are some hints written on the topic of package management. Visit
|
---|
| 38 | the <ulink url="http://www.linuxfromscratch.org/hints/">Hints subproject</ulink>
|
---|
| 39 | to find if one of them fits your need.</para>
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | <sect2>
|
---|
| 43 | <title>Upgrade Issues</title>
|
---|
| 44 |
|
---|
[20828163] | 45 | <para>A Package Manager makes it easy to upgrade to newer versions when they
|
---|
[1f629e3] | 46 | are released. Generally the instructions in the <acronym>LFS</acronym> and
|
---|
| 47 | <acronym>BLFS</acronym> Book can be used to upgrade to the newer versions.
|
---|
[20828163] | 48 | Here are some points that you should be aware of when upgrading
|
---|
[511570b] | 49 | packages, especially on a running system.</para>
|
---|
[3d760b6] | 50 |
|
---|
| 51 | <itemizedlist>
|
---|
[20828163] | 52 | <listitem><para>If one of the toolchain package (glibc, gcc,
|
---|
[3d760b6] | 53 | binutils) needs to be upgraded to a newer minor vesion, it is safer to rebuild
|
---|
[511570b] | 54 | <acronym>LFS</acronym>. Though you <emphasis>may</emphasis> be able to get by
|
---|
[20828163] | 55 | rebuilding all the packages in their dependency order. We do not recommend it.
|
---|
| 56 | For example, if glibc-2.2.x needs to be updated to glibc-2.3.x, it is safer
|
---|
[3d760b6] | 57 | to rebuild. For micro version updates, a simple reinstallation usually works, but
|
---|
| 58 | is not guaranteed. For example, upgrading from glibc-2.3.1 to glibc-2.3.2 will not
|
---|
| 59 | usually cause any problems.</para></listitem>
|
---|
| 60 | <listitem><para>If a package containing a shared library is updated, and if the
|
---|
[20828163] | 61 | name of the library changes, then all the packages dynamically linked to the
|
---|
[3d760b6] | 62 | library need to be recompiled to link against the newer library. (Note that there
|
---|
[20828163] | 63 | is no corelation between the package version and the name of the library.) For
|
---|
| 64 | example, consider a package foo-1.2.3 that installs a shared library with name
|
---|
[3d760b6] | 65 | <filename>libfoo.so.1</filename>. Say you upgrade the package to a newer version
|
---|
[20828163] | 66 | foo-1.2.4 that installs a shared library with name <filename>libfoo.so.2</filename>.
|
---|
[3d760b6] | 67 | In this case, all packages that are dynamically linked to <filename>libfoo.so.1</filename>
|
---|
| 68 | need to be recompiled to link against <filename>libfoo.so.2</filename>. Note that
|
---|
| 69 | you should not remove the previous libraries till the dependent packages are
|
---|
| 70 | recompiled.</para></listitem>
|
---|
| 71 | <listitem><para>If you are upgrading a running system, be on the lookout for
|
---|
| 72 | packages that use <command>cp</command> instead of <command>install</command> to
|
---|
| 73 | install files. The latter command is usually safer if the executable or library
|
---|
| 74 | is already loaded in memory.</para></listitem>
|
---|
| 75 | </itemizedlist>
|
---|
| 76 |
|
---|
| 77 | </sect2>
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | <sect2>
|
---|
| 81 | <title>Package Management Techniques</title>
|
---|
| 82 |
|
---|
[1f629e3] | 83 | <para>The following are some common package management techniques. Before
|
---|
| 84 | making a decision on a package manager, do a research on the various
|
---|
| 85 | techniques, particularly the drawbacks of the particular scheme.</para>
|
---|
[3d760b6] | 86 |
|
---|
| 87 | <sect3>
|
---|
[511570b] | 88 | <title>It is all in my head!</title>
|
---|
[3d760b6] | 89 |
|
---|
| 90 | <para>Yes, this is a package management technique. Some folks do not find the
|
---|
| 91 | need for a package manager because they know the packages intimately and know
|
---|
| 92 | what files are installed by each package. Some users also do not need any
|
---|
[20828163] | 93 | package management because they plan on rebuilding the entire system
|
---|
[3d760b6] | 94 | when a package is changed.</para>
|
---|
| 95 |
|
---|
| 96 | </sect3>
|
---|
| 97 |
|
---|
| 98 | <sect3>
|
---|
[1f629e3] | 99 | <title>Install in separate directories</title>
|
---|
[3d760b6] | 100 |
|
---|
| 101 | <para>This is a simplistic package management that does not need any extra package
|
---|
[1f629e3] | 102 | to manage the installations. Each package is installed in a separate directory.
|
---|
[3d760b6] | 103 | For example, package foo-1.1 is installed in <filename>/usr/pkg/foo-1.1</filename>
|
---|
| 104 | and a symlink is made from <filename>/usr/pkg/foo</filename> to
|
---|
| 105 | <filename>/usr/pkg/foo-1.1</filename>. When installing a new version foo-1.2,
|
---|
| 106 | it is installed in <filename>/usr/pkg/foo-1.2</filename> and the previous
|
---|
| 107 | symlink is replaced by a symlink to the new vesion.</para>
|
---|
| 108 |
|
---|
| 109 | <para>The environment variables such as those
|
---|
[b5ea3492] | 110 | mentioned in <xref linkend="intro-important-beyond"/> need to be expanded to
|
---|
[3d760b6] | 111 | include <filename>/usr/pkg/foo</filename>. For more than a few packages,
|
---|
[aa15d3e] | 112 | this scheme becomes unmanageable.</para>
|
---|
[3d760b6] | 113 |
|
---|
| 114 | </sect3>
|
---|
| 115 |
|
---|
| 116 | <sect3>
|
---|
| 117 | <title>Symlink style package management</title>
|
---|
| 118 |
|
---|
| 119 | <para>This is a variation of the previous package management technique. Each package
|
---|
| 120 | is installed similar to the previous scheme. But instead of making the symlink,
|
---|
| 121 | each file is symlinked into <filename>/usr</filename> hierarchy. This removes the need
|
---|
| 122 | to expand the environment variables. Though the symlinks can be created by the user,
|
---|
| 123 | to automate the creation, many package managers have been written on this approach.
|
---|
[aa15d3e] | 124 | A few of the popular ones are Stow, Epkg, Graft, and Depot.</para>
|
---|
[3d760b6] | 125 |
|
---|
| 126 | <para>The installation needs to be faked, so that the package thinks that it is
|
---|
[aa15d3e] | 127 | installed in <filename class="directory">/usr</filename> though in reality it is installed in
|
---|
| 128 | <filename class="directory">/usr/pkg</filename> hierarchy. Installing in this manner is not usually a trivial
|
---|
[3d760b6] | 129 | task. For example, consider that you are installing a package libfoo-1.1. The following
|
---|
| 130 | instructions may not install the package properly:</para>
|
---|
| 131 |
|
---|
[20828163] | 132 | <screen><userinput><command>./configure --prefix=/usr/pkg/libfoo/1.1
|
---|
| 133 | make
|
---|
[3d760b6] | 134 | make install</command></userinput></screen>
|
---|
| 135 |
|
---|
| 136 | <para>The installation will work, but the dependent packages may not link to
|
---|
| 137 | libfoo as you would expect. If you compile a package that links against libfoo,
|
---|
| 138 | you may notice that it is linked to <filename>/usr/pkg/libfoo/1.1/lib/libfoo.so.1</filename>
|
---|
| 139 | instead of <filename>/usr/lib/libfoo.so.1</filename> as you would expect. The correct
|
---|
| 140 | approach is to use <envar>DESTDIR</envar> strategy to fake installation of the package.
|
---|
| 141 | This approach works as follows:</para>
|
---|
| 142 |
|
---|
[20828163] | 143 | <screen><userinput><command>./configure --prefix=/usr
|
---|
| 144 | make
|
---|
[3d760b6] | 145 | make DESTDIR=/usr/pkg/libfoo/1.1 install</command></userinput></screen>
|
---|
| 146 |
|
---|
| 147 | <para>Most of the packages do support this approach, but there are some which do not.
|
---|
| 148 | For the non-compliant packages, you may either need to manually install the package,
|
---|
| 149 | or you may find that it is easier to install some problematic packages into
|
---|
| 150 | <filename>/opt</filename>.</para>
|
---|
| 151 |
|
---|
| 152 | </sect3>
|
---|
| 153 |
|
---|
| 154 | <sect3>
|
---|
| 155 | <title>Timestamp based</title>
|
---|
| 156 |
|
---|
| 157 | <para>In this technique, a file is timestamped before the installation of the package.
|
---|
| 158 | After the installation, a simple use of the <command>find</command> command with the
|
---|
| 159 | appropriate options can generate a log of all the files installed after the timestamp
|
---|
| 160 | file was created. A package manager written with this approach is install-log.</para>
|
---|
| 161 |
|
---|
| 162 | <para>Though this scheme has the advantage of being simple, it has two drawbacks.
|
---|
| 163 | If during installation, the files are installed with any timestamp other than the
|
---|
| 164 | current time, those files will not be tracked by the package manager. Also, this
|
---|
| 165 | scheme can only be used when one package is installed at a time. The logs are not
|
---|
| 166 | reliable if two packages are being installed on two different consoles.</para>
|
---|
| 167 |
|
---|
| 168 | </sect3>
|
---|
| 169 |
|
---|
| 170 | <sect3>
|
---|
| 171 | <title>LD_PRELOAD based</title>
|
---|
| 172 |
|
---|
[511570b] | 173 | <para>In this approach, a library is preloaded before installation. During
|
---|
[3d760b6] | 174 | installation, this library tracks the packages that are being installed by
|
---|
| 175 | attaching itself to various executables such as <command>cp</command>,
|
---|
| 176 | <command>install</command>, <command>mv</command> and tracking the system
|
---|
| 177 | calls that modify the filesystem. For this approach to work, all the executables
|
---|
| 178 | need to be dymanically linked without the suid or sgid bit. Preloading the
|
---|
[20828163] | 179 | library may cause some unwanted side-effects during installation. Therefore,
|
---|
[1f629e3] | 180 | do perform some tests to ensure that the package manager does not break
|
---|
| 181 | anything and logs all the appropriate files.</para>
|
---|
[3d760b6] | 182 |
|
---|
| 183 | </sect3>
|
---|
| 184 |
|
---|
| 185 | <sect3>
|
---|
| 186 | <title>Creating Package Archives</title>
|
---|
| 187 |
|
---|
[1f629e3] | 188 | <para>In this scheme, the package installation is faked into a separate
|
---|
[3d760b6] | 189 | tree as described in the Symlink style package management. After the
|
---|
| 190 | installation, a package archive is created using the installed files.
|
---|
| 191 | This archive is then used to install the package either on the local
|
---|
| 192 | machine or can even be used to install the package on other machines.</para>
|
---|
| 193 |
|
---|
| 194 | <para>This approach is used by most of the package managers found in the
|
---|
[20828163] | 195 | commercial distributions. Examples of package managers that follow this
|
---|
| 196 | approach are RPM, pkg-utils, Debian's apt, and Gentoo's Portage system.</para>
|
---|
[3d760b6] | 197 |
|
---|
| 198 | </sect3>
|
---|
| 199 |
|
---|
| 200 | <sect3>
|
---|
| 201 | <title>User Based Management</title>
|
---|
| 202 |
|
---|
| 203 | <para>This scheme, that is unique to <acronym>LFS</acronym>, was
|
---|
| 204 | devised by Matthias Benkmann, and is available from the <ulink
|
---|
| 205 | url="http://www.linuxfromscratch.org/hints/">Hints Project</ulink>.
|
---|
[1f629e3] | 206 | In this scheme, each package is installed as a separate user into
|
---|
[3d760b6] | 207 | the standard locations. Files belonging to a package are easily
|
---|
| 208 | identified by checking the user id. The features and shortcomings
|
---|
| 209 | of this approach are too complex to describe in this section. For
|
---|
| 210 | the details please see the hint at <ulink
|
---|
| 211 | url="http://www.linuxfromscratch.org/hints/downloads/files/more_control_and_pkg_man.txt"/>.</para>
|
---|
| 212 |
|
---|
| 213 | </sect3>
|
---|
| 214 |
|
---|
| 215 | </sect2>
|
---|
| 216 |
|
---|
| 217 |
|
---|
| 218 | </sect1>
|
---|