Management of the rpm package

C language program of the build process

1. Source Codes -> Pretreatment -> Compiler -> Assembler -> Links -> executable

 

  • Open Source: is the program code, text of the source code, written for humans to see the programming language, but the machine does not know, can not be performed;
  • Compiler: the program translated into machine code to see to understand language, similar to the role of translators, generate binary files;
  • Links: ld Use tools on Linux, the link o files and library files needed to work together to form an executable program. After linking the library file can initiate a number of system calls.
    • Static compiler: .a
      • The program corresponding to the copy package dependencies
      • libxxx.a
      • Packages fitted
      • Difficult to upgrade, need to be recompiled
      • Take up more space, easy migration
    • Dynamic compilation: .so
      • The only plus to be a dependent dynamic-link
      • libxxx.so
      • "Connection point"
      • It takes up less space, easy to upgrade
      • Pointer to, soft links
  • Executable: After the compiler becomes binary, machine-read to understand so files can be executed.

 

2. The program is part of a binary: binary files, library files, configuration files, help files

To view binary program depend on libraries:

  ·ldd /PATH/TO/BINARY_FILE

 

3. package naming rules:

 

源代码:name-VERSION.tar.gz | bz2 | xz;
VERSION: major.minor.release
    主版本号.次版本号.发行号 rpm包:name-VERSION-ARCH.rpm   
Example: bash- 4.2 . 46 - 19 .el7.x86_64.rpm 
    bash: Software name 
    4.2 . 46 ..: The software version number, the major version minor version release number
    19   : the number of software compiled 
    e17: OS platform
VERSION: major.minor.release (程序包的release)   ARCH :release.arch (rpm包的release)
   
release:release.OS
 常见的arch: x86: i386, i486, i586, i686 x86_64: x64, x86_64, amd64 powerpc: ppc 跟平台无关:noarch

 

Generally, the source code is packaged compressed file, which is usually ".gz",, "xz." Ending, source package contains the source code, also contains a number of documents will help to make a binary rpm of "bz2."; rpm package generally end in "rpm", are already compiled, the process of installing the rpm package is actually copying the files in the package on Linux, there may also execute some commands before and after copying files, such as creating a the necessary users, delete unnecessary files.

 

4. Package Manager:

  • debian: deb file, dpkg package manager
  • redhat: rpm file, rpm package manager
  • rpm: Redhat Package Manager
    • RPM Package Manager

 

The packet classification and unpacking
  Application-VERSION-ARCH.rpm: main package
  Application-devel-VERSION-ARCH.rpm development subpacket
  Application-utils-VERSION-ARHC.rpm other sub-packets or a packet branched
  Application-libs-VERSION -ARHC.rpm other sub-package

 

Note: there may be dependencies between packets, and even a circular relationship;

 

Resolving dependencies package management tools:
  yum: RPM of the tool the package manager
  apt-get: deb Package Manager tool bit
  zypper: rpm on a front end management tool SUSE
  DNF: Fedora 18+ RPM Package Manager front-end management tool

 

6. Obtain way package:

 

(1) or CD-ROM version of the system made the official server;
CentOS mirrors:
  https://www.centos.org/download/
  http://mirrors.aliyun.com
  http://mirrors.sohu.com
  HTTP: // mirrors.163.com

 

(2) Project official site

 

(3) a third party organization:
  Fedora-EPEL:
  Extra Packages Standard Package for Enterprise Linux
  RPMForge: RHEL recommendation, the whole package is very
  search engine:
  http://pkgs.org
  http://rpmfind.net
  http://rpm.pbone.net
  https://sourceforge.net/

 

Note: The third-party packages to check its legality, integrity! !

 

7. libraries
Some view the command:

ldd   /PATH/TO/BINARY_FILE    # 查看二进制程序所依赖的库文件
ldconfig -p   # 显示本机已经缓存的所有可用库文件名及文件路径映射关系

 

