gpsd: migrate option device to a list devices

More than one device can be added to the gpsd at startup. Currently the gpsd
service start script in OpenWrt treats this as an option with only one value.
To allow multiple devices to be specified, the uci 'option device' must be
removed and a new uci 'list devices' is added.

This change means that several devices can be specified at gpsd start with
the new uci 'list devices' configuration.

Running configurations in the field are migrated by a migration script.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2025-02-19 09:31:02 +01:00 committed by Florian Eckert
parent e377d07afd
commit ace9f160ce
4 changed files with 28 additions and 4 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=gpsd
PKG_VERSION:=3.25
PKG_RELEASE:=6
PKG_RELEASE:=7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@SAVANNAH/$(PKG_NAME)
@ -144,6 +144,9 @@ define Package/gpsd/install
$(INSTALL_DIR) $(1)/etc/gpsd
$(INSTALL_BIN) ./files/etc/gpsd/device-hook $(1)/etc/gpsd/
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DATA) ./files/etc/uci-defaults/* $(1)/etc/uci-defaults/
endef
define Package/gpsd-clients/install

View File

@ -0,0 +1,17 @@
. /lib/functions.sh
gpsd_migrate_device() {
local device
device="$(uci_get gpsd core device)"
[ -z "$device" ] && return
uci_add_list gpsd core devices "$device"
uci_remove gpsd core device
uci_commit gpsd
}
gpsd_migrate_device
exit 0

View File

@ -1,5 +1,5 @@
config gpsd 'core'
option enabled '0'
option device '/dev/ttyUSB0'
option port '2947'
option listen_globally '0'
list devices '/dev/ttyUSB0'

View File

@ -13,13 +13,15 @@ validate_section_gpsd()
uci_load_validate gpsd gpsd "$1" "$2" \
'enabled:bool:1' \
'readonly:bool:1' \
'device:string' \
'devices:list(string)' \
'listen_globally:bool:0' \
'port:port:2947'
}
gpsd_instance()
{
local device
[ "$2" = 0 ] || {
echo "validation failed"
return 1
@ -35,7 +37,9 @@ gpsd_instance()
procd_append_param command -D "$LOG_LEVEL"
[ "$readonly" = "1" ] && procd_append_param command -b
procd_append_param command -F /var/run/gpsd.sock
[ -n "$device" ] && procd_append_param command "$device"
for device in $devices; do
procd_append_param command "$device"
done
procd_set_param respawn
procd_close_instance