RPM installation articles

xiaoxiao2021-03-06  66

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 conflict of the package (Conflicts)

Some software cannot coexist with some software, 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 (preInstall)

Such programs are set by the software package author and need to be executed before installation. Usually the operating environment, establish a directory, clean up excess file, etc., prepare for successful installation.

4. Processing a configuration file (configfiles)

RPM has special processes for configuration files (Configfiles). 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 store it 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. Execute the script program (PostInstall)

Such programs are the correct execution of the software to set relevant resources, such as modifying inetd.conf, running the LDCONFIG program to take effect by the new dynamic link library.

7. Update RPM Database

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

8. Trigger script programs when performing installation (TRIGGERIN)

The trigger scripker refers to a script that is triggered when a package meets a certain condition (such as the installed package Sendmail, or File version is greater than 3.0), which is used for interaction control between the package. 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.

Command format

Install software packages in RPM format, you can use the following command format:

RPM -I [Installation Option 1 Installation Options 2 ...] package file 1 Pack file 2 ...

Note: Use -install instead of -i and the effect is the same.

Option list

Parcel file

For parcel files in the RPM format to be installed, RPM does not mandate its name. Users can use the following three ways: 1. Typical naming style (common):

Format is: Software Name - Version Number - Release No. System Number.rpm

Note: The system number refers to the processor system applicable to the execution 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 naming format: ftp: // [Username [: Password] @] Host [: Port] / Package 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).

* Named of http mode: http: // Host [: port] / package file

Note: [] The content hosted is optional. 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: arbitrary

If the ABC-3.2-1.i386.rpm is named abc.txt, the RPM installation is also installed, and the root cause is that the RPM determines whether a file is RPM format, not looking at the name, but looks, see if it is compliant. Specific format.

Options

First, install the specified option option

1.hash (or -h): display the installation schedule

If a package is very large and the installation fee, the user must use this option if you want 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 ##################### ###########################################

As always, the package is installed smoothly.

2.Percent: Displays the installation schedule with% (%)

The meaning of Percent is a percentage, and this option is to display the installation progress in 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 #

There are many outputs (... represented) in the above example. 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: Installation Test

The so-called installation test is not true to install, it does not copy and build 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 the MkTemp package required by Autofs does not exist, and the interrupt is installed.

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-t --test autofs-3.1.3-2.i386.rpm #

As seen from the above, there is no error in this test.

4.Replacepkgs: Replace package

Why 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 first uses the RPM check command to verify the File package, discover the /usr/man/man1/file.1 file loss. After installation, the RPM prompt package FILE-3.26-6 is already installed. (About the RPM check command, << Excellent RPM 6 - Check Articles >> will have a detailed introduction)

What is the result of using the --ReplacePkgs option?

# rpm -i --replacepkgs file-3.26-6.i386.rpm # rpm -v file #

It seems that RPM successfully replaces the original package, check the package, and find that there is no error output, so the current package is complete.

5. ReplacingFiles: Replacement 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: In this example, the software package to be installed is found to be installed in ZOO-6.0-1, which contains the same file /Root/my.a, but its content is not the same, so Prompt the error of the file conflict.

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 --replacefiles 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 files

Readers 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 example has been known in advance in the FOO package /etc/foo.conf with Missingok properties.

(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) Use the RM command to delete this file; (4) Repair the Foo package with the rpm -i -replacepkgs command;

(5) Because the -allfiles option is not used, it is wrong with the LS command / Etc/foo.conf: the file does not exist, 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: Mandatory Execution

The meaning of Force is mandatory. - 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 documentation

RPM has multiple functions, one of which is to divide the file into a configuration file, 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 not install the document by default, you can do this: Edit ~ / .rpmmacros file (the RPM macro file under the user home directory home), add the following line:

% _excludedocs 1

Its role is to define the _excludedocs macro within 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 typically 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 to use the -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: No script program

One rpm package can contain five scripts, namely: Pre-installation script, post-installed script, uninstall, script, uninstall, 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 #

The above is not prohibited from execution of the script, do not perform the script, please see the output:

# rpm -i --noscripts foo-6.0-1.i386.rpm #

Look, because there is no output, there is no output, so there is no output before the installation of the script program before installation.

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

RPM management packages, not only manage 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 an error in the installation (Autofs depends on MkTemp, but mktemp does not exist), and 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 wants to look at the software, do not use this option to maintain the normal dependencies between the software.

