summaryrefslogtreecommitdiffstats
path: root/chapter_17.xml
blob: 409349bd10a7932e6c8709fe5b780daf1f1b705b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "/usr/share/xml/docbook/xml-dtd-4.5/docbookx.dtd">

<chapter id="ch_pkg">
<title>Package Management</title>

<indexterm>
  <primary>Package Management</primary>
</indexterm>

<para>
Package management is an essential part of any Linux distribution.
Every piece of software included by Slackware, along with many
third-party tools are distributed as source code that can be compiled,
but compiling all those thousands of different applications and
libraries is tedious and time consuming. That's why many people prefer
to install pre-compiled software packages. In fact, when you installed
Slackware, the <application>setup</application> program primarily
worked by running package management tools on a list of packages. Here
we'll look at the various tools used for handling Slackware packages.
</para>

<section id="pkg_pktool">
<title><application>pkgtool</application></title>

<indexterm>
  <primary>pkgtool</primary>
</indexterm>

<para>
The simplest way to perform package maintenance tasks is to invoke
<application>pkgtool</application>(8), a menu-driven interface to some of
the other tools.  <application>pkgtool</application> allows you to
install or remove packages as well as view the contents of those
packages and the list of currently installed packages in a
user-friendly ncurses interface.
</para>

<imagedata fileref="img/pkgtool.png" format="PNG"/>

<para>
<application>pkgtool</application> is a convenient and easy way to
perform the most basic tasks, but for more advanced work more flexible
tools are needed.
</para>

</section>

<section id="pkg_install-remove-upgrade">
  <title>Installing, Removing, and Upgrading Packages</title>

<indexterm>
  <primary>installpkg</primary>
</indexterm>
<indexterm>
  <primary>removepkg</primary>
</indexterm>
<indexterm>
  <primary>upgradepkg</primary>
</indexterm>
<indexterm>
  <primary>Installing software</primary>
</indexterm>

<para>
While <application>pkgtool</application> scores points for convenience,
<application>installpkg</application>(8) is much more capable of
handling odd tasks, such as quickly installing a single package, 
installing an entire disk set of packages, or scripting an install.
<application>installpkg</application> takes a list of packages to
install, and simply installs them without asking any questions. Like
all Slackware package management tools, it assumes that you know what
you're doing and doesn't pretend to be smarter than you. In its
simplest form, <application>installpkg</application> simply takes a
list of packages to install, and does exactly what you would expect.
</para>

<screen><prompt>darkstar:~&#35; </prompt><userinput>installpkg blackbox-0.70.1-i486-2.txz</userinput>
Verifying package blackbox-0.70.1-i486-2.txz.
Installing package blackbox-0.70.1-i486-2.txz:
PACKAGE DESCRIPTION:
&#35; blackbox (Blackbox window manager)
&#35;
&#35; Blackbox is that fast, light window manager you have been looking for
&#35; without all those annoying library dependencies.
&#35;
&#35; Also included in this package is the bbkeys utility for controlling
&#35; keyboard shortcut commands from within Blackbox.
&#35;
&#35; The Blackbox home page is http://blackboxwm.sourceforge.net
&#35;
Package blackbox-0.70.1-i486-2.txz installed.</screen>

<para>
You can of course install multiple packages at a time, and in fact use
shell wild cards.  The following installs all of the "N" series
packages from a mounted CD-ROM:
</para>

<screen><prompt>darkstar:~&#35; </prompt><userinput>installpkg &#47;mnt&#47;cdrom&#47;slackware&#47;n&#47;&#42;.txz</userinput></screen>

<para>
  At any given time, you can see what packages are installed on your
  system by listing the contents of &#47;var&#47;log&#47;packages,
  which lists not only every application on your system but also the
  version number. Should you want to know what individual files were
  installed as a part of that package, <application>cat</application>
  the contents of the package:
</para>

<screen>
<prompt>darkstar:~&#35; </prompt> <userinput>cat &#47;var&#47;log&#47;packages&#47;foo-1.0-x86_64.txz</userinput>
</screen>

<para>
  This will return everything from the size of the package, a
  description of what it does, and the name and location of every file
  installed as a part of the package.
</para>

