RPM command Daquan

xiaoxiao2021-03-06  80

First, install

Command format: rpm -i (or --install) Options file1.rpm ... filen.rpm

Parameters: file1.rpm ... file name of the RPM package that Filen.rpm will be installed

Detailed options: -H (or --hash) Output Hash marks (`` # '') - TEST is only tested for installation and is not actually installed. --Percent outputs the scheduled progress in the form of a percentage. --ExCludedocs Do not install document files in the package - Remnocs to reinstall the installed package - Replacing files belonging to other packages - AllCeFiles Replace the Conflict for other packages - AllCE ignore packages and files --Noscripts Do not run pre-installation and post-installation scripts --prefix Install the package to the structure of the packet to the path of the Path> - Ignorers does not check the operating system of the package running the package - Ignoreos Nodeps does not check dependency relationship - FTPPROXY with as FTP proxy - FTPPORT Specifies the port number of FTP

General option

-v Display Additional Information -VV Display Debug Information - ROOT Let RPM use the path specified by as "root directory", so pre-installer and post installer are installed to this directory --Rcfile < Rcfile> Set the RPMRC file as --dbpath Set the path where RPM data inventory is in

Second, delete

Command format:

RPM-E (or --rase) Options Pkg1 ... PKGN

parameter

Pkg1 ... PKGN: Package to delete

Detailed option

--Test only executes the deleted test - Noscripts Does not run the pre-installation and post-installation script program - Nodeps does not check dependency

General option

-vv Display Debug Information - ROOT Let RPM use the path specified by as "root directory" so that the pre-installer and post installer are installed into this directory --Rcfile Setting RPMRC files Setting RPM data inventory for - dbpath The path is in

Third, upgrade

Command format

RPM -U (or --upgrade) Options file1.rpm ... filen.rpm

parameter

File1.rpm ... filen.rpm package name

Detailed option

-H (or --hash) Output Hash marks (`` # '') --OldPackage Allows "Upgrade" to an old version - Test only upgrade test --ExCludedocs Do not install document files in the package - -inCludedocs Installing Document - ReplacingPKGS Forced Reset Installed Package - ReplanationFiles Replace files belonging to other packages - the conflict of theforce ignore the package and files --Percent outputs the installation in the percentage form. --Noscripts Do not run pre-installation and post-installation scripts --PREFIX Install the package to the structure of the packet to the path of - Ignoreos does not check the software package operation System - Nodeps Does Delicate Relationship - FTPPROXY Use as FTP proxy - FTPPPORT Specifies the port number of FTP for FTP to General option

-v Display Additional Information -VV Display Debug Information - ROOT Let RPM use the path specified by as "root directory", so pre-installer and post installer are installed to this directory --Rcfile < Rcfile> Set the RPMRC file as --dbpath Set the path where RPM data inventory is in

Fourth, inquiry

Command format:

RPM -Q (or --query) Options

parameter:

Pkg1 ... PKGN: Query the installed package

Detailed option

-p (or `` - '') Query package file -F Query which package is part -a query all installed packages --whatProvides query provides Features package -g query package belonging to group --WhatRequires Query all packages that need feature

Information option

Display Package All Identifier -i Display Package Summary Information - L Display Package List-C Display Profile List -D Display Document File List - Splable Package List in Package and Displays each File status - Scripts Display Installation, Uninstall, Check Script - QueryFormat (OR --QF) Display Query Information in User Specified Mode - DUMP Displays all verified information for each file --Provides display package Features provided --Rquires (OR -R) Displays the features required for packages

General option

-v Display Additional Information -VV Display Debug Information - ROOT Let RPM use the path specified by as "root directory", so pre-installer and post installer are installed to this directory --Rcfile < Rcfile> Set the RPMRC file as --dbpath Set the path where RPM data inventory is in

5. Check the installed package

Command format:

RPM -V (or --verify, or -y) Options

parameter

Pkg1 ... PKGN will be verified by the software package name

Package option

-p verify against package file -f Verify Software Pack -A Verify check all packages - Group> Verify all software belonging to group package

Detailed option

--Noscripts Do not run check script - Nodeps does not check dependency - NOFILES does not check file properties Universal options

-v Display Additional Information -VV Display Debug Information - ROOT Let RPM use the path specified by as "root directory", so pre-installer and post installer are installed to this directory --Rcfile < Rcfile> Set the RPMRC file as --dbpath Set the path where RPM data inventory is in

6. Documents in the check package

grammar:

RPM -K (or --checksig) Options file1.rpm ... filen.rpm

parameter:

File1.rpm ... file name of filen.rpm package

Checksig - Detailed options

--NOPGP does not check PGP signature

General option

-v Display Additional Information -VV Display Debug Information --Rcfile Setting RPMRC files for

Seven, other RPM options

--Rebuilddb Rebuilding RPM Database - Initdb Create a new RPM Database - QUIET as much as possible to reduce the output - HELP Display Help File - Version Displays the current version of RPM

Production articles (on)

To make a software package in an RPM format, you need to write a package description file. Its standard naming format is: Software Name - Version Number - Release Number. Spect, this file, detailing many of the information about the package, such as software name, version, category, description summary, what instructions should be performed when creating, What to do during installation, and files you want to include in the package, etc. With this file, RPM can make the corresponding parcel file.

The following is aware of the software package (LZE-6.0-2.i386.rpm) of Xiao Zhao Editor LZE (LZE-6.0-2.i386.rpm), in detail the writing of the package description file. Its description file is LZE-6.0-2.SPEC, which is as follows: (listed with NL -BA commands, the number starting in each line is the line number in the file)

# 1 File Name: lze-6.0-2.spec2 # file functions: lze package description information of the file # 3: vertical and horizontal software production center rain also odd National Defense University Graduate Rosso Zhao Jianli # 4 Modified: 2001.10.1956 Name: lze7 Version: 6.08 Release: 29 Summary: Little Zhao full screen Chinese English multi-window multi-function editor (Linux / UNIX system) 10 Group: Applications / Editors11 license: Share12 Vendor: Crossing Software Production Center 13 packager: 雨 奇 奇 (zhsoft @ 371.net) 14 Source: http://zhsoft.myetang.com/lze-6.0-2.src.tgz15 prefix: / usr16 Requires: / bin / sh17 provides: Lze-edit1819% Description20 Xiao Zhao editor, is In order to use the major users of SCO UNIX, Linux multi-user systems, the full-screen multi-window 21-English multi-function editor. 22 It mainly has the following ten characteristics: 1. Full-screen menu operation. 2. Differently display. 3. Block is rich in operation. 4. Ten 23 words system is powerful. 5. Multi-window operation is flexible. 6. File operation is complete. 7. Interpret the output function is unique 24 color. 8. With the Chinese input method (enhanced five and enhanced pinyin), it is easy to use. 9. Hexadecimal editing function, such as Tiger 25. 10. Instant translation, press to translate. 26 In short, Xiao Zhao editor will become a good helper that makes and writing a general manuscript on UNIX, Linux system.

27 It will help you in your work, easy to get in the battle, there is more! 2829% Prep30 Echo "Preprocessing Script" 31% Setup3233% Build34 Echo "Compilation Connection Script Program (Build) Start Perform" 35 Make3637% Install38 Echo "installation script (install) start execution" 39 make install4041 % Clean42 Echo "After the completion of the package, the Clean Script Procedure" 4344% pre 45 Echo "Before executing the script program (PRE) starts to perform the" 4647% Post48 echo "After the script (POST) starts to execute" 4950 % preun51 echo "Uninstalled Script Procedure" 5253% Postun54 Echo "After uninstalling, executing a script (Postun) Start executing" 5556% Veryfiscript57 echo "software package checklist (VerifyScript) start executing" 5859% Triggerin - xiuwu60 echo "Software Package" Trigger "starts" 6162% Triggerun - Yuntaishan <2.063 echo "package uninstall trigger script" start "6465% TriggerPostun - Dapubu66 Echo" After the package is uninstalled, the trigger script is started to perform "6768% Files69% defattr (-, root, root) 70% config /etc/Funkey.def71% config /etc/inputme.def72% DOC / USR / DOC / LZE -6.0 / readme73% doc /usr/doc/lze-6.0/License74 / usr / bin / Lze75 /usr/bin/lzeime.py76 /usr/bin/lzeime.wb77 /etc/wbzc.dat7879% Changelog80 * Tue Aug 18 1998 Yizhen 81 - Built-in Pinyin, Five Input Method 82 * Fri May 01 1998 Yizhen 83 - Increase Multi-window Operation 84 * Mon Mar 24 1997 Rain 85 - Increase Block Operation Commands 86 This description includes the following aspects Content:

First, see 1-4. It starts with ##, decomposes, can help users understand the content written, but there is no effect on the generation of packages. In this file, the comment line is concentrated in the file header. In fact, it can be located anywhere in the description file.

Second, the file is taken along line 6-17. The file header describes the basic information of the package, which contains several domains, where there is a certain domain, and optional domains. One domain occupies a row, its description format is: domain name: Domain value Note: Domain name is not case sensitive, and the domain value cannot be empty. The file must have the following six:

1. Name: This domain defines the software name.

2. Version: This domain defines the version number. The version number is increased only when the software has changed much more. Note: No minus (-) characters are not included in the version number.

3. Release: This domain definition is released. If the software is smaller than previously changed, only the release number is increased, and the version number is not changed. Note: It is also impossible to include minus (-) characters in the release number. RPM named the package using the Name (Software Name), Version (version number), the release (release number), and the system line number, such as the parcel file of this example is LZE-6.0-2.i386.rpm.

4. Summary: This domain defines the software package introduction to a sentence.

5. Group: This domain defines the category of the software. See << Exquisite RPM five - query articles >>, this example Applications / Editors represents the "Application / Editor" class.

6. License: This domain defines the license or copyright rule applies to the software. This domain can also be defined by copyright (copyright), both agree. The license specific: GPL (General Public License, Free Software Applicable), BSD, MIT, Public Domain, Distributable, Commercial, Share (Sharing), etc. The file header optional domain includes the following categories: 1. Basic information

1.1 Vendor: This domain defines the supplier (vendor) of the software.

1.2 Distribution: This domain defines the release of the software, which is the software package author's own classification. Typically, a distribution consists of several packages. If I want to be a distribution called "Panda '95", then each package (such as bamboo leaves 95) describes such a line: distribution: Panda '95

1.3 ICON: This field specifies the icon file name used by the package. This file is GIF or XPM format, which must be stored in the% _sourcedir (source directory) macro indication directory of the RPM, default is / usr / src / dist / source. The RPM itself does not use icons, but it stores the contents of the icon file into the parcel file, and is also stored in the RPM database when installing. This icon can be used by the RPM packet management tool of the graphical interface to improve interface effects, increase visibility. The following example indicates that the package uses panda.xpm as an icon: icon: panda.xpm

1.4 Packager: This domain defines the packager, which is to establish the person or company of this package. Writing format is: Packager 's Name Please refer to the description file 13th line.

1.5 Serial: This domain defines the software serial number or use domain name EPOCH. The software serial number is an integer, which is specified by the package, which should continue to increase with the increase in the version number, and always maintain the uniqueness of the value. Software serial numbers can be used to illustrate the dependencies between packages. The following example specifies the software package serial number 4: Serial: 4 or: EPOCH: 4

1.6 URL: This domain defines a web address that contains information about the package software. Such as: URL: http://devplanet.fasternet.net/gxedit.html

2. Relationally dependent is that RPM is used to describe the relationship between the package. A package dependent thing RPM is called function, which can be a real-existing package, or a virtual package (virtual packet). There is no version number in the false package. Dependence related domains:

2.1 Provides: This domain defines the functionality provided by the package and repeats multiple lines. Its description format is: provides: Function 1 [, Features 2] ...

Note: [] Included is available, and multiple functions are separated by commas or spaces. The features provided by the package are generally shared libraries in the form of false bags. When multiple packages provide the same service, it is often used to represent its service. For example, a mail client software allows users to use different views (text forms, HTML forms, etc.), which can require any viewing program to provide Mail-Reader virtual packets. In this way, the description of the letter program should have such a line: Provides: mail-reader is so used by the mail client.

2.2 Requires: This domain defines the functions required for the package, repeat multiple lines. Its description format is: Requires: Function 1 [Comparison 符 1 [Serial Number 1:] Version Number 1 [Release Number 1]] [Function 2 [Comparison Guide 2 [Serial Number 2:] Version Number 2 [- Release No. 2]]] ...

Where: * [] is included; * Comparison can use <(less than),> (greater than), = (equal),> = (greater than or equal) or <= (less than or equal); * Serial number is not selected When the RPM defaults to 0; * The comma between functions is optional, or the space can be separated. Example: REQUIRES: AAA, BBB> = 3.0, CCC <2: 5.0-1 Note: This example is the resulting system that needs to be systematically available when installing: (1) AAA (AAA package installed in the system, or installed There is a software package in the package to provide aaa virtual packets); (2) The BBB package has been installed and version requirements are greater than or equal to 3.0; (3) The CCC package has been installed and the version requires less than the serial number 2, version number is 5.0 and released To 1. When the RPM is compared, the order in which the comparison is executed is; the first version number, release the emit, and finally the serial number. By comparison, determine which version is newer, which version is older.

2.3 Conflicts: This domain definitions have conflicts with this software package (cannot coexist). This domain can also be written many times in the description file. It describes the format shape with the Requires domain, for: Conflicts: Function 1 [Comparison 符 1 [Serial Number 1:] Version Number 1 [Release Number 1]] [, Function 2 [Comparison Guid 2 [Serial Number 2:] Version No. 2 [- Release 2]]] ... in which: * [] is included; * Comparison can use <(less than),> (greater than), = (equal),> = (greater than or equal to equal ) Or <= (less than or equal); * The serial number is not selected, the RPM defaults to 0; * The comma between the functions can be selected, or the space is separated. For example: conflicts: xxx = 1: 2.0 YYY> = 3.0 Note: This example clarifies the function of the generated package conflict: (1) When the XXX package version is equal to 1 in the system, the version number is 2.0; 2) When the YYY package version is greater than or equal to 3.0 in the system. *** Automatic implementation of the relationship *** In general, when RPM creates a package, it is to perform two applets in the / usr / lib / rpm directory. One is Find-Requires to find the shared libraries required for the package, which will be added to the functionality required by the package in the form of a false package. The other is Find-Provides, which is used to find the shared libraries provided by the package, which will join the function provided by the package in the form of a false package. These two programs are shell programs, although the amount of code is small, but it does help the software package author is a big busy - do not have to write this dependence on this dependence, because the program is automatically completed. The following three domains are used to indicate whether RPM performs both programs.

2.4 Autoreq: This domain is used to indicate whether the RPM is automatically found for the shared libraries needed. This program is executed only if the domain value is NO or 0, and the RPM does not perform the find-request program, otherwise the program is executed.

2.5 AutoProv: This domain is used to indicate whether RPM automatically finds the shared library provided by the software. The program does not perform the Find-Provides program only when the domain value is NO or 0, otherwise the program is executed.

2.6 AutoreqProv: This domain is used to indicate whether the RPM is automatically found for the shared libraries provided by the software. RPM does not perform two programs for Find-Requires and Find-Provides only when the domain value is NO or 0. This domain is equivalent to setting the value of Autoreq and AutoProv domain values. Note: The three domains described above are in the description file, and between them is different because of the order of order, it is generally subject to the last one. Such as: Autoreq: YESAUTOREQPROV: NoAutoprov: Yes

Note: In this example, although the first line allows Find-Requires, the second line does not allow Find-Requires to run two programs, while the third line allows Find-provides to run, so according to the order of execution, the result is Find-propide is not allowed to perform Find-Provides. Another example: Autoreq: NoAutoreqProv: YESAUTOPROV: NO

Note: The results of this example are allowed to perform Find-propides without allowing FIND-Provides.

3. When the system-related RPM creates a package, it can specify the applicable CPU system or operating system, or it can specify an unsuitable CPU system or operating system, so that when RPM discovers the current CPU system or operating system and software. When the package requirements are incompatible, the production of the package will be suspended. RPM default current CPU system is defined by macro% _Arch, generally I386. RPM default current operating system is defined by macro% _OS, generally Linux. The reader can get it by viewing the / usr / lib / rpm / macros macro definition file. The following four domains shows the scope of the package:

3.1 Excludearch: This domain defines the system that is not applicable. RPM optional system name See the Arch_canon project in the / usr / lib / rpm / rpmrc file. The package does not apply to a system, and there may be two reasons. First, the software has not been ported to the defined system; the other is that the software contains specific machine code (assembly language), which is incompatible with other systems. This domain description format is: ExcludDearch: System 1 [System 2] ...

Note: [] All included, each system is separated by space. If the current system is in this domain value, the RPM will be reported to exit when the RPM makes the package. Please see the example below. Add a line in the header of the LZE-6.0-2.Spec file: ExcludDearch: i386 Running the built package command rpm -bb (<< Excellent RPM 7 - Production articles (below) >> will say): # rpm -bb LZE-6.0-2.SpeCarchitecture is Excluded: i386 # As seen, RPM prompts an error in the "system not applicable: i386".

3.2 ExclusiveArch: This domain defines the system for software packages. It describes the format Similar to ExcludDear: Exclusivearch: System 1 [System 2] ...

Note: [] All included, each system is separated by space. If you join a line in the LZE-6.0-2.Spect file: Exclusiveability: i386 SPARC Running the buck command how to: # rpm -bb lze-6.0-2.specexecuting:% Prep Prerequisites (preP) Start Execute the executing:% Build Compile Script Program (Build) Start Perform Executing:% Install Installation Script (install) Start Perform Processing Files: Lzefinding Provides: (Using /usR/LIB/Find-Provides) : (using /usr/lib/rpm/find-requires )...Provides: lze-editprereq: / bin / shrequires: / bin / sh ld-linux.so.2 libc.so.6 libc.so.6 ( Glibc_2.0) Libc.SO.6 (Glibc_2.1) wrote: /usr/src/dist/rpms/i386/lze-6.0-2.i386.rpm#

Look, this built package (LZE-6.0-2.i386.rpm) was successful, because the current system (I386) is just applicable.

3.3 Excludeos: This domain defines the operating system that the package is not applicable. RPM optional operating system Please refer to the OS_CANON project in file / usr / lib / rpm / rpmrc. It describes the format: Excludeos: Operating System 1 [Operating System 2] ...

Note: [] For options, the operating system is separated by spaces. For example: Excludeos: Irix AIX Solaris Note: If you add this row to the description file of the LZE, it indicates that RPM is not built on the three operating systems of Irix, AIX, Solaris. If the current operating system is one of the three, the RPM will report an error and abort the production of the package. Such as: # rpm -bb lze-6.0-2.specos is Excluded: Solaris #

3.4 Exclusiveos: This domain defines the operating system that the package is applicable. Its description format is: Exclusiveos: Operating System 1 [Operating System 2] ... Note: [] is optional, the operating system is separated between space. For example: Exclusiveos: Linux Solaris

4. Directory Related 4.1 Prefix: This domain defines a repositionable directory prefix that can be written many times in the description file. Its description format is: prefix: directory prefix 1 [directory prefix 2] ...

Note: [] is optional, and each catalog prefix is ​​separated by spaces. For example: prefix: / usr / etc It also writes: prefix: / usrprefix: / etcrpm utilizes relocationable directory prefix to implement the repositioning installation of the package, so that the files in the software do not have to be fixed in a certain absolute position. This approach is very good. LZE Software Package Document LZE-6.0-2.SPEC defines a retransmible prefix / usr (see Chapter 15), which can be heavy in the / usr directory in / usr directory when installing Position to the directory specified by the user, such as: # rpm -i --prefix / TMP Lze-6.0-2.i386.rpm # or: # rpm -i --relocate / usr = / tmp Lze-6.0-2.i386. RPM # Note: This command is installed by the LZE package, locates the file containing the / usr relocation directory prefix to the / TMP directory. After the / usr / bin / lze file in the package is installed, / TMP / BIN / LZE is adjusted. (RPM installation command method Please refer to << Excellent RPM II - Installation >>) 4.2 Buildroot: This domain is defined by the file shared by the file included in the package, this root directory is only for RPM to establish a package use. That is, when the RPM is established, this directory is set to the root (call chroot function), extract the required file, generate a package. For example, when buildroot is set to / TMP, the RPM actually packaged for the / usr / bin / lze file in the LZE package description file, but after the generated package query It can be found that the original file name has not changed, or / usr / bin / lze. So, this is very interesting. General users can create a variety of packages, even if there are those directory or files that can only be operated by superusers like superuser (root). It is nothing to install such a package with the package created by the super user. This domain has a simple description format: BuildRoot: Directory, such as, the above example can be defined as: buildroot: / TMP

5. The following four domains of the source code are designed for production source packages. What is the source package? The user can get the list of files in the query package, the command is "RPM -QPL source package file" (see << Excellent RPM five - query articles >> related content). Under normal circumstances, there are such four types of files in the source package: First, the Source Code, the second is the source patch (PATCH), and the third is the package description file, and the fourth is the icon file (icon). By installing source package, users can easily achieve on-site compile, link and application, but also facilitates software developers and software packages creators: They maintenance procedures easy, and after maintenance can quickly generate and execute code package source package . This is also one of the important reasons for all people love RPM.

5.1 Source: This domain defines the program source file file to be included when the RPM package is packaged. These files generally package with the tar command, and then compress it with GZIP. A description file can contain multiple Source domains. When there are multiple such domains, you need to numbate: The first adopry is Source0 (can also be directly used for Source), the second composite is Source1, the third edited Source2, etc. This domain is described in: Source [Number]: Source Code File

Note: [] The option is included. Specific usages such as: Source0: Lze-6.0-2.tar.gzsource1: Lzeime-WB-6.0-2.Tar.gzSource2: Lzeime-PY-6.0-2.TAR.GZSource3: Lze-lib-6.0-2.tar. GZ Note: This domain domain value can be used in the form of URL (unified resource positioning), such as the LZE Description File No. 14. This form is used, mainly to provide the location information of the source code to other users. When the RPM makes the source package, it extracts the last file name LZE-6.0-2.tar.gz, not http://zhsoft.myetang.com/lze-6.0-2.tar.gz (url The content is ignored by RPM).

5.2 Nosource: In the previous example, if you do not want to include Source1 and Source2 defined files, what is one of the ways is to delete it; the second is to release it. (Ie The front of the row is plus ##); the third of the way is to define the Nosource domain, which can be repeated. Its description format is: Nosource: Source field number

This example can be written: nosource: 1nosource: 2 Note: 1 and 2 of them are numbered, represents Source1 and Source2. Note: If there is no Nosource field in the package description file, the source package name format generated by the RPM is "Software Name - Release" .Src.rpm. If you use the Nosource domain, the source package name format generated by the RPM is "Software Name - Release" .nosrc.rpm (you can see the source package containing the file from the name). 5.3 Patch: Patch: Patch is the reason for the patch, uses the patch of the source program here, which is the output generated by the new old source program with the DIFF command (command is "Diff -Nur new file new file> patch file") And the PATCH command in the system can use this output to upgrade the source of the old version to the new version. This domain defines the patch files you want to include when the RPM creates the source package. The file is named using the "Software Name-Version Number. Patch. Patch". A package description file can have multiple PATCH fields. When there are multiple such domains, it is also necessary to numbered like the Source domain (Note: The first domain is composed to PATCH0, and can be omitted 0, with patch). The format of this domain is: patch [Number]: Source Patch

Note: [] The option is included. Specific usages such as: patch0: blather-4.5-bugfix.patchpatch1: blather-4.5-config.patchpatch2: blather-4.5-somethingelse.patch Note: This domain value can also be in the form of a URL, RPM is only like a Source field. Extract the file name for use.

5.4 NOPATCH: This domain is functionally similar to Nosource, and the patch file RPM corresponding to the corresponding number is not packed. This domain can be repeated in the description file. As in the above example, if you do not want the source package containing the patch file indicated by the Patch0 and the Patch2 domain, you can write such two lines on the description file: NOPATCH: 0NOPATCH: 2 Note: If there is no NOPATCH field in the package description file, RPM generation The source package name format is "Software Name - Version Number - Release" .SRC.rpm. If the NOPATCH field is used, the source package name format generated by the RPM is "Software Name - Release" .nosrc.rpm "(Single from the name, you can see that the source package is incomplete).

Third, see Section 19-86 (the part below the file header). What is the function segment? It can be said that the function segment is the paragraph describing important data and operational instructions of the package, including the segment name and segment content. There is no function section, and RPM can't make any package file. The segment name of the function segment is started with a percentage (%), occupying one line. The segment of the function segment is defined as: it starts from the function segment name to the next function segment name or to the description file end. Such as the LZE description file, the% Description section is from Chapter 19 to 28th (% pred from line 29), paragraph 19, paragraph 20-28. The% Prep section is from 29th to 32nd lines (starting with the 33rd line% Build), the paragraph is in line 29, and the segment is within 30-32. Also note that the location of each functional segment is free, and can be placed anywhere below the file head, and it is not necessary to stick to a certain fixed position. Mandatory function segment description files are:

1.% Description This paragraph is a description segment, and the segment is a more detailed introduction to the package, and the Summary domain of the file header is not described in one sentence. The text form is free, and it is optional, and it is not limited. See the LZE description files 20-27 for details. This paragraph section name description format is:% Description [sub-package option]

The format of the sub-package option is: [- n] sub-package name: [] is included in the option.

Three forms of description segment name: (1) When the paragraph format is "% description": The content described in this function segment is about the parent package. The parent package can also be called the master package, which uses the software name to command, its name format is: Software Name - Version Number - Release Number. System. Rpm. Such as: Lze-6.0-2.i386.rpm. (2) When the format is "% Description sub-package name": The content described in this function segment is about subcaps. When there is no -n option in the sub-package option, the sub-package is named in the form of software name adds, format: Software Name - Sub-package name - version number - Release Number. Rpm. LZE software is divided into two subcles: Lze-bin-6.0-2.i386.rpm (execution package), Lze-config-6.0-2.i386.rpm (configuration file package). (3) When the paragraph format is "% Description -N sub-package name": The content described in this function segment is also about subcaps. When there is a -n option in the sub-package option, the sub-package is named directly in the form of a sub-package name. It does not include software name, named format: sub-package name - version number - Release mark. System. rpm. LZE software is divided into two subcles: bin-6.0-2.i386.rpm (execution package), config-6.0-2.i386.rpm (configuration file package). Note: This type of sub-package content is usually a library that can be shared by other packages, and if dedicated, try not to use this form to define a sub-package. 2.% Files This paragraph is a file segment. It is defined which files need to contain. This paragraph is usually placed in the end of the description file to facilitate adding the file name for easy editing. This paragraph segment name description format is:% Files [sub-package option] [-f file name]

Note: [] The option is included. When there is no option, this segment defines a list of files to package; when there is a sub-package option, the content defined by this segment is a list of files to package; when the -f option is selected, RPM In addition to reading the packaging file list from the file segment, the list of files to be packaged is read from the specified file. In the specified file, a file name takes up a line. This option makes it easy for the package producer, they can automatically generate a list of files for software, and write it into a specific file, when making packages, just reference this file, RPM will automatically Read the file name from this file and add it to the package. If there is no such option, the software package author can only write a file name that will be packaged in the file segment, a bit trouble.

The content format of the file segment is: [Modifier 1 [Modifier 2] ...] file name where: modifier is optional, one file can have multiple modifiers, the file name must be / start (absolute path form ). The modifier has the following categories:

(1) File-related *% DOC: This modifier sets the file type as the description document (see LZE Description Files Section 72,73); *% config: This modifier sets the file type as a configuration file (see LZE Description file) Sections 70, 71); *% config (missingok): This modifier sets the file type as a configuration file, and this file can be lost. Even if it is lost, RPM does not think this is an error when uninstalling the package, and does not report. This modifier is usually used for symbolic connection files established after those packages installed, such as /etc/rc.d/rc2.d/s55named, etc. Such files may need to be deleted after the package is unloaded, so it is not tight. *% config (Noreplace): This modifier sets the file type as a configuration file, and if there is a file in the system when installing, this file in the package will be installed, and the file name suffix adds a. rpmnew. (If you do not have this modifier, RPM is installed if you find a file, RPM will change this file in the system, and its suffix plus. Rpmorig, and the file in the package also uses the original name.) When the software package is unloaded, the same name file in the system is saved by RPM, and its suffix adds .rpmsave. As defined in the file segment of the description file:% config (noreplace) / etc / hello, the package made is installed, if this file / etc / hello has this file / etc / hello, RPM will prompt: Warning: / ETC / Hello Created As /etc/hello.rpmnew This indicates that the / etc / hello file in the package is created as a /etc/hello.rpmnew file. If this package is uninstalled, / etc / hello in the system will be renamed to /etc/hello.rpmsave. *% GHOST: This modifier is modified, and its content is not included in the package. Such files are typically a file, which is a log file, which is important (file name, home, genus, etc.), but the content is not important. After using this modifier, RPM only adds its file attribute to the package. *% attr: This modifier sets the properties information of the file, using the format:% attr (permission, home, group) Note: Permissions commonly used digital form (octal), the owner and the genus can be numbers, or you can It is a string. If the file's permissions, the owner, and the genus want to use the system default value, it can be used to indicate it with minus (-). The following example uses two modifiers, defines the permissions of the /etc/funkey.def file 755, the owner's default, group is root, type is configuration file:% attr (755, -, root)% config / etc / funkey .def *% verify: This modifier sets those attributes that the file needs to be verified. These properties are: Owner, Group, MODE (permission), MD5 (MD5 check, and), size (size), Maj (main device number), min (from device number), SYMLINK (symbol) Connection), MTIME (final modification time). This modifier uses the format:% Verify ([NOT] OWNER Group Mode MD5 Size MAJ MIN SYMLINK MTIME) Note: Not optional. When using NOT, indicating those properties that need to beat the selected properties. When the following example indicates the RPM check / dev / ttys0 file, you want to check the permissions, MD5 check, size, main device number, from device number, symbol connection, and final modification time total 7 attribute information:% Verify (Mode MD5 Size MAJ Min Symlink Mtime) / dev / ttys0 This can also be implemented using the NOT option, because the owner Owner and the Group Group of Group GROUP are removed, the rest is the property that needs to be verified:% Verify (Not Owner Group) / dev / ttys0 (2) directory related *% DOCDIR:

