source: introduction/important/pkgmgt.xml@ fabf04f7

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since fabf04f7 was 6732c094, checked in by Randy McMurchy <randy@…>, 17 years ago

Updated all the XML files (and the one stylesheet) to use the 4.5 version of DocBook XML DTD

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@6716 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 11.0 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="pkgmgt">
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&mdash;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&mdash;teaching how a Linux system is built.</para>
35 </listitem>
36 <listitem>
37 <para>There are multiple solutions for package management, each having
38 its strengths and drawbacks. Including one that satisfies all audiences is
39 difficult.</para>
40 </listitem>
41 </itemizedlist>
42
43 <para>There are some hints written on the topic of package management. Visit
44 the <ulink url="&hints-root;">Hints subproject</ulink>
45 and see if one of them fits your need.</para>
46
47 <sect2>
48 <title>Upgrade Issues</title>
49
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
53 be aware of when upgrading packages, especially on a running system.</para>
54
55 <itemizedlist>
56 <listitem>
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
60 minor version, it is safer to rebuild LFS. Though you
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>
67 </listitem>
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 <listitem>
86 <para>If you are upgrading a running system, be on the lookout for packages
87 that use <command>cp</command> instead of <command>install</command>
88 to install files. The latter command is usually safer if the executable
89 or library is already loaded in memory.</para>
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
99 making a decision on a package manager, do some research on the various
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
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
119 <filename class='directory'>/usr/pkg/foo-1.1</filename>
120 and a symlink is made from <filename>/usr/pkg/foo</filename> to
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>
125
126 <para>The environment variables such as those mentioned in
127 <quote><xref linkend="beyond"/></quote> need to be expanded to
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
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>
144
145 <para>The installation needs to be faked, so that the package thinks that it is
146 installed in <filename class="directory">/usr</filename> though in reality it is
147 installed in the <filename class="directory">/usr/pkg</filename> hierarchy.
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
150 not install the package properly:</para>
151
152<screen><userinput>./configure --prefix=/usr/pkg/libfoo/1.1
153make
154make install</userinput></screen>
155
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>
164
165<screen><userinput>./configure --prefix=/usr
166make
167make DESTDIR=/usr/pkg/libfoo/1.1 install</userinput></screen>
168
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>
174
175 </sect3>
176
177 <sect3>
178 <title>Timestamp Based</title>
179
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>
185
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>
191
192 </sect3>
193
194 <sect3>
195 <title>LD_PRELOAD Based</title>
196
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
202 need to be dynamically linked without the suid or sgid bit. Preloading the
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>
206
207 </sect3>
208
209 <sect3>
210 <title>Creating Package Archives</title>
211
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>
217
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>
221
222 </sect3>
223
224 <sect3>
225 <title>User Based Management</title>
226
227 <para>This scheme, unique to LFS, was devised by Matthias Benkmann,
228 and is available from the <ulink url="&hints-root;">Hints
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
231 by 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 hint at <ulink
233 url="&hints-root;/downloads/files/more_control_and_pkg_man.txt"/>.</para>
234
235 </sect3>
236
237 </sect2>
238
239</sect1>
Note: See TracBrowser for help on using the repository browser.