Linux: rpm installation articles

xiaoxiao2021-03-19  202

In general, the installation of the package is actually a copy of the file, and the RPM installed package is not affected. But RPM should be more work more, and more work is more work.

Smart installation

In general, the installation of the package is actually a copy of the file, that is, copy the various files used to the software to a specific directory. RPM installs the package, no addition. But RPM is further, smarter. Before installation, it usually performs the following:

1. Check the dependency of the package (Dependency)

A description of the dependency of the RPM format can include a description of dependencies. If you need a dynamic link library when execution, what program needs to exist and version number requirements. The default approach is to stop the package installation when the RPM is checked or not in accordance with the requirements.

2. Check the Conflicts Conflicts Software and some software cannot coexist, and the package producer will record this conflict into the RPM package. When the RPM found conflict, it will abort the installation.

3. Execute the pre-installation script program (Preinstall) This type of program is set by the software package author and needs to be executed before installation. Usually the operating environment, establish a directory, clean up excess file, etc., prepare for successful installation.

4. Processing the configuration file (Configfiles) RPM has special processes for configuration files. Because users often need to modify the software configuration files according to the actual situation. If such files are simply covered when installing, users have to re-manually set, it is very troublesome. In this case, RPM is more sensible: it saves the original configuration file (original file name suffix plus. Rpmorig), users can recover again to avoid resetting the embarrassment.

5. Unzip the package and stored to the corresponding position This is the most important part, and it is also the key to the package installation. In this step, RPM is compressed, and the files are stored in the correct position, and the attributes such as the file operation permission are correct.

6. Perform the installation Script Program (PostInstall) This type of program is the correct execution of the software to set the relevant resources, such as modifying inetd.conf, running the LDConfig program to take effect by the new dynamic link library.

7. After updating the RPM database installation, RPM records the installed software and related information into its database, which is easy to upgrade, query, check, and uninstall.

8. Implementation When the installation The trigger script is a scriptor that triggers a package satisfying a certain condition (such as the installed package Sendmail, or File version is greater than 3.0), which is used for software packages. Interactive control. Trigger script has three categories: First, the package is triggered when the package is installed. After the package is unloaded, the execution is triggered, referred to as uninstall, trigger the script program (TRIGGERPOSTUN). These trigger scripts have greatly extended the functionality of the RPM package management. The command format is installed in the RPM format, and the following command format can be used:

RPM -i [Installation Option 1 Installation Option 2 ...] package file 1 Pack file 2 ... Note: Available - ISTALL instead of -i, the effect is the same. Option list package file For parcel files in the RPM format to be installed, RPM does not make mandatory requirements for its name. Users can use the following three ways: 1. Typical naming style (common):

The format is: Software Name - Version Number - Release Number. System Number .RPM Note: The system number refers to the processor system applicable to the program, such as the i386 system, SPARC system, etc. When the system number is SRC, it indicates the source code package, otherwise it is to execute the package. For example, ABC-3.2-1.i386.rpm is the execution package, the software is named ABC, version number is 3.2, released is 1, the application system is I386, and ABC-3.2-1.src.rpm is the source code package.

2. Named style in the form of up (more common):

* FTP mode Name format: ftp: // [Username [: Password] @] Host [: Port] / Parcel file Note: [] The enclosed content represents optional. The host can be a host name, or an IP address. The package file can contain directory information. If the username is not specified, the RPM transmits data in anonymous mode (name anonymous). If the password is not specified, the RPM prompts the user to enter a password according to the actual situation. If the port is not specified, RPM uses the default port (generally 21).

Such as ftp://ftp.xxx.com/yyy.rpm (using anonymous transfer, host ftp.xxx.com, package file yyy.rpm); if ftp://24.109.164.55:1024/pub/yyy.rpm Anonymous FTP transmission, host IP: 24.109.164.55, use 1024 port, package file in / PUB directory); if ftp: //zhsoft@ftp.xxx.com/yyy.rpm (host ftp.xxx.com, FTP users Name zhsoft, if there is a password, RPM will automatically prompt the input); if ftp: // zhsoft: password@ftp.xxx.com/yyy.rpm (host ftp.xxx.com, ftp user name zhsoft, password password).

