RPM completely installed & upgrade & alternative usage

xiaoxiao2021-03-06  38

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 Said 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 wants to do the following: 1. Check the Dependency RPM format package can include a description of dependencies, such as what dynctive link library required for software execution, what program needs to exist and Version number requirements, etc. 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 (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 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.

Command format installation of the software package for the RPM format, you can use the following command format: rpm -i [Installation Option 1 Installation Option 2 ...] package file 1 Pack file 2 ... Note: You can use -install instead of -i, the same effect . 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): Format is: Software Name - Release Number. System Number .rpm Note: The system number refers to the processing of execution System, such as 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 (more common) * ftp mode in the form of the FTP mode: 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). 3 Naming of HTTP mode: Format is: http: // Host [: Port] / Package file Note: [] The enclosed content 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 host at www.xxx.com); if http://www.xxx.com:8080/pub/yyy.rpm (Use HTTP to get the YYY.RPM file under the / PUB directory on the host / pub directory, use port 8080).

3. Other forms (rarely): Name format: Random ABC-3.2-1.i386.rpm is renamed Abc.txt, and the RPM installation will be installed, and the root cause is RPM to determine whether a file is RPM format. Not looking at the name, but look at the content, see if it is in line with a specific format. Parameters: 1. Install the specified option 1.hash (or -h): Display the installation progress, if a package is very large, 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 ##################### ################# 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 following output is different: # rpm -i --percent mysql-3.22.32-1.i386.rpm %% 0.000000 %% 0.002600 %% 0.020586 ... %% 100.000000 # 省多多多 (...) is omitted in the previous 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: 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.rpm error: failed Deprondencies: mktemp is needed by autofs-3.1.3-2 # This example is discovered when the installation test is discovered, and the Autofs The MkTemp package required does not exist and install the interrupt. 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: 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 file missing / usr / man / man1 / file.1 # rpm -i file-3.26-6.i386.rpm package file -3.26-6 is Already Installed # Note: This example 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 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.rpm file /Root/my.a from install of ff-4.0-2 conflicts with file from package zoo-6.0-1 # Note: This example found the package FF to be installed -4.0-2 In ZOO-6.0-1, the installed package zoo-6.0-1 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 shown below: # rpm -i foo-6.0-1.i386.rpm warning: /etc/foo.conf saved as /etc/foo.conf.rpmorig # 6.AllFiles: Install all file readers to see this option, maybe To ask: Is the RPM installation package not installed all the files installed? 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 the actual 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 - rereplacepkgs foo-6.0-1.i386.rpm # ls -l /etc/foo.conf ls: /etc/foo.conf: file or Directory does not exist # rpm -i - rereplacepkgs --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) 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.1 ls: /usr/man/man1/file.1: file or directory does not exist # ls -l /usr/man/man4/magic.4 ls: /usr/man/man4/magic.4: file or directory does not exist # If the user wants the RPM without the instruction document by default, you can do this: Edit ~ / . rpmmacros file (RPM macro file under user main catalog Home), add the following line:% _exCludedocs 1 It 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.1 ls: /usr/man/man1/file.1: file or directory does not exist # ls -l / USR / MAN / Man4 / Magic.4 LS: /usr/man/man4/magic.4: File or Directory does not exist # 9.includedocs: Installation Description Document RPM is generally installation instruction document, but if the user modifies Setting (like the example above), RPM no longer installs 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: Do not perform a scriptor an RPM Five scripts can be included in the package, namely: before installing the script, post-installed script, uninstall the script, 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.rpm preInstall Is Running ... DONE POSTINSTALL IS Running ... DONE # Do not disable the execution of the script, do not perform the script, please see the output: # rpm - I --Noscripts foo-6.0-1.i386.rpm # see, because there is no output in the execution 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.rpm error: failed dependencies: mktemp is needed by autofs-3.1.3-2 # This example has a dependence error (Autofs rely on MkTemp, but mktemp is not The existence), 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, 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 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/man1/file.1 /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 5 - Query Articles >>) 16.Badreloc: Forced relocation of the RPM package relocation, depending 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 existence is used: # rpm -i --relocate / usr / man = / tmp file-3.26-6.i386.rpm path / 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. Together with the --badreloc option, how about: # 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, such a forced relocation is passed, then use the query command rpm -ql column file file file. I will find that the original /usr/man/man1/file.1 is positioned as /tmp/man1/file.1, and / /usr/man/man4/magic.4 is /tmp/man4/magic.4 . How? Magic! 17.ExCludePath: Do not install files in the specified directory to use 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 file normal / usr / bin / file not installed /usr/man/man1/file.1 Not installed / usr / man /man4/magic.4 normal / usr / share / magic # Note: Install the File package in the example, and use -excludePath to disable files under / usr / man, then use the RPM query command rpm -qls listing the file package The file and status can be seen: Noth 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 file normal / usr / bin / file normal / usr / man / man1 / file.1 Normal / USR / Man / Man4 / Magic.4 Normal / usr / share / magic # ls -l / usr / bin / file ls: / 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: The query command finds that 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 with the -relocate option. --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 / 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 the host name, or the IP address. 21.ftpport: Specifies that 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 --ftpport 8888 ftp://root@xwboc/tmp/file-3.26-6.i386.rpm password for root @ xwboc: password for root @ xwboc: retrieving ftp: // Root@xwboc/tmp/file-3.26-6.i386.rpm file-3.26-6 # This example is installed with File packages in FTP, and the data transfer uses 8888 ports. In execution, RPM first prompts to enter the password of the root user 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.rpm retrieving http://24.109.164.55/rpms/autofs-3.1.3-2.i386. RPM AutoFS-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: Display 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 Otherwise do not output), doing this 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 #, the package name is installed after using the -V option: # rpm -i -v file-3.26-6 .i386.rpm file-3.26-6 # 2.-vv: Display debugging information Select the -vv option, you can output more information to the RPM. 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 following example: # rpm -io --root / usr file-3.26-6.i386.rpm failed to open /usr/var/lib/rpm/packages.rpm error: Can't open / usr / var / lib / rpm /Packages.rpm # Note: Specify the RPM root directory to / usr installation File error, RPM does not open /usr/var/lib/rpm/packages.rpm file, this is because of actually in / usr / var / lib / There is no RPM database in the 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 (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: 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. -----------------------------------------------

