package/swupdate: add option to enable USB install
authorJames Hilliard <james.hilliard1@gmail.com>
Sun, 19 Sep 2021 08:09:02 +0000 (02:09 -0600)
committerYann E. MORIN <yann.morin.1998@free.fr>
Sun, 19 Sep 2021 09:30:02 +0000 (11:30 +0200)
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[yann.morin.1998@free.fr:
  - do not default to 'y'
  - add comment
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
package/swupdate/Config.in
package/swupdate/swupdate-usb.rules [new file with mode: 0644]
package/swupdate/swupdate.mk

index 6b832cfcbf45106218d6b893273a69094eb51141..7d9fc90e10c67a3deec55da29f978a65c643c362 100644 (file)
@@ -60,6 +60,15 @@ config BR2_PACKAGE_SWUPDATE_CONFIG
          I you wish to use your own modified swupdate configuration
          file specify the config file location with this option.
 
+config BR2_PACKAGE_SWUPDATE_USB
+       bool "swupdate usb"
+       depends on BR2_PACKAGE_SYSTEMD
+       help
+         Enable update from USB disk.
+
+comment "swupdate usb needs systemd"
+       depends on !BR2_PACKAGE_SYSTEMD
+
 config BR2_PACKAGE_SWUPDATE_WEBSERVER
        bool "swupdate webserver"
        default y
diff --git a/package/swupdate/swupdate-usb.rules b/package/swupdate/swupdate-usb.rules
new file mode 100644 (file)
index 0000000..72e003d
--- /dev/null
@@ -0,0 +1 @@
+ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_BUS}=="usb", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}+="swupdate-usb@%k.service"
index e191ab384a40b52e730beab3e3d81a0b488a9bb0..5ed2ca55d2a23801a99ab5743568cfb74277599b 100644 (file)
@@ -252,6 +252,9 @@ define SWUPDATE_INSTALL_INIT_SYSTEMD
                $(TARGET_DIR)/usr/lib/systemd/system/swupdate.socket
        $(INSTALL) -D -m 644 $(SWUPDATE_PKGDIR)/swupdate-usb@.service \
                $(TARGET_DIR)/usr/lib/systemd/system/swupdate-usb@.service
+       $(if $(BR2_PACKAGE_SWUPDATE_USB), \
+               $(INSTALL) -D -m 644 $(SWUPDATE_PKGDIR)/swupdate-usb.rules \
+                       $(TARGET_DIR)/lib/udev/rules.d/swupdate-usb.rules)
        $(INSTALL) -D -m 644 $(SWUPDATE_PKGDIR)/swupdate-progress.service \
                $(TARGET_DIR)/usr/lib/systemd/system/swupdate-progress.service
        $(INSTALL) -D -m 644 $(SWUPDATE_PKGDIR)/tmpfiles-swupdate.conf \