This modifier defines a document prefix so that there is a file containing the specified file name as a prefix, and the RPM is packaged to the description documentation. For example, there are such three lines in the file segment of a description file: / root / readme% DOCDIR / ROOT / ROOT/mydoc.txt

This example indicates that / root is the prefix of the document, because /root/mydoc.txt is in% DOCDIR's next row, so the RPM is packaged as a document. The / root / readme file does not make this setting because it is before the% DOCDIR definition. With this modifier, the user can easily set a file for documentation, as they are usually fixed under a directory, with a common prefix. *% DIR: RPM When making a package, if the file to be packaged is a directory, the RPM contains all the files below the directory to the package. (Note: If the file to be packaged is a symbol connection, this symbol connection points to a directory, and RPM does not treat it as a directory, will only treat it as a normal file.) If you only want this directory name In the package, the producer uses this modifier to modify this directory name. Such as: / etc is a system directory, there are multiple files, if you want to join the package, you can write such a line in the file segment of the file: / etc If you only want to include this directory, you can use:% DIR / etc (3) Alternative modifier This class has only one% defattr. Say it is an alternative modifier because it is set by the default file properties, not a specific file. It generally placed the first line of the file segment. Its format is:% defattr (authority, home, group)

Among them: Permissions, the owner and group group can be used (-). The property used will be set by the system. For example:% defattr (022, zzz, zhsoft) sets all file permissions to 022, the owner is ZZZ, the genus is zhsoft; Another example:% defattr (-, zzz, -) is set thereafter All file owners are ZZZ, permissions and genus by system settings. In an optional function segment description file, the content of the optional function segment is some script. (LZE Description File contains only one echo command only) The description format of the optional function segment is: Function Segment Name [Subplit Option]

