source: chapter06/pkgmgt.xml@ 2f494dc

Last change on this file since 2f494dc was 28b40e2, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Finished the PDF fixes.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/6.2/BOOK@7737 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 10.9 KB
RevLine 
[76ccbb3]1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
[3f3931b0]3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
[76ccbb3]4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-system-pkgmgt">
9 <?dbhtml filename="pkgmgt.html"?>
10
[3f3931b0]11 <title>Package Management</title>
12
[76ccbb3]13 <para>Package Management is an often requested addition to the LFS 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>
21
[3f3931b0]22 <para>Some reasons why no package manager is mentioned in LFS or BLFS
23 include:</para>
[76ccbb3]24
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>
30
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>
37
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>
41
42 <sect2>
43 <title>Upgrade Issues</title>
44
45 <para>A Package Manager makes it easy to upgrade to newer versions when they
46 are released. Generally the instructions in the LFS 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>
49
50 <itemizedlist>
51 <listitem>
[3f3931b0]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 rebuild LFS.
54 Though you <emphasis>may</emphasis> be able to get by rebuilding all
55 the packages in their dependency order, we do not recommend it. For
56 example, if glibc-2.2.x needs to be updated to glibc-2.3.x, it is safer
57 to rebuild. For micro version updates, a simple reinstallation usually
58 works, but is not guaranteed. For example, upgrading from glibc-2.3.4
59 to glibc-2.3.5 will not usually cause any problems.</para>
[76ccbb3]60 </listitem>
61
62 <listitem>
63 <para>If a package containing a shared library is updated, and if the
64 name of the library changes, then all the packages dynamically linked
65 to the library need to be recompiled to link against the newer library.
66 (Note that there is no correlation between the package version and the
67 name of the library.) For example, consider a package foo-1.2.3 that
68 installs a shared library with name
69 <filename class='libraryfile'>libfoo.so.1</filename>. Say you upgrade
70 the package to a newer version foo-1.2.4 that installs a shared library
71 with name <filename class='libraryfile'>libfoo.so.2</filename>. In this
72 case, all packages that are dynamically linked to
73 <filename class='libraryfile'>libfoo.so.1</filename> need to be
74 recompiled to link against
75 <filename class='libraryfile'>libfoo.so.2</filename>. Note that you
76 should not remove the previous libraries until the dependent packages
77 are recompiled.</para>
78 </listitem>
79 </itemizedlist>
80
81 </sect2>
82
83 <sect2>
84 <title>Package Management Techniques</title>
85
86 <para>The following are some common package management techniques. Before
87 making a decision on a package manager, do some research on the various
88 techniques, particularly the drawbacks of the particular scheme.</para>
89
[28b40e2]90 <beginpage/>
91
[76ccbb3]92 <sect3>
93 <title>It is All in My Head!</title>
94
95 <para>Yes, this is a package management technique. Some folks do not find
96 the need for a package manager because they know the packages intimately
97 and know what files are installed by each package. Some users also do not
98 need any package management because they plan on rebuilding the entire
99 system when a package is changed.</para>
[3f3931b0]100
[76ccbb3]101 </sect3>
102
103 <sect3>
104 <title>Install in Separate Directories</title>
105
106 <para>This is a simplistic package management that does not need any extra
107 package to manage the installations. Each package is installed in a
108 separate directory. For example, package foo-1.1 is installed in
109 <filename class='directory'>/usr/pkg/foo-1.1</filename>
110 and a symlink is made from <filename>/usr/pkg/foo</filename> to
111 <filename class='directory'>/usr/pkg/foo-1.1</filename>. When installing
112 a new version foo-1.2, it is installed in
113 <filename class='directory'>/usr/pkg/foo-1.2</filename> and the previous
114 symlink is replaced by a symlink to the new version.</para>
115
116 <para>Environment variables such as <envar>PATH</envar>,
117 <envar>LD_LIBRARY_PATH</envar>, <envar>MANPATH</envar>,
118 <envar>INFOPATH</envar> and <envar>CPPFLAGS</envar> need to be expanded to
119 include <filename>/usr/pkg/foo</filename>. For more than a few packages,
120 this scheme becomes unmanageable.</para>
[3f3931b0]121
[76ccbb3]122 </sect3>
123
124 <sect3>
125 <title>Symlink Style Package Management</title>
126
127 <para>This is a variation of the previous package management technique.
128 Each package is installed similar to the previous scheme. But instead of
129 making the symlink, each file is symlinked into the
130 <filename class='directory'>/usr</filename> hierarchy. This removes the
131 need to expand the environment variables. Though the symlinks can be
132 created by the user to automate the creation, many package managers have
133 been written using this approach. A few of the popular ones include Stow,
134 Epkg, Graft, and Depot.</para>
135
136 <para>The installation needs to be faked, so that the package thinks that
137 it is installed in <filename class="directory">/usr</filename> though in
138 reality it is installed in the
139 <filename class="directory">/usr/pkg</filename> hierarchy. Installing in
140 this manner is not usually a trivial task. For example, consider that you
141 are installing a package libfoo-1.1. The following instructions may
142 not install the package properly:</para>
143
[942465e]144<screen role="nodump"><userinput>./configure --prefix=/usr/pkg/libfoo/1.1
[76ccbb3]145make
146make install</userinput></screen>
147
148 <para>The installation will work, but the dependent packages may not link
149 to libfoo as you would expect. If you compile a package that links against
150 libfoo, you may notice that it is linked to
151 <filename class='libraryfile'>/usr/pkg/libfoo/1.1/lib/libfoo.so.1</filename>
152 instead of <filename class='libraryfile'>/usr/lib/libfoo.so.1</filename>
153 as you would expect. The correct approach is to use the
154 <envar>DESTDIR</envar> strategy to fake installation of the package. This
155 approach works as follows:</para>
156
[942465e]157<screen role="nodump"><userinput>./configure --prefix=/usr
[76ccbb3]158make
159make DESTDIR=/usr/pkg/libfoo/1.1 install</userinput></screen>
160
[3f3931b0]161 <para>Most packages support this approach, but there are some which do not.
162 For the non-compliant packages, you may either need to manually install the
163 package, or you may find that it is easier to install some problematic
164 packages into <filename class='directory'>/opt</filename>.</para>
165
[28b40e2]166 <beginpage/>
167
[76ccbb3]168 </sect3>
169
170 <sect3>
171 <title>Timestamp Based</title>
172
173 <para>In this technique, a file is timestamped before the installation of
174 the package. After the installation, a simple use of the
175 <command>find</command> command with the appropriate options can generate
176 a log of all the files installed after the timestamp file was created. A
177 package manager written with this approach is install-log.</para>
178
179 <para>Though this scheme has the advantage of being simple, it has two
180 drawbacks. If, during installation, the files are installed with any
181 timestamp other than the current time, those files will not be tracked by
182 the package manager. Also, this scheme can only be used when one package
183 is installed at a time. The logs are not reliable if two packages are
184 being installed on two different consoles.</para>
[3f3931b0]185
[76ccbb3]186 </sect3>
187
188 <sect3>
189 <title>LD_PRELOAD Based</title>
190
191 <para>In this approach, a library is preloaded before installation. During
192 installation, this library tracks the packages that are being installed by
193 attaching itself to various executables such as <command>cp</command>,
194 <command>install</command>, <command>mv</command> and tracking the system
195 calls that modify the filesystem. For this approach to work, all the
196 executables need to be dynamically linked without the suid or sgid bit.
197 Preloading the library may cause some unwanted side-effects during
198 installation. Therefore, it is advised that one performs some tests to
199 ensure that the package manager does not break anything and logs all the
200 appropriate files.</para>
[3f3931b0]201
[76ccbb3]202 </sect3>
203
204 <sect3>
205 <title>Creating Package Archives</title>
206
207 <para>In this scheme, the package installation is faked into a separate
208 tree as described in the Symlink style package management. After the
209 installation, a package archive is created using the installed files.
210 This archive is then used to install the package either on the local
[3f3931b0]211 machine or can even be used to install the package on other machines.</para>
[76ccbb3]212
213 <para>This approach is used by most of the package managers found in the
214 commercial distributions. Examples of package managers that follow this
215 approach are RPM (which, incidentally, is required by the <ulink
216 url="http://lsbbook.gforge.freestandards.org/package.html#RPM">Linux
217 Standard Base Specification</ulink>), pkg-utils, Debian's apt, and
218 Gentoo's Portage system. A hint describing how to adopt this style of
219 package management for LFS systems is located at <ulink
[6b8936f]220 url="&hints-root;fakeroot.txt"/>.</para>
[3f3931b0]221
[76ccbb3]222 </sect3>
223
224 <sect3>
225 <title>User Based Management</title>
226
227 <para>This scheme, unique to LFS, was devised by Matthias Benkmann, and is
228 available from the <ulink url="&hints-root;">Hints Project</ulink>. In
229 this scheme, each package is installed as a separate user into the
230 standard locations. Files belonging to a package are easily identified by
231 checking the user ID. The features and shortcomings of this approach are
232 too complex to describe in this section. For the details please see the
[6b8936f]233 hint at <ulink url="&hints-root;more_control_and_pkg_man.txt"/>.</para>
[3f3931b0]234
[76ccbb3]235 </sect3>
236
237 </sect2>
238
239</sect1>
Note: See TracBrowser for help on using the repository browser.