Excellent RPM - production articles (on)

xiaoxiao2021-03-06  50

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

81 - Built-in pinyin, five input method 82 * fri may 01 1998 rain is also odd

83 - Increase multi-window operation

84 * MON Mar 24 1997 rain is also odd

85 - Increase the block operation command

86

This description includes the following aspects: First, see 1-4 of the annotation line. 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 head 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). 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 release called "Panda '95", then each package (such as bamboo leaves 95) should have such a line: Distribution: Panda' 951.3 icon: This domain specified package Icon file name. 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.xpm1.4 packager: This domain defines the package, which is to establish this package or company. 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 that the software package serial number is 4: Serial: 4 or: EPOCH: 41.6 URL: This domain definition contains web pages related to the package software. Such as: URL: http://devplanet.fasternet.net/gxedit.html2. Dependency reliance is RPM 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 include: 2.1 provides: This domain defines the functionality provided by the package, repeat multiple rows. Its description format is:

Provides: Function 1 [, Features 2] ... Note: [] Included, multiple functions are separated between comma 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]]]] ... in which: * [] is included in option; * Comparison can use <(less than),> (greater than), = (equal),> = (greater than or equal) or <= Less than or equal to); * The serial number is not selected, the RPM defaults to 0; * The comma between functions can be selected, or the space is 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 field, for:

Conflicts: 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]] ] ... in which: * [] is included in option; * Comparison can use <(less than),> (greater than), = (equal),> = (greater than or equal) or <= (less than or equal); * When the serial number is not selected, the RPM defaults to 0; * The comma between the functions is optional, 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 needed for the package, which will be added to the functionality required by the package in the form of a false package (Requires). 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: This example Although the first line allows Find-Requires, the second line does not allow Find-Requires to run two programs with FIND-Provides, while the third line allows Find-Provides to run, So according to the order of execution, the result is not allowed to perform Find-Provides, and Find-Provides is permitted. Another example: Autoreq: NoAutoreqProv: YESAUTOPROV: NO NOT: The result of this example is to allow Find-Projects to be executed 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 domain descriptions 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: [] Included, each system is separated between 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 Run the built package command rpm -bb (<< Excellent RPM 7 - Production articles (below) >> will say):

# rpm -bb lze-6.0-2.speCarchitecture is Excluded: i386 # It is seen that the RPM prompts the "system not applicable: i386" error. 3.2 ExclusiveArch: This domain defines the system for software packages. Its description format Similar to ExcludDear:

Exclusivearch: System 1 [System 2] ... Note: [] Included, each system is separated between 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 an Executing:% Build Compile Script Program (Build) Start Perform Executing:% Install Installation Script Program (Install)

Processing Files: Lzefinding Provides: (using /usr/lib/rpm/find-provides)...finding requires: (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# See, 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. Its description format is:

Excludeos: Operating System 1 [Operating System 2] ... Note: [] is optional, the operating system is separated between space. 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 available. 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 Solaris4. Directory Related 4.1 Prefix: This domain defines a repositionable directory prefix that can be written multiple times in the description file. Its description format is:

Prefix: Directory Prefix 1 [Directory Prefix 2] ... Note: [] is optional, and each catalog prefix is ​​spaced apart. For example: prefix: / usr / etc This can also be written: prefix: / usrprefix: / etc RPM utilizes relocationable directory prefix, implements the software package relocation installation, so that files in the software do not have to be fixed in a certain absolute position This practice 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. The description format of this domain is simple: buildroot: Directory, such as: Buildroot: / TMP5. Source code is designed for production source package. 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. The description format of this domain is:

Source [Number]: Source File Note: [] It is enclosed for options. 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 description format of this domain is:

PATCH [Number]: Source Patch Note: [] It is enclosed for options. 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. The required function segment description file, the required function segments are: 1.% Description This paragraph is the description segment, the content of the segment is a more detailed introduction to the package, not like the Summary domain of the file header only one sentence. Description. 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 describes the format:% Description [sub-package option] where the sub-package option is: [- n] sub-package name: [] is included. 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 section segment name description format is:

% Files [sub-package option] [-f file name] Note: [] It is enclosed in the option. 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 the LZE Description Files 72,73); *% config: This modifier setting file type is Profile (see LZE Description Files): *% 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 the document prefix, so that all files containing the specified file name as a prefix, the RPM is packaged to the description documentation. For example, there is such a 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 for the document, because /root/mydoc.txt is in% DOCDIR's next row, so the type of this file is set when the RPM is packaged. For the documentation. 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 this 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 usage format is:

% defattr (authority, owner, genus) where: permissions, primary and genus can use minus (-). 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. (The description format of only one echo command in a plurality of scripts in the LZE description file) is:

Functional Segment Name [Sub-Pack 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 usage format is:

% setup [-n name] [-c] [-d] [-t] [-b n] [-a n] Note: [] It is enclosed for options. (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: (The command is the line number)

1 CD / USR / SRC / DIST / BUILD2 ECHO "Prerequisites" 3 CD / USR / SRC / DIST / BUILD4 RM-RF LZE-6.05 / BIN / DIST " / Sources/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 such directory, the program will have an error exit. 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 patches in the LZE package description file: patch0: lze-patch.zeropatch1: Lze-patch.onepatch2: lze-patch.three (1) When there is no option: no When any 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.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. The format of its segment is:% pre [sub-package option] 2.2% post: This segment is the installed script. 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 is the 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. The format of its segment is:% preun [sub-package option] 2.4% postun: This segment is the 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. Its segment name format 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" FI3. Triggerin,% Triggerun,% TriggerPostun,% TriggerPostun, Their content is a script program for RPM interacting between packages. These scripts are triggered under the specified condition: 1)% Triggerin: Trigger the script for installation, when the package is only installed when the package is installed, the software package is installed, the other party is installed. This program will be triggered; 2)% triggerun: Trigger the script when the package is uninstalled, 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 triggered after the software package is unloaded. 3.1 Segment name format They are described in the format:

Interactive Segment Name [Sub-Pack Option] [-P Interpreter] - Trigger Condition 1 [, Trigger Condition 2] ... Note: [] It is enclosed in option. 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 ,Such as:

% triggerin - sendmailn -sf / usr / bin / sendmail / etc / mymailer / mailer% triggerin - vMailn -sf / usr / bin / vmail / etc / mymailar / mailer Note: When defining package sub-package installation Trigger Script Program: When the trigger condition (FileUtils> 3.0, Perl <1.2) is satisfied, use the / usr / bin / perl to execute the script, that is, use 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 Version number] where: comparator 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 can write this:

% triggerin - sendmailn -sf / usr / bin / sendmail / etc / mymailer / mailer% triggerin - vmailn -sf / usr / bin / vmail / etc / mymailer / mailer This is triggered by Sendmail or vmail when two installations Script program. 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 script triggered by the latter events can be written like this:

% Triggerun - Sendmail [$ 2 = 0] || EXIT 0IF [-f / usr / bin / vmail] kiln -sf / usmailr / mailerm -f / etc / mymailer / mailerfi% Triggerun - - vmail [$ 2 = 0] || exit 0if [-f / usr / bin / sendmail] kiln -sf / usr / bin / sendmail / etc / mymailer / mailerm -f / etc / mymailer / mailerfi these two script In the following cases, the trigger execution: 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) Uninstall the sendmail package in the case where the MyMailer package is installed ; 4) Uninstall the VMAIL package when the MyMailer package is 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 for uninstalling in the% postUn segment, and 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)

Taken from Caidi

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

New Post(0)