具体的例子是,我有很多包含Source0:或其他包含宏的Source行的规范文件。如果不在specfile上实际开始构建或编写自己的解析器,我如何才能扩展这些宏?
发布于 2010-09-12 10:11:54
您可以使用grep获取源代码行,使用sed提取包含宏的字符串,然后使用rpm --eval ' string‘对其求值。请注意,这将仅展开全局宏,而不是此规范中定义的宏。
要对它们进行扩展,您可能需要为它们执行grep,并将它们作为自定义宏文件提供给rpm。
发布于 2011-10-26 18:19:37
从rpm 4.9开始,您可以使用:
rpmspec -P <spec_file>这将在stdout上打印出展开的规范文件
发布于 2011-04-18 09:14:49
如果这只是你需要解析的源代码行,spectool将为你做这件事。它是Fedora的rpmdevtools的一部分。
$ spectool ./mg.spec
Source0: http://homepage.boetes.org/software/mg/mg-20110120.tar.gz
$ 这是它的帮助屏幕
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 donehttps://stackoverflow.com/questions/3634650
复制相似问题