12.Notriggers: Do not perform trigger programs

For interaction control between the software package, the RPM designs three triggers: trigger the program, uninstalling the trigger, and the trigger program, and the trigger program. In order to prevent the implementation of the trigger program during installation due to a package, you can use the --NOTRIGERS option.

13.Ignorearch: ignore the system and Ignoreos: ignore the operating system

What is the system? The system is the category of the CPU, with Intel's X86 (e.g., 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, use the --ignorearch option to install. 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 size of space

RPM is installed 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: Relocation

The RPM package can define one or more relocation prefix during production, so that the software is relocated (ie, putting the files in the package in the custom directory), 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: In this case, the files in the package file file-3.26-6.i386.rpm are first listed in this example, which can see that the files are 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: Forced relocation

The relocation of the RPM package is dependent on the definition of the prefix when making it. 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 reactive prefix / usr / man in which it does not exist is installed:

# rpm -i --relocate / usr / man = / tmp file-3.26-6.i386.rpmpmpath / 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 #

As can be seen, such a forced relocation is passed, then use the query command RPM-QL to column file file, it will find the original /usr/man/man1/file.1 to be positioned to / TMP / Man1 / file.1, and / /usr/man/man4/magic.4 became /tmp/man4/magic.4. How? Magical!

17.ExCludePath: Do not install files in the specified directory

With this option, you can disable the 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, and the file under / usr / man is disabled with -excludePath, and then use the RPM query command rpm -qls to list the file and status of the file package, you can see: / usr / man The two files are not installed (Not installed).

18.justdb: only update the database

After installing the package With this option, RPM will only update its database data, the 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 / filels: / 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 is used to find all the file status in the package is normal (Normal), but the file contained in the LS command package / usr / bin / File, this file does not exist. This indicates that the films in the package were not established.

19.prefix: Specifies the relocation prefix

As previously mentioned, a 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 the / TMP directory:

# rpm -qpl file-3.26-6.i386.rpm / usr / bin / file / 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, and the host can be a host name or an IP address.

21.ftpport: Specifies the FTP port

This option specifies the TCP port used by the FTP protocol, and 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.rpm

FILE-3.26-6

#

In this example, the FILE package is installed in the FTP mode, and the data transfer uses the 8888 port. 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, and the host can be a host name or an IP address.

23.httpport: Specify 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, universal options

The so-called universal option is whether it is installation, upgrade, and unloading or other package operations, all applicable options.

Such options are the following:

1.-V: Display additional information

Under normal circumstances, RPM and many Linux commands (such as CP, RM, MV, etc.) are the same, in the principle of outputting information as little as possible (unless necessary, do not output), this 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:

# rpm -i file-3.26-6.i386.rpm #

When you use the -v option, you will output your name:

# rpm -i -v file-3.26-6.i386.rpmfile-3.26-6 #

2.-VV: Display debugging information

Use the -vv option to 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 by line:

Line 1: Statistical software package to be installed;

Chapter 2: RPM found 1 package;

Chapter 3: See which packages need to download (these packages to download, are the package names written in FTP or HTTP);

Chapter 4: Download 0 packages;

Article 5-10: Take the file header information of the parcel file, calculate the space 68019 (bytes) for the software package, to check

Whether there 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).

19th line: Prepare to install the execution code package;

20 line: obtain a list of installed file systems;

Row 21-26: Re-take the package file header information, calculate the package occupied by the package;

27-31 line: List the files in the package and the operation to be executed, the TEST = 0 of the 27th line is not the installation test,

The files in the FILE package must perform the creation operation (CREATE).

Chapter 32: If there is a script program before installation, execute it;

Chapter 33: Install the software package File-3.26-6;

34 line: If there is a script, execute the script, execute it.

3.Root: Specify root directory

Specifies the root root root, its role is to limit all operations in the specified directory, so that the database position of the RPM operation has changed, 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 -root / 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 can't open /usr/var/lib/rpm/packages.rpm file, this is because it is actually no anywhere in / usr / var / lib / rpm directory RPM database. 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: Specify RPM Resource Profile

In the resource profile of the RPM, the default settings of the RPM are stored. There are compilation option OptFlags, the system definition arch_canon, compatible definitions arch_compat, macro file definition macrofiles, etc. RPM default resource profile (sequence by reading) is: /us r/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: Specify the RPM database directory

This option is different from the -root option, which is just the directory of the specified RPM database, does not change the location of the installation file.

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

New Post(0)