gpsd: migrate option device to a list devices
authorFlorian Eckert <fe@dev.tdt.de>
Wed, 19 Feb 2025 08:31:02 +0000 (09:31 +0100)
committerFlorian Eckert <Eckert.Florian@googlemail.com>
Fri, 28 Feb 2025 07:13:00 +0000 (08:13 +0100)
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>
utils/gpsd/Makefile
utils/gpsd/files/etc/uci-defaults/50-gpsd-migrate-device [new file with mode: 0644]
utils/gpsd/files/gpsd.config
utils/gpsd/files/gpsd.init

index 806740b42c70506e28040956b8381342d4e1da0b..cd796eb672f9920de7c3d76f90edfbd0b9205a66 100644 (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
diff --git a/utils/gpsd/files/etc/uci-defaults/50-gpsd-migrate-device b/utils/gpsd/files/etc/uci-defaults/50-gpsd-migrate-device
new file mode 100644 (file)
index 0000000..9a164f7
--- /dev/null
@@ -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
index c0c88e0c46faf39b6012121a64f47e37e44ecefa..c49a44e3322a0368bb96af650f11f4a70968dc77 100644 (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'
index 5aad90ffc64dab83b98d74c21a4b231eff7958a6..94dcd2a6d7b7d7f1d4a87504980c2eb306461622 100644 (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