source: chapter06/pkgmgt.xml@ 76ccbb3

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.3 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 76ccbb3 was 76ccbb3, checked in by Matthew Burgess <matthew@…>, 18 years ago

Add information about package management

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

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