pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/wm/oatbar
Module Name: pkgsrc
Committed By: pin
Date: Mon Sep 14 14:39:47 UTC 2026
Modified Files:
pkgsrc/wm/oatbar: distinfo
Added Files:
pkgsrc/wm/oatbar/patches:
patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs
Log Message:
wm/oatbar: fix battery readout
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 pkgsrc/wm/oatbar/distinfo
cvs rdiff -u -r0 -r1.1 \
pkgsrc/wm/oatbar/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/wm/oatbar/distinfo
diff -u pkgsrc/wm/oatbar/distinfo:1.6 pkgsrc/wm/oatbar/distinfo:1.7
--- pkgsrc/wm/oatbar/distinfo:1.6 Thu Apr 16 07:56:20 2026
+++ pkgsrc/wm/oatbar/distinfo Mon Sep 14 14:39:46 2026
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.6 2026/04/16 07:56:20 pin Exp $
+$NetBSD: distinfo,v 1.7 2026/09/14 14:39:46 pin Exp $
BLAKE2s (addr2line-0.25.1.crate) = cc5c422ec48ccef5c2c46379d2f600644609490afafea5020f2020815d1146e6
SHA512 (addr2line-0.25.1.crate) = c400f3b6ccaff8a1c0d7d82c708a1784b8fd5ba64b6e420e85819d59b1cadb55fa59c852925093b921469f272d1d5140cf12f013ae75d1e1bc85021097df8fc2
@@ -1383,4 +1383,5 @@ Size (zvariant_derive-5.10.0.crate) = 16
BLAKE2s (zvariant_utils-3.3.0.crate) = 9dc2c0c28a434b74ad49042694b7bb9b6649a12dec80687690c50cb2b768903a
SHA512 (zvariant_utils-3.3.0.crate) = 55644ac7f81d60b414ac13e0da4db190ca58bc9d1d7ab82c447e0995d23970d3ebd9322ce7c066303e8455141bd91e2125618d924aaf17109d7015d49289f4d7
Size (zvariant_utils-3.3.0.crate) = 15417 bytes
+SHA1 (patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs) = 1cb29d0e51549b2abb8ab3b76d07d1116887163c
SHA1 (patch-Cargo.toml) = cb7ca6a33a9103279c95b0c94546780cb3bb5e47
Added files:
Index: pkgsrc/wm/oatbar/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs
diff -u /dev/null pkgsrc/wm/oatbar/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs:1.1
--- /dev/null Mon Sep 14 14:39:47 2026
+++ pkgsrc/wm/oatbar/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs Mon Sep 14 14:39:46 2026
@@ -0,0 +1,81 @@
+$NetBSD: patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs,v 1.1 2026/09/14 14:39:46 pin Exp $
+
+Fix battery readout using upstreams pull request.
+https://github.com/starship/rust-battery/pull/168
+
+--- ../vendor/starship-battery-0.11.0/src/platform/netbsd/sysmon.rs.orig 2026-09-14 11:26:29.446107617 +0000
++++ ../vendor/starship-battery-0.11.0/src/platform/netbsd/sysmon.rs
+@@ -1,3 +1,4 @@
++use std::ffi::CStr;
+ use std::fs;
+ use std::os::fd::AsRawFd;
+ use std::ptr::{addr_of_mut, null_mut, NonNull};
+@@ -49,9 +50,9 @@ pub fn get_system_envsys_plist() -> Result<plist::Dict
+ return Err(Error::invalid_data("Invalid result of EnvSys ioctl"));
+ }
+
+- let dict = plist::from_bytes(unsafe {
++ let dict = parse_envsys_plist(unsafe {
+ slice::from_raw_parts(plist_ref.pref_plist, plist_ref.pref_len)
+- })?;
++ });
+
+ unsafe {
+ // The netbsd libprop says ioctl returned mmap'ed memory that must be munmap'ed.
+@@ -64,5 +65,55 @@ pub fn get_system_envsys_plist() -> Result<plist::Dict
+ )?;
+ }
+
+- Ok(dict)
++ dict
++}
++
++/// Parse the XML plist the kernel hands back through `ENVSYS_GETDICTIONARY`.
++///
++/// libprop externalizes the dictionary as a C string and reports its length
++/// *including* the terminating NUL (`pref_len = strlen(buf) + 1`, see
++/// `common/lib/libprop/prop_kern.c`). Since plist 1.7.4 the XML reader
++/// rejects any non-whitespace after the closing `</plist>`, so the buffer is
++/// read as the C string it is, or every battery on NetBSD reads as
++/// "Problem while processing plist". A buffer with no NUL is parsed whole.
++fn parse_envsys_plist(bytes: &[u8]) -> Result<plist::Dictionary, Error> {
++ let document = CStr::from_bytes_until_nul(bytes).map_or(bytes, CStr::to_bytes);
++ Ok(plist::from_bytes(document)?)
++}
++
++#[cfg(test)]
++mod tests {
++ use super::parse_envsys_plist;
++
++ const ENVSYS: &str = concat!(
++ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
++ "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" ",
++ "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n",
++ "<plist version=\"1.0\">\n<dict>\n\t<key>acpibat0</key>\n\t<array>\n",
++ "\t\t<dict>\n\t\t\t<key>cur-value</key>\n\t\t\t<integer>1</integer>\n",
++ "\t\t\t<key>description</key>\n\t\t\t<string>present</string>\n",
++ "\t\t\t<key>state</key>\n\t\t\t<string>valid</string>\n",
++ "\t\t\t<key>type</key>\n\t\t\t<string>Indicator</string>\n\t\t</dict>\n",
++ "\t</array>\n</dict>\n</plist>\n"
++ );
++
++ #[test]
++ fn the_kernels_trailing_nul_is_not_part_of_the_document() {
++ let mut bytes = ENVSYS.as_bytes().to_vec();
++ bytes.push(0);
++ let dict = parse_envsys_plist(&bytes).expect("a NUL-terminated envsys plist parses");
++ assert!(dict.contains_key("acpibat0"));
++ }
++
++ #[test]
++ fn a_plist_without_the_nul_still_parses() {
++ let dict = parse_envsys_plist(ENVSYS.as_bytes()).expect("parses");
++ assert!(dict.contains_key("acpibat0"));
++ }
++
++ #[test]
++ fn only_nuls_is_an_error_not_a_panic() {
++ assert!(parse_envsys_plist(&[0, 0]).is_err());
++ assert!(parse_envsys_plist(&[]).is_err());
++ }
+ }
Home |
Main Index |
Thread Index |
Old Index