The concrete example being I have lots of specfiles with Source0
: or other Source
lines containing macros. How can I have these macros expanded without actually starting a build on the specfile or writing my own parser?
RPM provides a rich set of macros to make package maintenance simpler and consistent across packages. For example, it includes a list of default path definitions which are used by the build system macros, and definitions for RPM package build specific directories.
By using Buildroot: in your spec file you are indicating that your package can be built (installed into and packaged from) a user-definable directory. This helps package building by normal users. RPM will use the buildroot listed in the spec file as the default buildroot.
Since rpm 4.9 you can use:
rpmspec -P <spec_file>
This will print out expanded spec file on stdout
If its only the source lines you need parsed, spectool
will do that for you. It's part of Fedora's rpmdevtools.
$ spectool ./mg.spec
Source0: http://homepage.boetes.org/software/mg/mg-20110120.tar.gz
$
Here's its help screen
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With