Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   EPEL Development (http://www.linux-archive.org/epel-development/)
-   -   RPM macros question (http://www.linux-archive.org/epel-development/689996-rpm-macros-question.html)

Dmitry Makovey 08-02-2012 06:41 PM

RPM macros question
 
Hi,

I'm working on bringing pgpool-II packages (postgresql-pgpool-II-3.1.2-1) from
Fedora over to RHEL6. I've already "hacked" Fedora version to play nice with
RHEL (removing systemd references and supplanting systemd unit with init
script). I have also conditionalized it to build either one depending on
whether systemd is to be used or not using the

%if %{systemd_enabled}
...
%else
...
%endif

blocks. However I can't quite figure out an optimal way of determining which
platform package is being compiled for (in other words: how to set up
systemd_enabled macro automatically rather than rely on manual setup). I'm
sure people on this list came across this problem more than once, and I would
like to know what's the standard way of resolving it. What I'm trying to
achieve is to get one SPEC for both Fedora and RHEL. Am I attacking this
problem the wrong way?

--
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245
---
Confidence is what you have before you understand the problem
Woody Allen

When in trouble when in doubt run in circles scream and shout
http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=19330


--
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list

Paul Howarth 08-02-2012 07:12 PM

RPM macros question
 
On Thu, 02 Aug 2012 12:41:49 -0600
Dmitry Makovey <dmitry@athabascau.ca> wrote:
> I'm working on bringing pgpool-II packages
> (postgresql-pgpool-II-3.1.2-1) from Fedora over to RHEL6. I've
> already "hacked" Fedora version to play nice with RHEL (removing
> systemd references and supplanting systemd unit with init script). I
> have also conditionalized it to build either one depending on whether
> systemd is to be used or not using the
>
> %if %{systemd_enabled}
> ...
> %else
> ...
> %endif
>
> blocks. However I can't quite figure out an optimal way of
> determining which platform package is being compiled for (in other
> words: how to set up systemd_enabled macro automatically rather than
> rely on manual setup). I'm sure people on this list came across this
> problem more than once, and I would like to know what's the standard
> way of resolving it. What I'm trying to achieve is to get one SPEC
> for both Fedora and RHEL. Am I attacking this problem the wrong way?

I don't think there's a standard for this, but an approach I've used
with success is to test for the existence of the /run/lock directory:

# If directory /run/lock exists, do a systemd-based build; otherwise,a sysvinit-based build
%global use_systemd %([ -d /run/lock ] && echo 1 || echo 0)

Cheers, Paul.

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list

Dmitry Makovey 08-02-2012 07:21 PM

RPM macros question
 
On August 2, 2012 20:12:10 Paul Howarth wrote:
> I don't think there's a standard for this, but an approach I've used
> with success is to test for the existence of the /run/lock directory:
>
> # If directory /run/lock exists, do a systemd-based build; otherwise,a
> sysvinit-based build
> %global use_systemd %([ -d /run/lock ] && echo 1 || echo 0)

That's a good idea, thanks Paul.

Being paranoid I'm thinking of adding a step:

%global use_systemd %([ -d /run/lock ] && rpm --quiet -qf /run/lock && echo 1
|| echo 0)

that should make sure /run/lock is not there because it happened that sysadmin
just decided create it manually and doesn't happen to run any systemd... Does
that make sense?

--
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245
---
Confidence is what you have before you understand the problem
Woody Allen

When in trouble when in doubt run in circles scream and shout
http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=19330


--
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list

Paul Howarth 08-02-2012 07:59 PM

RPM macros question
 
On Thu, 02 Aug 2012 13:21:54 -0600
Dmitry Makovey <dmitry@athabascau.ca> wrote:

> On August 2, 2012 20:12:10 Paul Howarth wrote:
> > I don't think there's a standard for this, but an approach I've used
> > with success is to test for the existence of the /run/lock
> > directory:
> >
> > # If directory /run/lock exists, do a systemd-based build;
> > otherwise,a sysvinit-based build
> > %global use_systemd %([ -d /run/lock ] && echo 1 || echo 0)
>
> That's a good idea, thanks Paul.
>
> Being paranoid I'm thinking of adding a step:
>
> %global use_systemd %([ -d /run/lock ] && rpm --quiet -qf /run/lock
> && echo 1 || echo 0)
>
> that should make sure /run/lock is not there because it happened that
> sysadmin just decided create it manually and doesn't happen to run
> any systemd... Does that make sense?

Well it's fine in principle but unfortunately accessing the rpm
database like that from within a package build is a bad idea because
the build system may be using a chroot populated by a different version
of rpm than the one the target system uses, which could make the rpm
database unreadable at package build time, for instance if the builder
and target systems use different versions of Berkeley DB.

The mock approach used in Fedora/EPEL is affected by this.

Paul.

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list

Dmitry Makovey 08-02-2012 09:32 PM

RPM macros question
 
On August 2, 2012 20:59:30 Paul Howarth wrote:
> On Thu, 02 Aug 2012 13:21:54 -0600
>
> Dmitry Makovey <dmitry@athabascau.ca> wrote:
> > On August 2, 2012 20:12:10 Paul Howarth wrote:
> > > I don't think there's a standard for this, but an approach I've used
> > > with success is to test for the existence of the /run/lock
> > > directory:
> > >
> > > # If directory /run/lock exists, do a systemd-based build;
> > > otherwise,a sysvinit-based build
> > > %global use_systemd %([ -d /run/lock ] && echo 1 || echo 0)
> >
> > That's a good idea, thanks Paul.
> >
> > Being paranoid I'm thinking of adding a step:
> >
> > %global use_systemd %([ -d /run/lock ] && rpm --quiet -qf /run/lock
> > && echo 1 || echo 0)
> >
> > that should make sure /run/lock is not there because it happened that
> > sysadmin just decided create it manually and doesn't happen to run
> > any systemd... Does that make sense?
>
> Well it's fine in principle but unfortunately accessing the rpm
> database like that from within a package build is a bad idea because
> the build system may be using a chroot populated by a different version
> of rpm than the one the target system uses, which could make the rpm
> database unreadable at package build time, for instance if the builder
> and target systems use different versions of Berkeley DB.
>
> The mock approach used in Fedora/EPEL is affected by this.

ouch. good to know, thanks!

>
> Paul.
--
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245
---
Confidence is what you have before you understand the problem
Woody Allen

When in trouble when in doubt run in circles scream and shout
http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=19330


--
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list

Jos Vos 08-02-2012 09:36 PM

RPM macros question
 
On Thu, Aug 02, 2012 at 12:41:49PM -0600, Dmitry Makovey wrote:

> I'm working on bringing pgpool-II packages (postgresql-pgpool-II-3.1.2-1) from
> Fedora over to RHEL6. I've already "hacked" Fedora version to play nice with
> RHEL (removing systemd references and supplanting systemd unit with init
> script). I have also conditionalized it to build either one depending on
> whether systemd is to be used or not using the
>
> %if %{systemd_enabled}
> ...
> %else
> ...
> %endif
>
> blocks. However I can't quite figure out an optimal way of determining which
> platform package is being compiled for (in other words: how to set up
> systemd_enabled macro automatically rather than rely on manual setup). I'm
> sure people on this list came across this problem more than once, and I would
> like to know what's the standard way of resolving it. What I'm trying to
> achieve is to get one SPEC for both Fedora and RHEL. Am I attacking this
> problem the wrong way?

I would suggest to do it the following way:

%if 0%{?rhel} && 0%{?rhel} <= 6
%define systemd_enabled 0
%else
%define systemd_enabled 1
%endif

This is the way I do it in my backports (e.g. PostgreSQL 9.x for RHEL 6.x).

--
-- Jos Vos <jos@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list

Dmitry Makovey 08-02-2012 10:23 PM

RPM macros question
 
On August 2, 2012 23:36:25 Jos Vos wrote:
> I would suggest to do it the following way:
>
> %if 0%{?rhel} && 0%{?rhel} <= 6
> %define systemd_enabled 0
> %else
> %define systemd_enabled 1
> %endif
>
> This is the way I do it in my backports (e.g. PostgreSQL 9.x for RHEL 6.x).

I just applied above and it works exactly as needed, so I'm going to stick
with that for now due to it's simplicity :) Thanks.

--
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245
---
Confidence is what you have before you understand the problem
Woody Allen

When in trouble when in doubt run in circles scream and shout
http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=19330


--
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---

_______________________________________________
epel-devel-list mailing list
epel-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/epel-devel-list


All times are GMT. The time now is 04:46 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.