software package management

If we spend any time in the Linux community,we hear many options as to which of many Linux distributions is "best." Often,these discussions get really silly,focusing on such things as the prettiness(漂亮,可爱) of the desktop background (some people won't use Ubuntu because its default color scheme is brown!) and other trivial matters.

The most important determinant of distribution quality is the packaging system and the vitality(活力,生气,生命力) of the distribution's support community.As we spend more time with Linux,we see that its software landscape(风景,景色) is extremely dynamic.Things are constantly changing.Most of the top-tier(一线) Linux distributions release new versions every six months and many individual(独立的) program updates every day.To keep up with this blizzard(暴风雪) of software,we need good tools for package management.

Package management is a method of installing and maintaining software on the system.Today,most people can satisfy all of their software needs by installing packages from their Linux distributor.This contrasts(对比,对照) with the early days of Linux,when one had to download and compile source code in order to install software.Not that there is anything wrong with compiling source code;in fact,having access to source code is the great wonder of Linux.It gives us(and everybody else) the ability to examine and improve the system.It's just that having a pre-compiled package is faster and easier to deal with.In this chapter,we will look at some of the command line tools used for package management.While all of the major distributions provide powerful and sophisticated(老练的,老于世故的) graphical programs for maintaining the system,it is important to learn about the command line programs,too.They can perform many tasks that are difficult(or impossible) to do with their graphical counterparts.

 

packing system

Different distributions use different packing systems and as a general rule,a package intended for one distribution is not compatible with another distribution.Most distributions fall into one of two camps of packaging technologies:the Debian ".deb" camp and the Red Hat ".rpm" camp.There are some important execptions such as Gentoo,Slackware,and Foresight,but most others use one of these two basic systems.

Table 15-1:Major Packing System Families

Packing System Distributions(Partial Listing)
Debian Style(.deb) Debian,Ubuntu,Xandros,Linspire
Red Hat Style(.rpm) Fedora,CentOS,Red Hat Enterprise Linux,OpenSUSE,Mandriva,PCLinuxOS

 

How does software package mangement system work?

The method of software distribution found in the proprietary(控股公司) software industry usually entails buying a piece of installation media such as an "install disk" and then running an "installation wizard" to install a new application on the system.

Linux doesn't work that way.Virtually all software for a Linux system will be found on the Internet.Most of it will be provided by the distribution vendor(小贩,卖主) in the form of package files and the rest will be available in source code form that can be installed manually.We'll take a little about how to install software by compiling(收集) source code in a later chapter.

 

Package file

The basic unit of software in a packing system is the package file,A package file is a compressed collection of files that comprise(包含,由...组成) the software package.A package may consist of numerous programs and data files that support the programs.In addition to the files to be installed,the package file also includes metadata about the package,such as a text description of the package and its contents.Additionally,many package contain pre-  and post-installation scripts that perform configruation tasks before and after the package installation.

Package files are created by a person known as a package maintainer,often(but not always) an employee of the distribution vendor.The package maintainer gets the software in source code form from the upstream provider(the author of the program),compiles it,and creates the package metadata and any necessary installation scripts.Often,the package maintainer will apply modifications to the original source code to improve the program's integration(结合,整合,一体化) with the other parts of the Linux distribution.

 

Resource library

While some software projects choose to perform their own packaging and distribution,most packages today are created by the distribution vendors and interested third parties.Packages are made available to the users of a distribution in central repositories that may contain many thousands of packages,each specially built and maintained for the distribution.

A distribution may maintain several different repositories(存放处,储藏室,仓库,宝库) for different stages of the software  development life cycle.For example,there will usually be a "testing" repository that contains packages that have just been built and are intended for use by brave souls who are looking for bugs before they are released for general distribution.A distribution will often have a "development" repository where work-in-progress packages destined for inclusion in the distribution's next major release are kept.

A distribution may also also have related third-party repositories.These are often needed to supply software that,for legal reasons such as patents(专利权,专利) or DRM anti-circumvention(反规避) issues,cannot be included with the distribution.Perhaps the best known case is that of encrypted(加密,将...译成密码) DVD support,which is not legal in the United States.The third-party repositories operate in countries where software patents(专利权,专利) and anti-circumention laws do not apply.These repositories are usually wholly(完全地,全部) independent of the distribution they support and to use them,one must know about them and manually include them in the configuration files for the package management system.

 

Dependence

Programs seldom "standalone;" rather they rely on the presence of other software components to get their work done.Common activities,such as input/output for example,are handled by routines shared by many programs.These routines are stored in what are called shared libraries,which provide essential services to more than one program.If a package requires a shared resource such as a shared library,it is said to have a dependency.Modern package management systems all provide some method of dependency resolution to ensure that when a package is installed,all of its dependencies are installed,too.

 

Top and bottom package tools

Package management systems usually consist of two types of tools:low-level tools which handle tasks such as installing and removing package files,and high-level tools that perform metadata searching and dependency resolution.In this chapter,we will look at the tools supplied with Debian-style systems(such as Ubuntu and many others) and those used by recent Red Hat products.While all Red Hat-style distributions rely on the same low-level program(rpm),they use different high-level tools.For our discussion,we will cover the high-level program yum,used by Fedora,Red Hat Enterprise Linux,and CentOS.Other Red Hat-Style distributions provide high-level tools with comparable(类似的,同类的,相当的) features.

 

Table15-2:Packing System Tools

Distributions Low-Level Tools High-Level Tools
Debian-Style dpkg apt-get,aptitude
Fedora,Red Hat Enterprise Linux,CentOS rpm yum

 

Common software package management tasks

There are many operations that can be performed with the command line package management tools.We will look at the most common.Be aware that the low-level tools also support creation(创造) of  package files,an activity outside the scope of  this book.In the discussion below,the term "package_name" refers to the actual name of a package rather than the term "package_file," which is the name of the file that contains the package.

 

Find the software packages in resource library

Using the high-level tools to search repository metadata, a package can be located based on its name or description.

Table 15-3:Package Search Commands

Style Command(s)
Debian apt-get update;apt-cache search search_string
Red Hat yum search search_string

Example:To search a yum repository for the emacs text editor,this command could be used:

 

Install a software package from the resource library

High-level tools permit a package to be downloaded from a repository and installed with full dependency resolution(解决).

Table 15-4:Package Installation Commands

Style Commands
Debian apt-get update;apt-get install package_name
Red Hat yum install package_name

Example:To install the emacs text editor from an apt repository:

 

Install software  package from file

If a package file has been downloaded from a source other than a repository,it can be installed directly (through without dependency resolution) using a low-level tool.

Table 15-5:Low-Level Package

Installation Commands

Style Command(s)
Debian dpkg --install package_file
Red Hat rpm -i package_file

Example:If the emacs-22.1-7.fc7-i386.rpm package file had been downloaded from a non-reponsitory site,it would be installed this way:

Note:Since this technique uses the low-level rpm program to perform the installation,no dependency resolution is performed.If rpm discovers a missing dependency,rpm will exit with an error.

 

Uninstalled software

Packages can be uninstalled using either the high-level or low-tools.The high-level tools are shown below.

Table 15-6:Package Removel Commands

Style Command(s)
Debian apt-get remove package_name
Red Hat yum erase package_name

Example:To uninstall the emacs package from a Debian-style system:

 

Update software package by resource library

The most common package management task is keeping the system up-to-date with the latest packages.The high-level tools can perform this vital(极重要的,必不可少的) task in one single step.

Table 15-7:Package Update Commands

Style Command(s)
Debian apt-get update;apt-get upgrade
Red Hat yum update

Example:To apply any available updates to the installed packages on a Debian-style system:

Update software by software package file

If an updated version of a package has been downloaded from a non-repository source,it can be installed,replacing the previous version:

Table 15-8:Low-Level Package

Upgrade Commands

Style Command(s)
Debian dpkg --install package_file
Red Hat rpm -U package_file

Example:Updating an existing installation of emacs to the version contained in the package file emacs to the version contained in the package file emacs-22.1-7.fc7-i386.rpm on a Red Hat system:

Note:dpkg does not have a specific option for upgrading a  package versus(对j) installing one as rpm does.(rpm程序安装一个软件包和升级一个软件包所用的选项是不同的,而dpkg程序所用的选项是相同的)

 

List packages installed

These commands can be used to display a list of all the packages installed on the system:

Table 15-9:Package

Listing Commands

Style Command(s)
Debian dpkg --list
Red Hat rpm -qa

 

Determines whether a software package is installed

These low-level tools can be used to display whether a specified package is installed:

Table 15-10:Package Status Commands

Style Command(s)
Debian dpkg --status package_name
Red Hat rpm -q package_name

Example:To determine if the emacs package is installed on a Debian style system:

 

Display a description of the package

If the name of an installed package is known,the following commands can be used to display a description of the package:

Table 15-11:Package Information

Commands

Style Command(s)
Debian apt-cache show package_name
Red Hat yum info package_name

Example:To see a description of the emacs package on a Debian-style system:

 

Find packages that have installed a file

To determine what package is responsible for the installation of a particular file,the following commands can be used:

Table 15-12:Package File

Identification Commands

Style Command(s)
Debian dpkg --search file_name
Red Hat rpm -qf file_name

Example:To see what package installed the /usr/bin/vim file on a Red Hat system:

 

Summing up

In the chapters that follow,we will explore many different programs covering a wide range of application areas.While most of these programs are commonly installed by default,we may need to install additional packages if necessary programs are not already installed on your system.Wiith our newfound knowledge(and appreciation) of package management,we should have no problem installing and managing the programs we need.

 

The Linux Software Installation Myth(谣言)

People migrating(迁移) from other platforms sometimes fall victim to the myth that software is somehow difficult to install under Linux and that the  vatiety of packing schemes used by different distributions is a hindrance(起妨碍作用的事物或人).Well,it is a hindrance,but only to proprietary(私有的) software vendors(供应商,销售商) who wish to distribute binary-only versions of their secret software.

The Linux software ecosystem(生态系统) is based on the idea of open source code.If a program developer releases source code for a product,it is likely that a person associated(联合的,关联的) with a distribution will package the product and include it in their repository(存放处,储藏室,仓库,宝库).This method ensures that the product is well integrated(整体的) into the distribution and the user is given the convenience of "one-stop shopping"(一站式采购) for software,rather than having to search for each product's web site.

Device drivers are handled in much the same way,except that instead of being separate items in a distribution's repository,they become part of the Linux kernel itself.Generally speaking,there is no such thing as a "driver disk" in Linux.Either the kernel supports a device or it doesn't,and the Linux kernel supports a lot of devices.Many more,in fact,than Windows does.Of course,this is of no consolation(安慰,慰问)if the particular device you need is not supported.When that happens,you need to look at the cause.A lack of driver support is usually caused by one of three things:

1.The device is too new.Since many hardware vendors don't actively support Linux development,it falls upon a member of the Linux community to write the kernel driver code.This takes time.

2.The device is too exotic(奇异的).Not all distributions include every possible device driver.Each distribution builds their own kernels,and since kernels are very configurable(which is what makes it possible to run Linux on everyting from wristwatches(手表) to mainframes(主机,中央处理机) they may have overlooked a particular device.By locating and downloading the source code for the driver,it is possible for you(yes,you) to compile and install the diriver yourself.This process is not overly diffcult,but it is rather involved.We'll talk about compiling software in a later chapter.

3.The hardware vendor is hiding something.They have neither released source code for a Linux driver,nor have they released the technical documentation for somebody to create one for them.This means that the hardware vendor is trying to keep the programming interfaces to the device a secret.Since we don't want secret devices in our computers,I suggest that you remove the offending(不愉快的,厌恶的) hardware and pitch it into the trash,with your other useless items.

 

posted @ 2017-09-28 16:46  kgcqw  阅读(188)  评论(0编辑  收藏  举报