spec file issue for qt application :-Urgent help needed

Hi All,
I have to download libcurl based on the OS version my target OS is SUSE and HELiOS. in my spec file i had added a condition

# %define _unpackaged_files_terminate_build 0
# %define _missing_doc_files_terminate_build 0
# %define __find_requires %{nil}
%define debug_package %{nil}
 
%define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0)
 
 
Name            : Client
Summary         : Copies libraries to pre-defined locations 
Version         : 5
Release         : 0
License         : test
BuildArch       : x86_64
Group           : Development/Tools
 
 
 
 
%if %is_suse 
requires:       pacs-plugins >= 1-1, libcurl4
%else
requires:       pacs-plugins >= 1-1, libcurl >= 4
%endif

If works fine on SUSE but on HeliOS also it is looking for libcurl4 instead of libcurl. What i am doing wrong here . Had also tried different approach as well for example


%define os_type %(lsb_release -si)




%if "%{os_type}" == "HELiOS" 
requires:       pacs-plugins >= 1-1, libcurl >= 4
%else 
requires:       pacs-plugins >= 1-1, libcurl4
#endif

and this is also not working ,can someone help me to resolve this issue . Thanks in advance/

Why not just use the predefined macro suse_version, that’s only defined on (open)SUSE?
/etc/SuSE-release is deprecated anyway*…

And your requires lines look wrong to me too, there should not be a ‘,’.

%if 0{?suse_version}
Requires:       pacs-plugins >= 1-1  libcurl4
%else
Requires:       pacs-plugins >= 1-1  libcurl >= 4
%endif

See also https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto#Detect_a_distribution_flavor_for_special_code

*)

~> cat /etc/SuSE-release 
openSUSE 13.2 (x86_64)
VERSION = 13.2
CODENAME = Harlequin
# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead

On Thu 20 Aug 2015 05:16:01 PM CDT, rupeshshukla wrote:

Hi All,
I have to download libcurl based on the OS version my target
OS is SUSE and HELiOS. in my spec file i had added a condition

Code:

%define _unpackaged_files_terminate_build 0

%define _missing_doc_files_terminate_build 0

%define __find_requires %{nil}

%define debug_package %{nil}

%define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0)

Name : Client
Summary : Copies libraries to pre-defined locations
Version : 5
Release : 0
License : test
BuildArch : x86_64
Group : Development/Tools

%if %is_suse
requires: pacs-plugins >= 1-1, libcurl4
%else
requires: pacs-plugins >= 1-1, libcurl >= 4
%endif


If works fine on SUSE but on HeliOS also it is looking for libcurl4
instead of libcurl. What i am doing wrong here . Had also tried
different approach as well for example

Code:

%define os_type %(lsb_release -si)

%if “%{os_type}” == “HELiOS”
requires: pacs-plugins >= 1-1, libcurl >= 4
%else
requires: pacs-plugins >= 1-1, libcurl4
#endif


and this is also not working ,can someone help me to resolve this issue
… Thanks in advance/

Hi
Have a look at this document;
https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto

Does HELiOS use pkgconfig, if so use that, eg for openSUSE/SUSE it’s


BuildRequires: pkgconfig(libcurl)

Then it should in theory with rpm pull in any requires. You should see
that info in the build log at the end.


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel
3.12.44-52.10-default If you find this post helpful and are logged into
the web interface, please show your appreciation and click on the star
below… Thanks!

Hi,
First thank you so much for your reply . The thing is Requires: pacs-plugins >= 1-1, libcurl4 works fine if it is out of if loop and even in if loop it works fine for SUSE the only problem is in HELiOS which also fall in SUSE condition and look for libcurl4 . this is the issue and i am new to all of these things so i am not sure what is missing here ,Actually i went through the link also and used suse_version check as well ,but i don’t know even in case of HELiOS it is going through SUSE condition, which make me more confused.This also didn’t worked for me.

%if 0%{?suse_version}
BuildRequires : libcurl = %{>=4}
%else
BuildRequires : libcurl4
%endif

Thanks

“if” is no loop… :wink:

it works fine for SUSE the only problem is in HELiOS which also fall in SUSE condition and look for libcurl4

And how/wher exactly are you building it for HELiOS?
If you build it on (open)SUSE, it will always detect (open)SUSE obviously.

IOW, the check you have is done during the build, not during installation. You cannot have dynamic Requires depending on which distribution you install the package. Package requirements are static.

Yeah that is mine requirement, i know if is not a loop it’s a conditional statement :slight_smile: but you are right i am trying to do it at run time . is there any way i can perform this check during installation not the build.What i mean here, is there anyway that at run time i can check whether i am running in SUSE or HELiOS and based on it add some instruction to install the library or look for it.

Thanks

No.
You cannot set/change the package dependencies at installation time.

What i mean here, is there anyway that at run time i can check whether i am running in SUSE or HELiOS and based on it add some instruction to install the library or look for it.

You could probably do that in a %postinstall scriptlet. That gets run when the package is installed.

But what’s your requirement exactly?
You can also specify files. So if you e.g. need the curl executable, specify this:

Requires: /usr/bin/curl

If you need the library, something like this should do:

Requires: libcurl.so.4()(64bit)

Then it should not matter how the package is named.

Yes you are right i think %postinstall is the right place , the requirement is while deploying the app on the target os i want to make sure whether that os contain the required version of libcurl or not and if yes then only proceed else fail with proper error.

Thanks

The question is now how to check in %postinstall that particular lib is there or not and if not show the error and return etc.

Thanks

Well, on second thought you are probably not able to use package management tools in the %postinstall script. The package management is locked, your package is being installed at the moment. A “rpm -q xxx” might still work though, no idea.

Maybe you could do your version check differently? E.g. call curl -v and parse the output? Then you would need curl as well though, not only libcurl).

Or maybe rethink your whole package creation/installation process. E.g. build your HeliOS packages on a HeliOS host, and you can use such conditionals.
AIUI, you copy some precompiled binaries to the system during installation, and those need libcurl, right?
In that case, the “Requires: libcurl.so.4()(64bit)” approach should work, on openSUSE at least. (I don’t know HeliOS)

Or write some custom installation script that checks the libcurl version/installs it if necessary, and then installs the RPM (or maybe don’t even use an RPM in the first place).

Btw, %postinstall is called after the package installation, as the name implies. In your case you probably want to use %preinstall instead.