1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-03 01:23:49 +00:00

sysutils/rsfetch: fix memory reporting and add DragonFlyBSD support

Import upstream fix [1] to fix fix memory reporting and add DragonFlyBSD support.

[1] 2bd3ef9eaf

PR:		244861
Approved by:	Lewis Cook (maintainer), manu (mentor, implicit)
This commit is contained in:
Mikael Urankar 2020-03-18 08:34:36 +00:00
parent 61838c3a6d
commit 865ff6c103
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=528635
3 changed files with 49 additions and 0 deletions

View File

@ -2,6 +2,7 @@
PORTNAME= rsfetch
DISTVERSION= 2.0.0
PORTREVISION= 1
CATEGORIES= sysutils
MAINTAINER= vulcan@wired.sh

View File

@ -0,0 +1,20 @@
--- src/memory.rs.orig 2020-03-16 13:12:22 UTC
+++ src/memory.rs
@@ -74,12 +74,15 @@ impl RAMInfo {
self.used = Some(used / 1024_f64 / 1024_f64);
self.total = Some(total / 1024_f64 / 1024_f64);
return Ok(());
- } else if os == &OS::FreeBSD || os == &OS::Other {
+ } else if os == &OS::FreeBSD || os == &OS::DragonflyBSD {
let mut buffer = String::new();
Command::new("sysctl").arg("-n").arg("hw.physmem")
.output().context(RAMErr)?.stdout.iter()
.for_each(|b| buffer.push(*b as char));
- total = buffer.parse::<f64>().unwrap();
+
+ // remove non-integer chars from buffer
+ buffer = buffer.trim().replace("\n", "");
+ total = buffer.parse::<u64>().unwrap() as f64;
let pagesize: f64;
let inactive: f64;

View File

@ -0,0 +1,28 @@
--- src/util.rs.orig 2020-03-16 13:14:06 UTC
+++ src/util.rs
@@ -8,6 +8,7 @@ pub enum OS {
FreeBSD,
OpenBSD,
NetBSD,
+ DragonflyBSD,
Other
}
@@ -23,11 +24,12 @@ impl OSInfo {
.output()?.stdout.iter()
.for_each(|b| uname.push(*b as char));
let os = match uname.replace("\n", "").trim().as_ref() {
- "Linux" => OS::Linux,
- "FreeBSD" => OS::FreeBSD,
- "NetBSD" => OS::NetBSD,
- "OpenBSD" => OS::OpenBSD,
- &_ => OS::Other,
+ "Linux" => OS::Linux,
+ "FreeBSD" => OS::FreeBSD,
+ "NetBSD" => OS::NetBSD,
+ "OpenBSD" => OS::OpenBSD,
+ "DragonFly" => OS::DragonflyBSD,
+ &_ => OS::Other,
};
Ok(os)