The RPM system assumes five RPM directories
BUILD:rpmbuild编译软件的目录
RPMS:rpmbuild创建的binary RPM所存放的目录
SOURCES:存放源代码的目录
SPEC:存放spec文件的目录
SRPMS:rpmbuild创建的source RPM所存放的目录
rpm内建的宏在文件/usr/lib/rpm/redhat/macros文件中有定义,这些宏基本上定义了目录路径或体系结构等等,rpm也包含了一组用于调试有问题的spec文件的宏,如下:
%dump:打印宏的值
%{echo:message} :打印信息到标准错误
%{error:message} :打印信息到标准错误,然后返回BADSPEC
%{expand:expression} :like eval, expands expression
%{F:file_exp} :扩展file_exp到一个文件名
%global name value :定义一个全局宏
%{P:patch_exp} :扩展patch_exp到一个补丁文件名
%{S:source_exp} :扩展source_exp到一个源码文件名
%trace :跟踪调试信息
%{uncompress:filename}
Tests if file filename is compressed. If so, uncompresses and includes
in the given context. If not compressed, calls cat to include file in given context.
%undefine macro :取消给定的宏定义
%{warn:message} :打印信息到标准错误
宏
%define macro_name value
然后可以用%macro_name或者%{macro_name}来调用,也可以扩展到shell,如
%define today %(date)
也可以传递参数给宏
%define macro_name(option) value
%foo 1 2 3 传递1,2,3三个参数给宏foo
在宏扩展的宏参数
%0:宏的名字
%*:传递给宏的所有参数
%#:传递给宏的参数个数
%1:第一个参数
%2:第二个参数,等等
%{-p}:Holds -p
%{-p*}:Holds the value passed with the -p parameter, if the -p parameter was
-
-
passed to the macro;otherwise holds nothing
-
-
%{-p:text}:Holds text if the -p parameter was passed to the macr;otherwise holds
nothing
%{?macro_to_text:expression}:如果macro_to_text存在,expand expression,如
国不存在,则输出为空;也可以逆着用,:%{!?macro_to_text:expression}
%{?macro}:忽略表达式只测试该macro是否存在ÿ