<para>
  Removing a package is every bit as easy as installing one. As you
  might expect, the command to do this is
  <application>removepkg</application>(8). Simply tell it which
  packages to remove, and <application>removepkg</application> will
  check the contents of the package database and remove all the files
  and directories for that package with one caveat. If that file is
  included in multiple installed packages, it will be skipped and if a
  directory has new files in it, the directory will be left in
  place. Because of this, removing packages takes a good while longer
  than installing them.
</para>

<screen><prompt>darkstar:~&#35; </prompt><userinput>removepkg blackbox-0.70.1-i486-2.txz</userinput>
</screen>

<para>
Finally, upgrading is just as easy with (you guessed it),
<application>upgradepkg</application>(8) which first installs a new
package, then removes whatever files and directories are left-over from
the old package. One important thing to remember is that
<application>upgradepkg</application> doesn't check to see if the
previously installed package has a higher version number than the &#34;new&#34;
package, so it can also be used to downgrade to older versions.
</para>

<screen><prompt>darkstar:~&#35; </prompt><userinput>upgradepkg blackbox-0.70.1-i486-2.txz</userinput>

+==============================================================================
| Upgrading blackbox-0.65.0-x86_64-4 package using
.&#47;blackbox-0.70.1-i486-2.txz
+==============================================================================

Pre-installing package blackbox-0.70.1-i486-2...

Removing package
&#47;var&#47;log&#47;packages&#47;blackbox-0.65.0-x86_64-4-upgraded-2010-02-23,16:50:51...
  --> Deleting symlink &#47;usr&#47;share&#47;blackbox&#47;nls&#47;POSIX
  --> Deleting symlink &#47;usr&#47;share&#47;blackbox&#47;nls&#47;US_ASCII
  --> Deleting symlink &#47;usr&#47;share&#47;blackbox&#47;nls&#47;de
  --> Deleting symlink &#47;usr&#47;share&#47;blackbox&#47;nls&#47;en
  --> Deleting symlink &#47;usr&#47;share&#47;blackbox&#47;nls&#47;en_GB
...
Package blackbox-0.65.0-x86_64-4 upgraded with new package
.&#47;blackbox-0.70.1-i486-2.txz.</screen>

<para>
All of these tools have useful arguments. For example, the
<arg>--root</arg> to <application>installpkg</application> will install
packages into an arbitrary directory. The <arg>--dry-run</arg> argument
will instruct <application>upgradepkg</application> to simply tell you
what it would attempt without actually making any changes to the
system. For complete details, you should &#40;as always&#41; refer to the man
pages.
</para>

</section>

<section id="pkg_compression">
  <title>Package Compression Formats</title>

<para>
  In the past, all Slackware packages were compressed with the
  <application>gzip</application>(1) compression utility, which was a
  good compromise between compression speed and size.  Recently, new
  compression schemes have been added and the package management tools
  have been upgraded to handle these. Today, official Slackware
  packages are compressed with the <application>xz</application>
  utility and end with .txz extensions.  Older packages (and many
  third party packages) still use the .tgz extension.
</para>

<para>
  It's worth emphasizing that .tgz and .txz (or, more succinctly, .t?z
  files) are very standard, non-unique extensions for compressed .tar
  files. This has many advantages; they're easy to build on nearly any
  UNIX system (many other package formats require special toolchains),
  and they're just as simple to de-construct.
</para>

<para>
  However, it is also important to realize that just because all Slackware
  packages <emphasis>are</emphasis> .t?z files, not all .t?z files are
  Slackware packages. <application>Installpkg</application> won't
  magically install just any .t?z file, only Slackware packages.
</para>

<section id="pkg_slackpkg">
<title><application>slackpkg</application></title>

<indexterm>
  <primary>
    slackpkg
  </primary>
</indexterm>

<para>
  <application>Slackpkg</application> is an automated tool for
  management of Slackware Linux Packages. It originally appeared in
  &#47;extra for the release of slackware-12.1, and since the release
  of slackware-12.2 it has been included in the ap&#47; series of a
  base installation.
</para>

<para>
  Just as you are able to use <application>installpkg</application> to
  install Slackware packages from the &#47;extra directory included on
  the install media, you can use <application>slackpkg</application>
  to pull packages from the Internet and install them. This is
  particularly useful for security updates or significant application
  upgrades that are posted to the Slackware servers, some of which you
  may want to start using on your own system.
</para>

<para>
  Without <application>slackpkg</application>, the process would be:
</para>