Note: The sub-package option is "[-n] sub-package name." When there is no sub-package option, the segment content describes the script program of the parent package. When there is a sub-package option, the segment content is the script program describing the subcap.

The optional function segments can be divided into the following three categories: 1. Build package function segment: RPM When you create a package through the source program, you should perform the pretreatment, compile, install, and clean up four operations, respectively correspond to% Prep. Four paragraphs of% Build,% INSTALL and% CLEAN. The following will be described segmented by its execution sequence: 1.1% prep: This is the pretreatment segment, and its content is a preprocessing scriptor. This program completes the following tasks: * Create a software compilation directory; * Unpack the source program; * By playing patch, upgrading the source; * Execute other operations, allowing the source program to compile. In this scripp, you can use the following two macro commands: 1.1.1% Setup This macro uses the Gzip and TAR command in the system to decompress the source package. RPM automatically detects whether the source sequence is compressed, if compressed, it will decompress it with Gzip, otherwise the file is expanded directly with the tar command. Its use format is:% setup [-n name] [-c] [-d] [-t] [-b n] [-a n]

Note: [] The option is included. (1) When there is no option: This macro uses to extract the default source of source sequence (specified by the file header Source or Source0 domain). Note: The file application "Software Name" in the source program package is used as its upper directory, so% setup macro can work. If the "Software Name-Version Number" is not the upper class directory, the% setup macro has a command "CD Software Name" (rotation) will exit because there is no this directory in the system (unless there Macro Adding a command to establish this directory). For example, the directory where the LZE software source program is LZE-6.0, I need to pack and compress the source program with the command "TAR CVZF LZE-6.0", "such a package can be correctly protected by% setup macro. used. Below is a series of commands performed by the% Setup macro command: (Directive is the line number) 1 CD / USR / SRC / DIST / BUILD2 ECHO "PREP" Start "3 CD / USR / SRC / DIST / Build4 rm -rf Lze-6.05 / bin / gzip -dc /usr/src/dist/sorces/lze-6.0-2.src.tgz | tar -xvvf -6 status = $? 7 IF [$ status -ne 0 ]; THEN8EXIT $ STATUS9 FI10 CD LZE-6.011 [`/ usr / bin / id-u` = '0'] && / bin / chown-rhf root .12 [` / usr / bin / id-u` = '0 '] && / bin / chgrp -rhf root .13 / bin / chmod -rf a rx, gw, ow .14 exit 1, the 10th line has a command to go to the LZE-6.0 directory, if there is no this directory The program will have an error. Maybe you have to ask: How do you know these instructions? In fact, this is very simple, just add a "exit 1" command under the% Setup macro, let the pre-processed script will be absent normal. Such a preprocessing script executed by RPM is not deleted as a temporary file, as long as you look at this file (starting with RPM-TMP in / var / tmp), you know what the% setup macro command does.

(2) -n name: The above has been mentioned that the file in the source program should be used as the upper directory. If you use other directories (such as name),% setup macro does not work properly, then what should I do? It doesn't matter, you can use the -n option, reference this directory (Name). If the file in my LZE source package is in Lze as the upper directory, then I can use the "% setup -n lze" macro command to decompress the package.

