How to pass user defined parameters to rpmbuild to fill variables
Asked Answered
H

3

38

is it possible to pass parameters to rpmbuild to fill user defined variables that are called inside the spec file?

Example: The user defined variable %{foobar} which is called in the .spec file (but empty) should be filled with the variable which is passed when executing the rpmbuild command

rpmbuild -bb --foobar="Foo" somespecfile.spec
Heyes answered 4/2, 2014 at 17:36 Comment(0)
U
56
rpmbuild -bb --define '_foobar Foo' somespecfile.spec

and refer it within the spec as %{_foobar}

(the _ is a convention, not a must)

Undertook answered 5/2, 2014 at 6:23 Comment(0)
B
5

The closest you can get AFAIK are conditional builds, which allow you to do things like

rpmbuild -ba newpackage.spec --with feature

see http://rpm.org/user_doc/conditional_builds.html .

Baalman answered 4/2, 2014 at 17:50 Comment(1)
thank you - this sounds like an option. I will try this.Heyes
D
1

could add this into the SPEC file:

%define _topdir %(echo $PWD)/
Diphase answered 2/8, 2021 at 1:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.