RPM details of Linux package management tools

Source: Internet
Author: User

When it comes to package management tools, let's look at the application interface (API) and Application Binary interface (ABI).

    • Api:

      • Programming Interface Application Program Interface
      • In other words, things like the functions you call when you write an "application." For the kernel, there are two kinds of "applications": one is the real application of the user space on top of it, the kernel gives them the system to call this interface, such as read (2), write (2), and the kernel module, which is on the same level as the kernel. The kernel provides them with the exported kernel functions, such as Kmalloc (), PRINTK (). These interfaces are what you can see directly when writing programs, and can be used directly.
    • Abi:
      • Runtime call interface Application Binary Interface
      • Binary interface calls, if the binary interface changes, then the binary file should also be changed, the source code does not need to change, as long as recompile, the compiler will help you to complete the changes. Unless you use assembly language directly, this interface is generally not directly available. For example, the kernel system calls with which registers or simply use the stack to pass parameters, the return value is passed back through which register, the kernel defines a structure of a certain field offset is what, and these are the interface on the binary level. These interfaces are directly used for compiled binaries. In other words, if the ABI remains stable, the binary applications and kernel modules that you compiled on previous versions can be run without recompiling directly on the new version. Another particular ABI is a file exported under the/proc,/sys directory, which is not a direct binary form, but also affects the compiled binary, which is also an ABI if it is used within it.

RPM is the abbreviation for RPM Package Manager (RPM Packages Manager), is the Redhat package management tool, with S.U.S.E's package management tool has an unclear relationship, is also recognized as the industry standard, OpenLinux, S.U.S.E. and Turbo Linux distributions such as Linux are used.

RPM Function: The compilation of the application's constituent files packaged into one or several package files, making it easier to implement the package installation, upgrade, uninstall and query management operations;

Ways to get Packages: A system release disc or an official file server (or mirror site)

Naming conventions

    • Source code naming specification name-version.tar.gz

      • Version:major.minor.release
        • Major: Main version
        • Minor: Minor version
        • Fixes like Release:bug
    • RPM Package naming specification: Name-[function]-version-release. [os].arch.rpm
      • Functions: such as Dev, utils, etc., develop various function packs
      • Version:major.minor.release Source Code Package
      • Release.: RPM's own release version
      • OS: e.g. El7 REDHAT7 and CentOS 7
      • ARCH:CPU architectures such as x64 (Noarch and Platform independent)
    • Demo: Source Package redis-3.0.2.tar.gz--RPM Package: redis-3.0.2-1.el7.x64.rpm
RPM use

1. Common options

-v:verbose,详细信息-vv:更详细的输出