(3) -c: This option is to create an upper-level directory ("Software Name - Version Number" directory and go to this directory. For LZE software, its effect is equivalent to plus such two lines between the 4th line and the 5th line: MKDIR -P LZE-6.0CD LZE-6.0 It is suitable: Some source range is In the directory where the source program is located, the files do not have the upper part of the directory. In this case, if you want to decompress correctly, you must create an upper-level directory.

(4) -d: This option's role is to delete the upper part of the software (software name - version number) before decompressing the source package. In the above example, its effect is a command (RM-RM-RZE-6.0) that does not perform the fourth line.

(5) -t: This option is to do not decompress the default source program (defined by the Source or Source0 domain of the file header). In the above example, its effect is a command that does not execute column 5-9: The 5th line is the decompression source package (uncompressed with gzip -dc to decompress the contents of the package into the pipe, and then by TAR-XVVF - from the pipe Read the data and expand), the 6-9 line is to check the return value of the decompression command, and do not normal exit when not 0.

(6) -b N: This option indicates that the RPM decompresses the nth source package (defined by the file header SourceN domain) before turning to the upper catalog. This applies to source program packages containing the upper catalog. Note: If you use the -t option when you use this option, RPM decompress two source packages, one is the default package (defined by a source or source0 domain), one is the package specified by the -b option (by Sourceen Domain definition). Thus, when n is equal to 0, the default source of source sequence will be decompressed twice. So, if you want to extract only the specified source package, use the -t option at the same time to prohibit the decompression of the default source program package. The following macro command only decompresses the first source package, then go to the upper list:% setup -b 1 -t (7) -a N: This option indicates that the RPM will decompress the nth source after turning to the upper directory. Package (defined by the file headgencen domain). This applies to source program packages that do not contain the upper list. When using this option, you generally add -c option to create a top-level directory and go to this directory. Note: If you use the -t option when you use this option, RPM decompressed is two source packages, one is the default package (defined by the Source or Source0 domain), one is the package specified by the -a option (by Sourceen Domain definition). Thus, when n is equal to 0, the default source of source sequence will be decompressed twice. So, if you want to extract only the specified source package, use the -t option at the same time to prohibit the decompression of the default source program package.

The following macro command allows RPM to go to the upper part of the directory, then extract the second source package:% setup -t -a 21.1.2% Patch This macro uses the Patch command in the system to play the specified source. The patch is thus upgraded. Its format is:% PATCH [-P N] [-P N] [-b name] [-e] Note: [] It is enclosed in the option. To illustrate the role of the following options, we define three patch files in the LZE package description file: patch0: lze-patch.zeropatch1: Lze-patch.onepatch2: lze-patch.three

(1) When there is no option: Nothing option, the macro uses the default patch file (0th patch file), that is, the file defined by the file header Patch or Patch0 domain (LZE package uses Lze-patch) .zero. When the macro is executed, the extension is extended to the following instructions: Echo "Patch # 0:" Patch -p0 -s

(2) -p N: Use this option to indicate that RPM uses the nth patch file (defined by the file header Patchn domain). If you want RPM to use Lze-Patch.Three, you can use "-P 2" to specify when using Lze-patch.three.

(3) -p N: This option is directly transmitted by the% PATCH macro to the patch command. Please refer to the introduction of the -p option used by the Patch command above.

(4) -b name: When a plurality of patches commands operate the same file, Patch saves the original file to save the original file., If lze.c will change to Lze.orig. If you want to use another name to be a suffix, you can use -b to set it so that the original file will be renamed "Original File Name Suffix". If you use -b zzz, Lze.c will save to Lze.czz. This option is executed, and it is actually transmitted a option and parameter to the PATCH command, ie - Suffix Name.

(5) -e: This option is passed directly to the patch command, its function is that if a file is finished, the content is empty (byte 0), then remove this file.

1.2% build: This is a compilation section, which is the compilation script program. The program completes the compilation and connection of the source program. A simplest example is that there is only one MAKE command in the program. This applies to most of the cases because most software has its own makefile, so compile and connection can be implemented through the Make command. If there is no Makefile, you need the software package author to write a series of compilation connection commands in the compile segment. 1.3% INSTALL: This is a installation section, and its content is the installation script program. The program stores compiled execution programs or other files into the specified directory, these programs or files are used when the RPM is packaged. One of the simplest examples is to use only one make install command in the program to complete the installation. This also requires the corresponding software with a Makefile maintenance file. If there is no, the package producer also has to write instructions.

1.4% Clean: This is a cleaning section, and its content is a cleaning scriptor. This program executes after the RPM makes the package, which is usually deleted the temporary file or directory generated when compiling the connection, and the completion of the post.

2. Administrative function segments: This type of segment is used for the management (installation, unloading and check) of the package, including the% pre,% post,% preun,% postun, and the% VerifyScript five function segments. 2.1% pre:

This segment is a pre-installation scriptor. It executes before the package installation, usually detects the operating environment, establishes the relevant directory, cleanup excess file, etc., prepare for the smooth installation of the package. This paragraph is rarely used. Its segment name format is:% pre [sub-package option]

2.2% POST: This segment is a post-installed scriptor. It is executed after the package installation is complete, often used to establish a symbolic connection, modify the system configuration file, run the LDConfig program, etc., based on the normal operation of the software. The format of its segment is:% post [sub-package option]

2.3% preun: This segment content is a pre-uninstalled scriptor. It is executed before the software package is unloaded, mainly for uninstalling. Specifically, when a program is currently running in a package to be uninstalled, this scripter must kill it, otherwise it will not be uninstalled correctly. Its segment name format is:% preun [sub-package option]

2.4% Postun: This segment is a script program for uninstall. It is executed after the package is unloaded, and the unloaded work is completed. If you change the system profile inetd.conf back to the original look, re-run the ldconfig command, uninstall the shared library from buffer file ld.so.cache Delete, etc. The format of its segment is:% postun [sub-package option]

2.5% VerifyScript: This segment is the verification scriptor. When the RPM check package, in addition to the standard check, if the software package author sets this check scriptor, it will be executed.

Its segment name format is:% VerifyScript [sub-package option] below is the check script in XFree86-Libs-3.3.6-6.i386.rpm package, which verifies dynamic link library catalog / USR / X11R6 / lib. When checking, lookup / usr / x11r6 / lib in the /etc/ld.so.cache file, if you can't find it, display "Missing", display "Found". # verifyscriptecho -n "looking for / usr / x11r6 / lib in /etc/ld.so.conf ..." ing! grep "^ / usr / x11r6 / lib $" /etc/ld.so.conf> / dev / NullThenecho "Missing" Echo "/ usr / x11r6 / lib missing from /etc/ld.so.conf"> & 2ELSEECHO "FOUND" FI

3. Triert function segment: Such function segments include% Triggerin,% triggerun,% triggerpostun, and their content is a script program for RPM interactive control between packages. These scripts are triggered under the system to meet the specified conditions:

1)% Triggerin: Trigger the script for installation during the installation, when the package is only installed with the specified package, the installation will trigger this program;

2)% triggerun: Trigger a script for uninstalling, when the package is installed with the specified package, uninstalling any one of the two will trigger this program;

3)% triggerpostun: The script is triggered for the uninstallation, and only the program is executed only after the specified package is unloaded. 3.1 Segment name format They are described in the format: interactive segment name [sub-package option] [-P interpretation] - Trigger condition 1 [, trigger condition 2] ...

Note: [] The option is included. The sub-package option is described earlier, and details will not be described.

3.1.1 --P Options: This option is used to specify an interpreter to explain the script program that performs the interactive function segment. By default, RPM uses / bin / sh to perform scripts (such scripts are written in the shell language, also called the shell program). Some rpm packages are using / usr / bin / perl to perform scripts (this class script is written in this explanatory language), which requires the -p option to specify the interpretation for / usr / bin / perl , For% triggerin - sendmailn -sf / usr / bin / sendmail / etc / mymailer / mailer% Triggerin - vMailn -sf / usr / bin / vmail / etc / mymailer / mailer

Note: In this case, the Package sub-package is defined when the script is triggered: When the trigger condition (FileUtils> 3.0, Perl <1.2) is satisfied, use the / usr / bin / perl to execute the script, that is, using the print command to output a string "i 'm in my trigger! ".

3.1.2 Triggering Conditions: The trigger condition format of the interactive function segment is: function name [comparison volume version number]

Among them: The comparison is optional. Only one function name is displayed, the trigger program is executed when the function is present. The comparator can be used to be greater than (>), equal to (=), less than (<), greater than or equal to (> =) and less than or equal to (<=). Such as triggering conditions Bash, such as triggering conditions, FileUtils> 3.0, this use is legal. The interactive function segment has a trigger condition. When there are multiple trigger conditions, these conditions are separated by commas (,), and they are "or" relationships, that is, as long as one of the condition systems satisfies, the RPM will execute the trigger script. As described above, the example of the -p option is in the example, there are two trigger conditions FileUtils> 3.0 and Perl <1.2. When installing the package, as long as there is a condition satisfaction, the RPM will perform trigger scripts, that is, output "I ') m in my trigger! ".

3.2 How to use the interactive function segment to use the interactive function segment? The following example can explain the problem. Assume that the MyMailer package requires / etc / mymailr / mailer this symbol connection file points to the currently used mail sending agent. If the Sendmail package is installed, the symbol connection file should point to the / usr / bin / sendmail program. If the vmail package is installed, it should point to the / usr / bin / vmail program. If these two packages are installed (in fact, sendmail is conflict with VMAIL), then we do not need to consider which file of symbolic connection points. Of course, if the two packs are not installed, then the / etc / mymailer / mailer symbol connection file has no reason.

The above requirements are implemented by writing a trigger script for the MyMailer software package, which will change the / etc / mymailr / mailer symbol connection when the following events occur: 1) Sendmail is installed; 2) Vmail is installed; 3) Sendmail is uninstalled; 4) When Vmail is uninstalled.

The first two event triggered scripts to write:% triggerin - sendmailn -sf / usr / bin / sendmail / etc / mymailer / mailer% Triggerin - vMailn -sf / usr / bin / vmail / etc / mymailer / mailer

This is a script that is triggered by Sendmail or Vmail when two installations. They will be performed in the following cases: 1) Install or upgrade the sendmail package in the case where the MyMailer package is installed; 2) Install or upgrade the VMAIL package in the case where the MyMailer package is installed; 3) installed in the Sendmail package In the case, install or upgrade the MyMailer package; 4) Install or upgrade the MyMailer package in the case where the Vmail package is installed. The latter two event triggered scripts can be written like this:% triggerun - sendmail [$ 2 = 0] || EXIT 0IF [-f / usr / bin / vmail] kiln -sf / usr / bin / vmail / etc / mymailer / MaileRelSerm -f / etc / mymailer / mailerfi% triggerun - vmail [$ 2 = 0] || exit 0if [-f / usr / bin / sendmail] kiln -sf / usr / bin / sendmail / etc / mymailer / maileRelSerm -f / etc / mymailer / mailerfi These two scripts trigger execution in the following cases: 1) Uninstall the MyMailer package in the case where the Sendmail package is installed; 2) Uninstall the MyMailer package when the Vmail package is installed; 3) Uninstalling the sendmail package in the case where the Mymailer package is installed; 4) Uninstall the VMAIL package with the MyMailer package installed. To ensure that the symbol connection file / etc / mymailer / mailer is also deleted after the MyMailer package, you can add the command of the file:% postun [$ 1 = 0] && with the% postun function segment of the MyMailer package description file:% Postun RM-F / ETC / MyMAiler / MAILER

Note: The script is executed after the% postUn segment is uninstalled, and then executes after the MyMailer package is unloaded. As is seen, when a package is closely related to another software package, we can implement some files by interactive function segments, which not only expands the functionality of the RPM package management, but also helps the package. Normal operation.

4. Other functional segments of other functional segments are only one, namely% Changelog. The content of this section is a software maintenance record that records the time, maintenance of people and its Email, maintained projects each time, maintenance projects. % CHANGELOG segment content format is: * Month day year year maintenance content Note: Each maintenance record is started with * start, weeks, months must be abbreviated. Maintenance content can be written in a multi-time branch, and the beginning of each line is starting with minus (-). You can use a maintenance record format similar to the LZE mode: (see the LZE description file No. 80-85)

A rpm package description file, you can generate only one parent package or a sub-package, or a parent package and multiple subcles can be generated. By setting the sub-package option, the generated sub-package can be naming the standard name of the "Software Name-Sub-package name", or the generated subcales can be used to use their own name. A sub-package is usually generated in accordance with the purpose or type of files therebetween, and it is wrapped in a package. The previous LZE description file is simple, it contains all the files into the parent package. We can also classify files into subclonters, such as being divided into executing program sub-packs, configuring file subcaps, and document packets (LZE-DOC). We can also only share a configuration file sub-package (LZE-Config), and the other files are parental packets (LZE). By classifying this detailed class, it helps to manage software packages, avoiding excessive things, and also helps to upgrade.

To create a child package, you must describe the following:

1.% package: Create a subcales in this paragraph. Its name is controlled by sub-package option. The sub-package option is "[-n] subpack name", when the -n is not selected, the generated sub-bag file is "Software Name - Sub-package name - version number - Release"; The generated sub-bag document is "sub-package name - version number - Release". System. rpm. Its application format is:

% package sub-package option

2. Summary

This domain must be under% Package, which defines a sub-package function (a sentence description). The format is:

Summary: Subcombinant

3. Group

This domain must be under% package, which define the software category of the sub-package (for software category, please refer to << Excellent RPM five - query articles >>). Format is: Group: Software category

4.% Description:

The content of this description is a more detailed sub-package function, which is introduced to text form, format does not require, can be used anywhere or segment. The format is:% Description sub-package option ... Introduce the content of the sub-package function ...

5.% Files: The content of this file segment is a list of files to be included in the sub-package. In the list of files, a file occupies a row, and multiple file modes can be used. (See << Excellent RPM seven - production articles (on) >>

Segment name application format is:

% Files sub-package option [-f file name]

Note: The above-mentioned% Description and the sub-package options used by the% Files paragraph must match the sub-package options used by% package, otherwise, they are defined as the same sub-package, and RPM checks out. If you define a% Package Name, the description of the parameters must be used by% Description Name, and the file segment name is required to use the% FILES NAME. With% Description -N name, it is not possible, and% files -n name will not work.

Subcaps can also use seven optional feature segments such as% Pre,% POST,% preun,% postun,% triggerin,% triggerun, and% triggerpostun, as they can use sub-package options. When using sub-package options, their segment content is the script for managing subclubes. It should be noted that the form of sub-package options used in these segments must also be consistent with the sub-package options used by the% package segment.

Conditional statement

In the package description file, the conditional statement can be used flexibly, the location is not limited. These statements are used for judgments of the current system and the operating system. When the conditions are true or false, RPM references their corresponding description.

There are two formats in the condition statement:

1. {% iFARCH,% IFNARCH,% IFOS,% IFNOS} value 1 [value 2] ... Description Content% ENDIF

Note: {} Included one of the contents, [] is included, and each value is separated between space,% Endif indicates the end of the condition statement.

The meaning of this statement is: 1) When using the% IFARCH, it means that the description is described if the current system is 1 or value 2 ... 2) When using the% IFNARCH, it means that the description will be referred to if the current system is not a value of 1 or value 2 ... 3) When using% IFOS, indicating that if the current operating system is 1 or value 2 ..., the description is referenced. 4) When using% IFNOS, it means that if the current operating system is not a value of 1 or value 2 ..., the description content is referenced.

If you want to add files /etc/sparc.lze and /etc/sparc.iMe for the SPARC system in the file segment of the LZE package description file, you can add as follows:% iFARCH SPARC / ETC / SPARC. LZE / ETC / SPARC.IME% ENDIF

After doing so, if the current system is SPARC, RPM will join these two files when packaged.

