package/gpsd: add option to enable/disable the daemon

Some scenarii, like building an RTK base, does not require a gpsd
daemon, but just a few python based tools (e.g. the python scripts
to configure a GNSS device).

Add an option to enable or disable building and instaling the daemon.
We make it enabled by default, for legacy purposes.

When the daemon is installed, it also installs a few ancillary helpers,
which need some of the clients (e.g. the udev rule will use gpsdctl), so
ensure they are enabled with the daemon.

Speaking of the udev rule: without the daemon, it does not need to be
installed, so only try to fix its mode when the daemomn is installed.

Similarly for systemd, no need to install the drop-in when the daemon is
not installed. And for sysv init, no need for a startup script without
the daemon either.

Now that everything is optional, daemon, clients, and python stuff, we
need to ensure that at least something is installed. The obvious
solution would be to ensure that the daemon is installed, but that
causes conflicts in the Kconfig depencies (elided for readability):

    config BR2_PACAKGE_GPSD
        bool "gpsd:
        select BR2_PACKAGE_GPSD_DAEMON if ! BR2_PACKAGE_GPSD_CLIENTS \
                                       && ! BR2_PACKAGE_GPSD_PYTHON

    config BR2_PACKAGE_GPSD_DAEMON
        bool "daemon"
        select BR2_PACKAGE_GPSD_CLIENTS

would cause errors like:

    package/gpsd/Config.in:27:error: recursive dependency detected!
    package/gpsd/Config.in:27:      symbol BR2_PACKAGE_GPSD_DAEMON is selected by BR2_PACKAGE_GPSD_CLIENTS
    package/gpsd/Config.in:226:     symbol BR2_PACKAGE_GPSD_CLIENTS is selected by BR2_PACKAGE_GPSD_DAEMON

So we chose the next best option: ensure that the clients get built, if
nothing else does.

Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Cc: Bernd Kuhls <bernd@kuhls.net>
Reviewed-by: Jan Havran <havran.jan@email.cz>
Tested-by: Jan Havran <havran.jan@email.cz>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Yann E. MORIN 2024-07-09 16:24:01 +02:00 committed by Thomas Petazzoni
parent ef35d60e1a
commit f6aa6d1a5f
2 changed files with 49 additions and 26 deletions

View file

@ -9,6 +9,8 @@ menuconfig BR2_PACKAGE_GPSD
depends on BR2_TOOLCHAIN_HAS_THREADS
# Always tries to build a shared library
depends on !BR2_STATIC_LIBS
select BR2_PACKAGE_GPSD_CLIENTS if !BR2_PACKAGE_GPSD_DAEMON \
&& !BR2_PACKAGE_GPSD_PYTHON
help
gpsd is a service daemon that monitors one or more GPSes or
AIS receivers attached to a host computer through serial or
@ -22,6 +24,15 @@ menuconfig BR2_PACKAGE_GPSD
if BR2_PACKAGE_GPSD
config BR2_PACKAGE_GPSD_DAEMON
bool "gpsd daemon"
default y # legacy
select BR2_PACKAGE_GPSD_CLIENTS
help
Build and install the gpsd daemon itself
if BR2_PACKAGE_GPSD_DAEMON
config BR2_PACKAGE_GPSD_DEVICES
string "Where to look for GPSes"
default "/dev/ttyS1"
@ -210,6 +221,8 @@ config BR2_PACKAGE_GPSD_UBX
help
uBlox UBX binary support
endif # GPSD_DAEMON
config BR2_PACKAGE_GPSD_CLIENTS
bool "gpsd clients"
default y # legacy

View file

@ -26,8 +26,7 @@ GPSD_SCONS_OPTS = \
prefix=/usr \
sysroot=$(STAGING_DIR) \
strip=no \
qt=no \
systemd=$(if $(BR2_INIT_SYSTEMD),yes,no)
qt=no
ifeq ($(BR2_PACKAGE_NCURSES),y)
GPSD_DEPENDENCIES += ncurses
@ -178,6 +177,40 @@ ifeq ($(BR2_PACKAGE_GPSD_MAX_DEV),y)
GPSD_SCONS_OPTS += max_devices=$(BR2_PACKAGE_GPSD_MAX_DEV_VALUE)
endif
ifeq ($(BR2_PACKAGE_GPSD_DAEMON),y)
GPSD_SCONS_OPTS += \
gpsd=yes \
systemd=$(if $(BR2_INIT_SYSTEMD),yes,no)
GPSD_INSTALL_RULE = $(if $(BR2_PACKAGE_HAS_UDEV),udev-install,install)
# When using chrony, wait for after Buildroot's chrony.service
ifeq ($(BR2_PACKAGE_CHRONY),y)
define GPSD_INSTALL_INIT_SYSTEMD
$(INSTALL) -D -m 0644 $(GPSD_PKGDIR)/br-chrony.conf \
$(TARGET_DIR)/usr/lib/systemd/system/gpsd.service.d/br-chrony.conf
endef
endif
define GPSD_INSTALL_INIT_SYSV
$(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
endef
# After the udev rule is installed, make it writable so that this
# package can be re-built/re-installed.
ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
define GPSD_INSTALL_UDEV_RULES
chmod u+w $(TARGET_DIR)/lib/udev/rules.d/25-gpsd.rules
endef
GPSD_POST_INSTALL_TARGET_HOOKS += GPSD_INSTALL_UDEV_RULES
endif
else # GPSD_DAEMON
GPSD_SCONS_OPTS += gpsd=no systemd=no
GPSD_INSTALL_RULE = install
endif
ifeq ($(BR2_PACKAGE_GPSD_CLIENTS),y)
GPSD_SCONS_OPTS += gpsdclients=yes
else
@ -211,22 +244,9 @@ define GPSD_INSTALL_TARGET_CMDS
DESTDIR=$(TARGET_DIR) \
$(SCONS) \
$(GPSD_SCONS_OPTS) \
$(if $(BR2_PACKAGE_HAS_UDEV),udev-install,install))
$(GPSD_INSTALL_RULE))
endef
define GPSD_INSTALL_INIT_SYSV
$(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
endef
# When using chrony, wait for after Buildroot's chrony.service
ifeq ($(BR2_PACKAGE_CHRONY),y)
define GPSD_INSTALL_INIT_SYSTEMD
$(INSTALL) -D -m 0644 $(GPSD_PKGDIR)/br-chrony.conf \
$(TARGET_DIR)/usr/lib/systemd/system/gpsd.service.d/br-chrony.conf
endef
endif
define GPSD_INSTALL_STAGING_CMDS
(cd $(@D); \
$(GPSD_SCONS_ENV) \
@ -236,14 +256,4 @@ define GPSD_INSTALL_STAGING_CMDS
install)
endef
# After the udev rule is installed, make it writable so that this
# package can be re-built/re-installed.
ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
define GPSD_INSTALL_UDEV_RULES
chmod u+w $(TARGET_DIR)/lib/udev/rules.d/25-gpsd.rules
endef
GPSD_POST_INSTALL_TARGET_HOOKS += GPSD_INSTALL_UDEV_RULES
endif
$(eval $(generic-package))