首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以使用rpm来展开specfile中的宏吗?

我可以使用rpm来展开specfile中的宏吗?
EN

Stack Overflow用户
提问于 2010-09-03 17:56:48
回答 5查看 12.2K关注 0票数 19

具体的例子是,我有很多包含Source0:或其他包含宏的Source行的规范文件。如果不在specfile上实际开始构建或编写自己的解析器,我如何才能扩展这些宏?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2010-09-12 10:11:54

您可以使用grep获取源代码行,使用sed提取包含宏的字符串,然后使用rpm --eval ' string‘对其求值。请注意,这将仅展开全局宏,而不是此规范中定义的宏。

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

票数 -4
EN

Stack Overflow用户

发布于 2011-10-26 18:19:37

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

代码语言:javascript
复制
rpmspec -P <spec_file>

这将在stdout上打印出展开的规范文件

票数 35
EN

Stack Overflow用户

发布于 2011-04-18 09:14:49

如果这只是你需要解析的源代码行,spectool将为你做这件事。它是Fedora的rpmdevtools的一部分。

代码语言:javascript
复制
$ spectool ./mg.spec 
Source0: http://homepage.boetes.org/software/mg/mg-20110120.tar.gz
$ 

这是它的帮助屏幕

代码语言:javascript
复制
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
票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3634650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档