* Naming of HTTP: http: // Host [: Port] / Package file Note: [] The content hosted can be selected. The host can be a host name, or an IP address. The package file can contain directory information. If the port is not specified, the RPM uses an 80-port by default.

Such as http://www.xxx.com/yyy.rpm (get YYY.RPM file on the www.xxx.com host); Another http://www.xxx.com:8080/pub/yyy. RPM (Get the YYY.RPM file under the Www.xxx.com host / pub directory, use port 8080).

3. Other forms (rarely used):

Name format: If you rename ABC-3.2-1.i386.rpm to abc.txt, use RPM installations to be installed, the root cause is that the RPM determines whether a file is RPM format, not looking at the name, but see content, See if it is in line with a specific format. Options detailed, install the specified option

1.hash (or -h): Use this option if a package is very large if a package is very large, and the user wants to know the installation schedule. This option is expressed in the ## representation, each ## indicates a 2% progress, and 50 ## is displayed. Install the mysql package below, as shown below: # rpm -i --hash mysql-3.22.32-1.i386.rpm ##################### ##################### From the above, the package is installed smoothly.

2.Percent: The meaning of the installation schedule in% (percentage) is percentage, and this option is to display the installation progress at a percentage (%). Also install the MySQL package, the output below is different:

# rpm -i --percent mysql-3.22.32-1.i386.rpm %% 0.000000 %% 0.002600 %% 0.020586 ... %% 100.000000 # Previous omitted a lot of output (..... Indication). Because if the package is very large, the content that is output when using --percent is used, so the user is best to use the --hash option to indicate the installation schedule, which is simple.

3. Test: Install the test so-called installation test, which is not true installation, it does not copy and create any files. The purpose of this option is to detect whether the dependency of the package is satisfied, there is a potential conflict, etc.

# rpm -i --Test AutoFS-3.1.3-2.i386.rpmerror: failed dependencies: mktemp is needed by autofs-3.1.3-2 # This example is discovered when the installation test is discovered, and Autofs needs The MkTemp package does not exist, and the installation is interrupted. Let's install the mktemp package first, then perform the autofs installation test, how about the situation:

# rpm -i mktemp-1.5-2.i386.rpm # rpm -i --Test Autofs-3.1.3-2.i386.rpm # As seen, this test did not have any errors.

4.Replacepkgs: Why is the software package to replace the package? The reason may be that the package in the system has been destroyed, one or more files are lost or damaged. If the user wants to fix this package, use the method directly installed, RPM will report an error:

# rpm -v filemissing / usr / man / man1 / file.1 # rpm -i file-3.26-6.i386.rpmpackage file-3.26-6 is already installed # Note: This example is first checked with RPM verification command to verify File package, discovery /usr/man/man1/file.1 file loss. After installation, the RPM prompt package FILE-3.26-6 is already installed. (About rpm check command, << Excellent RPM 6 - Check Arts >> will have a detailed introduction) If the - replacepkgs option, what is the result?

# rpm -i - rereplacepkgs file-3.26-6.i386.rpm # rpm -v file # It seems that RPM successfully replaces the original package, verify the package, found that there is no error output, so the current package it `s complete.

5.ReplaceFiles: Replace file RPM is a smart package manager that maintains file information for each installed package. If the RPM discovers the file name in some files and the file name in some files, the RPM will think that this is a file conflict, it will report: # rpm -i ff-4.0-2.i386.rpmfile / ROOT/My.a from install of ff-4.0-2 conflicts with file from package zoo-6.0-1 # Note: This example finds the package ff- to be installed 4.0-2 In ZOO-6.0-1 installed, it contains the same file /root/my.a, but its content is not the same, so prompts the file conflict error. If the user wants to ignore this error, use the -ReplaceFiles option to indicate that the RPM discovery file conflict can replace the original file directly. Note: Unless the user has a deep understanding of the conflict, do not easily replace files, so as not to destroy the integrity of the installed package, make sure it can run normally.

# rpm -i - rereplacefiles FF-4.0-2.I386.RPM # After using this option, the package can be installed smoothly. In addition, it is said that the file is replaced, if the file in the package is already installed, but this file does not belong to any package, the RPM is the practice of saving the file to save (file name suffix. Rpmorig), and warned Information reminds users. As follows:

