I'm trying to tweak a package so that it autodetects when it's being built under Redhat/Fedora (et al) and does the right thing.
Is there a simple and foolproof test for this?
Thanks,
-Philip
Philip Prindeville wrote:
I'm trying to tweak a package so that it autodetects when it's being built under Redhat/Fedora (et al) and does the right thing.
Is there a simple and foolproof test for this?
I suppose you could check for the file /etc/redhat-release
$ cat /etc/redhat-release Fedora Core release 4 (Stentz)
Thanks,
-Philip
-M
Philip Prindeville wrote:
I'm trying to tweak a package so that it autodetects when it's being built under Redhat/Fedora (et al) and does the right thing.
Is there a simple and foolproof test for this?
How about something like this:
%define redhat %(/bin/grep "^Red Hat " /etc/redhat-release &> /dev/null && echo 1 || echo 0) %define fedora %(/bin/grep "^Fedora " /etc/redhat-release &> /dev/null && echo 1 || echo 0)
...
%if %{redhat} echo Building on RedHat %else echo Not building on RedHat %endif
%if %{fedora} echo Building on Fedora %else echo Not building on Fedora %endif
%if %{redhat} || %{fedora} echo Building on RedHat or Fedora %else echo Not building on RedHat or Fedora %endif
Paul.
Paul Howarth wrote:
Philip Prindeville wrote:
I'm trying to tweak a package so that it autodetects when it's being built under Redhat/Fedora (et al) and does the right thing.
Is there a simple and foolproof test for this?
How about something like this:
%define redhat %(/bin/grep "^Red Hat " /etc/redhat-release &> /dev/null && echo 1 || echo 0) %define fedora %(/bin/grep "^Fedora " /etc/redhat-release &> /dev/null && echo 1 || echo 0)
...
%if %{redhat} echo Building on RedHat %else echo Not building on RedHat %endif
%if %{fedora} echo Building on Fedora %else echo Not building on Fedora %endif
%if %{redhat} || %{fedora} echo Building on RedHat or Fedora %else echo Not building on RedHat or Fedora %endif
Paul.
Sorry, I wasn't very clear.
The test needs to be in the Makefile, not in the RPM spec file.
What I decided on was:
REDHAT := $(shell test -f /etc/redhat-release && echo yes)
...
ifeq ($(REDHAT),yes) ... endif
as the solution.
Thanks.
-Philip
On Fri, 2005-08-19 at 12:15 -0600, Philip Prindeville wrote:
Paul Howarth wrote:
Philip Prindeville wrote:
I'm trying to tweak a package so that it autodetects when it's being built under Redhat/Fedora (et al) and does the right thing.
Is there a simple and foolproof test for this?
How about something like this:
%define redhat %(/bin/grep "^Red Hat " /etc/redhat-release &> /dev/null && echo 1 || echo 0) %define fedora %(/bin/grep "^Fedora " /etc/redhat-release &> /dev/null && echo 1 || echo 0)
...
%if %{redhat} echo Building on RedHat %else echo Not building on RedHat %endif
%if %{fedora} echo Building on Fedora %else echo Not building on Fedora %endif
%if %{redhat} || %{fedora} echo Building on RedHat or Fedora %else echo Not building on RedHat or Fedora %endif
Paul.
Sorry, I wasn't very clear.
The test needs to be in the Makefile, not in the RPM spec file.
What I decided on was:
REDHAT := $(shell test -f /etc/redhat-release && echo yes)
...
ifeq ($(REDHAT),yes) ... endif
as the solution.
That may not be reliable. Mandriva will certainly be detected as a redhat distribution with this test; not sure about SuSE.
Paul.
On Fri, 2005-08-19 at 11:58 -0600, Philip Prindeville wrote:
I'm trying to tweak a package so that it autodetects when it's being built under Redhat/Fedora (et al) and does the right thing.
Is there a simple and foolproof test for this?
Have it depend on the redhat-release RPM. Using the existance or contents of /etc/redhat-release is not recommended because it can easily be removed, renamed, or changed.
Thomas