How to Analyze the Management Function of rpm Package

09-06-2023

Complete solution of Rpm package management function

The function of software package management: package each component file of the compiled program into one or several package files, in order to facilitate the installation, upgrade, uninstall, query, verification and database maintenance of the package.

Let's take a look at the resolution of RPM package management.

Rpm package has great application in redhat and S.U.S.E

Next, we will do some detailed functional analysis on the management of rpm package in centos system.

Dependency D can be automatically resolved when using yum(rhel series) for installation.

Rpm package naming format:

name-VERSION-release.arch.rpm

VERSION:major.minor.release

Major: major version number (version has been greatly updated); Minor: minor version number (minor update)

Release.arch: the release number of the rpm package.

Release.os: 2.el7 (platform). i386 (architecture). rpm archetecture: i386, x64(amd64), ppc, noarch processor;

Actual operation:

The machine has successfully downloaded zsh-4.3.10-9.el6.x86_64.rpm from the server, which is used for implementation.

Syntax: rpm [options] [packages_file]

Installation; -i,--install

rpm -ivh /path/to/rpm_package

-v; Display installation information

-vv; Displays more detailed installation information.

-h; Displays the installation progress by pound sign.

--nodeps; Ignore dependencies (for uninstallation)

--force; Forced installation (for unloading)

Reload; --replacepkgs will overwrite the original information.

Rpm -i --replacepkgs /path/to/rpm_name

[root@bucktan ~]# rpm -ivh --replacepkgs zsh-4.3.10-9.el6.x86_64.rpm

Unloading; -e,--erase

rmp -e package_name

--allmatches uninstalls packages that match all specified names.

--nodeps ignores dependencies.

--test test uninstall

Upgrade; -U -F

Upgrade or installation;

rpm -U /path/to/rpm_package

--oldpackage downgrade

Two packages were fetched from the server: zabbix-2.4.0-1.el6.x86 _ 64.rpm.

zabbix-2.4.5-1.el6.x86_64.rpm

Previously upgraded to zabbix-2.4.5-1.el6.x86 _ 64.rpm.

[root@bucktan]~# rpm -Uvh --oldpackage zabbix-2.4.0-1.el6.x86_64.rpm

Upgrade only; (If the old version does not exist, it will not be executed)

rpm -F /path/to/rpm_package

Usually used with vh;

rpm -Uvh|-Fvh /path/to/package

--nosignature does not check the legality of package signature information.

Attention; Do not upgrade the kernel.

Different kernel versions can coexist, so installation can be performed, but upgrading is not recommended.

(key) query; rpm {-q|--query} [select-options] [query-options]

Query whether the package is installed;

rpm -q package_name

[select-options]:

Rpm -qa queries all installed packages;

Rpm -qf /path/to/file queries which package generated a file;

-q-what providesfile _ name queries which package provides the specified capability.

-q -q --whatrequires file_name queries which package depends on the specified capability.

[query-options]:

Rpm -ql package_name queries files generated after package installation;

Brief description of rpm -qi package_name query package;

Rpm -qd package_name queries the help documents generated after package installation;

Rpm -qc package_name queries the configuration file generated after package installation;

Rpm -qR package_name queries the dependencies of the specified package.

Rpm -q --scripts query package related scripts;

Scripts are divided into four categories.

Pre-install pre-installation script

Postinstall post-installation script

Preuninstall pre-uninstall script

Postuninstall post-uninstall script

Inquire about the information about the uninstalled package; -qp

Rpm -qpl package_file queries the files that will be generated after installation.

Rpm -qpi package_file queries the simple description information of the package;

Can be used with its options, such as-qp-scripts.

Check; Check whether the installed files have been modified.

rpm -V package_name

[root@bucktan ~]# rpm -V zsh

S.5....T. c /etc/zshrc

Annotation information returned;

S file size differences size

M mode differences (including permissions and file type) header file.

5 digest (formerly MD5 sum) differs MD5

D Device major/minor number mismatch

L readLink(2) path mismatch

U user ownership differences owner

G group ownership differences genus group

Tmtime differences modification time

P capabilities different ability has changed.

Verify the legitimacy of the source and the integrity of the software.

Package integrity; Single encryption mechanism (MD5|sha1 ...)

Legitimacy of source; Public key encryption mechanism (RSA)

Rpm -K /path/to/packagefile directly verifies the legitimacy of the package source.

rpm --checksig /path/to/package_file

--nosigeature: Do not check the legitimacy of the source.

--nodigest: package integrity is not checked during verification.

Import GPG key file:

rpm --import /path/to/gpg-key-file

Verify after importing.

database

Location: /var/lib/rpm

Reconstruction:

Rpm --initdb: initialization

If a database does not exist in advance, create a new one.

Rpm --rebuilddb reconstruction

Creating a new database directly will overwrite the original database.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us