diff mbox

gpsd: make init script optional

Message ID 1371382468-5838-1-git-send-email-spdawson@gmail.com
State Rejected
Headers show

Commit Message

Simon Dawson June 16, 2013, 11:34 a.m. UTC
From: Simon Dawson <spdawson@gmail.com>

Signed-off-by: Simon Dawson <spdawson@gmail.com>
---
 package/gpsd/Config.in | 7 +++++++
 package/gpsd/gpsd.mk   | 7 +++++++
 2 files changed, 14 insertions(+)

Comments

Maxime Ripard June 16, 2013, 12:34 p.m. UTC | #1
Hi Simon,

On Sun, Jun 16, 2013 at 12:34:28PM +0100, spdawson@gmail.com wrote:
> From: Simon Dawson <spdawson@gmail.com>
> 
> Signed-off-by: Simon Dawson <spdawson@gmail.com>
> ---
>  package/gpsd/Config.in | 7 +++++++
>  package/gpsd/gpsd.mk   | 7 +++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/package/gpsd/Config.in b/package/gpsd/Config.in
> index 337f8e7..29e061f 100644
> --- a/package/gpsd/Config.in
> +++ b/package/gpsd/Config.in
> @@ -21,6 +21,13 @@ config BR2_PACKAGE_GPSD_DEVICES
>  	default "/dev/ttyS1"
>  	depends on BR2_PACKAGE_GPSD
>  
> +config BR2_PACKAGE_GPSD_INSTALL_INITSCRIPT
> +	bool "install init script"
> +	default y
> +	depends on BR2_PACKAGE_GPSD
> +	help
> +	  Install a gpsd init script
> +
>  menu "Features"
>  	depends on BR2_PACKAGE_GPSD
>  
> diff --git a/package/gpsd/gpsd.mk b/package/gpsd/gpsd.mk
> index be2e681..45d1aed 100644
> --- a/package/gpsd/gpsd.mk
> +++ b/package/gpsd/gpsd.mk
> @@ -207,12 +207,19 @@ define GPSD_INSTALL_TARGET_CMDS
>  		$(SCONS) \
>  		$(GPSD_SCONS_OPTS) \
>  		install)
> +endef
> +
> +define GPSD_INSTALL_INITSCRIPT
>  	if [ ! -f $(TARGET_DIR)/etc/init.d/S50gpsd ]; then \
>  		$(INSTALL) -m 0755 -D package/gpsd/S50gpsd $(TARGET_DIR)/etc/init.d/S50gpsd; \
>  		$(SED) 's,^DEVICES=.*,DEVICES=$(BR2_PACKAGE_GPSD_DEVICES),' $(TARGET_DIR)/etc/init.d/S50gpsd; \
>  	fi
>  endef
>  
> +ifeq ($(BR2_PACKAGE_GPSD_INSTALL_INITSCRIPT),y)
> +GPSD_POST_INSTALL_TARGET_HOOKS = GPSD_INSTALL_INITSCRIPT
> +endif

You should use GPSD_INSTALL_INIT_SYSV instead.

Maxime
Yann E. MORIN June 16, 2013, 1:09 p.m. UTC | #2
Simon, All,

On 2013-06-16 12:34 +0100, spdawson@gmail.com spake thusly:
> +config BR2_PACKAGE_GPSD_INSTALL_INITSCRIPT
> +	bool "install init script"
> +	default y
> +	depends on BR2_PACKAGE_GPSD
> +	help
> +	  Install a gpsd init script
> +

Why would one not want the init script? Is this because of systemd? If so,
then you should use GPSD_INSTALL_INIT_SYSV and GPSD_INSTALL_INIT_SYSTEMD
as pointed out by Maxime.

This ensures the init script will only be installed if a SysV init
scheme is used (and conversely for the systemd unit).

Otherwise, please expand on why not wanting the init script should be
configurable at all.