# rpm -i foo-6.0-1.i386.rpmwarning: /etc/foo.conf Saved as /etc/foo.conf.rpmorig#

6.AllFiles: Install all file readers to see this option, maybe ask: Is the RPM installation package not installed all of these files? My answer is: If it is installed for the first time, RPM is indeed installed all the files in the package. However, if it is a repair package (with the - replacepkigs option), the result is not necessarily. Some of the principle: Some configuration files in the RPM package can be identified as missingok properties (Missingok means even if it is lost, still OK), such package installation, if this type of profile is deleted, then RPM default The practice is no longer installed with this type, unless --allfiles option is adopted. Let's look at a practical example:

# rpm -i foo-6.0-1.i386.rpm # ls -l /etc/foo.conf-rw-r--r - 1 root root9 oct 11 09:50 /etc/foo.conf# RM -F /etc/foo.conf# rpm -i --replacepkgs foo-6.0-1.i386.rpm # ls -l /etc/foo.confls: /etc/foo.conf: file or directory does not exist # rpm -i - -replacepkgs --allfiles foo-6.0-1.i386.rpm # ls -l /etc/foo.conf-rw-r--r - 1 root root9 oct 11 09:50 /etc/foo.conf Note: this The configuration files in the FOO package have been known in advance, with the Missingok property. (1) Install the FOO package with the rpm -i command; (2) Use the LS command to belong to the configuration file /etc/foo.conf (can list, indicating that the file exists); (3) Delete the use of the RM command This file; (4) Repair the foo package with the rpm -i - rereplacepkgs command; (5) Because the -allfiles option is not used when the fix is ​​fixed, it is wrong with the LS command / Etc/foo.conf: Presented, no installation; (6) Install the foo package with the rpm -i --replacepkgs --allfiles command; (7) Re-use the LS command column file, listed, indicating that this time is installed. As seen from this example, if the user does want to restore (repair) a package, it is best to use the --allfiles option. Under normal circumstances, don't do this, because the configuration file with the Missingok property is that it can be lost, don't care too much. 7.FORCE: The meaning of enforcing the implementation of Force is forced. - The role offorce option is to force the installation package, regardless of whether the package is installed, do not consider there is no file conflict. Its effect is equivalent to the simultaneous use - ReplacePkgs installation with the --ReplaceFiles option.

8.ExCludedocs: Do not install the document RPM has multiple functions, one of which is divided into configuration files, documentation and other files, so that it is easy to treat, flexible. More than 5,000 instruction documents are included in the Linux distribution based on RPM installation, with 50m bytes, and the space occupied is not small. If you want to save space, use the --excludedocs option to exclude the installation instructions document. If the package file contains /usr/man/man1/file.1 and /usr/man/man4/magic.4 documentation. If you use the --excludedocs option when installing, these two documents will not be installed.

# rpm -i --excludedocs file-3.26-6.i386.rpm # ls -l /usr/man/man1/file.1ls: /usr/man/man1/file.1: file or directory does not exist # ls - l /usr/man/man4/magic.4ls: /usr/man/man4/magic.4: file or directory does not exist # If the user wants the RPM to install the document by default, you can do this: Edit ~ / .rpmmacros Document (RPM macro file under the user home directory home), add the following line:

%_excludedocs 1 The role is to define the _excludedocs macro inside the RPM. Confirm that the document is not installed. In this case, you don't have to use the --excludedocs option in the command line. # rpm -i file-3.26-6.i386.rpm # ls -l /usr/man/man1/file.1ls: /usr/man/man1/file.1: file or directory does not exist # ls -l / usr /man/man4/magic.4ls: /usr/man/man4/magic.4: file or directory does not exist #

9. Includedocs: Installation Description Document RPM is usually installed in the installation document, but if the user modifies the settings (like the above example), the RPM will no longer install the document, unless specified, this is used - Includedocs option. In this case, you can only ensure that the installation instruction document is installed.

# rpm -i --includedocs file-3.26-6.i386.rpm # ls -l /usr/man/man1/file.1-rwxr-xr-x 1 root root12023 mar 23 1999 / usr / man / man1 / file .1 # ls -l /usr/man/man4/magic.4-rwxr-xr-x 1 root root 6625 mar 23 1999 /usr/man/man4/magic.4#