Upgrade what RPM upgrade is one of the reasons why it is favored by users. Because the user upgrades a package from the old version to the new version, especially large software, it is necessary to have experienced support and technology accumulation, complicated, and use RPM upgrade software, just one rpm -u command is OK, It is very convenient for users. Software upgrades basically do two work, one is to install a new version, and the other is to uninstall the old version. RPM has an important job to do, this is to properly handle configuration files. If the installation method is directly used, the user has been configured to be overwritten and does not comply with the user requirements. The configuration file processes RPM to a configuration file, determine how to handle it by comparing three different MD5 checks and (checksum). These three different MD5 checks are: 1. Former inspection and. It is the MD5 check and the configuration file when the old version of the package is installed. 2. Current check and. It is an MD5 check and an old version of the configuration file when upgrading. 3. New inspection and. It is the MD5 check and the MD5 checking of the configuration file in the new version of the package. RPM processes the following cases: 1. When the original check and = X, the current check and = X, new inspection and = X: This indicates that the configuration file has not been modified. At this point, RPM covers the new profile to the original file instead of whether the original file is not processed. The reason is that although the file name and file content have no change, but the files of the file (such as the owner of the document) Group, permissions, etc.) may change, so it is necessary to overwrite. 2. When the original check and = x, the current check and = x, new inspections and = y: This indicates that the original configuration file has no changes, but it is different from the configuration files in the new package. In this case, RPM will overwrite the old file with a new file, and the old file is not saved (because it does not change, there is no need to save). 3. When the original check and = X, the current check and = Y, new inspection and = x: This indicates that the new file is the same as the old file content, but the current file has been modified, these modifications are legal for new versions. ,usable. Therefore, RPM is reserved for the current file. 4. When the original check and = x, the current check and = Y, new check and = y: This indicates that the original file has been modified, and now it has been the same as the new file, this may be the user to fix the vulnerability, the new version Also made the same modification. In this case, RPM overrides the current file to avoid file properties. 5. When the original check and = x, the current check and = Y, new check and = z: This indicates that the user has modified the original file, and the current content is different from the new file content. In this case, RPM cannot guarantee that the new version of the software can use the current configuration file normally, so it uses a more sensible approach to protect the user's configuration data, and guarantee the new version of the software. This method is to save the current file name (add a .rpmsave suffix to the original file name, if the original file is named ABC, then rename the ABC.RPMSAVE, install new files, and give a warning message, such as : Warning: /etc/.funkey Saved as /etc/.funkey.rpmsave 6. When there is no original check and time: In this case, the current check and new checks are not critical, this indicates that this configuration file is not installed. . Since this configuration file is not installed, the RPM cannot determine whether the current file has been modified by the user. In this case, RPM saves the current file name (the original file name suffix is ​​not a.rpmsave, but.rpmorig), install a new file, and give a warning message, such as: Warning: /etc/.inputdef Saved As /etc/.inputdef.rpmsave Upgrade Command Format Upgrade RPM Package, use the following command format: RPM -U [Upgrade Option 1 Upgrade Option 2 ...] [Package ID 1 Package ID ...] : Also use -UPGrade instead of -U, the effect is the same. Software Package Definition of the package ID, see the three - unloading articles >>. Option list option Description Because the upgrade is also a installation, the upgrade option list is basically the same as the installation option list, just an upgrade option list adds one - kenlPackage. Here, this option is now illustrated, and other options are explained << Excellent RPM 2 - Installation articles >>, this is not repeated. --OLDPACKAGE Options: It can be seen from the name is the meaning of the old version of the package. Why do you upgrade the software to the old version? (The upgrade here is actually downgrade) This is a reason.