Regards,
Yann E. MORIN.
Simon Dawson June 16, 2013, 3:59 p.m. UTC | #3
Hi Yann, Maxime.

On 16 June 2013 14:09, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Why would one not want the init script? Is this because of systemd? If so,
> then you should use GPSD_INSTALL_INIT_SYSV and GPSD_INSTALL_INIT_SYSTEMD
> as pointed out by Maxime.
>
> This ensures the init script will only be installed if a SysV init
> scheme is used (and conversely for the systemd unit).
>
> Otherwise, please expand on why not wanting the init script should be
> configurable at all.

There are other possibilities, beyond SysV and systemd: I've
previously run gpsd and other managed services using daemontools and
runit. My present use case has udev kicking off gpsd in response to
hotplug events for a USB GPS device.

I seem to always end up having to remove the gpsd SysV init script in
my post-build script; hence the desire for a configuration option.

Simon.
Peter Korsgaard June 16, 2013, 5:37 p.m. UTC | #4
>>>>> "Simon" == Simon Dawson <spdawson@gmail.com> writes:

Hi,

 >> Otherwise, please expand on why not wanting the init script should be
 >> configurable at all.

 Simon> There are other possibilities, beyond SysV and systemd: I've
 Simon> previously run gpsd and other managed services using daemontools
 Simon> and runit.

True, but we don't currently have any support for these in buildroot.

 Simon> My present use case has udev kicking off gpsd in response to
 Simon> hotplug events for a USB GPS device.

 Simon> I seem to always end up having to remove the gpsd SysV init
 Simon> script in my post-build script; hence the desire for a
 Simon> configuration option.

Sorry, but it imho doesn't scale to add configuration options for this
kind of stuff for each package.

Realisticly seem, you almost always need to do some minor fixups in
post-build for any real projects.
Simon Dawson June 16, 2013, 6:16 p.m. UTC | #5
Hi Peter.

On 16 June 2013 18:37, Peter Korsgaard <jacmet@uclibc.org> wrote:
> Sorry, but it imho doesn't scale to add configuration options for this
> kind of stuff for each package.
>
> Realisticly seem, you almost always need to do some minor fixups in
> post-build for any real projects.

Fair enough; thanks for the input.

Simon.
Maxime Ripard June 16, 2013, 6:30 p.m. UTC | #6
On Sun, Jun 16, 2013 at 04:59:06PM +0100, Simon Dawson wrote:
> Hi Yann, Maxime.
> 
> On 16 June 2013 14:09, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > Why would one not want the init script? Is this because of systemd? If so,
> > then you should use GPSD_INSTALL_INIT_SYSV and GPSD_INSTALL_INIT_SYSTEMD
> > as pointed out by Maxime.
> >
> > This ensures the init script will only be installed if a SysV init
> > scheme is used (and conversely for the systemd unit).
> >
> > Otherwise, please expand on why not wanting the init script should be
> > configurable at all.
> 
> There are other possibilities, beyond SysV and systemd: I've
> previously run gpsd and other managed services using daemontools and
> runit. My present use case has udev kicking off gpsd in response to
> hotplug events for a USB GPS device.
> 
> I seem to always end up having to remove the gpsd SysV init script in
> my post-build script; hence the desire for a configuration option.

Maybe you can add a BR2_INIT_NONE choice here then to not copy all the
install scripts.

