pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/shells/starship
Module Name: pkgsrc
Committed By: pin
Date: Mon Sep 14 14:31:42 UTC 2026
Modified Files:
pkgsrc/shells/starship: Makefile distinfo
Added Files:
pkgsrc/shells/starship/patches:
patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs
Log Message:
shells/starship: fix battery readout
See sysutils/mirador for details.
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 pkgsrc/shells/starship/Makefile
cvs rdiff -u -r1.42 -r1.43 pkgsrc/shells/starship/distinfo
cvs rdiff -u -r0 -r1.1 \
pkgsrc/shells/starship/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/shells/starship/Makefile
diff -u pkgsrc/shells/starship/Makefile:1.43 pkgsrc/shells/starship/Makefile:1.44
--- pkgsrc/shells/starship/Makefile:1.43 Mon Jun 29 08:05:37 2026
+++ pkgsrc/shells/starship/Makefile Mon Sep 14 14:31:42 2026
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.43 2026/06/29 08:05:37 pin Exp $
+# $NetBSD: Makefile,v 1.44 2026/09/14 14:31:42 pin Exp $
DISTNAME= starship-1.26.0
+PKGREVISION= 1
CATEGORIES= shells
MASTER_SITES= ${MASTER_SITE_GITHUB:=starship/}
GITHUB_TAG= v${PKGVERSION_NOREV}
Index: pkgsrc/shells/starship/distinfo
diff -u pkgsrc/shells/starship/distinfo:1.42 pkgsrc/shells/starship/distinfo:1.43
--- pkgsrc/shells/starship/distinfo:1.42 Mon Jun 29 08:05:37 2026
+++ pkgsrc/shells/starship/distinfo Mon Sep 14 14:31:42 2026
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.42 2026/06/29 08:05:37 pin Exp $
+$NetBSD: distinfo,v 1.43 2026/09/14 14:31:42 pin Exp $
BLAKE2s (aho-corasick-1.1.4.crate) = 1419308c5b0745af6cfa18dd4c9639f7078f564e9dacbe2b17b03df42c393409
SHA512 (aho-corasick-1.1.4.crate) = c77e35191b00546f5e499fab154170cedd619599e7250f92db9fba0a41c833eb426f214e58b00c5c39f8757406b33492b3241cb8cb233ce384ad0683c3ee4b62
@@ -1293,3 +1293,4 @@ Size (zvariant_derive-5.12.0.crate) = 17
BLAKE2s (zvariant_utils-3.4.0.crate) = 03272f0a7135bacdaa1162ec9bdac6e0787afc68d2ca921d411f9ca9f6254892
SHA512 (zvariant_utils-3.4.0.crate) = bd97f696e7eb03fb1909091f40341b711c490f62148603ba9ede60a932ce92264fb9e9de4b283fe411614c2dacb502436eb228c837a237fa87d0dee4304b54ee
Size (zvariant_utils-3.4.0.crate) = 15843 bytes
+SHA1 (patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs) = 1cb29d0e51549b2abb8ab3b76d07d1116887163c
Added files:
Index: pkgsrc/shells/starship/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs
diff -u /dev/null pkgsrc/shells/starship/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs:1.1
--- /dev/null Mon Sep 14 14:31:42 2026
+++ pkgsrc/shells/starship/patches/patch-.._vendor_starship-battery-0.11.0_src_platform_netbsd_sysmon.rs Mon Sep 14 14:31:42 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:31:42 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