2. {% Ifarch,% IFNARCH,% IFOS,% IFNOS} value 1 [value 2] ... Description content 1% ELSE Description Content 2% ENDIF

Note: {} Included one of the contents, [] is included, and each value is separated between space,% else indicates that the% ENDIF indicates the end of the condition statement.

The meaning of this statement is: 1) When using the% IFARCH, it means that if the current system is a value 1 or value 2 ..., the description content 1 is referred to, otherwise, the reference description 2.2 is used, indicating if the current system is used. Not a value 1 or value 2 ..., the description 1, otherwise the content 2.3) When using% IFOS, indicating that if the current operating system is 1 or value 2 ..., the reference description 1 , Otherwise, description 2.4) When using% IFNOS, indicating that if the current operating system is not a value 1 or value 2 ..., the description will be referred to, otherwise the content 2 is described.

If you want to determine the name of the LZE package according to the current operating system, you can use the following statement in the description file header:% ifos Linuxname: Lzeforlinux% ELSE

% IFOS AIXName: Lzeforaix% Elsename: Lzefor Porthersysi% Endif

% ENDIF

In this example, the nested condition statement is used, which is the case where the operating system is Linux, the software name is set to Lzeforlinux. If the operating system is AIX, the software name is set to Lzeforaix, if not the above two operating systems Then, the software name is set to Lzefor Porthersysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysys ". How to use macros in the description file (Macros)

1. What is macro? People who have learned C language know that macros are used to implement text alternative, that is, after the macro name and macro have, all macro-names in the file will be macro. Replace it. Using macros can reduce the entry of the text, it is convenient for programmers. Using macros in a package description file, it is based on this purpose, but this macro is different from the macro definition format of the C language.

2. Macro definition

Description File The definition format of the macro is:

% Define [(OPTS)]

Note: [] The option is included. For macro name, macro name available letters, numbers and underscores (_), and its length is 3. OPTS is one or more options, there is no separation between options, the options use the form of the getOpt function, that is, the option is a single character. If an option requires parameters, you need to add a colon (:) after this option. For the macro, the empty character around it will be deleted. The content of the macro body must be on one line.

If there is no macro definition:

% Define aaa "this is my software"

If there is only one macro definition:

% define xxx (p: z) echo% {- p:% {- p *}}% {- z}

3. Macro

The use format of the macro is:% [OPT1] [OPT2] ... [arg1] [arg2] ...

Or% {} [OPT1] [OPT2] ... [arg1] [arg2] ...

Note: [] There is an optional option; for the macro name applied, the macro name can be enclosed in {}; OPT1, OPT2 ... is an option, must start with minus (-), and if the option requires parameters If an option parameter must be provided; Arg1, Arg2 ... is a macro parameter.

As the XXX macro defined above, you can use this:

% xxx -p zhsoft hello world
example, xxx macro uses a parameter of the -p, zhsoft as the -p option, as well as two macro parameters Hello and World.

Note: It is best to change your way when the macro is used (ie, the macro below is empty), because the macro does not change after the extension, so if there is not much wrap, the following line will have the content, the content after the macro extension will be and the following line The content is combined together, and it is very prone to errors. This is also one of the issues that the author found RPM macro. There is also a problem, if there is a macro on the note, this macro will also be expanded! Because the comment is ignored, there is no need to expand again. These two issues need to cause the RPM developer's attention and resolve.

4. Macro body dedicated to the macro body can use the following special macro: (similar to the form of the shell)

1)% 0: Represents the macro name of the macro; 2)% *: Represents all parameters of the macro; 3)% #: indicates the number of parameters of the macro; 4)% {- f}: Indifies if the macro uses -f Option, it represents -f and its option parameters; 5)% {- f *}: Indicates that if the macro uses the -f option, it represents the parameters belled in -f; 6)% {- f: x}: Indicates that if the macro uses the -f option, it represents x; 7)% {! - f: y}: Indicates that if the macro does not use the -f option, it represents Y; 8)% 1,% 2, ... : Represents the parameters of the macro 1, parameter 2 ...

For example, when the XXX macro is executed in the above example, if there is a special macro in the macro body, the dedicated macro will be expanded to:

1)% 0 expansion to xxx; 2)% * extended to Hello WORLD; 3)% # expansion to 2; 4)% {- p} extension is -p zhsoft; 5)% {- p *} extension to zhsoft; 6)% {- p: good} extension to good; 7)% {! - z: BAD} extension to Bad; (because XXX Macro does not use -Z option) 8)% 1 Hello,% 2 is world, no Other parameters.

5. System built-in macro

The built-in macro built into the system is as follows:

5.1 Define Class 1)% Define ...: Define a macro; (original,% define is also a macro) 2)% undefine ...: Cancel a macro; (After macro decent, the description file below this statement cannot Use this macro, even if you use it, the macro will not be expanded)

5.2 Commissioning 1)% Trace: Debugging information before and after the printing macro; 2)% DUMP: Macro (macro name and macro) of the printed activity; 3)% {echo: ...}: Print ... to the standard Error device; 4)% {warn: ...}: Print ... to standard error devices; 5)% {error: ...}: Print ... to standard error devices, and return BadSpec values; 5.3 Special The default value of this macro is usually placed in the / usr / lib / rpm / macros file, and the user can redefine such macro by editing the .rpmmacros file under its home directory (~ .rpmmacros). Its defaults for rpm uses their own definitions when making, installation, and queries.

The definition format of this type of macro is:

%

Note: For the macro name, for the macro.

1)% packager,% vendor,% distribution:

These three macros are used to define the default domain values ​​of three optional domains in the description file, that is, if there is any of the three domains that are defined in the description file, and the corresponding macro is defined. However, RPM uses the macro body of its corresponding macro.

There is such a three lines like my ~ / .rpmmacros file:

% VENDOR Aspect Making Center% Packager Yizhen Note% Distribution Xiao Zhao '2001

In this way, the software package description file is no longer needed to define those three domains, and the package produced is automatically fixed when the package is inquiry, and its packagepers, sales, and distribution are automatically set. , Once again.

2)% buildroot,% _ provides:

These two macro define the root directory and software package provided by the software package. They do not take the initiative to be used by RPM when packaging the three macros above, but must be written in the description file. which is:

% VENDOR Aspect Software Production Center% Packager Yizhen% Distribution Xiao Zhao '2001Buildroot:% BuildRootProvides:% _Provides

3)% _TOPDIR,% _ builddir,% _ rpmdir,% _ sourcedir,% _ specdir,% _ srcrpmdir:

These six macros are used when the RPM makes a package, they are: in / usr / lib / rpm / macros file:

% _Topdir% {_ usrsrc} / dist% _builddir% {_ topdir} / BUILD% _rpmdir% {_ topdir} / RPMS% _sourcedir% {_ topdir} / SOURCES% _specdir% {_ topdir} / SPECS% _srcrpmdir% {_ topdir} / SRPMS

% _topdir macro definition is the top-level directory of the directory used when the RPM makes the package, typically / usr / src / dist (% {_ USRSRC} macro value / usr / src). In the top directory, there are five subdirectory:

* Directory used when the connection source program is compiled, is defined by% _builddir macro, often used build; * The generated RPM executes the directory stored by% _rpmdir macro, common RPMS; * Source program stored by% _Sourcedir Macro definition, common Sources; * Package description file stored directory, by% _specdir macro definition, common SPECS; * The generated RPM source package stored by% _srcrpmdir macro definition, often SrPMS.

Due to the recursive characteristics of the macro, we can achieve five macros such as change% _builddir by only the% _topdir macro. (Note:% _ Builddir, the macro body, such as no special requirements, try not to change, they are the standard definition, should be adopted) This is very important for ordinary users. Because rpm default top directory / USR / SRC / DIST is not for every user, ordinary users want to make some packages in all the RPMs in all their directory. I also have this idea, so add such a line in ~ /.rpmmacros file:

% _TOPDIR / USR / ZZZ / RPM

At the same time, the subdirectory required by RPM is established below this macro defined directory, and the command is:

$ CD / USR / ZZZ $ MKDIR -P RPM / {Build, RPMS / I386, Sources, SPECs, SRPMS} $ I386 in command is the RPM default system name, RPM generated execution package is stored in "RPMS / system Name "directory. After doing this, I can make RPM software packages in my own directory, like super users.

4)% _ Excludedocs,% _ ftpport,% _ ftpppproxy,% _ httpport,% _ httpproxy,% _ netsharepath:

These six macros play the installation and query of the RPM package.

*% _excludedocs: If its value is defined as 1, the RPM is installed when the package is installed, the default method of the document is not installed; *% _ftpport: This macro is used to define the RPM default FTP port; *% _ftppproxy: This macro Define RPM default FTP proxy servers; *% _httpport: This macro is used to define RPM default HTTP ports; *% _httpproxxy: This macro is used to define RPM default HTTP proxy servers; *% _NetshaRepath: This macro is used to define rpm The default network shared directory is available for Network File System (NFS).

6. A special macro use is:

% (Shell Command and Its Parameters)

Its result is the result of the standard output of the specified shell command as part of the description file content. If a part of the package description file needs to be added with the current date, you can use:

% (DATE % Y-% M-% D)

After execution, the macro will expand to date data similar to 2001-10-31. Users may wish to add such two rows in the pre-processing segment (% prepr) of our description file:

% (DATE % Y-% M-% D) EXIT 1

Note: EXIT 1 is used to abort the execution of RPM.

Description File Templates All Description File Templates are made as an example in which the LZE package is created, and the file generated after the source program is compiled as accurately generated package. The necessary portions are generally described in the description file. In addition, if all files of the file segment already exist in the system, and if you want to use the package directly, you can remove the Source domain, remove the RPM buckle function segment (% preip,% build,% install,% clean).

1. Only a parent package, no subcaps: This description file sees << Excellent RPM 7 - Production articles (on) >>. Several optional function segments can also be removed in this file, such as% pre,% post,% preun,% postun,% triggerin,% triggerun,% triggerpostun. These sections have no substantial use in this document, and only the RPM is only displayed when the RPM starts performing information. This description file only generates a package LZE-6.0-2.i386.rpm (parent package).

2. There is a parent package, there is a child package:

The description file is as follows:

# 1 File Name: lze-6.0-2.spec12 # file functions: lze package description information of the file # 3: vertical and horizontal software production center rain also odd National Defense University Graduate Rosso Zhao Jianli # 4 Modified: 2001.10.3156 Name: lze7 Version: 6.08 Release: 29 Summary: Little Zhao full screen Chinese English multi-window multi-function editor (Linux / UNIX system) 10 Group: Applications / Editors11 license: Share12 Source: http://ensoft.myetang.com/lze- 6.0-2.src.tgz1314% Description15 Xiao Zhao editor 17 It mainly has the following ten characteristics: 1. Full-screen menu operation. 2. Differently display. 3. Block is rich in operation. 4. Ten 18-style table is powerful. 5. Multi-window operation is flexible. 6. File operation is complete. 7. Explain the output function unique 19 colors. 8. With the Chinese input method (enhanced five and enhanced pinyin), it is easy to use. 9. Hexadecimal editing function, such as Tiger 20 Add Wings. 10. Instant translation, press to translate. 21 In short, Xiao Zhao editor will become a good helper for program and writing a general manuscript on UNIX, Linux system. 22 It will help you help you in your work, easy to go, and you have a long! 2324% PREP25 ECHO "Preprocessing Script Program" 26% SETUP2728% Build29 Echo "Compile Connection Script Program (Build) Started" 30 Make3132% Install33 Echo "installation script (INSTALL) start" 34 make install3536 # Profile package 37% package config38 summary: Small Zhao editor LZE configuration file 39 Group: Applications / Editors4041% Description Config42 Small Zhao editizer configured configuration file including function key definition files and 43 input method control file, users can depend The situation is modified. 4445% Files Config46% config /etc/funkey.def47% config /etc/inputme.def4849 # Description document sub-package 50% package Doc51 summary: Little Zhao editor Lze instructions Document 52 Group: Applications / Editors5354% Description DOC55 Xiao Zhao Editor Description Document, detail the function and operation of the 56 command line method of the editor and the built-in menu, which has a big role in familiar with 57 familiar Xiao Zhao editors. 5859% Files Doc60% Doc /usr/doc/lze-6.0/readme61% DOC /USR/DOC/LZE-6.0/LICENSE6263 # Parent package file segment 64% files65% defattr (-, root, root) 66 / usr / bin / LZE67 /USR/BIN/LZEIME.PY68 /USR/BIN/LZEIME.WB69 /ETC/WBZC.DAT70 This description file generation package is: LZE-6.0-2.i386.rpm (parent package), Lze-config- 6.0-2.i386.rpm (profile package) and Lze-DOC-6.0-2.i386.rpm (Description document package). 3. There is no parent package, only subcaps: there is no parent package, meaning that there is no parent package file (% files) in the description file, please see the description file below:

