Linux Package Management--RPM package Management

Source: Internet
Author: User
Tags gpg virtual environment asymmetric encryption

Software operating Environment
Api:application Programming Interface
Application interface (interface between application and operating system)
Any application that conforms to the API standard can be compiled on the operating system that supports the API
Program Source--preprocessing----compile-to-link
Static compilation: itself contains all the library files that need to be called
Dynamic compilation: Does not include itself and calls the shared library file (. so file) when needed
Abi:application Binary Interface
Application Binary Interface
Specifies the format, content, requirements of the load/unload program, parameter passing rules at function calls, registers, and use of stacks.

If the operating system supports this API, but the architecture of the machine is different, that is, their ABI is different, then the binary code generated on one machine can not run successfully on another machine, possibly because the parameter passing rule of the function call is different or the other behavior caused by the ABI definition
In fact, the key is that the ABI defines the runtime compatibility issue, which is the API cannot be resolved, the API can solve the static state of compatibility issues

Why Windows programs are incompatible with Linux programs
The first is because their ABI is different, and the API may be different next.

Windows environment: PE (Portable executable)
Linux environment: ELF (Executable and linkable Format)

Library-level virtualization:
Linux:wine can run Windows programs in a virtual environment
Windows:cywin can run Linux programs in a virtual environment

Development language
System-Level development
C
C++
Application-level development
Java
Delphi
Python
Go
Php
Perl
Ruby

Package Manager
Components of a binary application: binaries, library files, configuration files, Help files
Package Manager:
Debian:deb file, dpkg Package Manager
redhat:rpm file, RPM Package Manager
Rpm:redhat Package Manager
RPM Package Manager

Package naming
Source code: NAME-VERSION.TAR.GZ|BZ2|XZ
VERSION:major.minor.release


RPM Package Naming method:
name-version-release.arch.rpm
Example: bash-4.2.46-19.el7.x86_64.rpm
VERSION:major.minor.release
Release:release. OS


Common arch:
X86:i386, i486, i586, i686
X86_64:x64, x86_64, AMD64
Powerpc:ppc
Platform agnostic: Noarch

Classification and sub-packages
APPLICATION-VERSION-ARCH.RPM: Main Package
APPLICATION-DEVEL-VERSION-ARCH.RPM Development Sub-package
application-utils-version-arhc.rpm Other sub-packages
application-libs-version-arhc.rpm Other sub-packages

Between packages: There may be dependencies, or even cyclic dependencies


To resolve the dependency package management tool:
YUM:RPM Package Manager's front-end tool (currently widely used)
Apt-get:deb Package Manager Front End tool (should be widely available at this time)
RPM Front-end management tool on zypper:suse (older, obsolete)
Dnf:fedora + RPM Package Manager front-end management tool (relatively new, not yet popular)

