Re: passing a variable to a spec file from rpmbuild command line
"Jeff Johnson" <[email protected]>
| Newsgroups | gmane.linux.redhat.rpm.general |
|---|---|
| Message-ID | <[email protected]> |
On 11/11/07, [email protected] <[email protected] > wrote: > > Hi all, > > I have a question on passing a variable to a spec file. > > Say, for example, I have a feature, and i want to pass information to the > spec > file to either enable or disable that feature, so that the spec file can > then > pass to configure appropriayte option to enable/disable the cooresponding > feature. > > I've seen some references to "--with abc" or "--without abc" > > what exactly happens here ? is there a variable that I can reference > inside the > spec file to see if "abc" was mentioned with either "--with" or > "--without" ? > and how might I reference that variable? What happens is that a macro is conventionally defined. Here's what happens with "--with abc" This line in /usr/lib/rpm/rpmpopt-X.Y rpmb alias --with --define "_with_!#:+ --with-!#:+" causes a macro "_with_abc" to be defined with value "--with-abc". The option "--with abc" is exactly the same as typing --define '_with_abc --with-abc' I also have seen the syntax: > > %{?variable:1} > > I think this is testing "variable" and if the "variable" in question > doesn't > exist (hasn't been defined), then return a "1" for the test value. Is this > true > ? and what gets returned if the variable IS defined? the variables value ? Not quite. The construct expands to "1" if variable is defined, "" otherwise. If you wanted to use the defined value (if it exists) or a default value (if not), then that could be done with this (kinda clunky) construct. %{?variable}%{!?variable:1} The construct %{?variable} expands variable if defined, otherwise "" is the value. Since one is often using 1/0 as TRUE/FALSE with %if statements, then %if %{?variable:1}0 can be used. The expansion is either "10" or "0" depending on whether variable is defined (or not), and the %if is then either TRUE or FALSE. I've searched high and low all over the net as regards to the intracies of > user > defined variables, and the answers to the above questions have been > eluding me. > I'd be grateful for answers and/or pointers/urls to documentation. You can define any macro you please using --define 'name value' from the CLI. Macros are just a means to substitute strings recursively. Macros are distantly related to how gcc parses CLI arguments. Many ideas (but not code) were borrowed and reworked. hth 73 de Jeff _______________________________________________ Rpm-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/rpm-list