Selaa lähdekoodia

swupdategui-rs: build on scarthgap

The recipe was written for releases after scarthgap:

- set S, the git fetcher unpacks into ${WORKDIR}/git
- use WORKDIR, UNPACKDIR is not defined in scarthgap
- patch the GUI to build with LVGL 9.2, the version provided by this
  layer for scarthgap
- install the same SysV init script as swupdate-gui: the recipe
  shipped only a systemd unit, so the GUI did not start on sysvinit
  systems

Document in the README which layers are needed for Rust and clang.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
Stefano Babic 2 päivää sitten
vanhempi
commit
90c4d8c17f

+ 13 - 0
README

@@ -12,6 +12,19 @@ This layer depends on:
 URI: git://github.com/openembedded/meta-openembedded.git
 subdirectory: meta-oe
 
+Recovery GUI in Rust (swupdategui-rs)
+-------------------------------------
+
+swupdategui-rs needs more than scarthgap provides:
+
+* Rust >= 1.77 (scarthgap ships 1.75), for example from
+  URI: https://git.yoctoproject.org/meta-lts-mixins
+  branch: scarthgap/rust
+* clang-native, from
+  URI: https://github.com/kraj/meta-clang
+  branch: scarthgap
+* LVGL >= 9.2: this layer provides LVGL 9.2.2
+
 Documentation for the layer
 ---------------------------
 

+ 62 - 0
recipes-support/rescuegui/swupdategui-rs/0001-lv-build-with-LVGL-9.2.patch

@@ -0,0 +1,62 @@
+From 11f311332ab8307607884ce176d2b8ac05a623a9 Mon Sep 17 00:00:00 2001
+From: Stefano Babic <stefano.babic@swupdate.org>
+Date: Fri, 23 Oct 2026 13:59:43 +0200
+Subject: [PATCH] lv: build with LVGL 9.2
+
+LVGL 9.2 declares lv_state_t as uint16_t, while bindgen emits the
+LV_STATE_* values as u32. Accept any integer convertible to u32 in the
+state helpers and cast it to lv_state_t.
+
+lv_slider_set_value() takes an lv_anim_enable_t up to 9.2 and a bool
+in later versions: pass the default value, that is "animation off"
+for both.
+
+Upstream-Status: Pending
+Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
+---
+ src/lv.rs | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/src/lv.rs b/src/lv.rs
+index 55d7fe3..6eb41e0 100644
+--- a/src/lv.rs
++++ b/src/lv.rs
+@@ -215,16 +215,17 @@ impl Obj {
+         self.remove_flag(sys::LV_OBJ_FLAG_SCROLLABLE);
+     }
+ 
+-    pub fn add_state(self, state: sys::lv_state_t) {
+-        unsafe { sys::lv_obj_add_state(self.raw(), state) }
++    /* LVGL 9.2: lv_state_t is u16 but bindgen emits the LV_STATE_* values as u32 */
++    pub fn add_state(self, state: impl Into<u32>) {
++        unsafe { sys::lv_obj_add_state(self.raw(), state.into() as sys::lv_state_t) }
+     }
+ 
+-    pub fn remove_state(self, state: sys::lv_state_t) {
+-        unsafe { sys::lv_obj_remove_state(self.raw(), state) }
++    pub fn remove_state(self, state: impl Into<u32>) {
++        unsafe { sys::lv_obj_remove_state(self.raw(), state.into() as sys::lv_state_t) }
+     }
+ 
+-    pub fn has_state(self, state: sys::lv_state_t) -> bool {
+-        unsafe { sys::lv_obj_has_state(self.raw(), state) }
++    pub fn has_state(self, state: impl Into<u32>) -> bool {
++        unsafe { sys::lv_obj_has_state(self.raw(), state.into() as sys::lv_state_t) }
+     }
+ 
+     /* styles */
+@@ -292,8 +293,10 @@ impl Obj {
+ 
+     /* slider */
+ 
++    /* The animation flag is lv_anim_enable_t up to LVGL 9.2 and bool later:
++     * the default value is "off" for both */
+     pub fn slider_set_value(self, value: i32) {
+-        unsafe { sys::lv_slider_set_value(self.raw(), value, false) }
++        unsafe { sys::lv_slider_set_value(self.raw(), value, Default::default()) }
+     }
+ 
+     /* text area */
+-- 
+2.53.0
+

+ 21 - 3
recipes-support/rescuegui/swupdategui-rs_git.bb

@@ -8,17 +8,27 @@ LICENSE = "GPL-2.0-or-later"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=de4b1111cc7f3c8bc81546de6f9b24e4"
 
 SRC_URI = "git://github.com/sbabic/SWUpdateGUI.git;protocol=https;branch=rust-port \
+	file://0001-lv-build-with-LVGL-9.2.patch \
+	file://swupdate-gui \
 	file://swupdate-gui.service \
 	file://90-recovery-gui.rules \
 	"
 SRCREV = "e904a5768fba63dc484d2fdc948ae10772406af9"
 
+S = "${WORKDIR}/git"
+
 PV = "1.0.0+git"
 
 include swupdategui-rs-crates.inc
 
-inherit cargo cargo-update-recipe-crates pkgconfig systemd
+inherit cargo cargo-update-recipe-crates pkgconfig update-rc.d systemd
 
+# Requirements in scarthgap:
+# - Rust >= 1.77 (scarthgap ships 1.75), for example from meta-lts-mixins,
+#   branch scarthgap/rust
+# - LVGL >= 9.2 (provided by this layer)
+# - clang-native from meta-clang
+#
 # Bindings for LVGL and libswupdate are generated by bindgen, which needs libclang.
 # LVGL is found with pkg-config, libswupdate in the target sysroot.
 DEPENDS += "clang-native lvgl swupdate"
@@ -27,11 +37,19 @@ export BINDGEN_EXTRA_CLANG_ARGS = "--sysroot=${STAGING_DIR_HOST} -I${STAGING_INC
 export SWUPDATE_INCLUDE_DIR = "${STAGING_INCDIR}"
 export SWUPDATE_LIB_DIR = "${STAGING_LIBDIR}"
 
+INITSCRIPT_NAME = "swupdate-gui"
+INITSCRIPT_PARAMS = "defaults 90"
 SYSTEMD_SERVICE:${PN} = "swupdate-gui.service"
 
 do_install:append() {
 	install -d ${D}${systemd_system_unitdir}
-	install -m 0644 ${UNPACKDIR}/swupdate-gui.service ${D}${systemd_system_unitdir}
+	install -m 0644 ${WORKDIR}/swupdate-gui.service ${D}${systemd_system_unitdir}
+
+	# Same init script as the C implementation
+	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
+		install -d ${D}${sysconfdir}/init.d
+		install -m 0755 ${WORKDIR}/swupdate-gui ${D}${sysconfdir}/init.d/
+	fi
 
 	install -d ${D}${sysconfdir}/recovery_gui
 	install -m 0644 ${S}/config/config.txt ${D}${sysconfdir}/recovery_gui/
@@ -43,7 +61,7 @@ do_install:append() {
 
 	# The GUI opens /dev/fb and /dev/input/{keyboard0,touchscreen0}
 	install -d ${D}${sysconfdir}/udev/rules.d
-	install -m 0644 ${UNPACKDIR}/90-recovery-gui.rules ${D}${sysconfdir}/udev/rules.d/
+	install -m 0644 ${WORKDIR}/90-recovery-gui.rules ${D}${sysconfdir}/udev/rules.d/
 }
 
 FILES:${PN} += "${sysconfdir}/udev/rules.d/90-recovery-gui.rules"