I'm trying to make a spec file that uses the devtoolset in RHEL 5/6 ( rhn.redhat.com/errata/RHEA-2013-0175.html ) but I haven't been able to figure out how to enable devtoolset in the spec file. If I run 'scl enable devtoolset-1.1 bash' before doing rpmbuild it works, but how do I run a command like that in the spec file?
The closest thing I could find is this: http://www.rpm.org/wiki/PackagerDocs/Macros
But when I tried using a macro or running just %(shell_command) it appears that's happening in a subshell and not having the necessary effect when returning to the main shell. Is there some trick to run a shell command in the main shell?
Thanks, Dave
Le 28/08/2013 18:09, Dave Johansen a écrit :
I'm trying to make a spec file that uses the devtoolset in RHEL 5/6 ( rhn.redhat.com/errata/RHEA-2013-0175.html ) but I haven't been able to figure out how to enable devtoolset in the spec file. If I run 'scl enable devtoolset-1.1 bash' before doing rpmbuild it works, but how do I run a command like that in the spec file?
In %build:
. /opt/rh/<devtoolset-or-sclname>/enable
Remi.
On Wed, Aug 28, 2013 at 9:13 AM, Remi Collet Fedora@famillecollet.com wrote:
Le 28/08/2013 18:09, Dave Johansen a écrit :
I'm trying to make a spec file that uses the devtoolset in RHEL 5/6 ( rhn.redhat.com/errata/RHEA-2013-0175.html ) but I haven't been able to figure out how to enable devtoolset in the spec file. If I run 'scl enable devtoolset-1.1 bash' before doing rpmbuild it works, but how do I run a command like that in the spec file?
In %build:
. /opt/rh/<devtoolset-or-sclname>/enable
The enable script wasn't executable, but sourcing it worked like a charm.
Thanks, Dave
Quoting Dave Johansen (2013-08-28 21:58:38)
On Wed, Aug 28, 2013 at 9:13 AM, Remi Collet Fedora@famillecollet.com wrote:
Le 28/08/2013 18:09, Dave Johansen a écrit :
I'm trying to make a spec file that uses the devtoolset in RHEL 5/6 ( rhn.redhat.com/errata/RHEA-2013-0175.html ) but I haven't been able to figure out how to enable devtoolset in the spec file. If I run 'scl enable devtoolset-1.1 bash' before doing rpmbuild it works, but how do I run a command like that in the spec file?
In %build:
. /opt/rh/<devtoolset-or-sclname>/enable
The enable script wasn't executable, but sourcing it worked like a charm.
Technically, yes...the above works but doesn't ensure it will keep working. I believe normally this convoluted way is proper way to execute some commands in an SCL within spec file:
%{?scl:scl enable %{scl} "} # this is a shell command 1 command 2 ... %{?scl:"}
This way you can use the same spec file as SCL and out of SCL.
Dne 29.8.2013 10:19, Stanislav Ochotnicky napsal(a):
Quoting Dave Johansen (2013-08-28 21:58:38)
On Wed, Aug 28, 2013 at 9:13 AM, Remi Collet Fedora@famillecollet.com wrote:
Le 28/08/2013 18:09, Dave Johansen a écrit :
I'm trying to make a spec file that uses the devtoolset in RHEL 5/6 ( rhn.redhat.com/errata/RHEA-2013-0175.html ) but I haven't been able to figure out how to enable devtoolset in the spec file. If I run 'scl enable devtoolset-1.1 bash' before doing rpmbuild it works, but how do I run a command like that in the spec file?
In %build:
. /opt/rh/<devtoolset-or-sclname>/enable
The enable script wasn't executable, but sourcing it worked like a charm.
Technically, yes...the above works but doesn't ensure it will keep working. I believe normally this convoluted way is proper way to execute some commands in an SCL within spec file:
%{?scl:scl enable %{scl} "} # this is a shell command 1 command 2 ... %{?scl:"}
This way you can use the same spec file as SCL and out of SCL.
Or using heredoc sytax:
%{?scl:scl enable %scl - << \EOF} # this is a shell command 1 command 2 ... %{?scl:EOF}
Vít
On 08/29/2013 10:19 AM, Stanislav Ochotnicky wrote:
%{?scl:scl enable %{scl} "} # this is a shell command 1 command 2 ... %{?scl:"}
Just one command with this syntax. If you need more command, you have to use heredoc as Vít said in this thread.
On Thu, Aug 29, 2013 at 2:17 AM, Miroslav Suchý msuchy@redhat.com wrote:
On 08/29/2013 10:19 AM, Stanislav Ochotnicky wrote:
%{?scl:scl enable %{scl} "} # this is a shell command 1 command 2 ... %{?scl:"}
Just one command with this syntax. If you need more command, you have to use heredoc as Vít said in this thread.
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?
Thanks, Dave
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.
On Thu, Aug 29, 2013 at 4:09 AM, Miroslav Suchý msuchy@redhat.com wrote:
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.
Based on my understanding of what you said, this is my best guess at what the lines in the .spec should be:
%{?scl:scl enable devtoolset-1.1 "} %configure --disable-static %{?scl:"}
But that doesn't work, so I'm obviously doing something wrong.
If I just do these two lines, then it works: source /opt/rh/devtoolset-1.1/enable %configure --disable-static
But my understanding was that there was something wrong with doing that, so what is the proper way to enable the devtoolset-1.1 scl for use with the configure macro?
Thanks, Dave
On 08/30/2013 05:56 AM, Dave Johansen wrote:
But that doesn't work
You mean that it is not executed at all? Then you probably do not have defined macro scl. Which is probably because you do not have installed meta-package (devtoolset-1.1-build) in you buildroot. Note that if you are using buildroot, it will not help you to use BuildRequires as it need to be installed before src.rpm is evaluated. So you must modify mock config: https://fedoraproject.org/wiki/User:Bkabrda/SCLGuidelinesDraft#Building_Pack...
On Fri, Aug 30, 2013 at 12:46 AM, Miroslav Suchý msuchy@redhat.com wrote:
On 08/30/2013 05:56 AM, Dave Johansen wrote:
But that doesn't work
You mean that it is not executed at all? Then you probably do not have defined macro scl. Which is probably because you do not have installed meta-package (devtoolset-1.1-build) in you buildroot. Note that if you are using buildroot, it will not help you to use BuildRequires as it need to be installed before src.rpm is evaluated. So you must modify mock config:
https://fedoraproject.org/wiki/User:Bkabrda/SCLGuidelinesDraft#Building_Pack...
That seems a bit different than what I'm going for. These packages won't build without the devtoolset SCL, so I can't support the package without that SCL. So is using that macro really the right thing to do?
Dne 29.8.2013 11:17, Miroslav Suchý napsal(a):
On 08/29/2013 10:19 AM, Stanislav Ochotnicky wrote:
%{?scl:scl enable %{scl} "} # this is a shell command 1 command 2 ... %{?scl:"}
Just one command with this syntax. If you need more command, you have to use heredoc as Vít said in this thread.
Actually the syntax is correct. However, one advantage of heredoc is that you can use quotes freely, e.g. this does *not* work (unless you escape the double quotes):
%{?scl:scl enable %{scl} "} # this is a shell command "1" command "2" ... %{?scl:"}
while this is perfectly OK:
%{?scl:scl enable %scl - << \EOF} # this is a shell command "1" command "2" ... %{?scl:EOF}
In other words, heredoc makes the conversion from regular .spec to SCL .spec a bit easier in some cases.
Vít
On 2013-08-28 18:09, Dave Johansen wrote:
I'm trying to make a spec file that uses the devtoolset in RHEL 5/6 ( rhn.redhat.com/errata/RHEA-2013-0175.html ) but I haven't been able to figure out how to enable devtoolset in the spec file. If I run 'scl enable devtoolset-1.1 bash' before doing rpmbuild it works, but how do I run a command like that in the spec file?
The closest thing I could find is this: http://www.rpm.org/wiki/PackagerDocs/Macros
But when I tried using a macro or running just %(shell_command) it appears that's happening in a subshell and not having the necessary effect when returning to the main shell. Is there some trick to run a shell command in the main shell?
Thanks, Dave
Do you need it enabled while parsing the spec? Then I have no idea. Otherwise, can't you just run the command in e. g., %build like:
%build
scl enable devtoolset-1.1 bash more commands
--alec
devel@lists.stg.fedoraproject.org