source: chapter08/pkgmgt.xml@ 80838616

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 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 80838616 was 9a17861, checked in by Xi Ruoyao <xry111@…>, 3 years ago

add a paragraph for "downgrading issue" in package management page

  • Property mode set to 100644
File size: 14.5 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="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. As well as the binary and library files, a
16 package manager will handle the installation of configuration files. Before
17 you begin to wonder, NO&mdash;this section will not talk about nor recommend
18 any particular package manager. What it provides is a roundup of the more
19 popular techniques and how they work. The perfect package manager for you may
20 be among these techniques or may be a combination of two or more of these
21 techniques. This section briefly mentions issues that may arise when upgrading
22 packages.</para>
23
24 <para>Some reasons why no package manager is mentioned in LFS or BLFS
25 include:</para>
26
27 <itemizedlist>
28 <listitem>
29 <para>Dealing with package management takes the focus away from the goals
30 of these books&mdash;teaching how a Linux system is built.</para>
31 </listitem>
32
33 <listitem>
34 <para>There are multiple solutions for package management, each having
35 its strengths and drawbacks. Including one that satisfies all audiences
36 is difficult.</para>
37 </listitem>
38 </itemizedlist>
39
40 <para>There are some hints written on the topic of package management. Visit
41 the <ulink url="&hints-root;">Hints Project</ulink> and see if one of them
42 fits your need.</para>
43
44 <sect2>
45 <title>Upgrade Issues</title>
46
47 <para>A Package Manager makes it easy to upgrade to newer versions when they
48 are released. Generally the instructions in the LFS and BLFS books can be
49 used to upgrade to the newer versions. Here are some points that you should
50 be aware of when upgrading packages, especially on a running system.</para>
51
52 <itemizedlist>
53 <listitem>
54 <para>If Glibc needs to be upgraded to a newer version, (e.g. from
55 glibc-2.31 to glibc-2.32), it is safer to rebuild LFS. Though you
56 <emphasis>may</emphasis> be able to rebuild all the packages in their
57 dependency order, we do not recommend it. </para>
58 </listitem>
59
60 <listitem> <para>If a package containing a shared library is updated, and
61 if the name of the library changes, then any the packages dynamically
62 linked to the library need to be recompiled in order to link against the
63 newer library. (Note that there is no correlation between the package
64 version and the name of the library.) For example, consider a package
65 foo-1.2.3 that installs a shared library with name <filename
66 class='libraryfile'>libfoo.so.1</filename>. If you upgrade the package to
67 a newer version foo-1.2.4 that installs a shared library with name
68 <filename class='libraryfile'>libfoo.so.2</filename>. In this case, any
69 packages that are dynamically linked to <filename
70 class='libraryfile'>libfoo.so.1</filename> need to be recompiled to link
71 against <filename class='libraryfile'>libfoo.so.2</filename> in order to
72 use the new library version. You should not remove the previous
73 libraries unless all the dependent packages are recompiled.</para>
74 </listitem>
75
76 <listitem> <para>If a package containing a shared library is updated,
77 and the name of library doesn't change, but the version number of the
78 library <emphasis role="bold">file</emphasis> decreases (for example,
79 the name of the library is kept named
80 <filename class='libraryfile'>libfoo.so.1</filename>,
81 but the name of library file is changed from
82 <filename class='libraryfile'>libfoo.so.1.25</filename> to
83 <filename class='libraryfile'>libfoo.so.1.24</filename>),
84 you should remove the library file from the previously installed version
85 (<filename class='libraryfile'>libfoo.so.1.25</filename> in the case).
86 Or, a <command>ldconfig</command> run (by yourself using a command
87 line, or by the installation of some package) will reset the symlink
88 <filename class='libraryfile'>libfoo.so.1</filename> to point to
89 the old library file because it seems having a <quote>newer</quote>
90 version, as its version number is larger. This situation may happen if
91 you have to downgrade a package, or the package changes the versioning
92 scheme of library files suddenly.</para> </listitem>
93
94 </itemizedlist>
95
96 </sect2>
97
98 <sect2>
99 <title>Package Management Techniques</title>
100
101 <para>The following are some common package management techniques. Before
102 making a decision on a package manager, do some research on the various
103 techniques, particularly the drawbacks of the particular scheme.</para>
104
105 <sect3>
106 <title>It is All in My Head!</title>
107
108 <para>Yes, this is a package management technique. Some folks do not find
109 the need for a package manager because they know the packages intimately
110 and know what files are installed by each package. Some users also do not
111 need any package management because they plan on rebuilding the entire
112 system when a package is changed.</para>
113
114 </sect3>
115
116 <sect3>
117 <title>Install in Separate Directories</title>
118
119 <para>This is a simplistic package management that does not need any extra
120 package to manage the installations. Each package is installed in a
121 separate directory. For example, package foo-1.1 is installed in
122 <filename class='directory'>/usr/pkg/foo-1.1</filename>
123 and a symlink is made from <filename>/usr/pkg/foo</filename> to
124 <filename class='directory'>/usr/pkg/foo-1.1</filename>. When installing
125 a new version foo-1.2, it is installed in
126 <filename class='directory'>/usr/pkg/foo-1.2</filename> and the previous
127 symlink is replaced by a symlink to the new version.</para>
128
129 <para>Environment variables such as <envar>PATH</envar>,
130 <envar>LD_LIBRARY_PATH</envar>, <envar>MANPATH</envar>,
131 <envar>INFOPATH</envar> and <envar>CPPFLAGS</envar> need to be expanded to
132 include <filename>/usr/pkg/foo</filename>. For more than a few packages,
133 this scheme becomes unmanageable.</para>
134
135 </sect3>
136
137 <sect3>
138 <title>Symlink Style Package Management</title>
139
140 <para>This is a variation of the previous package management technique.
141 Each package is installed similar to the previous scheme. But instead of
142 making the symlink, each file is symlinked into the
143 <filename class='directory'>/usr</filename> hierarchy. This removes the
144 need to expand the environment variables. Though the symlinks can be
145 created by the user to automate the creation, many package managers have
146 been written using this approach. A few of the popular ones include Stow,
147 Epkg, Graft, and Depot.</para>
148
149 <para>The installation needs to be faked, so that the package thinks that
150 it is installed in <filename class="directory">/usr</filename> though in
151 reality it is installed in the
152 <filename class="directory">/usr/pkg</filename> hierarchy. Installing in
153 this manner is not usually a trivial task. For example, consider that you
154 are installing a package libfoo-1.1. The following instructions may
155 not install the package properly:</para>
156
157<screen role="nodump"><userinput>./configure --prefix=/usr/pkg/libfoo/1.1
158make
159make install</userinput></screen>
160
161 <para>The installation will work, but the dependent packages may not link
162 to libfoo as you would expect. If you compile a package that links against
163 libfoo, you may notice that it is linked to
164 <filename class='libraryfile'>/usr/pkg/libfoo/1.1/lib/libfoo.so.1</filename>
165 instead of <filename class='libraryfile'>/usr/lib/libfoo.so.1</filename>
166 as you would expect. The correct approach is to use the
167 <envar>DESTDIR</envar> strategy to fake installation of the package. This
168 approach works as follows:</para>
169
170<screen role="nodump"><userinput>./configure --prefix=/usr
171make
172make DESTDIR=/usr/pkg/libfoo/1.1 install</userinput></screen>
173
174 <para>Most packages support this approach, but there are some which do not.
175 For the non-compliant packages, you may either need to manually install the
176 package, or you may find that it is easier to install some problematic
177 packages into <filename class='directory'>/opt</filename>.</para>
178
179 </sect3>
180
181 <sect3>
182 <title>Timestamp Based</title>
183
184 <para>In this technique, a file is timestamped before the installation of
185 the package. After the installation, a simple use of the
186 <command>find</command> command with the appropriate options can generate
187 a log of all the files installed after the timestamp file was created. A
188 package manager written with this approach is install-log.</para>
189
190 <para>Though this scheme has the advantage of being simple, it has two
191 drawbacks. If, during installation, the files are installed with any
192 timestamp other than the current time, those files will not be tracked by
193 the package manager. Also, this scheme can only be used when one package
194 is installed at a time. The logs are not reliable if two packages are
195 being installed on two different consoles.</para>
196
197 </sect3>
198
199 <sect3>
200 <title>Tracing Installation Scripts</title>
201
202 <para>In this approach, the commands that the installation scripts perform
203 are recorded. There are two techniques that one can use:</para>
204
205 <para>The <envar>LD_PRELOAD</envar> environment variable can be set to
206 point to a library to be preloaded before installation. During
207 installation, this library tracks the packages that are being installed by
208 attaching itself to various executables such as <command>cp</command>,
209 <command>install</command>, <command>mv</command> and tracking the system
210 calls that modify the filesystem. For this approach to work, all the
211 executables need to be dynamically linked without the suid or sgid bit.
212 Preloading the library may cause some unwanted side-effects during
213 installation. Therefore, it is advised that one performs some tests to
214 ensure that the package manager does not break anything and logs all the
215 appropriate files.</para>
216
217 <para>The second technique is to use <command>strace</command>, which
218 logs all system calls made during the execution of the installation
219 scripts.</para>
220 </sect3>
221
222 <sect3>
223 <title>Creating Package Archives</title>
224
225 <para>In this scheme, the package installation is faked into a separate
226 tree as described in the Symlink style package management. After the
227 installation, a package archive is created using the installed files.
228 This archive is then used to install the package either on the local
229 machine or can even be used to install the package on other machines.</para>
230
231 <para>This approach is used by most of the package managers found in the
232 commercial distributions. Examples of package managers that follow this
233 approach are RPM (which, incidentally, is required by the <ulink
234 url="http://refspecs.linuxfoundation.org/lsb.shtml">Linux
235 Standard Base Specification</ulink>), pkg-utils, Debian's apt, and
236 Gentoo's Portage system. A hint describing how to adopt this style of
237 package management for LFS systems is located at <ulink
238 url="&hints-root;fakeroot.txt"/>.</para>
239
240 <para>Creation of package files that include dependency information is
241 complex and is beyond the scope of LFS.</para>
242
243 <para>Slackware uses a <command>tar</command> based system for package
244 archives. This system purposely does not handle package dependencies
245 as more complex package managers do. For details of Slackware package
246 management, see <ulink
247 url="http://www.slackbook.org/html/package-management.html"/>.</para>
248 </sect3>
249
250 <sect3>
251 <title>User Based Management</title>
252
253 <para>This scheme, unique to LFS, was devised by Matthias Benkmann, and is
254 available from the <ulink url="&hints-root;">Hints Project</ulink>. In
255 this scheme, each package is installed as a separate user into the
256 standard locations. Files belonging to a package are easily identified by
257 checking the user ID. The features and shortcomings of this approach are
258 too complex to describe in this section. For the details please see the
259 hint at <ulink url="&hints-root;more_control_and_pkg_man.txt"/>.</para>
260
261 </sect3>
262
263 </sect2>
264
265 <sect2>
266 <title>Deploying LFS on Multiple Systems</title>
267
268 <para>One of the advantages of an LFS system is that there are no files that
269 depend on the position of files on a disk system. Cloning an LFS build to
270 another computer with the same architecture as the base system is as
271 simple as using <command>tar</command> on the LFS partition that contains
272 the root directory (about 250MB uncompressed for a base LFS build), copying
273 that file via network transfer or CD-ROM to the new system and expanding
274 it. From that point, a few configuration files will have to be changed.
275 Configuration files that may need to be updated include:
276 <filename>/etc/hosts</filename>,
277 <filename>/etc/fstab</filename>,
278 <filename>/etc/passwd</filename>,
279 <filename>/etc/group</filename>,
280 <phrase revision="systemd">
281 <filename>/etc/shadow</filename>, and
282 <filename>/etc/ld.so.conf</filename>.
283 </phrase>
284 <phrase revision="sysv">
285 <filename>/etc/shadow</filename>,
286 <filename>/etc/ld.so.conf</filename>,
287 <filename>/etc/sysconfig/rc.site</filename>,
288 <filename>/etc/sysconfig/network</filename>, and
289 <filename>/etc/sysconfig/ifconfig.eth0</filename>.
290 </phrase>
291 </para>
292
293 <para>A custom kernel may need to be built for the new system depending on
294 differences in system hardware and the original kernel
295 configuration.</para>
296
297 <note><para>There have been some reports of issues when copying between
298 similar but not identical architectures. For instance, the instruction set
299 for an Intel system is not identical with an AMD processor and later
300 versions of some processors may have instructions that are unavailable in
301 earlier versions.</para></note>
302
303 <para>Finally the new system has to be made bootable via <xref
304 linkend="ch-bootable-grub"/>.</para>
305
306 </sect2>
307
308</sect1>
Note: See TracBrowser for help on using the repository browser.