The user has always used the old version of the software. When there is a new version release, immediately use the rpm -u command to upgrade to the system, but because the new version has "bug", this software cannot work properly. At this time, directly using the rpm -u command is not the old version, because the general situation is upgraded to the new version, and RPM is default this. If you want to upgrade to your old version, you must use this special option. The following example: # rpm -u -v Lze-6.0-1.i386.rpm package Lze-7.0-1 (Which is newer the Lze-6.0-1) is already installed # Note: This example occurs during the upgrade process Error, the RPM prompts the LZE package is installed, and the existing version number 7.0 is higher than the version number 6.0 ready to upgrade, and the upgrade cannot continue. If you use -OLDPACKAGE in the command line, what is the result? # Rpm -u -v --OldPackage Lze-6.0-1.i386.rpm Lze-6.0-1 # Note: The command execution outputs the package logo LZE -6.0-1, indicating that the upgrade to the old version is successful.

By outputting the debugging information to observe the main work of RPM when the upgrade package is observed: # rpm -u -vv --oldpackage foo-3.0-2.i386.rpm 2> & 1 | NL 1 D: Counting packages to install 2 D : Found 1 packages 3 D: Looking for packages to Download 4 D: Retrieved 0 packages 5 D: New Header Signature 6 D: Signature Size: 68 7 D: Signature Pad: 4 8 D: Sigsize: 72 9 D: Header Archive : 1577 10 D: EXPECTED SIZE: 1577 11 D: Opening Database Mode 0x42 In // VAR / LIB / RPM / 12 D: Found 0 Source and 1 Binary Packages 13 D: Requires: / bin / sh Satisfied by DB File Lists. 14 D: Installing Binary Packages 15 D: New Header Signature 17 D: Signature Size: 68 18 D: SIGNATURE PAD: 4 19 D: Sigsize: 72 20 D: Header Archive: 1577 21 D : EXPECTED SIZE: 1577 22 D: package: foo-3.0-2 files test = 0 23 D: file: /etc/foo.conf action: Create 24 D: file: / usr / bin / foo action: CREATE 25 D: Running Preinstall Script (if any) 26 Echo Preinstall 27 Preinstall 28 Foo-3.0-2 29 D: Running PostInstall Scripts (if any) 30 Echo PostInstall 31 postinstall 32 echo triggerinstall 33 triggerinstall 34 echo triggeruninstall 35 triggeruninstall 36 echo preuninstall 37 preuninstall 38 D: will remove files test = 0 39 D: file: / usr / bin / foo action: skip 40 D: file: / etc / foo.conf action: skip 41 D: running postuninstall script (if any) 42 echo postuninstall 43 postuninstall 44 D: removing database entry 45 D: removing name index 46 D: removing group index 47 D: removing requiredby index for / bin / SH 48 D: Removing Trigger Index for File 50 D: Removing Trigger Index for File 51 D: Removing File Index for Foo.conf 52 D: Removing File Index for Foo Note: 1-4 : Calculate the number of packets to upgrade on the command line and download the package files that need to download;