10.Noscripts: Do not perform a script A rpm package can contain five scripts, namely: Installing the script, post-installation script, uninstall the script program, uninstall the script, and check script. Use the --noscripts option when installing, which can disable the execution of the script program before installation.

# rpm -i foo-6.0-1.i386.rpmpreinstall is running ... DONEPOSTINSTALL IS RUNNING ... DONE # Do not prohibit the execution of script programs, do not perform scripts below, please see the output results:

# rpm -i --noscripts foo-6.0-1.i386.rpm # See, because there is no output in front of the script program before installation, so there is no output. Note: General users do not use this option. This option is primarily provided to the package producer. The entire system can be prevented by prohibiting the execution script programs. This option does not have to be used when the package has dropped the bug.

11.Nodeps: Do not check the RPM management package, not only management of all files in the package, but also manage the dependencies between packages. If a is running on B, if B does not exist, then A will not run. RPM maintains this relationship, try to avoid damage to ensure the normal operation of the software.

# rpm -i autofs-3.1.3-2.i386.rpmerror: failed Dependencies: mktemp is needed by autofs-3.1.3-2 # This example has a dependence error (Autofs depends on MkTemp, but mktem does not exist ), The installation process is interrupted. If you want RPM to install properly, it is necessary to use the --nodeps option to indicate that RPM does not check dependencies, so it can be installed.

# rpm -i --nodeps autofs-3.1.3-2.i386.rpm # Note: Do not use this option unless the user has enough understanding, or just want to see the software, do not use this option to maintain normal dependencies between software relationship.

12.Notriggers: Do not perform the trigger program for the interaction between the software package, RPM designs three triggers: Trigger the program, uninstall the programs, and the trigger programs before installing. In order to prevent the implementation of the trigger program during installation due to a package, you can use the --NOTRIGERS option. 13. Ignorerch: Ignore the system and Ignoreos: Ignore the operating system What is the system? System is the category of the CPU, with Intel's X86 (such as the i386, i486 series) system, SUN SPARC system, etc. When a package is established, RPM specifies the applicable CPU system, which also specifies the operating system applicable. The advantage of this is that rpm is easy to know if the package established for a computer is suitable for compatible with another computer. RPM resource profile (default is / usr / lib / rpm / rpmrc) defines a compatibility relationship of the system (ARCH_COMPAT expression) and the compatibility relationship of the operating system (OS_COMPAT expression). RPM When you install a parcel file, you have to do such a compatible check. If the user wants to ignore the system, no matter whether it is compatible, please use the - IGNOREARCH option. If you are also compatible with the operating system, you can use the --ignoreos option. It should be pointed out that if you don't know your own purpose, don't try to do this.

14. IgnoreSize: Do not check the space size RPM before installing the package, first check if there is enough remaining space if there is enough space, if the space is insufficient, the installation will not be completed. The purpose of this option is to indicate that the RPM does not do the size of the space size, that is, whether the system has the space to be installed, it will be installed.

15.Relocate: Relocating the RPM package In the production process, you can define one or more relocation prefixes to facilitate the relocation of the software (ie, put the files in the package in the custom directory), thereby increasing The flexibility of the package installation. This option is used to replace the specified relocation directory. If a package has multiple relocation prefix, you can use this option multiple times.

# rpm -qpl file-3.26-6.i386.rpm / usr / bin / file / usr / man / man4 / magic.4 / usr / share / magic # rpm -i - -relocate / usr = / tmp file-3.26-6.i386.rpm # rpm -ql file / tmp / bin / file / tmp / man / man1 / file.1 / tmp / man / man4 / magic.4 / TMP / Share / Magic # Note: This example is first used with RPM -QPL to list the files in the package file file-3.26-6.i386.rpm, which can be seen in this file is starting with / usr. After the reacting installation, the / usr is converted to / TMP. Finally, it can be seen from the list of files listed in the installed FILE package. The original / USR directory prefix is ​​converted to the specified prefix / TMP, so that the software relocation is achieved. (About RPM Query Command, see << Excellent RPM five - query articles >>)

