Running a command in spec file?

Miroslav Suchý msuchy at redhat.com
Thu Aug 29 11:09:47 UTC 2013


On 08/29/2013 12:04 PM, Dave Johansen wrote:
> So does that mean that this is the correct statement to put in the .spec file?
>
> %{?scl:scl enable %{scl} "}
> source /opt/rh/devtoolset-1.1/enable
> %{?scl:"}
>
> What is the %{?scl} macro doing? And am I using it correctly in the above?

This scriplet:

%{?scl:scl enable %{scl} "}
command 1
%{?scl:"}

basicaly expand to:

%if 0%{?scl}
   scl enable "command 1"
%endif

Therefore your scriplet:

%{?scl:scl enable %{scl} "}
source /opt/rh/devtoolset-1.1/enable
%{?scl:"}

would expand to:

%if 0%{?scl}
   scl enable "source /opt/rh/devtoolset-1.1/enable"
%endif

which does not have sense.
I see that you want to enable SCL and from that moment you want to have collection enabled.
This is not recommended (and therefore there is no such tool to do that).
You must enable collection for each specific command. Or block of commands by heredoc syntax.

For operating on command line, you can do:
   scl enable devtoolset-1.1 bash
which will open you shell where collection is enabled until you exit. But for spec file, please enable collection for 
each command/block.

-- 
Miroslav Suchy, RHCE, RHCDS
Red Hat, Software Engineer, #brno, #devexp, #fedora-buildsys


More information about the devel mailing list