<orderedlist>
  <listitem>
    <para>
      Notice in the Slackware changelog that an update has been
      released.
    </para>
  </listitem>

  <listitem>
    <para>
      Look on your local Slackware mirror to find a download link of
      the package.
    </para>
  </listitem>

  <listitem>
    <para>
      Download the package from a Slackware mirror to your hard drive.
    </para>
  </listitem>

  <listitem>
    Use either <application>installpkg</application> or
  <application>pkgtool</application> to install the downloaded
  package.
  </listitem>
</orderedlist>

<para>
  With <application>slackpkg</application>, this is reduced to:
</para>

<orderedlist>
  <listitem>
    <para>
      Notice in the Slackware changelog that an update for
      <application>foo</application> has been released.
    </para>
  </listitem>

  <listitem>
    <para>
      <command>slackpkg</command> <arg>install</arg> foo
    </para>
  </listitem>
</orderedlist>

<para>
  Clearly, this streamlines a fairly common task.
</para>

<para>
 To use <application>slackpkg</application>, configure your system
 with a Slackware mirror by editing
 <filename>&#47;etc&#47;slackpkg&#47;mirrors</filename> as root. Find
 the mirror that is associated with your Slackware version and
 architecture, and uncomment it. This list of mirrors offers ftp and
 http access, but you must uncomment <emphasis>only one</emphasis>
 mirror.
</para>

<para>
  Once a mirror has been selected, update the list of remote files by
  issuing the initial command <command>slackpkg update</command>. This
  should be done any time you notice that a new package has been
  posted (regularly checking in with the Slackware changelog is
  recommended; see <xref linkend="ch_updates"/> for more information).
</para>

<para>
  To search for a package, use <command>slackpkg search foo</command>,
  and to install use <command>slackpkg install foo</command>.
</para>

<para>
  Once a package has been installed with
  <application>slackpkg</application>, it can be removed or upgraded
  using <application>pkgtool</application> and the other package
  management commands as detailed in <xref
  linkend="pkg_install-remove-upgrade"/>.
</para>

<para>
  For more information see the <application>man</application> pages
  for slackpkg(8) and slackpkg.conf(5), and see its website at <ulink
  url="http://www.slackpkg.org/">http://www.slackpkg.org/</ulink>
</para>

</section>

<section id="pkg_rpm2tgz">
  <title>rpm2tgz</title>

<indexterm>
  <primary>rpm2tgz</primary>
</indexterm>

<para>
  One of the most ubiquitous package formats for Linux software is
  RPM; it's not uncommon to find a developer offering their
  application for download as either source code or an RPM file, and
  no more. In this case, you would have three options:
</para>

<orderedlist>
  <listitem>
    <para>
      Build your own Slackware package.
    </para>
  </listitem>

  <listitem>
    <para>
      Compile and install directly from source code.
    </para>
  </listitem>

  <listitem>
    <para>
      Convert and install from RPM.
    </para>
  </listitem>
</orderedlist>

<para>
  Building from source code or creating your own Slackware package is
  usually not as complex as you might think but installing directly from
  source code is generally discouraged because there is no easy way to
  track what has been installed on your system after issuing the
  <command>make install</command> command. Building your own Slackware
  packages is outside the scope of this chapter. So this leaves us with
  the helpful tool <application>rpm2tgz</application>.
</para>

<indexterm>
<primary>rpm</primary>
<secondary>redhat package manager</secondary>
</indexterm>

<para>
  <application>rpm2tgz</application> converts RPM packages into a
  Slackware package that can then be installed via
  <application>pkgtool</application> or
  <application>installpkg</application>. This circumvents the need to
  create your own Slackware package but grants you the benefit of
  being able to remove, update, and track what you've installed.
</para>

<warning>
  <para>
    While a Slackware package is just a shell script and source code,
    an RPM package can by comparison be a maze of dependency listings
    and special instructions. Therefore,
    <application>rpm2tgz</application> will not always work,
    especially on very complex applications, and it will never
    magically resolve dependencies.
  </para>
</warning>

<para>
  To try <application>rpm2tgz</application>, download an RPM file from
  a trusted source and convert it:
</para>

<programlisting>
  rpm2tgz foo-x.x.xx.rpm
</programlisting>

<para>
  The result is a .tgz file, so after the conversion is finished, the
  original RPM can safely be discarded. Use
  <application>installpkg</application> to install the Slackware
  package you've just created, provided that you've
  installed all dependency code for the application to actually function.
</para>

</section>
</section>
</chapter>