16.Badreloc: Mandatory relocation of the relocation of the RPM package, depending on the definition of the production timeup prefix. If no relocation prefix is ​​defined, or the relocation prefix specified in the user installation does not exist, the RPM will report an error and interrupt the installation. At this point, if this option is used, the RPM will make the mandatory relocation installation regardless of these errors. Note: This option and --Relocate option make sense when used simultaneously. As in the above example, the installation of the relocation prefix / usr / man does not exist: # rpm -i --relocate / usr / man = / tmpMPath / usr / man is not relocateable for package FILE-3.26-6 # rpm prompts the error: / usr / man directory is uncomfortable in the FILE-3.26-6 package. In addition, how is the --badreloc option, how is the result:

# rpm -i --relocate / usr / man = / tmp --Badreloc file-3.26-6.i386.rpm # rpm -ql file / usr / bin / file / tmp / man1 / file.1 / tmp / man4 / Magic.4 / usr / share / magic # can be seen by this forced relocation, then use the query command RPM-QL to column file files, will find the original / usr / man / man1 /file.1 is positioned into /tmp/man1/file.1, and /usr/man/man4/magic.4 is /tmp/man4/magic.4. How? Magical!

17.ExCludePath: Do not install files in the specified directory Utilize this option, you can disable RPM from installing files in some specified directory. You can use this option if you do not want to install the documentation in the File package. In addition to the available -excludedocs options. Because the documentation of the file is under directory / usr / man.

# rpm -i --excludepath / usr / man file-3.26-6.i386.rpm # rpm -qls filenormal / usr / bin / filenot installed /usr/man/man1/file.1Not Installed / USR / MAN / Man4 / Magic.4normal / usr / share / magic # Note: The file package is installed first in the example, and the files under the installation / usr / man are disabled with -excludePath, and then use the rpm query command rpm -qls to list files and status of the file package. You can see that both files under / usr / man are not installed (Not installed).

18.justdb: Only Update Database Installation Package After using this option, RPM will only update its database data, file system is not updated, and it is not copied and established in the package.

# rpm -i --justdb file-3.26-6.i386.rpm # rpm -qls filenormal / usr / bin / filenormal / usr / man / man1 / file.1normal / usr / man / man4 / magic.4normal / usr / Share / Magic # ls -l / usr / bin / file: / usr / bin / file: file or directory does not exist # Note: The file is installed in the example but indicates that only the database is updated, the result is: Although the query command finds it All file status in the package is normal (Normal), but file / usr / bin / file contained in the ls command package, which does not exist. This indicates that the films in the package were not established.

19.PREFIX: Specifies the repositioning prefix As mentioned, the heavy positionable package can contain one or more relocation prefixes, which can be used to change the value of a relocation prefix. --prefix option can only be used to change the default relocation prefix (the default is the first relocation prefix), it does not need to illustrate the original positional prefix. The following example also installs the file package to / TMP directory: # rpm -qpl file-3.26-6.i386.rpm / usr / bin / file / usr / man / man1 / file.1 / usr / man / man4 / magic .4 / usr / share / magic # rpm -i --prefix / tmp file-3.26-6.i386.rpm # rpm -ql file / tmp / bin / file / tmp / man / man1 / file.1 / tmp / Man / man4 / magic.4 / tmp / share / magic #

20.ftpproxy: Specifies the FTP Proxy Host This option specifies the FTP proxy host, the host can be a host name or an IP address.

21.ftpport: Specifies that the FTP port This option specifies the TCP port used by the FTP protocol. The system is 21. Please see the example below:

# rpm -iv --ft 8888 ftp: //root@xwboc/tmp/file-3.26-6.i386.rpmpassword for root @ xwboc:

Password for root @ xwboc:

Retrieving ftp://root@xwboc/tmp/file-3.26-6.i386.rpmfile-3.26-6# This example is installed in FTP mode, and the data transfer uses 8888 ports. In execution, RPM first prompts to enter the root user's password twice, then download (retrieve) software, and finally install it.

22. HttpProxy: Specifies the HTTP Proxy Host This option specifies the HTTP proxy host. The host can be a host name or an IP address.