Maxime
Arnout Vandecappelle June 18, 2013, 6:24 a.m. UTC | #7
On 16/06/13 20:30, Maxime Ripard wrote:
> On Sun, Jun 16, 2013 at 04:59:06PM +0100, Simon Dawson wrote:
>> Hi Yann, Maxime.
>>
>> On 16 June 2013 14:09, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>>> Why would one not want the init script? Is this because of systemd? If so,
>>> then you should use GPSD_INSTALL_INIT_SYSV and GPSD_INSTALL_INIT_SYSTEMD
>>> as pointed out by Maxime.
>>>
>>> This ensures the init script will only be installed if a SysV init
>>> scheme is used (and conversely for the systemd unit).
>>>
>>> Otherwise, please expand on why not wanting the init script should be
>>> configurable at all.
>>
>> There are other possibilities, beyond SysV and systemd: I've
>> previously run gpsd and other managed services using daemontools and
>> runit. My present use case has udev kicking off gpsd in response to
>> hotplug events for a USB GPS device.
>>
>> I seem to always end up having to remove the gpsd SysV init script in
>> my post-build script; hence the desire for a configuration option.
>
> Maybe you can add a BR2_INIT_NONE choice here then to not copy all the
> install scripts.

  There are just a few daemons that you'd want to run from hotplug, most 
of them would still run from init.d.

  But I really would like a better way to manage the services you want to 
run in init.d, and especially their order. I can't come up with a good 
solution, though, so I'm not actively complaining :-)

  I agree with Peter that having an option for each package is not a good 
solution.


  Regards,
  Arnout
Thomas Petazzoni June 18, 2013, 7:07 a.m. UTC | #8
Dear Arnout Vandecappelle,

On Tue, 18 Jun 2013 08:24:22 +0200, Arnout Vandecappelle wrote:

>   There are just a few daemons that you'd want to run from hotplug, most 
> of them would still run from init.d.
> 
>   But I really would like a better way to manage the services you want to 
> run in init.d, and especially their order. I can't come up with a good 
> solution, though, so I'm not actively complaining :-)

I believe it's typically the kind of customization that is left to the
user, through a post-build script. Buildroot provides a relatively sane
default installation, and the user has to further tweak it if needed. I
don't think we should make Buildroot more complex to allow directly in
the Buildroot configuration this kind of very specific customization.

Best regards,

Thomas
diff mbox

Patch

diff --git a/package/gpsd/Config.in b/package/gpsd/Config.in
index 337f8e7..29e061f 100644
--- a/package/gpsd/Config.in
+++ b/package/gpsd/Config.in
@@ -21,6 +21,13 @@  config BR2_PACKAGE_GPSD_DEVICES
 	default "/dev/ttyS1"
 	depends on BR2_PACKAGE_GPSD
 
+config BR2_PACKAGE_GPSD_INSTALL_INITSCRIPT
+	bool "install init script"
+	default y
+	depends on BR2_PACKAGE_GPSD
+	help
+	  Install a gpsd init script
+
 menu "Features"
 	depends on BR2_PACKAGE_GPSD
 
diff --git a/package/gpsd/gpsd.mk b/package/gpsd/gpsd.mk
index be2e681..45d1aed 100644
--- a/package/gpsd/gpsd.mk
+++ b/package/gpsd/gpsd.mk
@@ -207,12 +207,19 @@  define GPSD_INSTALL_TARGET_CMDS
 		$(SCONS) \
 		$(GPSD_SCONS_OPTS) \
 		install)
+endef
+
+define GPSD_INSTALL_INITSCRIPT
 	if [ ! -f $(TARGET_DIR)/etc/init.d/S50gpsd ]; then \
 		$(INSTALL) -m 0755 -D package/gpsd/S50gpsd $(TARGET_DIR)/etc/init.d/S50gpsd; \
 		$(SED) 's,^DEVICES=.*,DEVICES=$(BR2_PACKAGE_GPSD_DEVICES),' $(TARGET_DIR)/etc/init.d/S50gpsd; \
 	fi
 endef
 
+ifeq ($(BR2_PACKAGE_GPSD_INSTALL_INITSCRIPT),y)
+GPSD_POST_INSTALL_TARGET_HOOKS = GPSD_INSTALL_INITSCRIPT
+endif
+
 define GPSD_INSTALL_STAGING_CMDS
 	(cd $(@D); \
 		$(GPSD_SCONS_ENV) \