I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4 - Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro, but is there a "right" way to check the EL version short of calling rpm -q redhat-release? I don't see a macro defined for this in /etc/rpm.
I guess I could operate on the dist tag...
Ray
Ray Van Dolson wrote:
I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4
- Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro,
%{fedora} macro is the *fedora* release, for EL, the corresponding macro is %{rhel}.
In your case. you could use something like:
%if 0%{?rhel} >= 4 %patch1 ... %endif
%if 0%{?rhel} >= 5 %patch2 ... %endif
On Mon, Mar 16, 2009 at 07:51:27PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4
- Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro,
%{fedora} macro is the *fedora* release, for EL, the corresponding macro is %{rhel}.
In your case. you could use something like:
%if 0%{?rhel} >= 4 %patch1 ... %endif
%if 0%{?rhel} >= 5 %patch2 ... %endif
Slick. Thanks Rex.
Ray
Ray Van Dolson wrote:
On Mon, Mar 16, 2009 at 07:51:27PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4
- Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro,
%{fedora} macro is the *fedora* release, for EL, the corresponding macro is %{rhel}.
In your case. you could use something like:
%if 0%{?rhel} >= 4 %patch1 ... %endif
%if 0%{?rhel} >= 5 %patch2 ... %endif
Slick. Thanks Rex.
Here's more gory details: https://fedoraproject.org/wiki/Packaging/DistTag (sorry, should've included the link last time).
-- Rex
On Mon, Mar 16, 2009 at 08:04:52PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
On Mon, Mar 16, 2009 at 07:51:27PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4
- Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro,
%{fedora} macro is the *fedora* release, for EL, the corresponding macro is %{rhel}.
In your case. you could use something like:
%if 0%{?rhel} >= 4 %patch1 ... %endif
%if 0%{?rhel} >= 5 %patch2 ... %endif
Slick. Thanks Rex.
Here's more gory details: https://fedoraproject.org/wiki/Packaging/DistTag (sorry, should've included the link last time).
Hmm, it doesn't seem like %{rhel}, %{rhl}, %{el#} are set on CentOS. I tried adding an echo <var> to my .spec file for each and they all show up empty.
Actually, just tried on a real RHEL5 box and
echo %{?rhel}
Is empty as well. And, when I set up an if block using this:
%if 0%{?rhel} == 4 stuff %endif
"stuff" never is executed.
Guess I will rely on %{dist} for now.
Ray
On Mon, 2009-03-16 at 21:29 -0700, Ray Van Dolson wrote:
On Mon, Mar 16, 2009 at 08:04:52PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
On Mon, Mar 16, 2009 at 07:51:27PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4
- Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro,
%{fedora} macro is the *fedora* release, for EL, the corresponding macro is %{rhel}.
In your case. you could use something like:
%if 0%{?rhel} >= 4 %patch1 ... %endif
%if 0%{?rhel} >= 5 %patch2 ... %endif
Slick. Thanks Rex.
Here's more gory details: https://fedoraproject.org/wiki/Packaging/DistTag (sorry, should've included the link last time).
Hmm, it doesn't seem like %{rhel}, %{rhl}, %{el#} are set on CentOS. I tried adding an echo <var> to my .spec file for each and they all show up empty.
Well, in case you're making an EPEL package, %rhel macro will be defined in buildsystem, by buildsys-macros package. You can get it here:
http://buildsys.fedoraproject.org/buildgroups/rhel5/i386/
Regards,
On Tue, Mar 17, 2009 at 01:06:12PM +0100, Lubomir Rintel wrote:
On Mon, 2009-03-16 at 21:29 -0700, Ray Van Dolson wrote:
On Mon, Mar 16, 2009 at 08:04:52PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
On Mon, Mar 16, 2009 at 07:51:27PM -0500, Rex Dieter wrote:
Ray Van Dolson wrote:
I'm trying to write a "distro agnostic" spec file that will apply two patches:
- Patch 1 if and only if we're building for EL5 or EL4
- Patch 2 if and only if we're building for EL4
I know I can check for EL with the presence of the %{fedora} macro,
%{fedora} macro is the *fedora* release, for EL, the corresponding macro is %{rhel}.
In your case. you could use something like:
%if 0%{?rhel} >= 4 %patch1 ... %endif
%if 0%{?rhel} >= 5 %patch2 ... %endif
Slick. Thanks Rex.
Here's more gory details: https://fedoraproject.org/wiki/Packaging/DistTag (sorry, should've included the link last time).
Hmm, it doesn't seem like %{rhel}, %{rhl}, %{el#} are set on CentOS. I tried adding an echo <var> to my .spec file for each and they all show up empty.
Well, in case you're making an EPEL package, %rhel macro will be defined in buildsystem, by buildsys-macros package. You can get it here:
http://buildsys.fedoraproject.org/buildgroups/rhel5/i386/
Regards,
Ah, so when building by hand via rpmbuild, I should define "rhel 5" on the command line? Or would it be proper to BuildRequires on buildsys-macros? The package won't do the "right thing" unless I can apply a patch correctly based on the OS.
Maybe I just assume anyone building by hand will read the .spec file and know what they're doing though.
Thanks, Ray
On Tue, 2009-03-17 at 08:30 -0700, Ray Van Dolson wrote:
On Tue, Mar 17, 2009 at 01:06:12PM +0100, Lubomir Rintel wrote:
Well, in case you're making an EPEL package, %rhel macro will be defined in buildsystem, by buildsys-macros package. You can get it here:
http://buildsys.fedoraproject.org/buildgroups/rhel5/i386/
Regards,
Ah, so when building by hand via rpmbuild, I should define "rhel 5" on the command line? Or would it be proper to BuildRequires on buildsys-macros? The package won't do the "right thing" unless I can apply a patch correctly based on the OS.
Maybe I just assume anyone building by hand will read the .spec file and know what they're doing though.
Hmm, to my knowledge the %{rhel} macro is provided by /usr/lib/rpm/redhat/dist.sh which is contained in the redhat-rpm-config package.
Don't BR the package, since it's automatically provided by the build environment. If you want to compile packages on your own computers, just make sure redhat-rpm-config is installed.
On Tue, Mar 17, 2009 at 06:26:33PM +0200, Jussi Lehtola wrote:
On Tue, 2009-03-17 at 08:30 -0700, Ray Van Dolson wrote:
On Tue, Mar 17, 2009 at 01:06:12PM +0100, Lubomir Rintel wrote:
Well, in case you're making an EPEL package, %rhel macro will be defined in buildsystem, by buildsys-macros package. You can get it here:
http://buildsys.fedoraproject.org/buildgroups/rhel5/i386/
Regards,
Ah, so when building by hand via rpmbuild, I should define "rhel 5" on the command line? Or would it be proper to BuildRequires on buildsys-macros? The package won't do the "right thing" unless I can apply a patch correctly based on the OS.
Maybe I just assume anyone building by hand will read the .spec file and know what they're doing though.
Hmm, to my knowledge the %{rhel} macro is provided by /usr/lib/rpm/redhat/dist.sh which is contained in the redhat-rpm-config package.
Ah, sure enough. And this script doesn't appear to be modified to work with CentOS, although it does return distnum, all of the other ones come back blank. Perhaps I should file a bug with CentOS.
Don't BR the package, since it's automatically provided by the build environment. If you want to compile packages on your own computers, just make sure redhat-rpm-config is installed.
Sounds good.
Thanks, Ray
packaging@lists.fedoraproject.org