albafetch: update to 4.2.1

This commit is contained in:
Sergey Fedorov
2024-09-24 23:15:26 +08:00
committed by Herby Gillot
parent d822f541c6
commit 9344de0de6
5 changed files with 87 additions and 114 deletions
+25 -15
View File
@@ -3,13 +3,14 @@
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 1
# Commit-based until next release, to avoid numerous patches.
github.setup alba4k albafetch 430291185a85a018bea5832e6dac5ccbad1c3f6f
version 4.2.1
revision 0
description Faster neofetch alternative, written in C
long_description ${name} is a simple and fast program to display \
@@ -21,26 +22,35 @@ installs_libs no
license MIT
maintainers {@barracuda156 gmail.com:vital.had} openmaintainer
checksums rmd160 62266e581315914385ecaa1558641f4fb9e9312a \
sha256 3136765c40694bc71c8663fb90e90337a1826634ddec0bdc38b0ea6ad566f538 \
size 301380
checksums rmd160 6d4a5a959a31a108b1d7eba9ee7a3b0ec68de8f1 \
sha256 afee8da46c7d492736b7bd1ed8da4cd5f60b9228249d36a500fcdb0e4adec5db \
size 368259
github.tarball_from archive
# https://github.com/alba4k/albafetch/pull/85
patchfiles-append 0001-fix-macos_infos.patch \
0002-Fix-Makefile.patch
use_configure no
patchfiles-append 0001-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
reinplace "s|@DESTDIR@|${destroot}${prefix}|" ${worksrcpath}/Makefile
}
depends_lib-append port:curl
if {${os.platform} eq "darwin" && ${os.major} < 15} {
patchfiles-append \
0002-meson.build-legacysupport.patch
post-patch {
reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/meson.build
}
}
# Yes, it is called from a Makefile.
depends_build-append \
port:meson
if {${os.platform} ne "darwin"} {
depends_build-append \
path:bin/pkg-config:pkgconfig
depends_lib-append \
port:pciutils
}
@@ -0,0 +1,31 @@
--- meson.build
+++ meson.build
@@ -61,7 +61,7 @@
build_args = [
'-Wall',
'-Wextra',
- '-Ofast',
+ '-Os',
'-std=c99',
]
--- Makefile
+++ Makefile
@@ -1,6 +1,6 @@
.PHONY: build/albafetch
-OS := $(shell uname -o 2> /dev/null)
+OS := $(shell uname -s 2> /dev/null)
INSTALLPATH := /usr/local/bin
CONFIGPATH := /etc/xdg
@@ -17,7 +17,8 @@ endif
ifeq ($(OS),Darwin)
INSTALLFLAGS := -m755
CONFIGFLAGS := -m644
- CONFIGPATH := ~/.config/
+ INSTALLPATH := @DESTDIR@/bin
+ CONFIGPATH := @DESTDIR@/etc
MACOS_INFOS_H := src/macos_infos.h
BSDWRAP_H = src/bsdwrap.h
@@ -1,70 +0,0 @@
--- src/macos_infos.c
+++ src/macos_infos.c
@@ -17,6 +17,22 @@ static vm_size_t page_size(mach_port_t host) {
* 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 @@ static int get_stats(struct vm_statistics64 *stat, mach_port_t host) {
return 0;
}
+#endif
/* EXPORTS */
@@ -49,6 +66,20 @@ bytes_t system_mem_size() {
}
bytes_t used_mem_size() {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+ 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 @@ bytes_t used_mem_size() {
compressed = vm_stat.compressor_page_count;
return (internal + wired + compressed) * page_size(host);
+#endif
}
--- src/macos_infos.h
+++ src/macos_infos.h
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <mach/mach.h>
+#include <AvailabilityMacros.h>
#include "bsdwrap.h"
@@ -1,29 +0,0 @@
From 94e2a1c916aa0bcba9f1d4631a8e56b8b0adbfaf Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
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
@@ -0,0 +1,31 @@
diff --git meson.build meson.build
index 4349660..69d3b38 100644
--- meson.build
+++ meson.build
@@ -59,6 +59,7 @@ src_debug += src
src += 'src/main.c'
build_args = [
+ '-I@PREFIX@/include/LegacySupport',
'-Wall',
'-Wextra',
'-Os',
@@ -73,7 +74,8 @@ executable(
src,
dependencies : project_dependencies,
install : true,
- c_args : build_args
+ c_args : build_args,
+ link_args: ['-lMacportsLegacySupport']
)
executable(
@@ -81,6 +83,7 @@ executable(
src_debug,
dependencies : project_dependencies,
install : false,
- c_args : debug_args
+ c_args : debug_args,
+ link_args: ['-lMacportsLegacySupport']
)