source: introduction/important/pkgmgt.xml@ 3d760b6

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 6.0 6.1 6.2 6.2.0 6.2.0-rc1 6.2.0-rc2 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb v5_1 v5_1-pre1 xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 3d760b6 was 3d760b6, checked in by Tushar Teredesai <tushar@…>, 20 years ago

Added package management section

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

  • Property mode set to 100644
File size: 9.2 KB
Line 
1<sect1 id="intro-important-pkgmgt">
2<?dbhtml filename="pkgmgt.html" dir="introduction"?>
3<title>Package Management</title>
4
5<para>Package Management has been one of the often requested addition
6to the <acronym>LFS</acronym> Book. A Package Manager allows tracking
7the installation of files making it easy to remove and upgrade packages.
8And before you begin to wonder, NO - this section does not talk about any
9particular package manager, nor does it recommend one. What it provides is
10a roundup of the more popular techniques and how they work. The perfect
11package manager for you may be among these techniques or may be a combination
12of two or more of these techniques. This section also mentions
13in brief about some upgrade issues.</para>
14
15<para>Some reasons why no package manager is mentioned in <acronym>LFS</acronym>
16or <acronym>BLFS</acronym>:</para>
17
18<itemizedlist>
19<listitem><para>Dealing with package management takes the focus away from
20the goals of these books - Teaching how a Linux System is built.</para></listitem>
21<listitem><para>There are multiple solutions for package management, each having
22its strengths and drawbacks.</para></listitem>
23</itemizedlist>
24
25<para>There are some hints written on the topic of package management. Visit
26the <ulink url="http://www.linuxfromscratch.org/hints/">Hints subproject</ulink>
27to find if one of them fits your need.</para>
28
29
30<sect2>
31<title>Upgrade Issues</title>
32
33<para>Following are some points that you should be aware of when upgrading
34pacakges, especially on a running system.</para>
35
36<itemizedlist>
37<listitem><para>It is recommended that if one of the toolchain package (glibc, gcc,
38binutils) needs to be upgraded to a newer minor vesion, it is safer to rebuild
39<acronym>LFS</acronym>. Though you <emphasis>may</emphasis> be able to get by by
40rebuilding all the packages in their dependency order. We do not recommend the
41latter. For example if glibc-2.2.x needs to be updated to glibc-2.3.x, it is safer
42to rebuild. For micro version updates, a simple reinstallation usually works, but
43is not guaranteed. For example, upgrading from glibc-2.3.1 to glibc-2.3.2 will not
44usually cause any problems.</para></listitem>
45<listitem><para>If a package containing a shared library is updated, and if the
46soname of the library changes, then all the packages dynamically linked to the
47library need to be recompiled to link against the newer library. (Note that there
48is no corelation between the package version and the soname of the library.) For
49example, consider a package foo-1.2.3 that installs a shared library with soname
50<filename>libfoo.so.1</filename>. Say you upgrade the package to a newer version
51foo-1.2.4 that installs a shared library with soname <filename>libfoo.so.2</filename>.
52In this case, all packages that are dynamically linked to <filename>libfoo.so.1</filename>
53need to be recompiled to link against <filename>libfoo.so.2</filename>. Note that
54you should not remove the previous libraries till the dependent packages are
55recompiled.</para></listitem>
56<listitem><para>If you are upgrading a running system, be on the lookout for
57packages that use <command>cp</command> instead of <command>install</command> to
58install files. The latter command is usually safer if the executable or library
59is already loaded in memory.</para></listitem>
60</itemizedlist>
61
62</sect2>
63
64
65<sect2>
66<title>Package Management Techniques</title>
67
68<para>The following are some common package management techniques.</para>
69
70<sect3>
71<title>Its all in my head!</title>
72
73<para>Yes, this is a package management technique. Some folks do not find the
74need for a package manager because they know the packages intimately and know
75what files are installed by each package. Some users also do not need any
76package management because they plan on rebuilding the entire <acronym>LFS</acronym>
77when a package is changed.</para>
78
79</sect3>
80
81<sect3>
82<title>Install in seperate directories</title>
83
84<para>This is a simplistic package management that does not need any extra package
85to manage the installations. Each package is installed in a seperate directory.
86For example, package foo-1.1 is installed in <filename>/usr/pkg/foo-1.1</filename>
87and a symlink is made from <filename>/usr/pkg/foo</filename> to
88<filename>/usr/pkg/foo-1.1</filename>. When installing a new version foo-1.2,
89it is installed in <filename>/usr/pkg/foo-1.2</filename> and the previous
90symlink is replaced by a symlink to the new vesion.</para>
91
92<para>The environment variables such as those
93mentioned in <xref linkend="appendices-generic"/> need to be expanded to
94include <filename>/usr/pkg/foo</filename>. For more than a few packages,
95this scheme becomes unmanagable.</para>
96
97</sect3>
98
99<sect3>
100<title>Symlink style package management</title>
101
102<para>This is a variation of the previous package management technique. Each package
103is installed similar to the previous scheme. But instead of making the symlink,
104each file is symlinked into <filename>/usr</filename> hierarchy. This removes the need
105to expand the environment variables. Though the symlinks can be created by the user,
106to automate the creation, many package managers have been written on this approach.
107Few of the popular ones are Stow, Epkg, Graft, and Depot.</para>
108
109<para>The installation needs to be faked, so that the package thinks that it is
110installed in <filename>/usr</filename> though in reality it is installed in
111<filename>/ust/pkg</filename> hierachy. Installing in this manner is not usually a trivial
112task. For example, consider that you are installing a package libfoo-1.1. The following
113instructions may not install the package properly:</para>
114
115<screen><userinput><command>./configure --prefix=/usr/pkg/libfoo/1.1 &amp;&amp;
116make &amp;&amp;
117make install</command></userinput></screen>
118
119<para>The installation will work, but the dependent packages may not link to
120libfoo as you would expect. If you compile a package that links against libfoo,
121you may notice that it is linked to <filename>/usr/pkg/libfoo/1.1/lib/libfoo.so.1</filename>
122instead of <filename>/usr/lib/libfoo.so.1</filename> as you would expect. The correct
123approach is to use <envar>DESTDIR</envar> strategy to fake installation of the package.
124This approach works as follows:</para>
125
126<screen><userinput><command>./configure --prefix=/usr &amp;&amp;
127make &amp;&amp;
128make DESTDIR=/usr/pkg/libfoo/1.1 install</command></userinput></screen>
129
130<para>Most of the packages do support this approach, but there are some which do not.
131For the non-compliant packages, you may either need to manually install the package,
132or you may find that it is easier to install some problematic packages into
133<filename>/opt</filename>.</para>
134
135</sect3>
136
137<sect3>
138<title>Timestamp based</title>
139
140<para>In this technique, a file is timestamped before the installation of the package.
141After the installation, a simple use of the <command>find</command> command with the
142appropriate options can generate a log of all the files installed after the timestamp
143file was created. A package manager written with this approach is install-log.</para>
144
145<para>Though this scheme has the advantage of being simple, it has two drawbacks.
146If during installation, the files are installed with any timestamp other than the
147current time, those files will not be tracked by the package manager. Also, this
148scheme can only be used when one package is installed at a time. The logs are not
149reliable if two packages are being installed on two different consoles.</para>
150
151</sect3>
152
153<sect3>
154<title>LD_PRELOAD based</title>
155
156<para>In this approach, a library is preloaded before installation and during
157installation, this library tracks the packages that are being installed by
158attaching itself to various executables such as <command>cp</command>,
159<command>install</command>, <command>mv</command> and tracking the system
160calls that modify the filesystem. For this approach to work, all the executables
161need to be dymanically linked without the suid or sgid bit. Preloading the
162library may cause some unwanted side-effects during installation.</para>
163
164</sect3>
165
166<sect3>
167<title>Creating Package Archives</title>
168
169<para>In this scheme, the package installation is faked into a seperate
170tree as described in the Symlink style package management. After the
171installation, a package archive is created using the installed files.
172This archive is then used to install the package either on the local
173machine or can even be used to install the package on other machines.</para>
174
175<para>This approach is used by most of the package managers found in the
176commercial distributions. Examples of package Managers that follow this
177approach are RPM, pkg-utils, Debian's apt, Gentoo's Portage system.</para>
178
179</sect3>
180
181<sect3>
182<title>User Based Management</title>
183
184<para>This scheme, that is unique to <acronym>LFS</acronym>, was
185devised by Matthias Benkmann, and is available from the <ulink
186url="http://www.linuxfromscratch.org/hints/">Hints Project</ulink>.
187In this scheme, each package is installed as a seperate user into
188the standard locations. Files belonging to a package are easily
189identified by checking the user id. The features and shortcomings
190of this approach are too complex to describe in this section. For
191the details please see the hint at <ulink
192url="http://www.linuxfromscratch.org/hints/downloads/files/more_control_and_pkg_man.txt"/>.</para>
193
194</sect3>
195
196</sect2>
197
198
199</sect1>
Note: See TracBrowser for help on using the repository browser.