Library files
To view the library files on which the binaries depend: ldd/path/to/binary_file
Manage and view native-mounted library files: ldconfig
Displays all available library file names and file path mappings that have been cached by this computer:/sbin/ldconfig-p
Configuration files:/etc/ld.so.conf,/etc/ld.so.conf.d/*.conf
Cache files:/etc/ld.so.cache

Package Manager
Function: Package The compilation of the application of the components of one or several package files, so as to quickly and easily implement package installation, uninstallation, query, upgrade and verify management operations
1. package file composition (unique for each package)
The files in the RPM package
RPM metadata, such as name, version, dependency, description, etc.
Scripts to run when installing or uninstalling
2. Database (public)
Package Name and version
Dependent relationships
Function description
File path and checksum information generated after package installation

How to manage Packages:
Using Package Manager: RPM
Using the front end tool: Yum, DNF


Ways to get Packages:
(1) The system issued by the CD or the official server;
CentOS Image:
https://www.centos.org/download/
Http://mirrors.aliyun.com
Http://mirrors.sohu.com
Http://mirrors.163.com
(2) Official site of the project
(3) Third party organizations:
Fedora-epel:
Extra Packages for Enterprise Linux
Rpmforge:rhel recommended, the package is full
Search engine:
http://pkgs.org
Http://rpmfind.net
Http://rpm.pbone.net
https://sourceforge.net/
(4) Make your own
Note: Check its legitimacy: source legitimacy, package integrity

RPM Package Management
Using the RPM command management package on the CentOS system: installation, uninstallation, upgrade, query, checksum, database maintenance

RPM Package Installation
RPM {-i|--install} [install-options] package_file ...
-I: Installation
-V: Show detailed installation procedures
-VV: Show more detailed installation process (up to 3v)
-H: Displays the installation progress in # (each # represents 2%)
RPM Installation Common format: RPM-IVH package_file ...

RPM-IVH Package_file
--test: Test installation, but do not actually perform installation; dry run mode
--nodeps: Ignoring dependencies
--replacepkgs: Replace all installations
--replacefiles: Replace only the original installation file
--nosignature: Does not check the legitimacy of the source
--nodigest: Package integrity is not checked
--noscipts: Do not execute Package script fragment
%pre: Pre-installation;--nopre
%post: Post-installation script;--nopost
%preun: Unloading the forefoot;--nopreun
%postun: Post-uninstall script;--nopostun

RPM Package Upgrade
RPM-UVH Package_file ... Upgrade if an older version is installed, or install the current version
RPM-FVH Package_file ... If an older version is installed, upgrade;
--oldpackage: Downgrade Installation
--force: Forced installation (can be combined with upgrade, downgrade, replace installation)

Upgrade Considerations:
(1) Do not upgrade the kernel, Linux supports multi-core version coexistence, so the new version of the kernel can be installed directly
(2) If the original package configuration file has been modified after installation, upgrade, the new version of the same profile provided does not directly overwrite the old version of the configuration file, and the new version of the file renamed (filename.rpmnew) retained

RMP Packet Query
After the package installs the query:
Rpm-q package-name: Query whether the specified package is already installed
-QA: Querying all installed Packages
-qi package-name: Query For instructions after the specified package is installed
-QL package-name: Query the list of files generated after the installation of the specified package
-QC package-name: Query the configuration file that is generated after the specified package is installed
-QD package-name: Query the Help file that is generated after the specified package is installed
-Q--scripts: Query the script file that the specified package contains
Pretinstall scriptlet: Scripts executed prior to installation
Postinstall scriptlet: Scripts executed after installation
Preuninstall scriptlet: script executed prior to uninstallation
Postuninstall scriptlet: script executed after uninstallation
--changelog: Query rpm Package for Changelog
--provides: Lists the capability provided by the specified package (the ability to make other programs dependent)
-QR: Querying the capability that the specified package depends on (the functionality of other programs)
-qf/path/to/somefile: To see which package installs the specified file for build

Queries for packages that are not installed:
RPM-QP package-name: Query operation for the package files that have not been installed;
--whatprovides CAPABILITY: Query which package is supplied by the specified CAPABILITY
--whatrequires CAPABILITY: Query which package the specified CAPABILITY is dependent on
-QPI package-file: Query for description information that is about to be generated after installation of a package that is not installed
-QPL package-file: Query the list of files that are about to be generated after installation of a package that is not installed
-QPC package-file: Query for configuration files that are about to be generated after installation of a package that is not installed
-QPD package-file: Query for help files that are about to be generated after installation of a package that is not installed

RPM File Unpacking
Rpm2cpio Package Files |cpio–itv Preview in-Package files
Rpm2cpio package file |cpio–id "*.conf" release in-Package files

RPM Package Uninstall
Rpm-e|--erase Programe-name
--nodeps Ignore dependencies
--noscripts do not execute unload scripts
--test Test Uninstall

RPM Package Check
Verifying positive and completeness of the source legality of RPM package
Integrity Verification: SHA256
SOURCE legality verification: RSA
Public Key cryptography:
Symmetric encryption: Encrypt, decrypt using the same key
Asymmetric encryption: The key is in pairs
Public key: Private key, public owner
Secret key: Private key, cannot be exposed

To import the required public key:
Rpm-k|checksig Rpmfile Check Package integrity and signature
RPM--import/etc/pki/rpm-gpg/rpm-gpg-key-centos-7
CentOS 7 Release CD offers: Rpm-gpg-key-centos-7

Rpm-qa gpg-pubkey*

RPM Package Check Check failure code

Rpm-v|--verify Programe-name
The size of the S file size differs file has changed
M Mode differs (includes permissions and file type) file permissions and files types
5 Digest (formerly MD5 sum) differs MD5 digital signature
D device Major/minor number mismatch device has changed the main device number and the secondary
L Readlink (2) path mismatch file link changed
U User ownership differs file the owner has changed.
G group ownership differs file group changed
T MTime differs the timestamp of modifying the contents of a file has changed
P capabilities differ file provides a change in dependency capability
Missing: The file is missing

RPM Database

RPM Database:/var/lib/rpm
Database rebuild: rpm {--INITDB|--REBUILDDB}
INITDB: Initialization
If the database does not exist beforehand, no action is taken to create the new
REBUILDDB: Rebuilding
Re-create the database database directly, regardless of the current presence or not

This article is from the "Love Firewall" blog, be sure to keep this source http://183530300.blog.51cto.com/894387/1841253

Linux Package Management--RPM package Management

Related Article

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.