public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Davide Cavalca <dcavalca@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/rust-tiny-dfr] epel10: Backport upstream fix for ppc64le and s390x
Date: Fri, 25 Sep 2026 10:38:54 GMT	[thread overview]
Message-ID: <179033273473.1.11917992981066906026.rpms-rust-tiny-dfr-b466a8dafe20@fedoraproject.org> (raw)

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"]

                 reply	other threads:[~2026-09-25 10:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179033273473.1.11917992981066906026.rpms-rust-tiny-dfr-b466a8dafe20@fedoraproject.org \
    --to=dcavalca@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox