104.

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); }

Book: LPI Linux Certification in a Nutshell
Section: Chapter 14.  Linux Installation and Package Management (Topic 2.2)



14.5 Objective 5: Use Debian Package Management

The Debian package management system is a versatile and automated suite of tools used to acquire and manage software packages for Debian Linux. The system automatically handles many of the management details associated with interdependent software running on your system.

14.5.1 Debian Package Management Overview

Each Debian package contains program and configuration files, documentation, and noted dependencies on other packages. The names of Debian packages have three common elements, including:

Package name

A Debian package name is short and descriptive. When multiple words are used in the name, they are separated by hyphens. Typical names include binutils, kernel-source, and telnet.

Version number

Each package has a version number. Most package versions are the same as that of the software they contain, thus the format of package versions varies from package to package. Most are numeric, with major, patch, and release numbers, but other information may appear as well. Typical versions are 0.6.7-7, 0.96a-14, 6.05, 80b2-8, and 2.0.7.19981211. The version is separated from the package name with an underscore.

A file extension

By default, all Debian packages end with .deb file extension.

Figure 14-1 illustrates a Debian package name.

Figure 14-1. The structure of a Debian GNU/Linux package name
figs/lpi_1401.gif

14.5.2 Managing Debian Packages

The original Debian package management tool is dpkg, which operates directly on .deb package files and can be used to automate the installation and maintenance of software packages. The alternative apt-get tool operates using package names, obtaining them from a predefined source (such as CD-ROMs, FTP sites, etc.). Both tools work from the command line.

The dselect command offers an interactive menu that allows the administrator to select from a list of available packages and mark them for subsequent installation. The alien command allows the use of non-Debian packages, such as the Red Hat RPM format.

For complete information on Debian package management commands, see details in their respective manpages.

dpkg

Syntax

dpkg [options] action

Description

The Debian package manager command, dpkg, consists of an action that specifies a major mode of operation as well as zero or more options, which modify the action's behavior.

The dpkg command maintains package information in /var/lib/dpkg. Two files located there of particular interest are:

available

The list of all available packages.

status

Contains package attributes, such as whether it is installed or marked for removal.

These files are modified by dpkg, dselect, and apt-get, and it is unlikely that they will ever need to be edited.

Frequently used options

-E

Using this option, dpkg will not overwrite a previously installed package of the same version.

-G

Using this option, dpkg will not overwrite a previously installed package with an older version of that same package.

-R (also -- recursive)

Recursively process package files in specified subdirectories. Works with -i, -- install, -- unpack, and so on.

Frequently used actions

-- configure package

Configure an unpacked package. This involves setup of configuration files.

-i package_ file (also -- install package_ file)

Install the package contained in package_ file. This involves backup of old files, unpacking and installation of new files, and configuration.

-l [pattern] (also -- list [pattern])

Display information for installed package names that match pattern.

-L package (also -- listfiles package)

List files installed from package.

-- print-avail package

Display details found in /var/lib/dpkg/available about package.

-- -purge package

Remove everything for package.

-r package (also -- remove package)

Remove everything except configuration files for package.

-s package (also -- status package)

Report the status of package.

-S search_pattern (also -- search search_ pattern)

Search for a filename matching search_ pattern from installed packages.

-- unpack package_ file

Unpack package_ file, but don't install the package it contains.

14.5.2.1 Example 1

Install a package using dpkg -i with the name of an available package file:

# dpkg -i ./hdparm_3.3-3.deb (Reading database ... 54816 files and directories    currently installed.) Preparing to replace hdparm 3.3-3 (using hdparm_3.3-3.deb) Unpacking replacement hdparm ... Setting up hdparm (3.3-3) ...

Alternatively, use apt-get install with the name of the package. In this case, the package comes from the location or locations configured in /etc/apt/sources.list. For this example, the location is http://http.us.debian.org/:

# apt-get install elvis Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed:   libncurses4 xlib6g The following NEW packages will be installed:   elvis 2 packages upgraded, 1 newly installed, 0 to remove    and 376 not upgraded. Need to get 1678kB of archives. After unpacking 2544kB    will be used. Do you want to continue? [Y/n] y Get:1 http://http.us.debian.org stable/main    libncurses4 4.2-9 [180kB] Get:2 http://http.us.debian.org stable/main    xlib6g 3.3.6-11 [993kB] Get:3 http://http.us.debian.org stable/main    elvis 2.1.4-1 [505kB] Fetched 1678kB in 4m11s (6663B/s) (Reading database ... 54730 files and directories    currently installed.) Preparing to replace libncurses4 4.2-3 (using    .../libncurses4_4.2-9_i386.deb) ... Unpacking replacement libncurses4 ... (installation continues...)
14.5.2.2 Example 2

