[opensuse-kde] kde-obs-generator: how to install files conditionally on the KDE version
I'm using the KDE OpenSUSE build service to build my KDE application. There are some files which need to be installed for systems which provide KDE 4.2, but not for KDE 4.3 or later. I've tried a couple of methods in the .spec file to specify this, but the build failed each time. How can I specify this condition? One example of what I've tried is: %install %kde4_makeinstall -C build for lang in kalarm; do %find_lang $lang %{name}.lang done if test %{kde4_minor_version} -le 2 ; then echo %dir %{_kde4_appsdir}/kalarm/holidays >>%{name}.lang echo %{_kde4_appsdir}/kalarm/holidays/holiday_* >>%{name}.lang fi ... This just produces some syntax error which unfortunately doesn't give enough of a hint as to why it's going wrong: /var/tmp/rpm-tmp.lTgUWL: line 28: syntax error near unexpected token `(' error: Bad exit status from /var/tmp/rpm-tmp.lTgUWL (%install) -- David Jarvie. KAlarm author and maintainer. http://www.astrojar.org.uk/kalarm -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Sunday 01 of August 2010, David Jarvie wrote:
I'm using the KDE OpenSUSE build service to build my KDE application. There are some files which need to be installed for systems which provide KDE 4.2, but not for KDE 4.3 or later. I've tried a couple of methods in the .spec file to specify this, but the build failed each time. How can I specify this condition?
There doesn't seem to be a pre-made check for this, but you can do e.g. %files ... ... %if %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1, $2,$3 }') >= 040200 ... %endif ... -- Lubos Lunak openSUSE Boosters team, KDE developer l.lunak@suse.cz , l.lunak@kde.org -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Mon, August 2, 2010 12:30 pm, Lubos Lunak wrote:
On Sunday 01 of August 2010, David Jarvie wrote:
I'm using the KDE OpenSUSE build service to build my KDE application. There are some files which need to be installed for systems which provide KDE 4.2, but not for KDE 4.3 or later. I've tried a couple of methods in the .spec file to specify this, but the build failed each time. How can I specify this condition?
There doesn't seem to be a pre-made check for this, but you can do e.g.
%files ... ... %if %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1, $2,$3 }') >= 040200 ... %endif ...
This test only works for OpenSUSE - other distros use other names for the kdelibs package. But actually (I forgot to say this) I wasn't wanting to know how to find the KDE version - I did it using kde4-config. My problem was how to put conditional code in the %install section. Your syntax does seem to work, but only if the %if ... %endif is at the end of the %install section. If it's in the middle, the rest of the %install statements seem either to be ignored or to be treated as if they were part of the %if ... %endif (I'm not sure which yet). This could pose problems if two or more independent conditions needed to be used for different groups of install statements. -- David Jarvie. KDE developer. KAlarm author - http://www.astrojar.org.uk/kalarm -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Tuesday 03 of August 2010, David Jarvie wrote:
My problem was how to put conditional code in the %install section.
Either %if-%endif, which is like #if-#endif in C++, or normal shell's if-fi.
Your syntax does seem to work, but only if the %if ... %endif is at the end of the %install section. If it's in the middle, the rest of the %install statements seem either to be ignored or to be treated as if they were part of the %if ... %endif (I'm not sure which yet). This could pose problems if two or more independent conditions needed to be used for different groups of install statements.
That sounds strange, and I think this is used often enough that somebody would notice. You probably had a problem in the .spec somewhere. -- Lubos Lunak openSUSE Boosters team, KDE developer l.lunak@suse.cz , l.lunak@kde.org -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Mon, August 2, 2010 12:30 pm, Lubos Lunak wrote:
On Sunday 01 of August 2010, David Jarvie wrote:
There are some files which need to be installed for systems which provide KDE 4.2, but not for KDE 4.3 or later. I've tried a couple of methods in the .spec file to specify this, but the build failed each time. How can I specify this condition?
There doesn't seem to be a pre-made check for this, but you can do e.g.
%files ... ... %if %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1, $2,$3 }') >= 040200 ... %endif ...
This doesn't work after all. Putting it into the %files section results in a parse error in the spec file (it complains that it can't parse "%(..." ). So instead I tried if [ %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1,$2,$3 }') -ge 040200 ]; then ... fi This parses successfully, but at the end of the build each whitespace delimited token in the 'if' statement is assumed to be a file name, resulting in errors such as File must begin with "/": $(rpm So I'm back to square one - I can't find a syntax that enables files to be included conditionally in the %files section. -- David Jarvie. KDE developer. KAlarm author - http://www.astrojar.org.uk/kalarm -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Wednesday 04 August 2010 18:05:11 David Jarvie wrote:
On Mon, August 2, 2010 12:30 pm, Lubos Lunak wrote:
On Sunday 01 of August 2010, David Jarvie wrote:
There are some files which need to be installed for systems which provide KDE 4.2, but not for KDE 4.3 or later. I've tried a couple of methods in the .spec file to specify this, but the build failed each time. How can I specify this condition?
There doesn't seem to be a pre-made check for this, but you can do e.g.
%files ... ... %if %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1, $2,$3 }') >= 040200 ... %endif ...
This doesn't work after all. Putting it into the %files section results in a parse error in the spec file (it complains that it can't parse "%(..." ). So instead I tried
do something like this in %install section: cat > somefile << EOF /usr/bin/binary %if %(`echo rpm -q --qf "%{VERSION}" kdelibs4 ....`) == "blahfasel" /lib/lib ... %endif EOF and then %files -f somefile I have not tested it in detail, but I think you get they idea how to deal with it. bye adrian
if [ %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1,$2,$3 }') -ge 040200 ]; then ... fi
This parses successfully, but at the end of the build each whitespace delimited token in the 'if' statement is assumed to be a file name, resulting in errors such as
File must begin with "/": $(rpm
So I'm back to square one - I can't find a syntax that enables files to be included conditionally in the %files section.
-- Adrian Schroeter SUSE Linux Products GmbH email: adrian@suse.de -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Wednesday 04 August 2010 17:34:51 you wrote:
On Wednesday 04 August 2010 18:05:11 David Jarvie wrote:
On Mon, August 2, 2010 12:30 pm, Lubos Lunak wrote:
On Sunday 01 of August 2010, David Jarvie wrote:
There are some files which need to be installed for systems which provide KDE 4.2, but not for KDE 4.3 or later. I've tried a couple of methods in the .spec file to specify this, but the build failed each time. How can I specify this condition?
There doesn't seem to be a pre-made check for this, but you can do e.g.
%files ... ... %if %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1, $2,$3 }') >= 040200 ... %endif ...
This doesn't work after all. Putting it into the %files section results in a parse error in the spec file (it complains that it can't parse "%(..." ). So instead I tried
do something like this in %install section:
cat > somefile << EOF /usr/bin/binary %if %(`echo rpm -q --qf "%{VERSION}" kdelibs4 ....`) == "blahfasel" /lib/lib ... %endif EOF
and then %files -f somefile
I have not tested it in detail, but I think you get they idea how to deal with it.
Thanks. Your solution works except that for the Mandriva build to work, I had to change it to echo /lib/libfile.so >>somefile instead of "cat > somefile << EOF".
if [ %(rpm -q --qf "%{VERSION}" kdelibs4 | awk -F . '{ printf "%d%02d%02d",$1,$2,$3 }') -ge 040200 ]; then ... fi
This parses successfully, but at the end of the build each whitespace delimited token in the 'if' statement is assumed to be a file name, resulting in errors such as
File must begin with "/": $(rpm
So I'm back to square one - I can't find a syntax that enables files to be included conditionally in the %files section.
-- David Jarvie. KAlarm author and maintainer. http://www.astrojar.org.uk/kalarm -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
participants (3)
-
Adrian Schröter
-
David Jarvie
-
Lubos Lunak