# 1 File Name: lze-6.0-2.spec22 # file functions: lze package description information of the file # 3: vertical and horizontal software production center rain also odd National Defense University Graduate Rosso Zhao Jianli # 4 Modified: 2001.10.3156 Name: lze7 Version: 6.08 Release: 29 Summary: Little Zhao full screen Chinese English multi-window multi-function editor (Linux / UNIX system) 10 Group: Applications / Editors11 license: Share12 Source: http://ensoft.myetang.com/lze- 6.0-2.Src.tgz1314% Description15 Xiao Zhao editor, is a full-screen multi-window 16-English multi-function editor for full-screen multi-user design for the majority of users of SCO UNIX, Linux multi-user systems. 17 It mainly has the following ten characteristics: 1. Full-screen menu operation. 2. Differently display. 3. Block is rich in operation. 4. Ten 18-style table is powerful. 5. Multi-window operation is flexible. 6. File operation is complete. 7. Explain the output function unique 19 colors. 8. With the Chinese input method (enhanced five and enhanced pinyin), it is easy to use. 9. Hexadecimal editing function, such as Tiger 20 Add Wings. 10. Instant translation, press to translate. 21 In short, Xiao Zhao editor will become a good helper for program and writing a general manuscript on UNIX, Linux system. 22 It will help you help you in your work, easy to go, and you have a long! 2324% PREP25 ECHO "Preprocessing Script Program" 26% SETUP2728% Build29 Echo "Compile Connection Script Program (Build) Started" 30 Make3132% Install33 Echo "installation script (INSTALL) start" 34 make install3536 # Profile package 37% package config38 summary: Small Zhao editor LZE configuration file 39 Group: Applications / Editors4041% Description Config42 Small Zhao editizer configured configuration file including function key definition files and 43 input method control file, users can depend The situation is modified. 4445% Files Config46% config /etc/funkey.def47% config /etc/inputme.def4849 # Description document sub-package 50% package Doc51 summary: Little Zhao editor Lze instructions Document 52 Group: Applications / Editors5354% Description DOC55 Xiao Zhao Editor Description Document, detail the function and operation of the 56 command line method of the editor and the built-in menu, which has a big role in familiar with 57 familiar Xiao Zhao editors. 5859% Files Doc60% Doc /usr/doc/lze-6.0/readme61% DOC /USR/DOC/LZE-6.0/LICENSE6263 # execute program package 64% package bin65 summary: Little Zhao Editor Lze executive 66 Group: Applications / Editors6768% Description BIN69 Small Zhao Editor Execute Program for LZE, five input method server executor 70 is LZEIME.WB, Pinyin input method server execution program is LZEIME.PY. 7172% Files bin73% defattr (-, root, root) 74 / usr / bin / lze75 /usr/bin/lzeime.py76 /usr/bin/lzeime.wb77 /etc/wbzc.dat78 This description file generates three packages : Lze-config-6.0-2.i386.rpm (profile package), LZE-DOC-6.0-2.i386.rpm (Description Document package), Lze-bin-6.0-2.i386.rpm (execution Program package).

Production articles (below) (Yiji Zhao Jianli December 10, 2001 09:38) To make a software package in the RPM format, you need to use the following command format:

RPM-BX [Production Option 1 Production Option 2 ...] Description File 1 Description File 2 ...

Note: -bx can be replaced with -tx, and the effect is different: when using -b, you need to specify a package description file on the command line; and use -t, you need to specify the specified package description file on the command line, Is the parcel file (must be compressed with Gzip), and RPM automatically extracts the description file from this package file when preparing a package file, and generates a software package in the RPM format according to the built-in instructions. Note: This description must have a .spec as a suffix, where there must be a source domain, and this domain defined source sequence package must be stored in the current directory, otherwise, RPM will report an error to exit. Note that when -bx is X, take different values, RPM will perform different operations: (The following examples operate on LZE's description file LZE-6.0-2.SPEC, and some passed pipe technology , Use the nl command to add a line number to explain)

1) When x = p, an RPM is instructed to perform a script program (% preip) in the description file. This scripker is typically used to decompress the source package, and patch the source program and upgrade the source program. # rpm-bplze-6.0-2.spec2> & 1 | NL1EXECUTING:% Prep2 UMASK0223 CD / USR / SRC / DIST / BUILD4 Echo 'Pre-Processing Script Program (PREP) Start Perform' 5 Preprocessing Scripts (PREP) Start 6 CD / USR / SRC / DIST / Build7 RM-RFLZE-6.08 / bin / Gzip-DC / USR / SRC / DIST / SOURCES / LZE-6.0-2.SRC.TGZ9 TAR-XVVF-10DRWXR -XR-XROOT / ROOT02001-11-0216: 02Lze-6.0 / 11-rw ------- root / root2462262001-11-0216: 00Lze-6.0 / lze.c12-rw ------ ROOT /Root982492001-11-0216:00Lze-6.0/lzeime.wb.c13-rw -------Root/root3399022001-11-0216:00Lze-6.0/lzeime.py.c14-rw-r--r-R- -root / root12832001-11-0216: 00Lze-6.0 / funkey.def15-rwxr - r - root / root2502001-11-0216: 00Lze-6.0 / inputme.def16-rw-r - r - root / root8132742001 -11-0216: 00Lze-6.0 / wbzc.dat17-rw ------- root / root4742001-11-0216: 02lze-6.0 / makefile18 status = 019 "['0-ne0'] '20 CDLZE-6.021 / usr / bin / ID-U22 '[0 = 0'] '23 / bin / chown-rhfroot.24 / usr / bin / id-u25 ' ['0 = 0'] '26 / bin / chgrp-rhfroot.27 / bin / chmod-rfa RX, GW, OW.28 EXIT #

Note: "Executing:% PreP" displayed in this example indicates that the RPM begins to perform a script program for the preprocessing segment. In the case of the line number, the lines starting with the plug-in ( ) are instructions for the preparation segment script, and the other content executes the result of the output. From the instructions executed by the preprocessing segment script, we can see what rPM is doing: Line 2: Settings file creation mask; line 3: Go to RPM default compilation directory; line 4: Back Character Strings, this is the beginning of the preparational segment script written by the user, and the second, third lines are the increased instructions of RPM; line 6-27: The command expanded to% Setup and its execution results, which can See the RPM with the gzip command to extract the Lze source sequence (8th line), and use the tar command to expand the source package (line 9). Row 28: Normal exiting, return value is 0.2) X = L, indicating whether the RPM check file segment (% files) is to see if the files are present. If there is no existence, the RPM will report an error exit. # RPM-BL-VVLZE-6.0-2.SPEC | NL1PROCESSINGFILES: LZE2D: FILE0: 0100644Root.Root / etc / funkey.def3d: file1: 0100644Root.root / etc / infutme.def4d: file2: 0100644Root.root / usr / doc /LZE-6.0-2/Readme5filenotfound:/USR/doc/lze-6.0-2/license6d:file3:01005555555555555555555555555555555555551ROOT.ROT /USR/BIN/LZEIME.PY8D: FILE5: 0100511Root.Root / usr / bin / Lzeime.wb9d: file6: 0100644Root.root / etc / wbzc.dat10Provides: Lze-edit11prereq: / bin / sh12requires: / bin / sh #

Note: General option -vv is used in this command to output debugging information when RPM check (on line number and D: start). As seen from the above, RPM checks one by one by all files in the file segment, and the file is found, the owner and the associate information, and the result is found that /usr/doc/lze-6.0-2.license file does not exist, so File Not Found (see Chapter 5). RPM also shows the function (provvice) that describes the functionality provided by the description file request Lze after checking the file.

3) When X = C, the RPM indicates that the pre-processing segment (% preip), the compiler (% build) script is executed. The script program of the compilation section is used to compile the source program of the connection software, generate an executable, usually a MAKE command is sufficient. Because a programmer with good habits will write makefile (program maintenance files) so that other programmers compile this software. If a software does not maintain a file, the user either writes Makefile, or write the software compiles and connects to the connection in the compile section.

4) When x = i, the RPM indicates that the pre-processing segment (% preip), the compilation section (% build), and the installation segment (% install) script. The task of the installation segment script is to copy the execution program that is compiled into the appropriate directory (such as / bin, / usr / bin) to package or execute. The instructions it usually execute are make install.

5) When x = b, indicating that the RPM sequentially performs the preprocessing segment (% preip), the script, the installation section (% install) script, and then according to the file segment (% FILES) list, File packaging, generate RPM execution package, and finally perform the cleaning segment (% Clean).

# rpm-bblze-6.0-2.spec2> & 1 | NL1EXECUTING:% Prep2 UMASK0223 CD / USR / SRC / DIST / BUILD4 ECHO 'Prerequisite Script Program (PREP) Start Perform' 5 Preprocessing Scripts (PREP) Start executing 6 CD / USR / SRC / DIST / BUILD7 RM-RFLZE-6.08 TAR-XVVF-9 / BIN / GZIP-DC / USR / SRC / DIST / SOURCES / LZE-6.0-2.SRC.TGZ10DRWXR -XR-XROOT / ROOT02001-11-0217: 04Lze-6.0 / 11-rw ------ Root / root2462262001-11-0216: 00Lze-6.0 / Lze.c12-rw ------ ROOT /Root982492001-11-0216:00Lze-6.0/lzeime.wb.c13-rw -------Root/root3399022001-11-0216:00Lze-6.0/lzeime.py.c14-rw-r--r-R- -root / root12832001-11-0216: 00Lze-6.0 / funkey.def15-rwxr - r - root / root2502001-11-0216: 00Lze-6.0 / inputme.def16-rw-r - r - root / root8132742001 -11-0216: 00Lze-6.0 / wbzc.dat17-rw ------- root / root4742001-11-0216: 02lze-6.0 / makefile18-RW-R - r - root / root12552001-11-0217 : 04LZE-6.0 / GetInputme.c19 status = 020 '[' 0-NE0 ']' 21 CDLZE-6.022 / usr / bin / id-u23 '[' 0 = 0 ']' 24 / bin / Chinese-rhfroot.25 /usr/bin/id-u26 ['0=0']'27 /bin/chgrp-rhfroot.28 /bin/chmod-rfa RX, GW ,ow.29 EXIT030EXECUTING:% Build31 Umask02232 CD / USR / SRC / DIST / Build33 CDLZE-6.034 Echo 'Compile Connection Script Program (Build) Started 35 Compilation Connection Script Program (Build) Start Perform 36 Make37cc-Fwritable-Strings-Duse_AS_LZE-DFOR_LINUX-SI / USR / ZZZ / SRC / ILZE_LZE_INPUTME-OLZE / USR / ZZZ / SRC / Li-38BSRC / MyCurses.clze. CGetinputme.c / usr / zzz / src / my.a39cc-dfor_linux-si / usr / zzz / src / include-ilzeime.wbGetinputme.clzeime.wb.c / usr / zzz / src / my.a40lzeime.wb.c: Infunction`do_service ': 41lzeime.wb.c: 1409: warning: passingarg5of`bsearch'fromincompatiblepointertype42cc-DFOR_LINUX-sI / usr / zzz / src / include-olzeime.pygetinputme.clzeime.py.c / usr / zzz / src / my .a43 exit044EXECUTING:% INSTALL45 UMASK02246

cd / usr / src / dist / BUILD47 cdlze-6.048 echo 'installation script (the install) '49 begin the installation script (the install) started 50 makeinstall51installing ... 52done53 exit054Processingfiles: lze55FindingProvides: (using / usr /LIB/rpm/find-provides: (using/usr/lib/rpm/find-requires): Luze-edit58prereq:/bin/sh59requires :/bin/shld-linux.so. 2Libc.SO.6LIBC.SO.6 (Glibc_2.0) Libc.SO.6 (Glibc_2.1) 60wrote: /usr/src/dist/rpms/i386/lze-6.0-2.i386.rpm61executing:% Clean62 UMASK02263 CD / USR / SRC / DIST / BUILD64 CDLZE-6.065 ECHO 'After the completion of the package, the Clean Script is started to perform the '66 built package After the cleaning script (Clean) starts to perform 67 exit0 # Note: In this example, each line is explained as follows: Chapter 1: Display RPM Start Performing Pre-Processing Section (% PREP); line 2-29: For the command and results executed by the pretreatment segment (% preip) script, there is an addition No. ( ), the result is not. Pre-processing completed the decompression (Gzip-DC) of the LZE source package (TAR-XVF), thus laying the foundation for the compilation of the source program; 20 lines: rpm indicates that the compilation segment is started (% build) ;. 31-43: Commands and results executed for the compilation section (% build) script program. The Make maintenance command executed by the script, which executes the CC compiler to compile and connect to the LZE software; 44th line: RPM indicates that the installation segment (% install); 45-53 line: is the installation section (% install ) The commands and results executed by the scripter. This program executes the MakeInstall command, copy files such as Lze to the system directory; section 54: RPM display: Start processing LZE file (content for% Files file); 155-59 line: rpm Use the / usr / lib / rpm / find-provides to find the functions provided by Lze, and use / usr / lib / rpm / find-request to find the functions dependent on Lze to set the dependencies of LZE; 20th line: production Complete the LZE execution package, the file name is LZE-6.0-2.i386.rpm, under / usr / src / DIST / RPMS / I386 directory; 61 line: RPM display: Start execution of the cleaning segment (% Clean) script This section is used to clean up temporary files; lines 62-67: commands and results executed for the cleaning segment (% clean) script program.

From the top floor, we can clearly see the workflow of the RPM production package: preprocessing sections, compilation segments, installation sections, software package production, and cleaning segments.

6) When x = s, the RPM is indicated to establish a source package. The contents of the RPM source package include a few items such as package description file (SPEC), software source, software patches, icon files. Creating a source package does not require each function segment in a package description file, just in the package you need to include it in the package.

