source: BOOK/final-system/common/pkgmgt.xml @ 9f08378

Last change on this file since 9f08378 was 9f08378, checked in by Jim Gifford <clfs@…>, 17 years ago

r3564@server (orig r1629): chris | 2006-05-17 13:05:26 -0700
More text updates, mostly to change LFS references to CLFS

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