zoukankan      html  css  js  c++  java
  • linux软件包rpm的使用

    一rpm包管理器

    (一)rpm的介绍

    rpm不仅是文件的后缀,也是一个工具,外部命令,程序包管理器

    功能:将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装、卸载、查询、升级和校验等管理操作。

    [root@centos71 ~]# which   rpm
    /usr/bin/rpm

    (二)包文件组成 (每个包独有) 

    1RPM包内的文件    

    2RPM的元数据,如名称,版本,依赖性,描述等。打包但没有压缩。  

    3安装或卸载时运行的脚本。

    rpm所谓的安装大部分是解压包,并且复制到设置好的路径。

    要对复制的目录或者文件设置好相应的属性,比如文件的所有者和所属组。

    如果系统没有这个账号那么就要编写脚本创建出来了。这是安装前的脚本。

    系统中安装的软件是以rpm方式安装的。

    安装好了之后那么Linux的数据库就会记录以rpm这种方式安装的所有包的信息。

    可以查询在系统中安装了哪些rpm包,哪时候安装的,生成了哪些文件,在哪些目录里面。

     从光盘里面拷贝一个文件

    [root@centos71 ~]# cd  /mnt/Packages/
    [root@centos71 Packages]# cp    tree-1.6.0-10.el7.x86_64.rpm     /app/
    [root@centos71 Packages]# cd /app/
    [root@centos71 app]# ls
    tree-1.6.0-10.el7.x86_64.rpm

    (三)数据库(公共):/var/lib/rpm


    程序包名称及版本
    依赖关系
    功能说明
    包安装后生成的各文件路径及校验码信息

     /var/lib/rpm/下面的文件是很重要的,为了安全可以做备份。

    [root@centos71 app]# cd  /var/lib/rpm/
    [root@centos71 rpm]# ls
    Basenames  Conflictname  __db.001  __db.002  __db.003  Dirnames  Group  Installtid  Name  Obsoletename  Packages  Providename  Requirename  Sha1header  Sigmd5  Triggername
    [root@centos71 rpm]# ll
    total 93708
    -rw-r--r--. 1 root root  4247552 Jan 10 17:13 Basenames
    -rw-r--r--. 1 root root    16384 Jan 10 12:08 Conflictname
    -rw-r--r--. 1 root root   270336 Jan 10 17:13 __db.001
    -rw-r--r--. 1 root root    81920 Jan 10 17:13 __db.002
    -rw-r--r--. 1 root root  1318912 Jan 10 17:13 __db.003
    -rw-r--r--. 1 root root  1146880 Jan 10 17:13 Dirnames
    -rw-r--r--. 1 root root    32768 Jan 10 17:13 Group
    -rw-r--r--. 1 root root    20480 Jan 10 17:13 Installtid
    -rw-r--r--. 1 root root    69632 Jan 10 17:13 Name
    -rw-r--r--. 1 root root    32768 Jan 10 12:08 Obsoletename
    -rw-r--r--. 1 root root 85598208 Jan 10 17:13 Packages
    -rw-r--r--. 1 root root  2486272 Jan 10 17:13 Providename
    -rw-r--r--. 1 root root   544768 Jan 10 17:13 Requirename
    -rw-r--r--. 1 root root   131072 Jan 10 17:13 Sha1header
    -rw-r--r--. 1 root root    73728 Jan 10 17:13 Sigmd5
    -rw-r--r--. 1 root root     8192 Jan 10 12:05 Triggername

    在6上查看

    [root@centos65 ~]# ls  /var/lib/rpm/
    Basenames     Dirnames     Group       Name          Packages     Provideversion  Requirename     Sha1header  Triggername
    Conflictname  Filedigests  Installtid  Obsoletename  Providename  Pubkeys         Requireversion  Sigmd5
    [root@centos65 ~]# ls  /var/lib/rpm/  -lh
    total 46M
    -rw-r--r--. 1 root root 2.7M Mar  3 17:51 Basenames
    -rw-r--r--. 1 root root  12K Jan 23 18:38 Conflictname
    -rw-r--r--. 1 root root 908K Mar  3 17:51 Dirnames
    -rw-r--r--. 1 root root 4.6M Mar  3 17:51 Filedigests
    -rw-r--r--. 1 root root  16K Mar  3 17:51 Group
    -rw-r--r--. 1 root root  16K Mar  3 17:51 Installtid
    -rw-r--r--. 1 root root  24K Mar  3 17:51 Name
    -rw-r--r--. 1 root root  12K Jan 23 18:45 Obsoletename
    -rw-r--r--. 1 root root  39M Mar  3 17:51 Packages
    -rw-r--r--. 1 root root 1.3M Mar  3 17:51 Providename
    -rw-r--r--. 1 root root 640K Mar  3 17:51 Provideversion
    -rw-r--r--. 1 root root  12K Jan 23 16:50 Pubkeys
    -rw-r--r--. 1 root root 212K Mar  3 17:51 Requirename
    -rw-r--r--. 1 root root 144K Mar  3 17:51 Requireversion
    -rw-r--r--. 1 root root  80K Mar  3 17:51 Sha1header
    -rw-r--r--. 1 root root  44K Mar  3 17:51 Sigmd5
    -rw-r--r--. 1 root root  12K Jan 23 19:10 Triggername

    (四)程序包的来源

    (1) 系统发版的光盘或官方的服务器


    CentOS镜像:
    https://www.centos.org/download/
    http://mirrors.aliyun.com
    http://mirrors.sohu.com
    http://mirrors.163.com


    (2) 项目官方站点

    (3) 第三方组织


    Fedora-EPEL:Extra Packages for Enterprise Linux

    都是经过红帽测试过的,可以放心使用。

    https://mirrors.aliyun.com/epel/

    [root@centos71 rpm]# cd
    [root@centos71 ~]# wget    https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
    --2019-01-10 23:43:01--  https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
    Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.136.135.213, 183.136.135.223, 183.136.135.221, ...
    Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.136.135.213|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 14244 (14K) [application/x-redhat-package-manager]
    Saving to: ‘sl-5.02-1.el7.x86_64.rpm’
    
    100%[==================================================================================================================================================>] 14,244      --.-K/s   in 0.05s   
    
    2019-01-10 23:43:07 (284 KB/s) - ‘sl-5.02-1.el7.x86_64.rpm’ saved [14244/14244]
    
    [root@centos71 ~]# ls
    anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  oCam.exe  Pictures  Public  sl-5.02-1.el7.x86_64.rpm  Templates  Videos
    [root@centos71 ~]# rpm   -i   sl-5.02-1.el7.x86_64.rpm 
    warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    
    [root@centos71 ~]# ls
    anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  oCam.exe  Pictures  Public  sl-5.02-1.el7.x86_64.rpm  Templates  Videos
    [root@centos71 ~]# sl
    [root@centos65 ~]# wget    https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
    --2019-03-14 19:43:13--  https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
    Resolving mirrors.aliyun.com... 119.96.206.233, 119.96.206.228, 119.96.206.230, ...
    Connecting to mirrors.aliyun.com|119.96.206.233|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 14244 (14K) [application/x-redhat-package-manager]
    Saving to: “sl-5.02-1.el7.x86_64.rpm”
    
    100%[============================================================================================>] 14,244      --.-K/s   in 0.07s   
    
    2019-03-14 19:43:19 (200 KB/s) - “sl-5.02-1.el7.x86_64.rpm” saved [14244/14244]
    
    [root@centos65 ~]# sl
    -bash: sl: command not found
    [root@centos65 ~]# ls
    1Gb.file  a  anaconda-ks.cfg  bin  blkid  f1  f2  f3  install.log  install.log.syslog  restore_iptables.sh  sl-5.02-1.el7.x86_64.rpm
    [root@centos65 ~]# yum install sl
    Loaded plugins: fastestmirror, security
    Setting up Install Process
    Determining fastest mirrors
    ali-centos                                                                                                     | 3.7 kB     00:00     
    base                                                                                                           | 4.0 kB     00:00 ... 
    epel                                                                                                           | 4.7 kB     00:00     
    epel/primary_db                                                                                                | 6.0 MB     00:06     
    Resolving Dependencies
    --> Running transaction check
    ---> Package sl.x86_64 0:5.02-1.el6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ======================================================================================================================================
     Package                     Arch                            Version                              Repository                     Size
    ======================================================================================================================================
    Installing:
     sl                          x86_64                          5.02-1.el6                           epel                           13 k
    
    Transaction Summary
    ======================================================================================================================================
    Install       1 Package(s)
    
    Total download size: 13 k
    Installed size: 15 k
    Is this ok [y/N]: y
    Downloading Packages:
    sl-5.02-1.el6.x86_64.rpm                                                                                       |  13 kB     00:00     
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : sl-5.02-1.el6.x86_64                                                                                               1/1 
      Verifying  : sl-5.02-1.el6.x86_64                                                                                               1/1 
    
    Installed:
      sl.x86_64 0:5.02-1.el6                                                                                                              
    
    Complete!

     输入sl就会出现下面的图片

    Rpmforge:RHEL推荐,包很全
    搜索引擎:
    http://pkgs.org
    http://rpmfind.net
    http://rpm.pbone.net
    https://sourceforge.net/

    注意搜索出来的包可能会有问题。


    (4) 自己制作。注意:第三方包建议要检查其合法性,来源合法性,程序包的完整性

    二rpm包管理

    CentOS系统上使用rpm命令管理程序包:安装、卸载、升级、查询、校验、数据库维护

    (一)使用rpm命令安装包


    rpm {-i|--install} [install-options]    PACKAGE_FILE…


    -v: verbose显示详细信息


    -vv:显示更详细信息,可以在出现报错的时候进行排错的时候使用


    -h: 以#显示程序包管理执行进度


    rpm -ivh PACKAGE_FILE ..

    注意安装包的时候要写明路径在哪

    [root@centos71 app]# rpm   -ivvh   tree-1.6.0-10.el7.x86_64.rpm 
    D: ============== tree-1.6.0-10.el7.x86_64.rpm
    D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
    D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
    D: loading keyring from rpmdb
    D: opening  db environment /var/lib/rpm cdb:0x401
    D: opening  db index       /var/lib/rpm/Packages 0x400 mode=0x0
    D: locked   db index       /var/lib/rpm/Packages
    D: opening  db index       /var/lib/rpm/Name 0x400 mode=0x0
    D: Expected size:        47508 = lead(96)+sigs(1284)+pad(4)+data(46124)
    D:   Actual size:        47508
    warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:     added binary package [0]
    D: found 0 source and 1 binary packages
    D: opening  db index       /var/lib/rpm/Conflictname 0x400 mode=0x0
    D: ========== +++ tree-1.6.0-10.el7 x86_64/linux 0x2
    D: opening  db index       /var/lib/rpm/Providename 0x400 mode=0x0
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6()(64bit)                            YES (db provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6(GLIBC_2.14)(64bit)                  YES (db provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6(GLIBC_2.2.5)(64bit)                 YES (db provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6(GLIBC_2.3)(64bit)                   YES (db provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6(GLIBC_2.3.4)(64bit)                 YES (db provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6(GLIBC_2.4)(64bit)                   YES (db provides)
    D:  Requires: rpmlib(CompressedFileNames) <= 3.0.4-1        YES (rpmlib provides)
    D:  Requires: rpmlib(FileDigests) <= 4.6.0-1                YES (rpmlib provides)
    D:  Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1       YES (rpmlib provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: rtld(GNU_HASH)                                YES (db provides)
    D:  Requires: rpmlib(PayloadIsXz) <= 5.2-1                  YES (rpmlib provides)
    D: opening  db index       /var/lib/rpm/Obsoletename 0x400 mode=0x0
    D: ========== recording tsort relations
    D: ========== tsorting packages (order, #predecessors, #succesors, depth)
    D:     0    0    0    1   +tree-1.6.0-10.el7.x86_64
    D: installing binary packages
    D: closed   db index       /var/lib/rpm/Obsoletename
    D: closed   db index       /var/lib/rpm/Conflictname
    D: closed   db index       /var/lib/rpm/Providename
    D: closed   db index       /var/lib/rpm/Name
    D: closed   db index       /var/lib/rpm/Packages
    D: closed   db environment /var/lib/rpm
    D: opening  db environment /var/lib/rpm cdb:0x401
    D: opening  db index       /var/lib/rpm/Packages (none) mode=0x42
    D: sanity checking 1 elements
    D: opening  db index       /var/lib/rpm/Name (none) mode=0x42
    D:  read h#    1363 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  read h#    1363 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D: computing 5 file fingerprints
    D: opening  db index       /var/lib/rpm/Basenames (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Group (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Requirename (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Providename (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Conflictname (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Obsoletename (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Triggername (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Dirnames (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Installtid (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Sigmd5 (none) mode=0x42
    D: opening  db index       /var/lib/rpm/Sha1header (none) mode=0x42
    Preparing...                          D: computing file dispositions
    D: 0x00000802     4096     12157150     26087632 /
    ################################# [100%]
        package tree-1.6.0-10.el7.x86_64 is already installed
    D: closed   db index       /var/lib/rpm/Sha1header
    D: closed   db index       /var/lib/rpm/Sigmd5
    D: closed   db index       /var/lib/rpm/Installtid
    D: closed   db index       /var/lib/rpm/Dirnames
    D: closed   db index       /var/lib/rpm/Triggername
    D: closed   db index       /var/lib/rpm/Obsoletename
    D: closed   db index       /var/lib/rpm/Conflictname
    D: closed   db index       /var/lib/rpm/Providename
    D: closed   db index       /var/lib/rpm/Requirename
    D: closed   db index       /var/lib/rpm/Group
    D: closed   db index       /var/lib/rpm/Basenames
    D: closed   db index       /var/lib/rpm/Name
    D: closed   db index       /var/lib/rpm/Packages
    D: closed   db environment /var/lib/rpm

    (二)rpm包安装的相关设置

    [install-options]


    --test: 测试安装,但不真正执行安装,即dry run模式


    --nodeps:忽略依赖关系


    --replacepkgs | replacefiles


    --nosignature: 不检查来源合法性


    --nodigest:不检查包完整性


    --noscripts:不执行程序包脚本


    %pre: 安装前脚本; --nopre


    %post: 安装后脚本; --nopost


    %preun: 卸载前脚本; --nopreun


    %postun: 卸载后脚本; --nopostun

    卸载包

    [root@centos71 app]# rpm  -e  sl
    [root@centos71 app]#
    [root@centos71 app]# cd
    [root@centos71 ~]# ls
    anaconda-ks.cfg   Desktop    Downloads             Music     Pictures  skipfish-2.10-0.2.b.el7.x86_64.rpm  Templates
    Documents  initial-setup-ks.cfg  oCam.exe  Public    sl-5.02-1.el7.x86_64.rpm            Videos 
    [root@centos71 ~]# ls
    anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  oCam.exe  Pictures  Public 
    skipfish-2.10-0.2.b.el7.x86_64.rpm sl-5.02-1.el7.x86_64.rpm Templates Videos [root@centos71 ~]# mv sl-5.02-1.el7.x86_64.rpm /app/ [root@centos71 ~]# cd /app/ [root@centos71 app]# ls sl-5.02-1.el7.x86_64.rpm tree-1.6.0-10.el7.x86_64.rpm

     --test: 测试安装,但不真正执行安装,即dry run模式

    [root@centos71 app]# rpm  -i    sl-5.02-1.el7.x86_64.rpm      --test 
    warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    [root@centos71 app]# rpm  -ivh    sl-5.02-1.el7.x86_64.rpm      --test 
    warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    Preparing...                          ################################# [100%]
    [root@centos71 app]# rpm  -ivvh    sl-5.02-1.el7.x86_64.rpm      --test 
    D: ============== sl-5.02-1.el7.x86_64.rpm
    D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
    D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
    D: loading keyring from rpmdb
    D: opening  db environment /var/lib/rpm cdb:0x401
    D: opening  db index       /var/lib/rpm/Packages 0x400 mode=0x0
    D: locked   db index       /var/lib/rpm/Packages
    D: opening  db index       /var/lib/rpm/Name 0x400 mode=0x0
    D: Expected size:        14244 = lead(96)+sigs(1284)+pad(4)+data(12860)
    D:   Actual size:        14244
    warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    D:     added binary package [0]
    D: found 0 source and 1 binary packages
    D: opening  db index       /var/lib/rpm/Conflictname 0x400 mode=0x0
    D: ========== +++ sl-5.02-1.el7 x86_64/linux 0x2
    D: opening  db index       /var/lib/rpm/Providename 0x400 mode=0x0
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6()(64bit)                            YES (db provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libc.so.6(GLIBC_2.2.5)(64bit)                 YES (db provides)
    D:  read h#      53 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libncurses.so.5()(64bit)                      YES (db provides)
    D:  read h#      53 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: libtinfo.so.5()(64bit)                        YES (db provides)
    D:  Requires: rpmlib(CompressedFileNames) <= 3.0.4-1        YES (rpmlib provides)
    D:  Requires: rpmlib(FileDigests) <= 4.6.0-1                YES (rpmlib provides)
    D:  Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1       YES (rpmlib provides)
    D:  read h#      47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    D:  Requires: rtld(GNU_HASH)                                YES (db provides)
    D:  Requires: rpmlib(PayloadIsXz) <= 5.2-1                  YES (rpmlib provides)
    D: opening  db index       /var/lib/rpm/Obsoletename 0x400 mode=0x0
    D: ========== recording tsort relations
    D: ========== tsorting packages (order, #predecessors, #succesors, depth)
    D:     0    0    0    1   +sl-5.02-1.el7.x86_64
    D: installing binary packages
    D: Selinux disabled.
    D: sanity checking 1 elements
    D: computing 7 file fingerprints
    D: opening  db index       /var/lib/rpm/Basenames 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Group 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Requirename 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Triggername 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Dirnames 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Installtid 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Sigmd5 0x400 mode=0x0
    D: opening  db index       /var/lib/rpm/Sha1header 0x400 mode=0x0
    Preparing...                          D: computing file dispositions
    D: 0x00000802     4096     12157164     26087641 /
    ################################# [100%]
    D: ========== +++ sl-5.02-1.el7 x86_64-linux 0x2
    D: Expected size:        14244 = lead(96)+sigs(1284)+pad(4)+data(12860)
    D:   Actual size:        14244
    D: sl-5.02-1.el7.x86_64: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    D: closed   db index       /var/lib/rpm/Sha1header
    D: closed   db index       /var/lib/rpm/Sigmd5
    D: closed   db index       /var/lib/rpm/Installtid
    D: closed   db index       /var/lib/rpm/Dirnames
    D: closed   db index       /var/lib/rpm/Triggername
    D: closed   db index       /var/lib/rpm/Obsoletename
    D: closed   db index       /var/lib/rpm/Conflictname
    D: closed   db index       /var/lib/rpm/Providename
    D: closed   db index       /var/lib/rpm/Requirename
    D: closed   db index       /var/lib/rpm/Group
    D: closed   db index       /var/lib/rpm/Basenames
    D: closed   db index       /var/lib/rpm/Name
    D: closed   db index       /var/lib/rpm/Packages
    D: closed   db environment /var/lib/rpm

    下面显示并没有真正的安装

    [root@centos71 app]# sl
    -bash: /usr/bin/sl: No such file or directory

    因为有依赖关系

    包依赖关系就好比是楼与楼的关系。

    假如A包依赖于B包,那么安装的时候就要先安装B包了。

    但是在卸载的时候就要先卸载A包了。安装就相当于盖楼,B包是地基;卸载就相当于拆楼,A在楼上。

    [root@centos71 app]# rpm   -ivh    /mnt/Packages/gcc-4.8.5-28.el7.x86_64.rpm 
    warning: /mnt/Packages/gcc-4.8.5-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    error: Failed dependencies:
        cpp = 4.8.5-28.el7 is needed by gcc-4.8.5-28.el7.x86_64
        glibc-devel >= 2.2.90-12 is needed by gcc-4.8.5-28.el7.x86_64
        libmpc.so.3()(64bit) is needed by gcc-4.8.5-28.el7.x86_64

    --replacepkgs

    [root@centos71 app]# rpm  -q  tree 
    tree-1.6.0-10.el7.x86_64
    [root@centos71 app]# rpm  -ql  tree 安装包生成的文件。因为rpm包是打包文件,这些就相当于子文件。
    /usr/bin/tree
    /usr/share/doc/tree-1.6.0
    /usr/share/doc/tree-1.6.0/LICENSE
    /usr/share/doc/tree-1.6.0/README
    /usr/share/man/man1/tree.1.gz
    [root@centos71 app]# which   tree 注意tree命令就是来自这个包的
    /usr/bin/tree
    [root@centos71 app]# rm  -f  /usr/bin/tree

    后面加上选项--replacepkgs

    [root@centos71 app]# rpm  -ivh     tree-1.6.0-10.el7.x86_64.rpm 
    warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Preparing...                          ################################# [100%]
        package tree-1.6.0-10.el7.x86_64 is already installed
    [root@centos71 app]# #重新安装但是提示已经安装了。
    [root@centos71 app]# rpm  -ivh     tree-1.6.0-10.el7.x86_64.rpm             --replacepkgs   
    warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:tree-1.6.0-10.el7                ################################# [100%]
    [root@centos71 app]# tree 
    .
    ├── sl-5.02-1.el7.x86_64.rpm
    └── tree-1.6.0-10.el7.x86_64.rpm
    
    0 directories, 2 files

    --replacepkgs的作用就是安装上包中所有的子包,已经有的文件就覆盖了。

    [root@centos71 app]# ll    /usr/share/doc/tree-1.6.0/README
    -rw-r--r--. 1 root root 4628 Jun 24  2011 /usr/share/doc/tree-1.6.0/README
    [root@centos71 app]# echo   >>      /usr/share/doc/tree-1.6.0/README
    [root@centos71 app]# ll    /usr/share/doc/tree-1.6.0/README
    -rw-r--r--. 1 root root 4629 Jan 11 09:43 /usr/share/doc/tree-1.6.0/README
    [root@centos71 app]# rpm  -ivh     tree-1.6.0-10.el7.x86_64.rpm             --replacepkgs   
    warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:tree-1.6.0-10.el7                ################################# [100%]
    [root@centos71 app]# ll    /usr/share/doc/tree-1.6.0/README
    -rw-r--r--. 1 root root 4628 Jun 24  2011 /usr/share/doc/tree-1.6.0/README

    注意大部分程序是放在/usr/bin/或者/usr/sbin,并且不带版本号。

    [root@centos71 app]# ls   /usr/bin/*    |   wc
       1695    1695   32695
    [root@centos71 app]# ls   /usr/sbin/*    |   wc
        663     663   13361
    [root@centos71 app]# ll   /usr/bin/mpstat  
    -rwxr-xr-x. 1 root root 53728 Apr 11  2018 /usr/bin/mpstat

     内核文件就带版本号。几个内核是可以并存的。启动的时候可以选择。

    [root@centos71 app]# cd   /boot/
    [root@centos71 boot]# ls
    config-3.10.0-862.el7.x86_64  grub   initramfs-0-rescue-685dc66dda59420c9a03dae9e6d67f2c.img  
    symvers-3.10.0-862.el7.x86_64.gz vmlinuz-0-rescue-685dc66dda59420c9a03dae9e6d67f2cefi
    grub2 initramfs-3.10.0-862.el7.x86_64.img
    System.map-3.10.0-862.el7.x86_64 vmlinuz-3.10.0-862.el7.x86_64

    做rpm包的人已经指定好了文件安装的路径了。

    目录满了就清理,报错就提示。

    每个软件包都是按照文件的分层结构FHS来装入目录的。在Linux里面每个文件都是有规定的路径的。

    (三)rpm包升级

    升级:


    rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...


    rpm {-F|--freshen} [install-options] PACKAGE_FILE ...


    upgrade:安装有旧版程序包,则“升级”。如果不存在旧版程序包,则“安装”。

    注意对应内核不要把进行升级,这样有风险的。内核占用的空间不大,所以可以在系统中设置双内核。

    freshen:安装有旧版程序包,则“升级”。如果不存在旧版程序包,则不执行升级操作。

    rpm -Uvh PACKAGE_FILE ...
    rpm -Fvh PACKAGE_FILE ...
    --oldpackage:降级
    --force: 强制安装

    卸载-e,后面加上包名就可以了。

    为什么不写路径就可以卸载和查询,是从数据库里面查的。

    安装的时候就要写上完整的文件路径了。

    [root@centos71 ~]# rpm  -e  tree 
    [root@centos71 ~]# rpm  -q  tree 
    package tree is not installed


    作者:wang618
    出处:https://www.cnblogs.com/wang618/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

  • 相关阅读:
    动态获取Resources里面的图片列表
    在LINQ中实现多条件联合主键LEFT JOIN
    Failed to fetch URL http://dlssl.google.com/android/repository/repository.xml
    LINQ多条件OR模糊查询
    使用ILMerge将所有引用的DLL和exe文件打成一个exe文件
    安卓模拟器、电脑运行安卓系统android、apk文件
    C/C++中枚举类型(enum)
    指针详解
    Visaul Studio 2008 中配置DirectX9c的开发环境
    出自涅磐,缘自凤凰
  • 原文地址:https://www.cnblogs.com/wang618/p/11117771.html
Copyright © 2011-2022 走看看