8. The program files and configuration cache file:
Profile:
  /etc/ld.so.conf all into a file, or
  /etc/ld.so.conf.d/*.conf the end of the file directory .cong the document, to facilitate a program to write a configuration file 

Cache files:
  /etc/ld.so.cache

 


 

First, the package manager:

 

Function: constituent documents compiled application package or several packages a file, thus quickly and easily implement the installation package, uninstall, query, update and verify management operations

 

Package files (unique to each packet)
  files in RPM package
  metadata RPM, such as name, version, dependency, and the like described in
  a script to run install or uninstall

 

Database (common): / var / lib / rpm
  package name and version
  dependencies
  Function
of each file path generated after installation and check information packet

 

 

ll  /var/lib/rpm/
total 75612   
-rw-r--r--. 1 root root  5521408 Oct 23 18:48 Basenames
-rw-r--r--. 1 root root    12288 Oct 23 18:47 Conflictname
-rw-r--r--. 1 root root    73728 Dec  4 11:57 __db.001
-rw-r--r--. 1 root root   229376 Dec  4 11:57 __db.002
-R & lt -rw - r--. . 1 the root the root   1,318,912 On Dec   . 4  . 11 : 57 is . __db 003 
.-R & lt -rw - r-- . 1 the root the root    753 664 On Dec   . 4  . 11 : 57 is . __db 004 
# rpm package database file that folder contains a variety of information available already installed packages, including installation version, installation time, upgrade time, unloading time and so on is very important, the best backup

 

 

Two, rpm command

Rpm on CentOS systems management package,

  Realization install, uninstall, query, verify, update, database maintenance

2.1 installation:

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

    -v  : verbose

    -vv: more detail

    -h: # to display the progress of the implementation of the package manager, each # represents 2% of progress

  

RPM - IVH PACKAGE_FILE ... # install a package
 
[install-Options]
     --test: test installation, but does not actually perform the installation, namely dry run mode 
    --nodeps: Ignore dependencies 
    --replacepkgs | replacefiles reinstall 
      # For package already installed, if not through the uninstall, just delete the files, it will lead this program can not be used,

      when we re-install this package will show this package has been installed, because in / var / lib / rpm this file has a record of the installation program.
      So, we need to re-install this package in this case it is necessary rpm -ivh --replacepkgs this option!
--nosignature: Do not check the legitimacy of sources --nodigest: Do not check package integrity --noscripts: do not execute package script
% pre: pre-install script; -nopre % POST: After installing the script; -nopost % preun: uninstall script before; -nopreun % postun: uninstall script; --nopostun

note:

We screenshot rpm red line position is displayed when installing nokey because we do not import the RPM-GPG-KEY-CentOS-7 this check tool to check its legality,

After importing to display
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 (centos6)

To import the public inspection, so as not to display nokey legitimate sources during installation package.

 

2.2 Upgrade

{RPM -U | --upgrade} [ the install - Options] PACKAGE_FILE ...
  upgrade # mounted legacy packages, the "upgrade"; if not present legacy package, the "install" 
RPM { -F | --freshen } [ the install - Options] PACKAGE_FILE ...
  freshens a # mounted legacy packages, the "upgrade"; if there are no legacy packages, the upgrade operation is performed 
RPM - -Uvh PACKAGE_FILE ... 
RPM - FVH PACKAGE_FILE ...

 - - oldpackage: downgrade
 --force: force the installation

 

note:

(1) do not do the kernel upgrade ; Linux support for multi-core versions co-exist, therefore, directly install the new version of the kernel;

(2) If the original installation package configuration file has been modified , upgraded, with a new version of the configuration file provided does not directly cover the old version of the configuration file, the new version of the file and rename (FILENAME . rpmnew keep the latter).

(3) Package version upgrade, but the old profile and new profile is exactly the same, then install the new version will not come in; you only keep the old version and revised version of the format

 

2.3, query 

{RPM -q | --query} [ SELECT -options] [query- Options] 
[ SELECT - Options]
     -a: all packets (common)
     -f: See the file specified by the packet generation which is installed (common) 
    -p rpmfile: for yet installed do query (common) package files
     - whatprovides CAPABILITY: CAPABILITY specified by the query which package offered
     - whatrequires CAPABILITY: query specified CAPABILITY be dependent on which package 

[query - Options]
     - changelog: query the rpm package ChangeLog
     - c: query's profile
     - d: Archie program
     -i: information (commonly)
    the -l: View the specified package all files generated after installation (common)
   

- scripts: the package comes with the script -provides: lists specified package provided The CAPABILITY - R: query specified package depends The CAPABILITY rpm2cpio package file | cpio -itv preview package in the file rpm2cpio package file | cpio - the above mentioned id "* .conf" release of the package file

  

 

2.4, uninstall

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

Note: Since we setup package will install a number of files at the same time dependent, and this uninstall just uninstall the program itself , while not dependent files to uninstall, so in order to complete uninstall then need to use yum

yum History # view the history, find the operation is the first of several
 yum   History # # Use the undo history told in the first operation of the anti-# want to operate

 

2.5, the package check

   -V RPM [Option-Selection] [Verify- Options] [PACKAGE_FILE ...] 

   check the contents of 

                S: size change 

                . 5 : MD5 

                T: Modify timestamp 

                D: Device, major and minor device number does not match 

                L: link path 

                U: User 

                G: Group

 

Import public key needed
rpm -K | checksig rpmfile checking the integrity of packages and signature
RPM --import / etc / pki / RPM-gpg / RPM-GPG-KEY-CentOS-7
CentOS 7 Release CD-ROM: RPM-GPG CentOS-7--Key
RPM -qa "gpg-pubkey *"

 

Source of legitimacy and integrity of the test is on the package before the package installation

       Integrity test positive: md5, sha1, sha128, sha256, sha384, sh512 

       Source of legitimacy: RSA

          For the source of legitimacy and integrity test positive: GPG

 

 Encryption Type:

    Symmetric encryption: encryption key is the same

    Different asymmetric encryption and decryption key, pk (public key) sk (secre key)

    1, encrypted with one key can only be used to decrypt the other key matching

     2, the private key can not open, open public

 

 The program to be installed on the package check

   1, a public key system is introduced into the package provides: rpm -import RPM-GPG-KEY-CentOS-7    

   2, when the package is installed, the error message no longer appears

 

database maintenance

  Position; status / var / lib program

  When the database is corrupted, rebuild the database

   --rebuildb direct reconstruction

   --initdb existence of the database will not rebuild, does not exist, reconstruction

 

Guess you like

Origin www.cnblogs.com/liuzhiyun/p/11369408.html