设为首页 收藏本站
查看: 793|回复: 0

[经验分享] software package management

[复制链接]

尚未签到

发表于 2017-11-21 18:27:11 | 显示全部楼层 |阅读模式
  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 SystemDistributions(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
DistributionsLow-Level ToolsHigh-Level Tools
Debian-Styledpkgapt-get,aptitude
Fedora,Red Hat Enterprise Linux,CentOSrpmyum
  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
StyleCommand(s)
Debianapt-get update;apt-cache search search_string
Red Hatyum search search_string
  Example:To search a yum repository for the emacs text editor,this command could be used:
DSC0000.png

  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
StyleCommands
Debianapt-get update;apt-get install package_name
Red Hatyum install package_name
  Example:To install the emacs text editor from an apt repository:
DSC0001.png

  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
StyleCommand(s)
Debiandpkg --install package_file
Red Hatrpm -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:
DSC0002.png

  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
StyleCommand(s)
Debianapt-get remove package_name
Red Hatyum erase package_name
  Example:To uninstall the emacs package from a Debian-style system:
DSC0003.png

  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
StyleCommand(s)
Debianapt-get update;apt-get upgrade
Red Hatyum update
  Example:To apply any available updates to the installed packages on a Debian-style system:
DSC0004.png

  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
StyleCommand(s)
Debiandpkg --install package_file
Red Hatrpm -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:
DSC0005.png

  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
StyleCommand(s)
Debiandpkg --list
Red Hatrpm -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
StyleCommand(s)
Debiandpkg --status package_name
Red Hatrpm -q package_name
  Example:To determine if the emacs package is installed on a Debian style system:
DSC0006.png

  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
StyleCommand(s)
Debianapt-cache show package_name
Red Hatyum info package_name
  Example:To see a description of the emacs package on a Debian-style system:
DSC0007.png

  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
StyleCommand(s)
Debiandpkg --search file_name
Red Hatrpm -qf file_name
  Example:To see what package installed the /usr/bin/vim file on a Red Hat system:
DSC0008.png

  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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-409285-1-1.html 上篇帖子: linux ubuntu 16.04下deb文件的安装以及一些问题的解决 下篇帖子: vue环境搭建以及vue-cli使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表