Production articles (medium)
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 subcap with 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 Subscriber Options 2. Summary This domain must be under% Package, which defines a sub-package function (a sentence description). The format is:
Summary: Introduction to Sub Pack 3. Group This domain must be under% Package, its definition sub-package belongs (software category, see << Excellent RPM five - query articles >>). The format is:
Group: Software Category 4.% Description: This description segment is a more detailed sub-package function, which is introduced as text form, format does not require requirements, can be used anywhere or segmentation. The format is:
% Description sub-package option ... Introduce the content of the sub-package function ... 5.% files: This file segment is the 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 7 - 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 segment must match the sub-package options used by% package, otherwise, they are not the same sub-package, RPM is quit when the RPM is checked. 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. The use of conditional statements In the package description file, you can flexibly use the conditional statement, 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 them, [] is included, each The value is separated by space, and% 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 the following statement within the file segment:
% iFARCH SPARC / ETC / SPARC.LZE / etc / sparc.ime% ENDIF is made in this way, 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 them, [] Thereby, each value is separated between space,% else represents another case,% ENDIF indicates the end of the conditional 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 define the Name domain using the following statement in the description file header:
% iFOS LinuxName: Lzeforlinux% ELSE% IFOS AIXNAME: LZEFORAIX% ELSENAME: LZEFOROTHERSYS% ELSENAME: LZEFOROTHERSYS% ELSENAME: LZEFOROORTHERSYS% ENDIF% ENDIF This example uses nested conditional statements, which is description: If 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, and if it is not the above two operating systems, the software name is set to Lzefor Porthersysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysys. How to use macro (macros) in the description file? What is the macro? People who have learned C language know that macro is used to implement text alternative, that is, after the macro name and macro, all macro names in the file The place will be replaced by the macro body during pre-treatment. 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 of macros is:
%
[OPT1] [OPT2] ... [arg1] [arg2] ...
or
% {
} [OPT1] [OPT2] ... [arg1] [arg2] ...
Note: [] All there is an option;
For the macro name applied, the macro name can be enclosed in {}; OPT1, OPT2 ... for the option, must start with minus (-), and if the option requires parameters, you must provide an option parameter; Arg1, Arg2 ... is a macro parameter.
As the XXX macro defined above, you can use this:
% xxx -p zhsoft hello world
In the example, the XXX macro uses an option -p, the parameters of the zhsoft as the -p option, and 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-specific macro
The following special macros can be used in the macro body: (similar to the form of 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}: Indicates that if the macro uses the -f option, it represents -f and its option parameters; 5)% {- f *}: Indicates that if the macro uses the -f option, it represents -f Parameters belled;
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, ...: indicates the parameters 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 is expanded to XXX;
2)% * extension is Hello World;
3)% # expand to 2;
4)% {- p} is extended to -p zhsoft;
5)% {- p *} is extended to zHSOFT;
6)% {- p: good} extension is good;
7)% {! - z: BAD} is extended to Bad; (because XXX Macro is not using the -z option)
8)% 1 is 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 Definition
1)% Define ...: Define a macro; (originally,% define is also a macro)
2)% undefine ...: Cancel a macro; (After macro dedupons, the description file below this statement can no longer use this macro, even if it is used, the macro will not be expanded)
5.2 debugging class
1)% trace: Debugging information before and after printing macro;
2)% DUMP: Macro (macro name and macro) of the printed activity;
3)% {echo: ...}: Print ... to standard error devices;
4)% {warn: ...}: Print ... to standard error devices;
5)% {Error: ...}: Print ... to standard error devices, and return the BadSpec value;
5.3 Special Class
The default value of such macros is usually placed in the / usr / lib / rpm / macros file, and the user can redefine such macro by editing the .rpmmacros file (~ / .rpmmacros) under the home owner (~ / .rpmmacros). Defaults for rpm to use their own definitions when making, installation, and queries.
The definition format of this type of macro is:
%
Note:
For a 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: the directory used when compiling the connection source program, is defined by% _builddir macro, often used build; generated RPM execute package storage, by% _rpmdir macro, common RPMS; software source Directory stored by the program, is defined by the% _SourCedir macro, commonly used, the directory stored by the package description file, is defined by the% _Specdir macro, commonly used SPECS; the generated RPM source package is 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} $
The i386 in the command is the RPM default system name, and the execution package generated by the RPM is stored below the "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, when the RPM is installed, the default method of the document is not installed;% _ftpport: This macro is used to define the RPM default FTP port;% _ftpproxy: This macro is used to define rpm The default FTP proxy server;% _ httpport: This macro is used to define the RPM default HTTP port;% _httpproxy: This macro is used to define the RPM default HTTP proxy server;% _NetSharePath: This macro is used to define the RPM default network sharing directory, Suitable for network file systems (NFS). 6. A special macro
This macro is usage:
% (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 template
All of the following describes that file templates are made as an example, and the files generated after the source program are compiled by the quasi-generating 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 files see << 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.SPEC1
2 # file function: LZE package description information
3 # file Author: vertical and horizontal software production center rain also odd National Defense University Graduate Rosso Zhao Jianli # 4 Modified: 2001.10.31
5
6 Name: Lze
7 Version: 6.0
8 Release: 2
9 Summary: Small Zhao Quanshou in English Multi-Function Editor (Linux / UNIX System)
10 Group: Applications / Editors
11 license: Share
12 Source: http://zhsoft.myetang.com/lze-6.0-2.src.tgz
13
14% Description
15 Little Zhao editor, is a full-screen multi-window for the majority of users of SCO UNIX, Linux multi-user systems
16-port Chinese and English multi-function 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
The 18-word system 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 Wing. 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!
twenty three
24% preput
25 Echo "Preprocessing Script Program (PREP) Start"
26% setup
27
28% build
29 Echo "Compilation Connection Script Program (Build) Started"
30 Make
31
32% INSTALL
33 Echo "Installing Script Program (Install) Started"
34 make install
35
36 # profile package
37% package config
38 Summary: Little Zhao Editor LZE configuration file
39 Group: Applications / Editors
40
41% Description Config
42 Small Zhao editors use configuration files including function keys definition files
43 Input method control file, the user can modify according to the actual situation.
44
45% Files Config
46% config /etc/funkey.def
47% config /etc/inputme.def
48
49 # Description document package
50% package doc
51 Summary: Little Zhao Editor LZE's Description Document
52 Group: Applications / Editors
53
54% Description Doc
55 Xiao Zhao Editor Description Document, detail the editor
56 Command usage method and built-in menu function and operation,
57 familiar familiar Xiao Zhao editors have a big role.
58
59% Files DOC
60% doc /usr/doc/lze-6.0/readme
61% doc /usr/doc/lze-6.0/license
62
63 # Parent package file segment
64% Files
65% defattr (- ROOT, ROOT)
66 / usr / bin / lze
67 /usr/bin/lzeime.py
68 /usr/bin/lzeime.wb
69 /etc/wbzc.dat
70
This description file generates package is: Lze-6.0-2.i386.rpm (parent package), Lze-config-6.0-2.i386.rpm (configuration file sub-package) and Lze-DOC-6.0-2.i386. RPM (document sub-package).
3. There is no parent package, only subcaps:
Without a parent package, it means that there is no file segment (% files) in the description file, please see the description file below:
1 # File Name: Lze-6.0-2.SPEC2
2 # file function: LZE package description information
3 # file Author: vertical and horizontal software production center rain also odd National Defense University Graduate Rosso Zhao Jianli # 4 Modified: 2001.10.31
5
6 Name: Lze
7 Version: 6.0
8 Release: 2
9 Summary: Small Zhao Quanshou in English Multi-Function Editor (Linux / UNIX System)
10 Group: Applications / Editors
11 license: Share
12 Source: http://zhsoft.myetang.com/lze-6.0-2.src.tgz
13
14% Description
15 Little Zhao editor, is a full-screen multi-window for the majority of users of SCO UNIX, Linux multi-user systems
16-port Chinese and English multi-function 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
The 18-word system 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 Wing. 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!
twenty three
24% preput
25 Echo "Preprocessing Script Program (PREP) Start"
26% setup
27
28% build
29 Echo "Compilation Connection Script Program (Build) Started"
30 Make
31
32% INSTALL
33 Echo "Installing Script Program (Install) Started"
34 make install
35
36 # profile package
37% package config
38 Summary: Little Zhao Editor LZE configuration file
39 Group: Applications / Editors
40
41% Description Config
42 Small Zhao editors use configuration files including function keys definition files
43 Input method control file, the user can modify according to the actual situation.
44
45% Files Config
46% config /etc/funkey.def
47% config /etc/inputme.def
48
49 # Description document package
50% package doc
51 Summary: Little Zhao Editor LZE's Description Document
52 Group: Applications / Editors
53
54% Description Doc
55 Xiao Zhao Editor Description Document, detail the editor
56 Command usage method and built-in menu function and operation,
57 familiar familiar Xiao Zhao editors have a big role.
58
59% Files DOC
60% doc /usr/doc/lze-6.0/readme
61% doc /usr/doc/lze-6.0/license
62
63 # Execute the program package
64% package bin
65 Summary: Little Zhao Editor LZE executive
66 Group: Applications / Editors
67
68% Description Bin
69 Little Zhao Editor Execute Program for Lze, Five Input Method Server Executers
70 is Lzeime.wb, the Pinyin input method server execution program is Lzeime.py.
71
72% Files Bin
73% defattr (- ROOT, ROOT)
74 / USR / BIN / LZE
75 /usr/bin/lzeime.py
76 /usr/bin/lzeime.wb
77 /etc/wbzc.dat
78