Article 5-10: Determine the software occupation space based on the package file header; 11th, 12th line: Open the RPM database and package file; line 13: Check whether the dependence is met, this example is satisfied; Package; 15th line: Take the currently installed file system list; 1st line: Re-check the package information, determine the occupied system space; "Determine the implementation operation of each file in the package, All is created; 25th line: Perform a pre-installation script (if any); 26-27 line: The command executed by starting the script program, after which it outputs the result; : Installing the FOO-3.0-2 package; 29th line: Perform the post-installed script (if any); section 30-31: Command executed by starting for the scriptor, other as the result result; 32- 33 lines: Implementation of the script program; line 34-35: Execute the first trigger script before uninstall, start unloading the original package; 36-37 line: Execute the uninstalled script; section 38-40: Determine The implementation of each document in the original package is skipped (SKIP), ie not processed; line 41-43: Execute the unloading script; section 44-52: Delete all the original package in the RPM database Information (data and index). --------------------------------------------- We are in the wind In front

RPM is not only in installation, upgrade, and unloading, but also better than other package management tools in terms of inquiries. This can be seen from the following cases: * When you are browsing the system file, find a file, I want to know which packages are from which packages come from, can use rpm to query; * When your friends send you to send one Software package, but you don't know what software package, don't know what it does, what is installed, where is the source. At this time, you can use the RPM query to get it; * I have installed XFree86 window software a few months, but now you forget it, and I don't know where it is the documentation. At this time, you can query this package with rpm to get information on this. RPM's query has a advanced feature, that is, a custom output function. You can use - QueryFormat (or -qf) to customize the output format, so that the information obtained by the RPM query will be output in your custom format, which is very convenient, especially for the process of the program. The command format queries the software package in the RPM format, you can use the following command format: RPM -Q [Query Option 1 Query Option 2 ...] Note: You can also use -Query instead of -Q, the effect is the same. Option List Option Details The four options related to FTP and HTTP in the option (- FTPPROXY, FTPPORT, HTTPPROXY, - HTTPPORT), and the general options are explained, see the second-installation of the RPM - installation Articles >> This article is no longer described. Below the specified options: Specify options can be divided into the following categories: 1. Package Select Class This option can only select one at a time, select multiple RPMs will be prompted: rpm: one Type of Query / Verify May Be Performed At A TIME is in terms of query, one is to query the installed packages, one is querying un installed packages. 1. Query the installed package, use the following options: (1) -a (or --all): Query all installed packages # rpm -q -a setup-2.0.2-1 FileSystem -1.3.4-5 BaseSystem-6.0-5 AGREP-2.04-5 Aktion-0.3.6-2 AMOR-0.5-1 DHCPCD-1.3.17PL2-1 ldconfig-1.9.5-15 GLIBC-2.1.2-12 Chkconfig -1.0.6-2 ... # Note: This example finds all the packages installed in the current system, there are a lot of output, only a few, the remaining omitted (in ... Representation).