2. Verification and completeness of the legitimacy of the package source
The legitimacy of the package is too important to be confirmed before the package is installed.
Verification principle: The signature of the acquisition packet MD5, with the private key encryption method (based on the RSA PGP algorithm) to encrypt the signature, the client simply imports the correct public key, can unlock the private key encryption, to obtain the data signature (because the private key exists only service side, the third party can not decode the signature encryption field. It means that the client cannot decrypt the signature without the private key of the server, and then the signature is compared to the signature parking in the file.

#导入公钥[[email protected] dvd]# rpm --import RPM-GPG-KEY-CentOS-7[[email protected] Packages]# rpm -K zsh-5.0.2-28.el7.x86_64.rpmzsh-5.0.2-28.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 确定

3. Installation

RPM {-i|--install} [install-options] package_file ...
Common install-options:
-h:hash marks output progress bar; Print 50 #, each # represents 2% progress;
--test: Test installation, check and report dependencies and conflict messages, etc.
--nodeps: ignoring dependencies; not recommended;
--replacepkgs: Reinstall;
--noscripts: Do not execute any scripts;
--nopre:preinstall: Scripts that run before the installation process starts,%pre;
--nopost:postinstall: Scripts that run after the installation process is complete,%post;
--nopreun:preuninstall: The uninstallation process really starts executing the script before running,%preun;
--nopostun:postuninstall: The script to run after the uninstallation process is complete,%postun;
--nosignature: Does not check the package signature information, does not check the source legitimacy;
--nodigest: does not check package integrity information;

Demo

 [[email protected] Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm 准备中...                          ################################# [100%]正在升级/安装...   1:zsh-5.0.2-28.el7                 ################################# [100%]

4. Upgrade

RPM {-u|--upgrade} [install-options] package_file ...
RPM {-f|--freshen} [install-options] package_file ...
-U: Upgrade or install;
-F: Upgrade
--oldpackage: downgrade; allow old packages to be upgraded in place of new packages
--force: Mandatory upgrade;

5. Uninstall

RPM {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--test] package_name ...
--allmatches: Uninstalls all versions of packages that match the specified name;
--nodeps: Ignoring dependencies
--test: Test Uninstall, dry run mode

[[email protected] Packages]# rpm -e zsh

6. Enquiry

RPM {-q|--query} [select-options] [query-options]
[Select-options]
Package_name: Query Whether the specified package has been installed and its version;
-A,--all: Check all packages that have already been installed;
-F File: Queries the specified file by which package is installed to build;
-P,--package package_file: Used to implement query operations on packages that are not installed;
--whatprovides CAPABILITY: Query which package is provided by the specified CAPABILITY;
--whatrequires CAPABILITY: The query specifies which packet the CAPABILITY is dependent on;
[Query-options]
--changelog: Query rpm package of Changlog;
-L,--list: List of all files generated by the program installation;
-I,--info: package-related information, version number, size, the package group belonging to, etc.;
-C,--configfiles: Queries the configuration file provided by the specified package;
-D,--docfiles: queries the documentation provided by the specified package;
--provides: Lists all the capability provided by the specified package;
-R,--requires: Queries the dependencies of the specified package;
--scripts: View the script fragment that comes with the package;

To view the number of installation packages

[[email protected] Packages]# rpm -qa|wc -l360

It's good to see which package is installed by the specified file.

[[email protected] Packages]# rpm -qf /etc/passwdsetup-2.8.71-7.el7.noarch

View all files installed by the package

[[email protected] Packages]# rpm -ql  zsh/bin/zsh/etc/skel/.zshrc/etc/zlogin/etc/zlogout/etc/zprofile/etc/zshenv....

View Package Metadata

[[email protected] Packages]# rpm -qi  zshName        : zshVersion     : 5.0.2Release     : 28.el7Architecture: x86_64Install Date: 2018年04月25日 星期三 11时02分54秒Group       : System Environment/ShellsSize        : 5855982.....

To view the configuration file for a package

[[email protected] Packages]# rpm -qc  zsh/etc/skel/.zshrc/etc/zlogin/etc/zlogout/etc/zprofile/etc/zshenv/etc/zshrc

Document view

[[email protected] Packages]# rpm -qd  zsh/usr/share/doc/zsh-5.0.2/BUGS/usr/share/doc/zsh-5.0.2/CONTRIBUTORS/usr/share/doc/zsh-5.0.2/FAQ.....

To view a script fragment that comes with a package

4段信息 可以在install时候查看[[email protected] Packages]# rpm -q --scripts  zshpostinstall scriptlet (using /bin/sh):if [ ! -f /etc/shells ] ; then    echo "/bin/zsh" > /etc/shellselse    grep -q "^/bin/zsh$" /etc/shells || echo "/bin/zsh" >> /etc/shellsfi.....

View package Dependencies

[[email protected] Packages]# rpm -qR  zsh/bin/sh....

Lists all the capability provided by the specified package

[[email protected] Packages]# rpm -q --provides  zshconfig(zsh) = 5.0.2-28.el7zsh = 5.0.2-28.el7zsh(x86-64) = 5.0.2-28.el7

See the providers of capability

[[email protected] Packages]# rpm -q  --whatprovides  ‘config(zsh)‘zsh-5.0.2-28.el7.x86_64

View the dependencies of the capability provider

[[email protected] Packages]# rpm -q --whatrequires  bashrsyslog-8.24.0-12.el7.x86_64lvm2-2.02.171-8.el7.x86_64dracut-033-502.el7.x86_64initscripts-9.49.39-1.el7.x86_64[[email protected]alhost Packages]# rpm -q --whatrequires  zsh没有软件包需要 zsh

No packages installed all files need to be installed view

[[email protected] Packages]# rpm -qpl zsh-html-5.0.2-28.el7.x86_64.rpm/usr/share/doc/zsh-html-5.0.2/zsh_31.html/usr/share/doc/zsh-html-5.0.2/zsh_33.html/usr/share/doc/zsh-html-5.0.2/zsh_34.html/usr/share/doc/zsh-html-5.0.2/zsh_36.html...

Package meta-Data view is not installed

[[email protected] Packages]# rpm -qpi  zsh-html-5.0.2-28.el7.x86_64.rpmName        : zsh-htmlVersion     : 5.0.2Release     : 28.el7Architecture: x86_64....

7, check whether the installation has been modified

S file Size differs
M Mode differs (includes permissions and file type)
5 Digest (formerly MD5 sum) differs
D Device Major/minor number mismatch
L Readlink (2) path mismatch
U User ownership differs
G Group ownership differs
T MTime differs
P capabilities differ

#在随意zsh的安装文件中添加一个空行[[email protected] Packages]# vim /etc/skel/.zshrc [[email protected] Packages]# rpm -V zshS.5....T.  c /etc/skel/.zshrc  #文件大小不一样  说明被改动#删除重装[[email protected] Packages]# rpm -e zsh[[email protected] Packages]# rpm -i  --replacepkgs zsh-5.0.2-28.el7.x86_64.rpm[[email protected] Packages]# rpm -V zsh   #没有消息就ok

8, Database reconstruction, the general database is damaged when used

RPM {--INITDB|--REBUILDDB} [--dbpath directory] [--root directory]
--INITDB: Initializes the database, currently no database can be initialized to create a new one;
--REBUILDDB: Rebuilt, re-created by reading all installed packages on the current system;
RPM Default Manager database path:/var/lib/rpm/

[[email protected] Packages]# rpmdb --initdb --dbpath=/tmp/rpm[[email protected] Packages]# cd /tmp/rpm[[email protected] rpm]# lsBasenames     __db.002  Group       Obsoletename  Requirename  TriggernameConflictname  __db.003  Installtid  Packages      Sha1header__db.001      Dirnames  Name        Providename   Sigmd5

RPM details of Linux package management tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.