forked from macports/macports-ports
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7aea4ba
commit a656aeb
Showing
3 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 | ||
|
||
PortSystem 1.0 | ||
PortGroup github 1.0 | ||
PortGroup legacysupport 1.1 | ||
PortGroup makefile 1.0 | ||
|
||
# getline, MAP_ANON | ||
legacysupport.newest_darwin_requires_legacy 14 | ||
|
||
github.setup alba4k albafetch 4.1 v | ||
revision 0 | ||
|
||
description Faster neofetch alternative, written in C | ||
long_description ${name} is a simple and fast program to display \ | ||
a lot of system information in a neofetch-like layout \ | ||
in way less than a second. | ||
|
||
categories sysutils | ||
installs_libs no | ||
license MIT | ||
maintainers {@barracuda156 gmail.com:vital.had} openmaintainer | ||
|
||
checksums rmd160 62266e581315914385ecaa1558641f4fb9e9312a \ | ||
sha256 3136765c40694bc71c8663fb90e90337a1826634ddec0bdc38b0ea6ad566f538 \ | ||
size 301380 | ||
github.tarball_from archive | ||
|
||
# https://github.com/alba4k/albafetch/pull/85 | ||
patchfiles-append 0001-macos_infos.c-fix-for-i386-and-ppc.patch \ | ||
0002-Fix-Makefile.patch | ||
|
||
# cc1: error: invalid option argument ‘-Ofast’ | ||
# error: ‘for’ loop initial declaration used outside C99 mode | ||
post-patch { | ||
reinplace "s|@PREFIX@|${destroot}${prefix}|" ${worksrcpath}/Makefile | ||
reinplace "s|@CFLAGS@|${configure.cflags} -std=c99 [get_canonical_archflags cc]|" ${worksrcpath}/Makefile | ||
reinplace "s|@LDFLAGS@|${configure.ldflags} [get_canonical_archflags ld]|" ${worksrcpath}/Makefile | ||
} | ||
|
||
depends_lib-append port:curl | ||
|
||
if {${os.platform} ne "darwin"} { | ||
depends_lib-append \ | ||
port:pciutils | ||
} | ||
|
||
compiler.c_standard 1999 |
67 changes: 67 additions & 0 deletions
67
sysutils/albafetch/files/0001-macos_infos.c-fix-for-i386-and-ppc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
From 6362e1d3538b5aeb61e02d6564802f9b536f81e8 Mon Sep 17 00:00:00 2001 | ||
From: barracuda156 <[email protected]> | ||
Date: Mon, 20 May 2024 13:43:36 +0800 | ||
Subject: [PATCH] macos_infos.c: fix for i386 and ppc | ||
|
||
diff --git src/macos_infos.c src/macos_infos.c | ||
index a1b4d19..8b90eb0 100644 | ||
--- src/macos_infos.c | ||
+++ src/macos_infos.c | ||
@@ -17,6 +17,22 @@ | ||
* Original source: | ||
* https://opensource.apple.com/source/system_cmds/system_cmds-496/vm_stat.tproj/vm_stat.c.auto.html | ||
*/ | ||
+#if defined(__i386__) || defined(__ppc__) | ||
+static int get_stats(struct vm_statistics *stat, mach_port_t host) { | ||
+ int error; | ||
+ | ||
+ unsigned count = HOST_VM_INFO_COUNT; | ||
+ error = host_statistics(host, | ||
+ HOST_VM_INFO, | ||
+ (host_info_t) stat, | ||
+ &count); | ||
+ | ||
+ if(error != KERN_SUCCESS) | ||
+ return error; | ||
+ | ||
+ return 0; | ||
+} | ||
+#else | ||
static int get_stats(struct vm_statistics64 *stat, mach_port_t host) { | ||
int error; | ||
|
||
@@ -31,6 +47,7 @@ | ||
|
||
return 0; | ||
} | ||
+#endif | ||
|
||
/* EXPORTS */ | ||
|
||
@@ -49,6 +66,20 @@ | ||
} | ||
|
||
bytes_t used_mem_size() { | ||
+#if defined(__i386__) || defined(__ppc__) | ||
+ pages_t active, wired, inactive; | ||
+ mach_port_t host = mach_host_self(); | ||
+ | ||
+ struct vm_statistics vm_stat; | ||
+ if(get_stats(&vm_stat, host) < 0) | ||
+ return 0; | ||
+ | ||
+ active = vm_stat.active_count; | ||
+ wired = vm_stat.wire_count; | ||
+ inactive = vm_stat.inactive_count; | ||
+ | ||
+ return (active + wired + inactive) * page_size(host); | ||
+#else | ||
pages_t internal, wired, compressed; | ||
mach_port_t host = mach_host_self(); | ||
|
||
@@ -61,4 +92,5 @@ | ||
compressed = vm_stat.compressor_page_count; | ||
|
||
return (internal + wired + compressed) * page_size(host); | ||
+#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From 94e2a1c916aa0bcba9f1d4631a8e56b8b0adbfaf Mon Sep 17 00:00:00 2001 | ||
From: barracuda156 <[email protected]> | ||
Date: Mon, 20 May 2024 14:26:01 +0800 | ||
Subject: [PATCH] Fix Makefile | ||
|
||
diff --git Makefile Makefile | ||
index e83e1eb..34cf077 100644 | ||
--- Makefile | ||
+++ Makefile | ||
@@ -1,7 +1,7 @@ | ||
.PHONY: build/albafetch | ||
|
||
CC := gcc | ||
-CFLAGS := -Wall -Wextra -Ofast | ||
+CFLAGS := -Wall -Wextra @CFLAGS@ | ||
TARGET := albafetch | ||
|
||
KERNEL := $(shell uname -s 2> /dev/null) | ||
@@ -26,8 +26,8 @@ | ||
OBJ := info.o main.o macos_infos.o bsdwrap.o macos_gpu_string.o utils.o | ||
SRC := src/main.c src/info.c src/queue.c src/macos_infos.c src/bsdwrap.c src/macos_gpu_string.m src/utils.c | ||
SRC_DEBUG := src/debug.c src/info.c src/queue.c src/macos_infos.c src/bsdwrap.c src/macos_gpu_string.m src/utils.c | ||
- INSTALLPATH := /usr/local/bin | ||
- INCLUDE := -framework Foundation -framework IOKit -l curl | ||
+ INSTALLPATH := @PREFIX@/bin | ||
+ INCLUDE := -framework Foundation -framework IOKit -lcurl @LDFLAGS@ | ||
endif | ||
|
||
all: build/$(TARGET) build/debug |