Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of rpm package and rpm command

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Software running environment

API: Application Programming Interface

International standard POSIX: Portable OS

Execution process: program source code-> preprocessing-> compilation-> assembly-> link

Static compilation: package the compiled program code and dependent library files together

Shared (dynamic) compilation: using independent external library files, sharing libraries with other programs in the system, ending with .so in linux, translated as shared objects

ABI: Application Binary Interface application binary interface

(Windows is not compatible with Linux's ABI)

Linux: ELF (Executable and Linkable Format)

Windows:PE (Portable Executable)

Library-level virtualization:

Linux: WINE

Windows: Cywin

II. C program compilation process

III. Java program running

III. Development language

System-level development

C

C++

Application-level development

Java

Delphi

Python

Go

Php

Perl

Ruby

IV. 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

How the rpm package is named:

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 independent: noarch

Package naming and tools

Packages: sorting and unpacking

Application-VERSION-ARCH.rpm: main package

Application-devel-VERSION-ARCH.rpm development subpackage

Other subpackages of Application-utils-VERSION-ARHC.rpm

Other subpackages of Application-libs-VERSION-ARHC.rpm

Between packages: there may be dependencies, even circular dependencies

Resolve dependency package management tools:

Yum: the front-end tool for the rpm package manager

Apt-get: deb package Manager front-end tool

Zypper: rpm front-end management tool on suse

Dnf: Fedora 18 + rpm package Manager front-end management tool

Library file

View the library files that the binary depends on:

Ldd / PATH/TO/BINARY_FILE

Manage and view the library files loaded on this machine:

Ldconfig

/ sbin/ldconfig-p: displays all available library files that have been cached on this machine

Mapping relationship between name and file path

Configuration file: / etc/ld.so.conf, / etc/ld.so.conf.d/*.conf

Cache file: / etc/ld.so.cache

(when you need to rely on the library during installation, you need to manually add the path of the dependent library in the conf file, and then use ldconifg to read the address of the library into the cache for call during installation)

Package Manager

Package Manager:

Function: package one or more component files of the compiled application

Package files, so that you can easily and quickly install, uninstall, query,

Management operations such as upgrade and verification

1. Composition of package files (unique to each package)

Files in the RPM package

RPM metadata, such as name, version, dependency, description, etc.

Script that runs during installation or uninstallation (unofficial package, you should pay special attention to this script and install it only if it is correct)

2. Database (public)

Package name and version

Dependency relationship

Function description

File path and check code information generated after package installation

The source of the package

How to manage packages:

Use the package manager: rpm

Use front-end tools: yum, dnf

The way to get the package:

(1) the CD-ROM of the system version 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

Recommended by Rpmforge:RHEL, the package is very complete

Search engine:

Http://pkgs.org

Http://rpmfind.net

Http://rpm.pbone.net

Https://sourceforge.net/

(4) make it yourself.

Note: check its legitimacy: source legitimacy, package integrity

Rpm package management

Use the rpm command to manage the package on a CentOS system:

Installation, uninstallation, upgrade, query, verification, database maintenance

Installation:

Rpm {- I |-install} [install-options] PACKAGE_FILE...

-v: verbose displays details

-vv: displays more detailed information

-ql displays package contents

-h: displays the progress of package management execution in #

Rpm-ivh PACKAGE_FILE...

Rpm package installation

[install-options]

-test: test the installation, but do not actually perform the installation; dry run mode

-nodeps: ignore dependencies

-replacepkgs replacement, override installation | replacefiles installation package, version, etc., but the generated

The system content is the same, overwrite the installation

-nosignature: do not check the validity of source

-nodigest: do not check package integrity

-noscipts: do not execute package script fragments

% pre: run the script before installation;-nopre

% post: post-installation script;-nopost

% preun: pre-uninstall script;-nopreun

% postun: script after uninstallation;-nopostun

Rpm package upgrade

Upgrade:

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

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

Upgrade: upgrade if an old package is installed

If there is no legacy package, install

Freshen: upgrade if an old package is installed

If there is no legacy package, no upgrade operation is performed

Rpm-Uvh PACKAGE_FILE...

Rpm-Fvh PACKAGE_FILE...

-oldpackage: downgrade

-force: force upgrade

Upgrade attention item

(1) do not upgrade the kernel; Linux supports the coexistence of multiple kernel versions, so

For directly installing a new version of the kernel

(2) if the configuration file of the original package has been modified after installation, when upgrading, the new version

Does not directly overwrite the previous version of the configuration file, and

Keep the new version of the file after renaming (FILENAME.rpmnew)

Packet query

Rpm {- Q |-query} [select-options] [query-options]

[select-options]

-a: all packages

-f: check which package installation generates the specified file

-p rpmfile: query for package files that have not been installed

-whatprovides CAPABILITY: query the specified CAPABILITY

Which package is provided by

-whatrequires CAPABILITY: query that the specified CAPABILITY is

Which package depends on

Rpm2cpio package files | cpio-itv preview the files in the package

Rpm2cpio package files | cpio-id "* .conf" release the files in the package

Packet query

[query-options]

-changelog: query the changelog of the rpm package

-c: the configuration file of the query program

-d: query the documentation of the program

-I: information

-l: view all files generated after the specified package is installed

-scripts: script snippet that comes with the package

-R: query the CAPABILITY on which the specified package depends

-provides: lists the CAPABILITY provided by the specified package

Query usage:

-qi PACKAGE.-qf FILE.-qc PACKAGE.-ql.

PACKAGE.-qd PACKAGE.

-qpi PACKAGE_FILE,-qpl PACKAGE_FILE,...

-qa

Uninstall:

Rpm {- e |-erase} [- allmatches] [- nodeps] [-

Noscripts] [- notriggers] [- test] PACKAGE_NAME...

Packet check

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

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

Validity and integrity verification of package sources:

Integrity verification: SHA256

Source legality verification: RSA

Public key encryption:

Symmetric encryption: encrypt and decrypt using the same key

Asymmetric encryption: keys are paired

Public key: public key, public owner

Secret key: private key, cannot be made public

Import the required public key:

Rpm-K | checksig rpmfile checks the integrity and signature of the packet

Rpm- import / etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Available on the CentOS 7 distribution CD: RPM-GPG-KEY-CentOS-7

Rpm-qa gpg-pubkey*

Rpm database

Database Reconstruction:

/ var/lib/rpm

Rpm {- initdb |-rebuilddb}

Initdb: initialization

If the database does not exist in advance, create a new database

Otherwise, no action is performed

Rebuilddb: rebuilding

Recreate the database directly, whether it currently exists or not

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report