# rpm-bslze-6.0-2.specwrote: /usr/src/dist/srpms/lze-6.0-2.src.rpm#rpm-qplv/usr/src/dist/srpms/lze-6.0-2.src. RPM-RW ------ Rootroot 201711, 2009: 44LZE-6.0-2.SPEC-RW-R - R - Rootroot5387061191] 217: 05lze-6.0-2.src.tgz #

Note: In this example, use the RPM-BS command to generate a LZE source package LZE-6.0-2.Src.rpm (under the RPM Standard Source Catalog / USR / SRC / DIST / SRPMS), then use the rpm -qplv command to query the source code The file information contained in the package can see two files in the LZE source package: one is the package description file LZE-6.0-2.SPEC, one is the LZE source package Lze-6.0-2.src.tgz (TAR package is compressed with Gzip), this file is determined by the Source field in the description file. 7) When X = A, the indication RPM sequentially executes the pre-processing segment (% preip), the compilation segment (% build), the installation section (% INSTALL) script, after which is a RPM source package, and then according to the file segment (% Files) ) File list, package the file, generate the RPM execution package, and finally perform the cleaning segment (% Clean) script, clear the intermediate file. The results executed by this command are equivalent to executing the RPM-BS command generation source package, and then execute the RPM-BB command to generate the execution package.

Option list

Options

The interpretation of the general option see << Excellent RPM 2 - Installation articles >> This article is not described later.

1 .-- short-circuit: The purpose of single-step execution this option is to single-step execution function, only the user is RPM-BC (or -TC) and -bi (or -ti). When using the RPM-BC-Short-Circuit command, RPM will no longer perform the script program of the pre-processing segment (% preP), directly execute the script program of the Compile Segment (% Build). When using the RPM-BI-Short-Circuit command, RPM will no longer perform the script program of the Pre-Processing Segment (% PreP) and Compile Section (% Build), and only the installation segment (% install) script.

Why use this option? It may be a problem with the file in the source package, resulting in such an error in the compilation or installation process, if it is unable to execute, these errors cannot be excluded. After single-step execution, the user can enter the directory where the source program is located, see the source program, modify the error, and then use the tar command to generate a correct source program package, override the original package. In this way, there will be no problem when RPM is again.

2 .-- TimeCheck: Setting the time check value This option is: - TimeCheck Note: is the time period of the check, the unit is second, if the timecheck600 setup check is 600 seconds, 10 minutes.

Setting the time check value for verifying whether the package file is a new file generated within the specified time period. The error is caused. This error may be due to the makefile or the installation segment script in the description file is not written incorrectly, so that a program cannot be properly installed to the specified directory, so the RPM is always quoted when the old program file is always referenced. As in the following example: # rpm-bl - timecheck600lze-6.0-2.specProcessingfiles: lzewarning: TIMECHECKfailure: / usr / bin / lzeFindingProvides: (using / usr / lib / rpm / find-provides) ... FindingRequires: (using /usr/lib/rpm/find-requires )...Provides: brout-editpreq:/bin/shrequires:/bin/shld-linux.so.2libc.so.6libc.so.6 (Glibc_2.0 )Libc. SO.6 (Glibc_2.1) #

Note: This example uses the RPM check file list, see which file is the old file generated before 10 minutes, and the result rpm issues a warning message: "Warning: timecheckfailure: / usr / bin / lze", this shows file / usr / bin / LZE Time Check an error, this is an old file. After investigation, it is Makefile problem, there is a "CPLZE / USR / BIN". After the correction, the connection program is compiled again, and there is no such problem for time check.

3 .-- Buildroot: Setting Unscutions Used Root Catalog This option is: - Buildroot

Note:

The root directory for the built package specified by the user. This option is equivalent to the file header of the package description file: buildroot:

Just set to set more freely in the command line.

By setting the root directory for the construction package, the general user can also establish the RPM package that only the superuser (root) can be established. The LZE package is established by the normal user ZZZ as an example, indicating the establishment of this form of package.

1) Under User ZZZ's Home Directory (/ USR / ZZZ), establish a directory for RPM bucks: $ CD / USR / ZZZ $ MKDIR-PRPM / {Build, RPMS / I386, Sources, Specs, Srpms} $

2) Copy Description File LZE-6.0-2.SPEC to the RPM / SPECS directory, copy source package Lze-6.0-2.src.tgz to the RPM / Sources directory.

$ CD / USR / ZZZ $ CP / ROOT / LZE-6.0-2.SPECRPM / SPECS $ CP / ROOT / LZE-6.0-2.SRC.TGZRPM / SOURCES $

3) Establish. Rpmmacros file, edit it: $ CD / USR / ZZZ $ VI.RPMMCROS Add a line in this file:% _ TOPDIR / USR / ZZZ / RPM

The top-level directory for determining the RPM buck is / USR / ZZZ / RPM.

4) Go to the description file directory, edit the script of the Lze-6.0-2.SPEC installation segment: $ CD / USR / ZZZ / RPM / SPECS $ VILZE-6.0-2.SPEC $

The top-level directory for determining the RPM buck is / USR / ZZZ / RPM.

The installation segment script is modified to: (the original make command is commented)

% Installecho "installation script (install) started" # makeinstallmkdir-p $ RPM_BUILD_ROOT / usr / binmkdir-p $ RPM_BUILD_ROOT / etcmkdir-p $ RPM_BUILD_ROOT / usr / doc / lze-6.0cplzelzeime.wblzeime.py $ RPM_BUILD_ROOT / usr / Bincpinputme.deffunkey.defwbzc.dat $ rpm_build_root / etccp / usr / doc / lze-6.0 / * $ rpm_build_root / usr / doc / lze-6.0

Note: In the script, use the buffet of the root of the root directory RPM_BUILD_ROOT, and then create several subdirectory (USR / BIN, ETC, USR / DOC / LZE-6.0) in the buck, and then copy programs or files. To the corresponding subdirectory, it is completed.

5) Select the -buildroot option, execute rpm buck command: $ CD / USR / ZZZ / RPM / SPECS $ rpm-bb - Buildroot / USR / ZZZ / TMPLZE-6.0-2.Specexecuting:% Prep Umask022 CD / USR / ZZZ / RPM / Build Echo 'Pre-Processing Script Program (PREP) Start Perform the' Pre-Processing Script Program (PREP) Start Perform CD / USR / ZZZ / RPM / Build RM-RFLZE-6.0 / bin / Gzip-DC / USR / ZZZ / RPM / SOURCES / LZE-6.0-2.SRC.TGZ TAR-XVVF-DRWXR-XR-XROOT / ROOT02001-11-0217: 04LZE-6.0 / -RW ------ -root / root2462262001-11-0216: 00Lze-6.0 / lze.c-rw ------- root / root982492001-11-0216: 00Lze-6.0 / lzeime.wb.c-rw ------ -root / root3399022001-11-0216: 00Lze-6.0 / lzeime.py.c-rw-r - r - root / root12832001-11-0216: 00Lze-6.0 / funkey.def-rwxr - r - root / ROOT2502001-11-0216:00Lze-6.0/INputme.def-rw-r--r--root/root8132742001-11-0216:00Lze-6.0/wbzc.dat-rw -------Root/Root4742001 -11-0216: 02Lze-6.0 / makefile-rw-r - r - root / root12552001-11-0217: 04Lze-6.0 / getInputme.c status = 0 '[' 0-ne0 '] cdlze -6.0 / usr / bin / id-u '[' 500 = 0 ']' / usr / bin / id-u '[' 500 = 0 '] / bin / chmod-rfa rx, GW, OW. EXIT0EXECUTING:% Build UMASK022 CD / USR / ZZZ / RPM / Build CDLZE-6.0 Echo 'Compile Connection Script Program (Build) Start executing the' Compile Connection Script Program (Build) Start Download Makecc FWRITAB Le-strings-duse_as_lze-dfor_linux-si / usr / zzz / src / include-dfor_lze_inputme-olze / usr / zzz / src / libsrc / mycurses.clze.cgetinputMe.c / usr / zzz / src / my.acc-dfor_linux- Si / usr / zzz / src / include-ilzeime.wb.c / usr / zzz / src / my.alzeime.wb.c: infunction`do_service ': Lzeime.wb.c: 1409: Warning: PassingArg5of `bsearch'fromincompatiblepointertypecc-DFOR_LINUX-sI / usr / zzz / src / include-olzeime.pygetinputme.clzeime.py.c / usr / zzz / src / my.a exit0Executing:% install umask022 cd / usr / zzz / RPM / Build CDLZE-6.0 ECHO 'Installation Script Restall Started