(2) -g (or --Group): Which packages have a package that belong to the specified category RPM varies according to software functions, and divides software into the following categories: (Note in parentheses) AMUSEments / GAMES (Entertainment / Games Amusements / Graphics Applications / Archiving Applications / Communications Applications / Databases (Applications / Database) Applications / Editors (Applications / Editor) Applications / Emulators (Applications / Simulator Applications / Engineering Applications / File (Applications / Internet) Applications / MultiMedia (Applications / Multimedia) Applications / Productivity (Applications / Products) Applications / Publishing (Applications / Printing) Applications / System (Applications / Text) Applications / Text (Applications / Text) Development / Debuggers DEVELOPMENT / LIBRARES (Development / Library) Development / System (Development / System) Development / Tools Documentation (Description Document) System Environment / Base (System Environment / Basi) System Environment / Daemons System Environment / KERNEL (System Environment / Core) System Environment / Libraries (System Environment / Funcy library) System Environment / shells (System Environment / Interface) User Interface / Desktops User Interface / X (User Interface / X Window) User Interface / X Hardware Support (User Interface / X Hardware Support) Other Others) Note: Class Don't be sensitive, you should be careful when you enter. If the user wants to query which game classes have been installed in the current system, you can do this: # rpm -q -g amusements / Games Clanbomber-1.01-1 Kdegames-1.1.2-1 Xbill-2.0-6 XBoard-4.0. 0-3 XBoing-2.4-7 xgammon-0.98-14 xjewel-1.6-11 xpat2-1.04-10 xpilot-3.6.2-6 xpuzzles-5.4.1-7 xtrojka-1.2.3-6 # If the user wants to query a number When the category software package, you can list the category, query together, such as: # rpm -q -g applications / editors application / file emacs-20.3-15 EMACS-NOX-20.3-15 EMACS-X11-20.3-15 VIM -COMMON-5.6-12 VIM-minimal-5.6-12 VIM-X11-5.6-12 fileUtils-4.0-3 bzip2-0.9.5D-1 FindUTILS-4.1-32 git-4.3.17-6 gzip-1.2.4- 15 Slocate-1.4-7 STAT-1.5-12 FILE-3.26-6 # Note: This example is the first 6 items in the "Application / Editor" category, and then 8 is "App / File" category. (3) -f (or --file): What packages have a specified file to have a specified file very useful. Try this option when the user doesn't know which package belongs to a file.

If I remember / usr / sbin / ftpd this file in which package, now use rpm queries: # rpm -q / usr / sbin / ftpd inet6-apps-0.36-3 # Now I know, it is in inet6-apps -0.36-3 Package. The command in the command is the abbreviation of -q -f. When the option is only one reduction, multiple options can be combined together, such as -A -B -C three options to write -ABC, the execution effect is the same. (4) --WHATREQUIRES: What packages do you need to specify a function This option indicates which packages from all installed packages, which packages provide the user's specified function, and you can enter one or more command lines. Features. # rpm -q --whatrequires / bin / ps libc.so.6 | Head Autofs-3.1.3-2 AGREP-2.04-5 Aktion-0.3.6-2 AMOR-0.5-1 chkconfig-1.0.6-2 LIBTERMCAP -2.0.8-16 Bash-2.03-10 ncurses-4.2-18 INFO-3.12F-4 FileUtils-4.0-3 # Note: This example is queried from the system which packages need / bin / ps and libc.so.6 Function, output the top 10 lines through the pipeline. (5) --WHATPROVIDES: What packages are available in Query Features This option indicates which packages are available from all installed packages, which packages provide the user's designated function. One or more functions can be entered on the command line. # rpm -q --WhatProvides libc.so.6 / bin / ps glibc-2.1.2-12 no package provides / bin / ps # Note: This example provides libc.so.6 from the system query. / bin / ps function, the result is the GLIBC-2.1.2-12 package provides libc.so.26 without packets to provide / bin / PS functionality. (  6) --Triggeredby: What packages have been specified by the specified package Trigger this option indicates which packages are triggered by the user specified by the user from all installed packages. The specified package can be entered one or more. # rpm -q --triggeredby file foo-8.0-1 # Note: This example is known, install, or uninstall the FOO-8.0-1 package after query, will trigger the script execution related to the FILE package. 2. Query the un installed package: (only one option is available)   (1) -p: Query specified information using this option, by specifying one or more package file name, RPM can get Information about the corresponding package. The package file can be in general form, but also ftp / http form. # rpm -qp -l --ftpport 2121 ftp: // zzz: Pass@linux/en zoft/file-3.26-6.i386.rpm / usr / bin / file /usr/man/man1/file.1 / usr / MAN / MAN4 / MAGIC.4 / USR / Share / Magic # Note: This example queries the package of the FTP form, showing its file list (-l option, let's talk below). FTP User Name ZZZ, password is Pass, remote machine is Linux, file name /zhsoft/file-3.26-6.i386.rpm, ftp uses 2121 ports. Second, the information display class This class option can be selected simultaneously to display a variety of information.     -i: Display package information   When the user needs to know the header information of the package, use this option.

# rpm -qi file name: file relocations: / usr version: 3.26 Vendor: Red Hat Software Release: 6 Build Date: March 23, 1999 05:32 29 Sunday, October 14, 2001 21 18 minutes 25 seconds Build Host: porky.devel.redhat.com Group: Applications / File Source RPM: file-3.26-6.src.rpm Size: 211946 License: distributable Packager: Red Hat Software Summary: A utility for determining file types Description:. The file command is used to identify a particular file according to the type of data contained by the file File can identify many different file types, including ELF binaries, system libraries, RPM packages, and different graphics formats You should.. In the above output, in the above output, including multiple domains, the meaning of each domain is: name: software name; Relocations: relocation directory prefix (one or more); version : Version number; vendor: Developer; Release: Release: Build Date: package establishment time; install date: installation time; build host: package to establish a host; Group: Category; source rpm: Source package; size: Size; SIZE: Size; License: License; packager: packagepers; Summary: Software brief; Description: Detailed description.     -1 (or --list): Display the list of package files When the user wants to know which files contain, you want to use this option. When outputting, a line is a file name to form a list of files. The following example lists the files in the file package: # rpm -qlv file -rtwxr-xr-x root Root23948 March 23 1999 / usr / bin / file -rtwxr-xr-x root root12023 March 23 1999 / usr / man1 /FILE.1 -RWXR-XR-X root root 6625 March 23 1999 /usr/man/man4/magic.4 -RWXR-XR-X root root 169350 March 23 1999 / usr / share / magic # Note: This The universal option -v is selected when the file is column, so the format listed in the format is listed in the format, which can see the permissions of each file, the owner, group, size, final modification time and file name.   3. -D (or --docfiles): Display package Description Document RPM divides the files in the package into three categories, one is the configuration file, one is to explain the document, then one is other files (including executable And data files, etc.). With the -d option, all instructions in the package can be listed. The following example lists the documentation in the file package: # rpm -qd file /usr/man/man1/file.1 /usr/man/man4/magic.4 #    (or --configfiles): Show Package Profile Use this option to list all profiles in the package.

The following example lists the configuration files in the LZE package: # rpm -qc lze /etc/funkey.def /etc/inputme.def #     (or --state): Show package file status RPM installed The files in the package can have the following four states: * Normal (Normal): This indicates that the file is not modified by other packages. * Replaced: This indicates that the file has been replaced by other software package modifications, no longer the original file. * Not installed: This indicates that the file is not installed. There is a reason that can cause this happening, which is the use of the -excludedocs option (or by setting the% _excludedocs macro 1) when installing the package, indicating that the document is not installed into the system. This state is displayed when you query this package status with RPM. * Net Shared: This indicates that the file is in the network sharing status. This state is RPM to support NFS (Network File System), to avoid an NFS client system to delete a file being shared, another NFS client system does not function properly with this file. There are two situations to make the file in this state, one is that the file is installed in the real network shared directory, and the other is that the file is installed in the directory determined in the RPM resource profile. # rpm -i - EXCLUDEDOCS file-3.26-6.i386.rpm # rpm -qs file normal / usr / bin / file not installed /usr/man/man1/file.1 Not installed / usr / man / man4 / magic .4 NORMAL / USR / Share / Magic # Note: This example is installed first, select -excludedocs indicating that the document is not installed. Then query the status of the File package file, you can see that the documentation is not installed (not installed), and the other file is Normal (normal) state.   6. -r (or --requires): Displays the so-called functionality required by the package, which can be a package ID, which can be a file (such as shared library libc.so.6), or a virtual name . The dependency of the package is to rely on functionality. RPM When the package is installed, if the required function does not exist, its dependency is not satisfied, and the RPM will interrupt the installation process. # rpm -q -r lze / bin / sh ld-linux.so.2 libc.so.6 libc.so.6 (glibc_2.0) libc.so.6 (glibc_2.1) # Note: This example is LZE The features required for the package. 7. --Provides: Displays a package provided by a package that provides several functions that can be actual files such as dynamic link libraries, or a virtual name (as long as other packages can be used. ). If you want to query which features provide a package, you want to use the -provides option. The following example queries the features provided by a parcel file: # rpm -qp --Provides Zlib-1.1.3-6.i386.rpm libz.so.1 libz.so.1 (gcc.internal) # Note: This package The function provided by the file is the libz.so.1 dynamic link library. 8. --conflicts: What is the function of displaying a package conflict? Conflict is a phenomenon that cannot coexist between different packages. When the RPM creates a package, you can record the functions that cannot coexist with this package. When the package is installed, if the function of the conflict has existed, the RPM will abort the installation. The following example queries whether the AT-3.1.7-8 package has a function of conflict: # rpm -q --conflicts AT-3.1.7-8 crontabs <= 1.5 # Note: This example shows the AT package and version number less than 1.5 CRONTABS package has conflict. 9. --scripts: Display the built-in script Scripts built into the package, refers to the program written in the shell language. When this option is selected, RPM outputs the contents of the various script programs included in the package.

There are a total of 5 such scripts, which is the pre-installation scripter (preInstall), postInstall, uninstall, preunition, postuninstall, and check script (Verify). The following example lists the scripts of the ZSH package: # rpm -q --scripts ZSH-3.0.7-4 | NL 1 PostInstall Script: 2 if [! -F / etc / shells]; THEN 3 echo "/ bin / zsh"> / etc / shells 4 else 5 echo "/ bin / zsh" >> / etc / shells 6 Fi 7 / sbin / install-info /usr/info/zsh.info.gz / USR / info / dir / 8 --entry = "* zsh: (zsh). AN enhanced bourne shell." 9 PreunInstall Script: 10 IF ["$ 1" = 0]; THEN 11 / SBIN / install-info --delete /usr/info/zsh.info.gz / usr / info / dir / 12 --entry = "* zsh: (zsh). An enhanced bourne shell." 13 Fi 14 PostunInstall Script (THROUGH / BIN / SH): 15 IF ["$ 1" = 0]; THEN 16 IF [-f / etc / shells]; the 17 TMPFILE = `/ bin / mktemp / tmp / .zshrpmxxxxxx` 18 grep -v '^ / BIN / ZSH $ '/ etc / shells> $ TMPFILE 19 CP -F $ TMPFILE / ETC / Shells 20 RM -F $ TMPFILE 21 CHMOD 644 / ETC / shells 22 Fi 23 Fi # Note: This example uses pipeline technology to query Each line output plus a line number is convenient for observation. Line 2-8: For the source code of the postInstall; section 10-13: To uninstall the source code of preuncture (preuncture); line 15-23: To uninstall the script program (PostunInStall) Source code. All scripts in the example are performed by / bin / SH, and this example does not install the pre-script and check script (Verify).   10. --Triggers: Display package built-in trigger script trigger script is an extension of the Scripts class scriptor, which is used for interaction control between packages. Trigger the script programs that trigger scripts (TRIGGERIN), uninstall, trigger script programs (TRIGGERUN) and uninstalling trigger (TriggerPostun). The following example lists the trigger script in the ZSH package: # rpm -q --triggers ZSH-3.0.7-4 TriggerPostun script (through / bin / sh) - ZSH <= 3.0.7-2 if [! F / etc / shells]; THEN Echo "/ bin / zsh"> / etc / shells else echo "/ bin / zsh" >> / etc / shells Fi # Note: Output Chapter 1 Description Script Program Category ( After uninstalling the script program triggerpostun, what program is used to explain (general / bin / sh), and the triggered condition (described later). The trigger condition of this example is ZSH version of less than or equal to 3.0.7-2. This scripter will execute if the condition is established.

The output of the second-6 behavior is uninstalled and triggered the source code for the scriptor. 11. --changelog: Display software maintenance record Changelog is software maintenance record, use it to record, what time, change the software. Through viewing maintenance records, developers or users can understand the development progress of software. The following example queries the maintenance of the LZE package: # rpm -q --changelog Lze-6.0-2 * May 01 1998 雨 奇 - Increase multi-window operation * March 24 1997 rain is also a quicker - increase block operation command # Note: From this example, you can see that the writing of maintenance records has a certain specification: the row record maintenance time, maintenance person and its email start with the start of the asterisk (*), and starting with minus (-) The line records the specific content of the maintenance. 12. - Dump: Display Properties Information of all files in the package If the user wants to view the properties information of a file in a package, use the -dump option. # Rpm -q --dump file / usr / bin / file 23948 922138347 abaf6cfd51588ac7c484526fbdb84e5b 0100755 root root 0 0 0 X /usr/man/man1/file.1 12023 922138346 76d9ff6567ab64a53eab50911272f5c1 0100755 root root 0 1 0 X / usr / man / man4 /magic.4 6625 922138346 b8d126803709f0da7f39f5125a132cd3 0100755root root 0 1 0 X / usr / share / magic 169350 922138346 3bd2eaf3c5e0e84153ba7df38b7561fc 0100755 root root 0 0 0 X # according to the output current example, to explain the attribute information of each file contained in the RPM owned :( With the first behavior example) / usr / bin / file: is the file name; 23948: refers to the size of the file (byte); 922138347: Fire file final modification time (second number); ABAF6CFD51588AC7C484526FBDB84E5B: Refers to the MD5 calculated according to the contents of the file content Check and; 0100755: File access rights; root: refers to the file owner; root: refers to the file genus; 0: Profile flag, indicate that the file is non-configuration file, indicating that the file is a configuration file; 0 : Describe the document mark, indicating that the file is not explained in 0, indicating that the file is a document; 0: File type, 0 means a normal file, non-0 represents the device file, contains the master slave device number; x: symbol Connection content, if the file is not a symbolic connection, this value is X. 3. Customized output class custom output is a powerful function of RPM. When the user wants RPM to output software package information in their own format, customization can be customized by using the --QF (or --queryformat) option. Customized output To specify a formatted string (similar to PrintF's format string), the string can be taken in single quotation marks' or double quotes. The format can include ordinary text, text, function tag, and array of essential characters. Three different components. * Ordinary text in the normal text format will be output as it will be output. * The emotional resonance defined by the econfrackwork is / called a backslash. When RPM encounters this character The back character is explained according to the predefined escape sequence. The escape sequence is as follows: / A: The output ring character (value 7), the effect is the speaker called. / B: Output Qualification ( The value is 8), the effect is to delete a character in front of the cursor, and the cursor will return a character position. / F: The output change page (value 12), depending on the terminal explanation, the effect is different, and some implement the clear screen operation, Some are changing a row. / N: The output wrap (10), the effect is the cursor movement to the next line. / R: Output carriage return (value 13), the effect is the cursor back to the lead. / T : Output jump (value 9), depending on the terminal interpretation, the effect is different, some is output a space, some output up to 8 spaces. / V: Output vertical jump (value 11), use Not big. //: Output a backslash (/) This character. * Function label RPM has a lot of function tags, such as Name represents the software name, version represents version number, release representation.

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

New Post(0)