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