我可以使用rpm扩展specfile中的宏吗?

use*_*403 19 rpm rpm-spec

具体的例子是我有很多specfiles Source0:或其他Source包含宏的行.如何在不实际启动specfile构建或编写自己的解析器的情况下扩展这些宏?

Sta*_*tan 31

从rpm 4.9开始,您可以使用:

rpmspec -P <spec_file>
Run Code Online (Sandbox Code Playgroud)

这将在stdout上打印出扩展的spec文件

  • 如果它只在当前的企业发行版(RHEL/CentOS)中可用,那将是非常棒的. (4认同)
  • 为了澄清@Guss的评论,`rpmspec`在RHEL/CentOS 7上可用,但在RHEL/CentOS 6或更早版本上没有. (2认同)

小智 12

如果它只需要解析您需要的源代码行,那么spectool就可以为您完成.它是Fedora的rpmdevtools的一部分.

$ spectool ./mg.spec 
Source0: http://homepage.boetes.org/software/mg/mg-20110120.tar.gz
$ 
Run Code Online (Sandbox Code Playgroud)

这是它的帮助屏幕

Usage: spectool [<options>] <specfile>
Options:
operating mode:
-l, --lf, --list-files        lists the expanded sources/patches (default)
-g, --gf, --get-files         gets the sources/patches that are listed with
                              a URL
-h, --help                    display this help screen

files on which to operate:
-A, --all                     all files, sources and patches (default)
-S, --sources                 all sources
-P, --patches                 all patches
-s, --source x[,y[,...]]      specified sources
-p, --patch a[,b[,...]]       specified patches

misc:
-d, --define 'macro value'    defines RPM macro 'macro' to be 'value'
-C, --directory dir           download into specified directory (default '.')
-R, --sourcedir               download into rpm's %{_sourcedir}
-n, --dryrun, --dry-run       don't download anything, just show what would be
                              done
-D, --debug                   output debug info, don't clean up when done
Run Code Online (Sandbox Code Playgroud)


m1t*_*tk4 -4

您可以使用 grep 获取源行,使用 sed 提取包含宏的字符串,然后使用 rpm --eval 'string' 对其进行评估。请注意,这只会扩展全局宏,而不是本规范中定义的宏。

要扩展它们,您可能需要 grep 查找它们并将它们作为自定义宏文件提供给 rpm。

  • 这是完全错误的:https://wiki.merproject.org/wiki/Packaging_guidelines/ParsingSpecFiles (2认同)