23.httpport: Specify the HTTP Port This option specifies the TCP port used by the HTTP protocol. The system is 80 defaults. The following example specifies an 80-port to install AutoFS software, of course, not specified, because the system is the default is this port.

# rpm -iv - httpport 80 http://24.109.164.55/rpms/autofs-3.1.3-2.i386.rpmReving http://24.109.164.55/rpms/autofs-3.1.3-2.i386.rpmautofs -3.1.3-2 # Note: Like FTP mode, RPM is downloaded and installed. Second, the universal options so-called general option, whether it is installation, upgrade, uninstall or other package operation, all the options. Such options are the following:

1.-V: Show additional information, RPM and a lot of Linux commands (such as CP, RM, MV, etc.), all of which output information as little as possible (unless necessary, do not output), It is to avoid waste of CPU resources. So, when the user uses a command, there is no output, which means that the command is executed successfully. If there is any error, the program will prompt. RPM is also this. In order to output more information about the RPM, the -v option can be used. If you don't have this option to install the file package, no output:

# r r i f 3 3 包 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名 名

2.-VV: Display debugging information Selection -VV option, you can output more information. These information, mainly for RPM software developers to study, general users can also see, from it you can know what RPM is doing. The following is installed with this option to install the file package, and the output data is sent to the output data to output per line data with the line number. From the execution result, there are many information in the output, where D: The line of the beginning is debugging information. Now explain: Chapter 1: Statistical software package to be installed; line 2: RPM found 1 package; line 3: See which packages need to download (these to download package, all in ftp or http The name of the package is written); 4th line: Download 0 packages; Article 5-10: Take the file header information of the package file, calculate the space 68019 (bytes) for the package, so that the system is sufficient space. Chapter 11: Open the RPM Database; Chapter 12: Find 0 source code packs, 1 execution code package; section 13-18: Check the dependencies of the package. Its requires is satisfied (Satisfied). Chapter 19: Prepare to install the execution code package; 20 lines: obtain a list of installed file systems; line 21-26: Retreat the package file header information, calculate the package occupied by the package; 27-31 line: List the package In Chinese and the operation to be executed, the Test = 0 of the 27th line indicates that the file is not installed, and the file in the file package is executed. Create. Chapter 32: If there is a script program before installation, execute it; 33 line: Install the software package file-3.26-6; 34th line: If you have a script, execute the script, execute it.

3.Root: Specifies the root directory to specify root directory root, which limits all of the system all operations under the specified directory so that the database position of the RPM operation has changed, and the installation location of the package has changed. It is implemented by the Chroot system call. The RPM default database directory is / var / lib / rpm, if the root directory is / usr, the RPM database directory will change to / usr / var / lib / rpm. Similarly, if there is a file in the package to /etc/zhsoft.txt, it is installed for /usr/etc/zhsoft.txt. Look at the example below:

# rpm-ot / usr file-3.26-6.i386.rpmfailed to open /usr/var/lib/rpm/packages.rpmerror: Can't open /usr/var/lib/rpm/packages.rpm# Note: Specifies the RPM root directory to / usr installation File error, RPM does not open /usr/var/lib/rpm/packages.rpm file, because there is no RPM database in / usr / var / lib / rpm directory . If you want to successfully install, you can use the RPM database command to build the RPM database, the command is RPM --initdb --root / usr (these features will be told later). 4.rcfile: Specifies the RPM Resource Profile RPM resource profile, stores the default settings of the RPM, with the compilation option OptFlags, the system definition arch_canon, compatible definition arch_compat, macro file definition macrofiles, etc. RPM default resource profile (in the read order) is: / usr / lib / rpm / rpmrc, /etc/rpmrc ,~/.rpmrc. (The two documents are now unpleasant, and now it is generally changed by the RPM macro file. Compared with the resource profile, the macro file has greater flexibility.) If you want RPM to use the user-specified resource profile, --rcfile is set to set multiple files at the same time, and the file is separated by a colon (:), such as /usr/lib/rpmrc:/etc/rpmrc:~/.rpmrc this form.

5.Dbpath: Specifies the RPM Database Tablebook This option is different from the -root option, which is just the directory of the RPM database and does not change the location of the installation file.

转载请注明原文地址:https://www.9cbs.com/read-130238.html

New Post(0)