source: chapter06/pkgmgt.xml@ 31534911

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 31534911 was 31534911, checked in by Archaic <archaic@…>, 18 years ago

Removed warning about install being safer than cp. Closes ticket #1728.

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

  • Property mode set to 100644
File size: 10.9 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 <?dbhtml filename="pkgmgt.html"?>
10
11 <title>Package Management</title>
12
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
22 <para>Some reasons why no package manager is mentioned in LFS or BLFS
23 include:</para>
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>
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>
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
90 <sect3>
91 <title>It is All in My Head!</title>
92
93 <para>Yes, this is a package management technique. Some folks do not find
94 the need for a package manager because they know the packages intimately
95 and know what files are installed by each package. Some users also do not
96 need any package management because they plan on rebuilding the entire
97 system when a package is changed.</para>
98
99 </sect3>
100
101 <sect3>
102 <title>Install in Separate Directories</title>
103
104 <para>This is a simplistic package management that does not need any extra
105 package to manage the installations. Each package is installed in a
106 separate directory. For example, package foo-1.1 is installed in
107 <filename class='directory'>/usr/pkg/foo-1.1</filename>
108 and a symlink is made from <filename>/usr/pkg/foo</filename> to
109 <filename class='directory'>/usr/pkg/foo-1.1</filename>. When installing
110 a new version foo-1.2, it is installed in
111 <filename class='directory'>/usr/pkg/foo-1.2</filename> and the previous
112 symlink is replaced by a symlink to the new version.</para>
113
114 <para>Environment variables such as <envar>PATH</envar>,
115 <envar>LD_LIBRARY_PATH</envar>, <envar>MANPATH</envar>,
116 <envar>INFOPATH</envar> and <envar>CPPFLAGS</envar> need to be expanded to
117 include <filename>/usr/pkg/foo</filename>. For more than a few packages,
118 this scheme becomes unmanageable.</para>
119
120 </sect3>
121
122 <sect3>
123 <title>Symlink Style Package Management</title>
124
125 <para>This is a variation of the previous package management technique.
126 Each package is installed similar to the previous scheme. But instead of
127 making the symlink, each file is symlinked into the
128 <filename class='directory'>/usr</filename> hierarchy. This removes the
129 need to expand the environment variables. Though the symlinks can be
130 created by the user to automate the creation, many package managers have
131 been written using this approach. A few of the popular ones include Stow,
132 Epkg, Graft, and Depot.</para>
133
134 <para>The installation needs to be faked, so that the package thinks that
135 it is installed in <filename class="directory">/usr</filename> though in
136 reality it is installed in the
137 <filename class="directory">/usr/pkg</filename> hierarchy. Installing in
138 this manner is not usually a trivial task. For example, consider that you
139 are installing a package libfoo-1.1. The following instructions may
140 not install the package properly:</para>
141
142<screen role="nodump"><userinput>./configure --prefix=/usr/pkg/libfoo/1.1
143make
144make install</userinput></screen>
145
146 <para>The installation will work, but the dependent packages may not link
147 to libfoo as you would expect. If you compile a package that links against
148 libfoo, you may notice that it is linked to
149 <filename class='libraryfile'>/usr/pkg/libfoo/1.1/lib/libfoo.so.1</filename>
150 instead of <filename class='libraryfile'>/usr/lib/libfoo.so.1</filename>
151 as you would expect. The correct approach is to use the
152 <envar>DESTDIR</envar> strategy to fake installation of the package. This
153 approach works as follows:</para>
154
155<screen role="nodump"><userinput>./configure --prefix=/usr
156make
157make DESTDIR=/usr/pkg/libfoo/1.1 install</userinput></screen>
158
159 <para>Most packages support this approach, but there are some which do not.
160 For the non-compliant packages, you may either need to manually install the
161 package, or you may find that it is easier to install some problematic
162 packages into <filename class='directory'>/opt</filename>.</para>
163
164 </sect3>
165
166 <sect3>
167 <title>Timestamp Based</title>
168
169 <para>In this technique, a file is timestamped before the installation of
170 the package. After the installation, a simple use of the
171 <command>find</command> command with the appropriate options can generate
172 a log of all the files installed after the timestamp file was created. A
173 package manager written with this approach is install-log.</para>
174
175 <para>Though this scheme has the advantage of being simple, it has two
176 drawbacks. If, during installation, the files are installed with any
177 timestamp other than the current time, those files will not be tracked by
178 the package manager. Also, this scheme can only be used when one package
179 is installed at a time. The logs are not reliable if two packages are
180 being installed on two different consoles.</para>
181
182 </sect3>
183
184 <sect3>
185 <title>LD_PRELOAD Based</title>
186
187 <para>In this approach, a library is preloaded before installation. During
188 installation, this library tracks the packages that are being installed by
189 attaching itself to various executables such as <command>cp</command>,
190 <command>install</command>, <command>mv</command> and tracking the system
191 calls that modify the filesystem. For this approach to work, all the
192 executables need to be dynamically linked without the suid or sgid bit.
193 Preloading the library may cause some unwanted side-effects during
194 installation. Therefore, it is advised that one performs some tests to
195 ensure that the package manager does not break anything and logs all the
196 appropriate files.</para>
197
198 </sect3>
199
200 <sect3>
201 <title>Creating Package Archives</title>
202
203 <para>In this scheme, the package installation is faked into a separate
204 tree as described in the Symlink style package management. After the
205 installation, a package archive is created using the installed files.
206 This archive is then used to install the package either on the local
207 machine or can even be used to install the package on other machines.</para>
208
209 <para>This approach is used by most of the package managers found in the
210 commercial distributions. Examples of package managers that follow this
211 approach are RPM (which, incidentally, is required by the <ulink
212 url="http://lsbbook.gforge.freestandards.org/package.html#RPM">Linux
213 Standard Base Specification</ulink>), pkg-utils, Debian's apt, and
214 Gentoo's Portage system. A hint describing how to adopt this style of
215 package management for LFS systems is located at <ulink
216 url="&hints-root;fakeroot.txt"/>.</para>
217
218 </sect3>
219
220 <sect3>
221 <title>User Based Management</title>
222
223 <para>This scheme, unique to LFS, was devised by Matthias Benkmann, and is
224 available from the <ulink url="&hints-root;">Hints Project</ulink>. In
225 this scheme, each package is installed as a separate user into the
226 standard locations. Files belonging to a package are easily identified by
227 checking the user ID. The features and shortcomings of this approach are
228 too complex to describe in this section. For the details please see the
229 hint at <ulink url="&hints-root;more_control_and_pkg_man.txt"/>.</para>
230
231 </sect3>
232
233 </sect2>
234
235</sect1>
Note: See TracBrowser for help on using the repository browser.