Upgrading a package is no different from installing one. However, you should use the -G option when upgrading with dpkg to ensure that the installation won't proceed if a newer version of the same package is already installed.

14.5.2.3 Example 3

Use dpkg -r or dpkg -- purge to remove a package:

# dpkg --purge elvis (Reading database ... 54816 files and directories    currently installed.) Removing elvis ... (purge continues...)
14.5.2.4 Example 4

Use the dpkg -S command to find a package containing specific files. In this example, apt-get is contained in the apt package:

# dpkg -S apt-get apt: /usr/share/man/man8/apt-get.8.gz apt: /usr/bin/apt-get
14.5.2.5 Example 5

Obtain package status information, such as version, content, dependencies, integrity, and installation status, using dpkg -s:

# dpkg -s apt Package: apt Status: install ok installed Priority: optional Section: admin Installed-Size: 1388 (listing continues...)
14.5.2.6 Example 6

List the files in a package using dpkg -L and process the output using grep or less:

# dpkg -L apt | grep '^/usr/bin' /usr/bin /usr/bin/apt-cache /usr/bin/apt-cdrom /usr/bin/apt-config /usr/bin/apt-get
14.5.2.7 Example 7

List the installed packages using dpkg -l; if you don't specify a pattern, all packages will be listed:

# dpkg -l xdm ii  xdm             3.3.2.3a-11    X display manager
14.5.2.8 Example 8

Use dpkg -S to determine the package from which a particular file was installed with the filename:

# dpkg -S /usr/bin/nl textutils: /usr/bin/nl
apt-get

Syntax

apt-get [options] [command] [package_name ...]

Description

The apt-get command is part of the Advanced Package Tool (APT) management system. It does not work directly with .deb files like dpkg, but uses package names instead. apt-get maintains a database of package information that enables the tool to automatically upgrade packages and their dependencies as new package releases become available.

Frequently used options

-d

Download files, but do not install. This is useful when you wish to get a large number of package files but delay their installation to prevent installation errors from stopping the download process.

-s

Simulate the steps in a package change, but do not actually change the system.

-y

Automatically respond "yes" to all prompts, instead of prompting you for a response during package installation/removal.

Frequently used commands

dist-upgrade

This command is used to automatically upgrade to new versions of Debian Linux.

install

The install command is used to install or upgrade one or more packages by name.

remove

This command is used to remove the specified packages.

update

Running apt-get update fetches a list of currently available packages. This is typically done before any changes are made to existing packages.

upgrade

The upgrade command is used to safely upgrade a system's complete set of packages to current versions. It is conservative and will not process upgrades that could cause a conflict or break an existing configuration; it also will not remove packages.

Additional commands and options are available. See the apt-get manpage for more information.

apt-get uses /etc/apt/sources.list to determine where packages should be obtained. This file is not in the Objectives for Exam 102.

Example

Remove the elvis package using apt-get.

# apt-get remove elvis Reading Package Lists... Done Building Dependency Tree... Done The following packages will be REMOVED:   elvis 0 packages upgraded, 0 newly installed, 1 to remove    and 376 not upgraded. Need to get 0B of archives. After unpacking 1363kB    will be freed. Do you want to continue? [Y/n] y (Reading database ... 54816 files and directories    currently installed.) Removing elvis ... (removal continues...)

In this example, the user is required to respond with y when promted to continue. Using the -y option to apt-get would eliminate this interaction.

dselect

Syntax

dselect

Description

dselect is an interactive, menu-driven, frontend tool for dpkg and is usually invoked without parameters. The dselect command lets you interactively manage packages by selecting them for installation, removal, configuration, and so forth. Selections are made from a locally stored list of available packages, which may be updated while running dselect. Package actions initiated by dselect are carried out using dpkg.

alien

Syntax

alien [--to-deb] [--patch=patchfile] [options] file

Description

Convert to or install a non-Debian (or "alien") package. Supported package types include Red Hat .rpm, Stampede .slp, Slackware .tgz, and generic .tar.gz files. rpm must also be installed on the system in order to convert an RPM package into a .deb package. The alien command produces an output package in Debian format by default after conversion.

Frequently used option

-i

Automatically install the output package and remove the converted package file.

Example

Install a non-Debian package on Debian system using alien with the -i option:

alien -i package.rpm

On the Exam

dselect, apt-get, and alien are important parts of Debian package management, but detailed knowledge of dpkg is of primary importance for Exam 102.

 


LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2000
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net