public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rust-tiny-dfr] epel10: Backport upstream fix for ppc64le and s390x
@ 2026-09-25 10:38 Davide Cavalca
  0 siblings, 0 replies; only message in thread
From: Davide Cavalca @ 2026-09-25 10:38 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/rust-tiny-dfr
Branch : epel10
Commit : b466a8dafe20b4167a2668236edf619ac4f13fc3
Author : Davide Cavalca <dcavalca@fedoraproject.org>
Date   : 2026-03-01T13:04:24-08:00
Stats  : +71/-0 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/rust-tiny-dfr/c/b466a8dafe20b4167a2668236edf619ac4f13fc3?branch=epel10

Log:
Backport upstream fix for ppc64le and s390x

---
diff --git a/81.patch b/81.patch
new file mode 100644
index 0000000..b6f8c44
--- /dev/null
+++ b/81.patch
@@ -0,0 +1,66 @@
+From 815ebf83c4d682387629cf56dae5dfa350cdfd28 Mon Sep 17 00:00:00 2001
+From: Davide Cavalca <davide@asahilinux.org>
+Date: Sun, 1 Mar 2026 12:44:44 -0800
+Subject: [PATCH] Add a battery state fallback for all arches
+
+Signed-off-by: Davide Cavalca <davide@asahilinux.org>
+---
+ src/main.rs | 43 ++++++++++++++++++++++---------------------
+ 1 file changed, 22 insertions(+), 21 deletions(-)
+
+diff --git a/src/main.rs b/src/main.rs
+index 5be5b162..dbfca833 100644
+--- a/src/main.rs
++++ b/src/main.rs
+@@ -207,29 +207,30 @@ fn get_battery_state(battery: &str) -> (u32, BatteryState) {
+     let status = fs::read_to_string(&status_path)
+         .unwrap_or_else(|_| "Unknown".to_string());
+ 
+-    #[cfg(target_arch = "x86_64")]
+     let capacity = {
+-        let charge_now_path = format!("/sys/class/power_supply/{}/charge_now", battery);
+-        let charge_full_path = format!("/sys/class/power_supply/{}/charge_full", battery);
+-        let charge_now = fs::read_to_string(&charge_now_path)
+-            .ok()
+-            .and_then(|s| s.trim().parse::<f64>().ok());
+-        let charge_full = fs::read_to_string(&charge_full_path)
+-            .ok()
+-            .and_then(|s| s.trim().parse::<f64>().ok());
+-        match (charge_now, charge_full) {
+-            (Some(now), Some(full)) if full > 0.0 => ((now / full) * 100.0).round() as u32,
+-            _ => 100,
++        #[cfg(target_arch = "x86_64")]
++        {
++            let charge_now_path = format!("/sys/class/power_supply/{}/charge_now", battery);
++            let charge_full_path = format!("/sys/class/power_supply/{}/charge_full", battery);
++            let charge_now = fs::read_to_string(&charge_now_path)
++                .ok()
++                .and_then(|s| s.trim().parse::<f64>().ok());
++            let charge_full = fs::read_to_string(&charge_full_path)
++                .ok()
++                .and_then(|s| s.trim().parse::<f64>().ok());
++            match (charge_now, charge_full) {
++                (Some(now), Some(full)) if full > 0.0 => ((now / full) * 100.0).round() as u32,
++                _ => 100,
++            }
++        }
++        #[cfg(not(target_arch = "x86_64"))]
++        {
++            let capacity_path = format!("/sys/class/power_supply/{}/capacity", battery);
++            fs::read_to_string(&capacity_path)
++                .ok()
++                .and_then(|s| s.trim().parse::<u32>().ok())
++                .unwrap_or(100)
+         }
+-    };
+-
+-    #[cfg(target_arch = "aarch64")]
+-    let capacity = {
+-        let capacity_path = format!("/sys/class/power_supply/{}/capacity", battery);
+-        fs::read_to_string(&capacity_path)
+-            .ok()
+-            .and_then(|s| s.trim().parse::<u32>().ok())
+-            .unwrap_or(100)
+     };
+ 
+     let status = match status.trim() {

diff --git a/rust-tiny-dfr.spec b/rust-tiny-dfr.spec
index 1835ca9..9f7c826 100644
--- a/rust-tiny-dfr.spec
+++ b/rust-tiny-dfr.spec
@@ -11,6 +11,8 @@ Summary:        Most basic dynamic function row daemon possible
 License:        MIT AND Apache-2.0
 URL:            https://crates.io/crates/tiny-dfr
 Source:         %{crates_source}
+# * Add a battery state fallback for all arches
+Patch2:         https://github.com/AsahiLinux/tiny-dfr/pull/81.patch
 
 BuildRequires:  cargo-rpm-macros >= 24
 BuildRequires:  systemd-rpm-macros

diff --git a/rust2rpm.toml b/rust2rpm.toml
index 679c015..17b060c 100644
--- a/rust2rpm.toml
+++ b/rust2rpm.toml
@@ -6,6 +6,9 @@ extra-files = [
   "%dir %{_sysconfdir}/%{crate}/",
   "%config(noreplace) %ghost %{_sysconfdir}/%{crate}/config.toml",
 ]
+extra-patches = [
+  { number = 2, file = "https://github.com/AsahiLinux/tiny-dfr/pull/81.patch", comments = ["Add a battery state fallback for all arches"] },
+]
 
 [requires]
 build = ["systemd-rpm-macros"]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-25 10:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 10:38 [rpms/rust-tiny-dfr] epel10: Backport upstream fix for ppc64le and s390x Davide Cavalca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox