Linux package management learning -rpm

Foreword

On linux, usually consists of a software binaries, libraries, configuration files, and help files. among them:

  • Binaries are generally placed in / bin, / sbin, / usr / bin, / usr / sbin, / usr / local / bin and / usr / local / sbin these directories below;
  • Library files are placed in / lib, / lib64, / usr / lib, / usr / lib64, under / usr / local / lib and / usr / local / lib64 these directories;
  • Profiles are generally placed in the / etc directory under;
  • The most basic of man Help file is placed in the / usr / share / man this directory.

Package Manager

In the application, and then went looking for the source code compiled into binary files, a process that takes a lot of time, so there will be a package manager every time you want to install the program through.

Package Manager functions are: to package each set of files compiled into the application package one or more files, making it easier to achieve the installation package, upgrade, unloading and query management operations.

Front-end tools

With this we can only Package Manager to manually resolve dependencies between packages. The so-called automatic dependency resolution, nothing more than carry out a program before installing the package file analysis to see which programs are dependent on it, and then install these programs together to solve package dependencies, we will automatically resolve dependencies the tool is called to resolve dependencies front-end tools.

Linux distributions can be divided into two categories: Class RedHat and class Debain, vary on different distributions used package manager, the following figure is used by each release of the package manager:

clipboard.png

 

rpm package naming

Rpm format of a package is: httpd-2.2.15-59.el7.x86_64.rpm, wherein:

  • httpd is the name of the rpm package;
  • 2.2.15 is the version number of rpm package;
  • 59.el7 license is issued;
  • x86_64 indicate which platform is suitable, where applicable to computer AMD / Intel 64-bit architecture configuration bond.
  • .rpm is the file extension rpm package

 

rpm package management command

rpm Package Manager is mainly implemented features include: installation, upgrade, query, and the checksum database maintenance

rpm command format:

rpm [OPTIONS] [PACKAGE_FILE]

Command options:

  • -i, --install: Installation
  • -U, -update, -F, --freshen: Masu级
  • -e, --erase: Uninstall
  • -q, --query: inquiry
  • -V, --verify: check
  • --builddb, --initdb: Creating a database

1, the installation

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

RPM # - IVH PACKAGE_FILE 
the GENERAL the OPTIONS
     - v: verbose, detailed information
     -vv: more verbose output

[install-options]

-h: hash marks outputs a progress bar; each # represents 2 percent of progress;
 - the Test: Test the installation, inspection reports and messages, dependencies and conflicts;
 - nodeps: Ignore dependencies; 
    Note: Ignore dependencies installed when the program after installation is complete, it may not function properly, so this installation option is not recommended;
 - replacepkgs: re-install; 
    for example, after the configuration file of a program to modify the information, want to restore the configuration file, but ; forget the previous configuration, then you can delete the configuration file after using this installation option to reinstall the program to restore its a profile
 - the legitimacy of the signature does not check package information, do not check package sources: nosignature ;
 - nodigest: Do not check package integrity of information;
 --noscripts: do not execute the script file during installation

Note: rpm can bring their own script

rpm package script in four categories: 
preinstall: a script that runs before the installation process begins, % pre, - nopre 
postinstall: script to run after the installation process is complete, POST%, - nopost 
preuninstall: uninstall process actually started running before the script, preun%, - nopreun 
postuninstall: a script that runs after the uninstall process is complete, postun%, - nopostun

Installation Command demo

(1) install a rpm package

clipboard.png

(2) ignore the dependencies installed

clipboard.png

Dependence error when installing php rpm package, then you can ignore the dependence of the package installed

clipboard.png

(3) Installation Test

clipboard.png

clipboard.png

(4) Reinstall

clipboard.png

2, upgrade

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

- U: upgrade or install
 - F: Upgrade 
RPM - Uvh PACKAGE_FILE ... 
RPM -Fvh PACKAGE_FILE ...

[install-options]

- oldpackage: Downgrade
 --foece: mandatory upgrade

note:

(1)不要对内核做升级操作;Linux支持多内核版本并存,因此,直接安装新版内核;
(2)如果某原程序包的配置文件安装后曾被修改过,升级时,新版本的程序提供一个配置文件不会覆盖原有版本的配置文件,而是把新版本的配置文件重命名(FILENAME.rpmnew)后提供;

3、卸载

rpm {-e|--erase} [--allmatches] [--justdb] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME ...

--allmarches: 卸载所有匹配指定名称的程序包的各版本;
--nodeps: 忽略依赖关系;
--test: 测试卸载,dry run模式

4、查询

rpm {-q|--query} [select-options] [query-options]

[select-options]

PACKAGE_NAME: 查询指定程序包是否已经安装,及其版本;
-a, --all: 查询所有已经安装过的包;
-f FILE: 查询指定的文件由哪个程序安装包生成;
-p, --package PACKAGE_FILE: 用于实现对未安装的程序包执行查询操作;
--whatprovides CAPABILITY: 查询指定的CAPABILITY由哪个包提供;
--whatrequires CAPABILITY: 查询指定的CAPABILITY被哪个包所依赖;

[query-options]

--changelog: 查询rpm包的changelog;
-l, --list: 程序包安装生成的所有文件列表;
-i, --info: 程序包相关的信息,版本号、大小、所属组等;
-c, --configfiles: 查询指定的程序提供的配置文件;
-d, --docfiles: 查询指定的程序包提供的文档;
--provides: 列出指定程序包提供的所有CAPABILITY;
-R, --require: 查询指定程序包的依赖关系;
--scripts: 查询程序包自带的脚本片段;

查询命令演示

(1) 查询指定的安装后的程序

clipboard.png

(2) 查询指定的文件由哪个程序安装包生成

clipboard.png

(3) 查询程序包安装后生成的文件列表或者某程序的文件列表

clipboard.png

clipboard.png

(4) 列出指定程序包提供的所有CAPABILITY

clipboard.png

(5) 查询指定的CAPABILITY由哪个包提供

clipboard.png

(6) 查询指定的CAPABILITY被哪个包所依赖

clipboard.png

(7) 查询指定程序包的依赖关系

clipboard.png

(8) 查询程序包自带的脚本片段

clipboard.png

5、校验

软件包的校验一般是验证其来源的合法性以及软件包完整性的验证;来源合法性验证利用数字签名奇数,完整性验证利用单项函数加密技术。

软件包校验命令

rpm {-V|--verify} [select-options] [verify-options]

校验过程:

(1) 首先获取并导入信任的包制作者的密钥

对于CentOS发行版来说,利用下面的命令进行密钥的导入:
# rpm -import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

(2) 验证

a. 安装此组织签名的程序时,会自动执行验证;
b. 手动验证:rmp -K PACKAGE_FILE

6、数据库重建

Path Manager database rpm / var / lib / rpm /

Gets rpm database tools help

CentOS 6: man rpm
CentOS 7: man rpmdb

Database rebuild command

rpm {--initdb|--rebuilddb}

--initdb: initialize the database, the current can be achieved without any database to create a new initialization; current sometimes does not do anything; 
--rebuilddb: rebuild, re-created by reading all the packages already installed on the current system;

 

 

 

 

 

reference:

rpm package management function of the whole solution

centos rpm package management systems

 

Guess you like

Origin www.cnblogs.com/Jason-Xiang/p/11754313.html