Installation Script Program (INSTALL) starts to perform MKDIR-P / USR / ZZZ / TMP / USR / BIN MKDIR-P / USR / ZZZ / TMP / ETC MKDIR-P / USR / ZZZ / TMP / USR / DOC / LZE -6.0 cplzelzeime.wblzeime.py / usr / zzz / tmp / usr / bin cpinputme.deffunkey.defwbzc.dat / usr / zZZ / TMP / ETC CP / USR / DOC / LZE-6.0 / license / usr / doc /LZE-6.0/Readme/usr/zzz/tmp/usr/doc/lze-6.0 Exit0ProcessingFiles: LuzefindingProvides: (using/usr/lib/rpm/find-provides )...findingRequires: (usinger/usr/lib/ RPM / Find-Requires ... provides: Lze-editprequ: / bin / shrequires: /bin/shld-linux.so.2libc.so.6libc.so.s 6 (glibc_2.0) libc.so.6 (Glibc_2 .1) Wrote: /usr/zzz/rpm/rpms/i386/lze-6.0-2.i386.rpmexecuting:% Clean Umask022 CD / USR / ZZZ / RPM / Build CDLZE-6.0 ECHO 'built package end After the cleaning script (Clean) starts executing the 'After the end of the package, the script will start execution exit0 $ Note: After the RPM built package is successful, generated /usr/zz/rpm/rpms/i386/lze-6.0- 2.i386.rpm package file, through the query command of RPM, we can know that the package is unless the package built by superuser: $ rpm-qPLV / USR / ZZZ / RPM / RPMS / I386 / LZE-6.0-2 r 609: 24 / etc / funkey.def-rwxr-xr-xrootroot25011 month 609: 24 / etc / infutme.def-rw-r - r - rootroot81327411 Month 609: 24 / ETC / WBZC.DAT-RWXR-XR-XROOTROOT40863217 Upper 609: 24 / usr / b IN / LZE-RWXR-XR-XROOTROOT8292016 2009: 24 / usr / bin / lzeime.py-rwxr-xr-xrootroot38568116, 2009: 24 / usr / bin / lzeime.wb-rw-r - r - rootroot12151 609: 24 / USR / DOC / LZE-6.0 / License-RW-R - R - ROOTROOT369011909: 24 / USR / DOC / LZE-6.0 / ReadMe $ Now we can say that ordinary users can also establish freely Various forms of RPM packages!

4. Target: Set the Target Platform This option is: - TARGET System - Platform - Operating System Note: The default system created by RPM is i386, the platform is PC, the operating system is Linux. If users want to change, they need to use this option to determine, as in the following examples: # rpm-bb - targeti686-pc-solaris - quietlze-6.0-2.spec creation target platform: i686-PC-Solaris is creating a goal : I686-PC-Solaris #

This example sets the target platform for the generated RPM package to: i686-PC-Solaris (ie, the system is I686, the platform is PC, the operating system is Solaris). Note: You must create a subdirectory of one I686 in the / usr / src / dist / rpms directory, no subdirectory of the system, RPM will not generate a package. We can query the generated package to see what the system and operating system is:

# rpm-qp - qf "Archis% {Arch} nosis% {OS} n" /usr/src/dist/rpms/i686/lze-6.0-2.i686.rpmarchisi686osissolaris# can be seen from the output, its system And the operating system is exactly what we set.

5 .-- quiet: Try to minimize the purpose of this option to reduce the output of the RPM. After using this option, if there is no error, RPM does not output excess information, and the RPM is also comparable to "Quiet). $ rpm-bl - quietlze-6.0-2.spec $

6 .-- Clean: Executive Document Cleaning If the package description file is cleaned (% Clean) does not delete the temporary file command, then the temporary files still exist after the RPM build package, accounting for a certain space. If you want RPM to automatically delete those temporary files, you can use the --clean option when built. This option performs a command, namely: RM-RF software name - version number

Use it to delete the Software Name - Version Number directory and all files in this directory. This "Software Name" directory, that is, the directory of the RPM default storage and decompression source program. # rpm-bl - Cleanlze-6.0-2.specprocessingfiles: LzefindingProvides: (useing / usr / lib / rpm / find-provides) ... FindingRequires: (useing / usr / lib / rpm / find-required) ... Provides: lze-editprereq: / bin / shrequires: /bin/shld-linux.so.2libc.so.6libc.SO.6 (Glibc_2.0) libc.so.6 (glibc_2.1) Executing: - Clean Umask022 CD / USR / SRC / DIST / BUILD RM-RFLZE-6.0 EXIT0

Note: "Executing: - Clean" in Example Indicates that RPM starts to perform its own file cleaning operation.

7 .-- RMSource: Delete the source program and description file

This option is used to indicate that the RPM deletes a software source program and a package description file after the package, and the software source program is defined by the Source Domain in the Pack Description File. This option can also be used alone, such as: # rpm - rmsourceElze-6.0-2.spec # lslze-6.0-2.spec ../ Sourcees / Lze-6.0-2.src.tgzls: LZE-6.0-2.SPEC : The file or directory does not exist ls: ../ Sources / Lze-6.0-2.src.tgz: file or directory does not exist #

8 .-- Sign: Package Built-in Digital Signature This option is used to add a PGP digital signature in the package. By digital signature, the user can check if the package is original, whether it is modified. To use a PGP digital signature, you must install the PGP application and generate your own key pair. (For the content of digital signatures, see << Excellent RPM Eight - Signature Articles >>

When using this option to build a package, RPM will require a password to verify the correct series of operations that start the package, which generates a digital signature before the package is built. Please see the case: (omit a lot of output, ...) # rpm-bb - sIGNLZE-6.0-2.Specenterpassphrase: mypasspassphraseisgood.executing:% preip ... Executing:% build. ..... executing:% install ... processingfiles: Lze ... Requires: /bin/shld-linux.so.2libc.so.6generatingSignature: 1002GneneratingSignatureusingPgp.prettygoodprivacy (TM) Version6.5.8 . (c) 1999NetworkAssociatesInc.UsestheRSAREF (tm) Toolkit, whichiscopyrightRSADataSecurity, Inc.ExportofthissoftwaremayberestrictedbytheU.S.government Wrote: /root/test/RPMS/i386/lze-6.0-2.i386.rpmExecuting:% clean ...... # Note: The password is required in the example. Enter the MYPASS successfully, then the RPM starts to build a package operation. (In fact, myPass does not show it on the screen) The few lines under the GeneratingSignature in the case are what outputs when digital signatures.

Other package related orders

There are two commands related to other built packages, they are all operating for the source package for the RPM format, and then install the source package first, and then perform the next step according to the package description file. 1. Re-compiling commands: Usage: rpm - RecompilerPM source package 1RPM source package 2 ... such as: rpm - recompilelze-6.0-2.src.rpm

When this command is executed, the source package is first installed, and then perform the pre-processing segment (% preip), the Compile Segment (% Build), the installation section (% install) of the software package description file. This command is equivalent to the following two commands:

1) RPM-ILZE-6.0-2.SRC.RPM2) RPM-BILZE-6.0-2.SPEC

2. Reconstruction: Usage: rpm - RebuildRPM source package 1RPM source package 2 ... such as: rpm - rebuildlze-6.0-2.src.rpm

After the recoilation command is executed, the new RPM package is not established, and this reconstructed command will make a new RPM package. When the reconstruction command is executed, first install the RPM source package, then execute the pre-processing segment (% preip), the compile segment (% build), the installation section (% install), the installation segment (% clean) The script program generates a new RPM execution package, finally delete the source package, description file, and other temporary files. This command is equivalent to the following two commands: 1) RPM-ILZE-6.0-2.SRC.RPM2) RPM-BB - Clean - ResourceElze-6.0-2.SPEC

------------ ROM's alternative usage

RPM is not only in installation, upgrade, and unloading, but also better than other packages management tools in terms of query. This can be seen from the following situations:

* When you are browsing system files, discover a file, if you want to know which packages come from, you can use rpm to query you;

* When your friend sent you to a package, you don't know what packages are what packages, 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;

* You have installed Xfree86 window software a few months, but now you forget its version number, 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. Command format

Query the software package in the RPM format, you can use the following command format:

RPM -Q [Query Option 1 Query Options 2 ...]

Note: You can also use -Query instead of -Q, the effect is the same.

Option list

Options

Specifies the four options related to the FTP and HTTP in the option (- FTPPROXY, - FTPPORT, HTTPPROXY, - HTTPPORT), and the general options, please refer to << Excellent RPM 2 - Installation articles >> This article is not described later. The following explains the specified option:

The specified option can be divided into the following categories:

First, package selection class

This type of option can only select one at a time, and the RPM will prompt the error when selecting multiple times:

RPM: One Type of Query / Verify May Be Performed At A TIME

From a query, one is to query the installed packages, one is querying un installed packages.

1. Query the installed package and 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 many outputs, only a few, the remaining omitted (indicated by ...).

(2) -g (or --Group): Which packages have a package that belong to the specified category

RPM divides software into the following classes based on software functions: (notes in parentheses)

Amusements / Games (Entertainment / Games)

AMUSEMENTS / Graphics (Entertainment / Graph)

Applications / Archiving (Applications / Archives)

Applications / Communications (Applications / Communications)

Applications / Databasesses (Applications / Database)

Applications / Editors (Applications / Editor)

Applications / Emulators (Applications / Simulator)

Applications / Engineering (Applications / Project)

Applications / File (Application / File)

Applications / Internet (Applications)

Applications / MultiMedia (Applications / Multimedia)

Applications / Productivity (Applications / Products)

Applications / Publishing (Applications / Printing)

Applications / System (Application / System)

Applications / Text (Application / Text)

Developments / Debuggers (Development / Debugger)

Developments / Languages ​​(Development / Language)

Developments / libraries (Development / Library)

Development / System (Development / System)

Developments / Tools (Development / Tool)

Documentation

System Environment / Base (System Environment / Foundation)

System Environment / Daemons (System Environment / Guard)

System Environment / KERNEL (System Environment / Core)

System Environment / Libraries (System Environment / Library)

System Environment / Shells (System Environment / Interface)

User Interface / Desktops (User Interface / Desktop)

User Interface / X (User Interface / X Window) User Interface / X Hardware Support (User Interface / X Hardware Support)

Other (other)

Note: Category is sensitive, be careful when this is entered. If the user wants to query which game classes 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 the software package of several categories, you can list the category, query together, such as:

# rpm -q -g Applications / Editors Applications / 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 "Application / Editor" categories in this example, and then 8 is "App / File" category.

(3) -f (or --file): It is very useful to check which packages have a specified file. 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 -qf / usr / sbin / ftpd

inet6-apps-0.36-3

#

Now I know, it is in the 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 need to be specified

This option indicates which packages from all installed packages, which packages provide the user-specified features, and one or more functions can be entered on the command line.

# 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 from the system which packages need / bin / ps and libc.so.6 function, and output the top 10 lines through the pipeline output.

(5) --WHATPROVIDES: What packages are available for specified features

This option indicates which packages are available from all installed packages from all installed packages. 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 provikes / bin / ps

#

Note: This example is from the system which packages provide libc.so.6 and / bin / ps function, resulting in the GLIBC-2.1.2-12 package provides libc.so.6, without packages / bin / PS function.

(6) --Triggeredby: What packages have been specified by the package Trigger this option indicates that the RPM is triggered by the package 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, which will trigger the script program related to the file package. 2. Query un installed packages: (only one option is available)

(1) -p: Query the information of the specified parcel file

Use this option to specify one or more package file names, RPM can get information about the corresponding parcel. 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 FTP, showing its file list (-L options, 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, information display class

This class option can be selected simultaneously to display a variety of information.

1. -i: Show package information

Use this option when the user needs to know the header information of the package.

# rpm -qi file

Name: File Relocations: / usr

Version: 3.26 Vendor: Red Hat Software

Release: 6 Build Date: Tuesday, March 23, 1999 05:32 29 seconds

Install Date: October 14, 2001 21:25 in 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 type.

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 Install The File Package, Since The File Command Is Such A

Useful utility.

#

In the above output, there is a plurality of domains, and the meaning of each domain is:

Name: Software Name; Relocations: Relocation directory prefix (one or more);

Version: version number; vendor: developer;

Release: Release Number; Build Date: Package Establishment Time;

Install Date: Installation Time; Build Host: Package Establishing Host;

Group: Category; Source RPM: Source Code;

Size: Size; License: License;

Packager: packagepers;

Summary: Software Introduction;

Description: Detailed description.

2. -L (or --List): Display a list of package files

Use this option when the user wants to know which files contains the package. When outputting, a line is a file name to form a text

A list of pieces. The following example lists the files in the file:

# rpm -qlv file

-RWXR-XR-X root root23948 March 23 1999 / USR / BIN / FILE

-rwxr-xr-x root root12023 March 23 1999 /usr/man/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: The general option -V is selected when the column file is selected. The format listed in this format is listed in the format listed in the LS command, which can see the permissions of each file, the owner, group, size, final modification time and file name. And other information.

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 program and data) Document, 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

#

4. -c (or --configfiles): Display 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

#

5. -s (or --State): Display Package File status RPM All files can have the following four status:

* 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 installs the file package file, select -exCludedocs to indicate 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): Display the features required for the package

The so-called function can be a package identifier, which can be a file (such as shared library libc.so.6, etc.) 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 queries the features required by the LZE package.

7. --Provides: Display features provided by packages

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 a package provides, you want to use --Provides

Options.

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: The function provided by this package file is the libz.so.1 dynamic link library. 8. --Conflicts: Show the function of the package conflict

What is the 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 conflicting it:

# rpm -q --conflicts AT-3.1.7-8

crontabs <= 1.5

#

Note: This example shows that the AT package with a CRONTABS package with a version number of less than 1.5 has a conflict.

9. --Scripts: Display the built-in script built into package

Scripts is the script 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 script of the ZSH package:

# rpm -q --scripts ZSH-3.0.7-4 | NL

1 PostInstall script (THROUGH / BIN / SH):

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: THROUGH / BIN / SH:

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]; then

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 pipe technology to add a line number to the query, which is convenient for observation.

2-8 line: For the source code of the postInstall;

10-13: To uninstall the source code of the preunities (preuncture ";

Chapter 15-23: To uninstall the source code of PostunInstall.

All scripts in the example are performed by / bin / SH, this example does not have a pre-installed script (Preinstall) and

Verify the script program (Verify).

10. --Triggers: Display the built-in trigger script program built in the package

The trigger script is an extension of the Scripts class script, which is used for interaction control between packages. Trigger script

The program is triggered when the program is installed, and the trigger the script before uninstalling the script.

Three of this program (TriggerPostun).

The following example lists the trigger script in the ZSH package: # rpm -q --triggers zsh-3.0.7-4

TriggerPostun Script - ZSH <= 3.0.7-2

IF [! -f / etc / shells]; then

Echo "/ bin / zsh"> / etc / shells

Else

Echo "/ bin / zsh" >> / etc / shells

Fi

#

Note: The output of the first line indicates the category of the script (for uninstalling the scripter TriggerPostun), what program is used to interpret (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, what time is changed to the software. through

After 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 rain is also odd

- Increase multi-window operation

* March 24 1997 rain is also odd

- Add block operation command

#

Note: From this example, it can be seen that the writing of maintenance records has certain specifications: the row record maintenance time, maintenance people and its email starts in the start of the asterisk (*), and the opening of the minus (-) The specific content of the maintenance is recorded.

12. - DUMP: Display properties information of all files in the package

Use the -dump option if the user wants to view the properties information of a file in a package.

# 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

#

Now, according to the output of the example, explain the attribute information owned by each file in the RPM package: (in the first behavior)

/ usr / bin / file: for the file name;

23948: Refers to the size of the file (number of bytes);

922138347: Find the final modification time (second number of seconds);

ABAF6CFD51588AC7C484526FBDB84E5B: Refers to the MD5 inspection calculated according to the contents of the file;

0100755: Refers to file access rights;

ROOT: refers to the owner of the file;

Root: refers to the file group;

0: Profile flag, indicate the file non-configuration file for 0, indicating that the file is a configuration file;

0: Describe the document sign, indicating that the file is not explained by the document, indicating that the file is a document;

0: File type, 0 represents normal files, non-0 represents device files, contains the master from device number;

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

New Post(0)