From 25ae0cfad9e152b35232a5fc33941f49a464588c Mon Sep 17 00:00:00 2001 From: Nexoniarz Date: Sat, 12 Sep 2026 19:08:53 +0200 Subject: [PATCH] ports: fastfetch, unpatched, and /etc/os-release so it can name us fastfetch builds and runs on SchOS: OS: SchOS 0.1.0 x86_64 Kernel: SchIFT 0.1.0 Shell: sh Terminal: schinit CPU: AMD Ryzen 7 5700G Memory: 11.94 MiB / 1016.93 MiB (1%) Disk (/): 4.64 MiB / 31.25 MiB (15%) - schfs Here because it is a good acceptance test, not because SchOS needs a fetch tool. It is ~410 C files somebody else wrote against Linux rather than against our bugs, and running it exercises procfs, per-process directories, uname, statfs, getpwuid, terminal detection by walking ppid, and an ANSI renderer all at once -- which is the shape docs/plan/roadmap.md asked for when the previous full-stack test was removed. patches/ is empty and should stay that way. When fastfetch cannot detect something the answer is to give the system the thing it is looking for, because every other program looks for the same things. Its first run reported four misses and they are being worked in that order: OS: Could not detect OS -> /etc/os-release, this commit Local IP: getifaddrs() failed -> AF_NETLINK, next Host: not set by O.E.M. -> DMI in /sys, later Users: Unable to detect any users -> utmp, a userland convention Four things the port needs that say nothing about SchOS, recorded in the Makefile because each cost time to find: * Every ENABLE_* off. All 29 files calling dlopen are optional detection modules, and ENABLE_THREADS=OFF removes the single pthread_create -- which matters, because clone() here does not share an address space. * -isystem the compiler's own include dir. -nostdinc removes it too, and cpuid.h is emitted by the compiler with no musl equivalent. * Linux UAPI headers. musl ships none by design; a musl toolchain is normally paired with a separate linux-headers install. * libgcc on the link line, and libc twice -- libgcc pulls symbols back out of it (__popcountdi2), and a static link resolves left to right. The toolchain settings are a CMake toolchain file rather than command-line flags because CMAKE_*_INIT variables are only honoured when the cache is first created. Reconfiguring an existing build directory ignores them silently. Also rebuilt musl: build/ports/musl/prefix/bin/musl-gcc had the pre-move path /home/nexoniarz/Documents/SchOS baked in by configure. The tree does not use that wrapper -- it links with explicit -I/-L and crt objects -- so nothing was broken by it, but it was stale and would mislead anyone who found it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2 --- NOTICE | 8 +++ etc/os-release | 9 +++ ports/fastfetch/Makefile | 98 ++++++++++++++++++++++++++++++++ ports/fastfetch/patches/.gitkeep | 0 4 files changed, 115 insertions(+) create mode 100644 etc/os-release create mode 100644 ports/fastfetch/Makefile create mode 100644 ports/fastfetch/patches/.gitkeep diff --git a/NOTICE b/NOTICE index c092ccf..113b5b9 100644 --- a/NOTICE +++ b/NOTICE @@ -178,3 +178,11 @@ work there. See docs/layout.md. Licence questions -- what may be copied in, what may never be, and how to check a NetBSD file's clause before using it -- are worked through in docs/licensing.md. + +fastfetch MIT +https://github.com/fastfetch-cli/fastfetch +Copyright (c) 2022 Linus Dierheimer and contributors + + Built from source by ports/fastfetch and installed as /bin/fastfetch. + Unpatched: see the note at the top of that Makefile about why what it + cannot detect becomes work in the kernel rather than a patch here. diff --git a/etc/os-release b/etc/os-release new file mode 100644 index 0000000..953e2b1 --- /dev/null +++ b/etc/os-release @@ -0,0 +1,9 @@ +NAME="SchOS" +PRETTY_NAME="SchOS" +ID=schos +VERSION="0.1.0" +VERSION_ID=0.1.0 +BUILD_ID=0.1.0 +HOME_URL="https://github.com/Nexoniarz/SchOS" +LOGO=schos +ANSI_COLOR="0;35" diff --git a/ports/fastfetch/Makefile b/ports/fastfetch/Makefile new file mode 100644 index 0000000..4e890d6 --- /dev/null +++ b/ports/fastfetch/Makefile @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: Apache-2.0 +# fastfetch -- system information, MIT: https://github.com/fastfetch-cli/fastfetch +# +# Here because it is a good acceptance test, not because SchOS needs a fetch +# tool. It is ~410 C files somebody else wrote, against Linux rather than +# against our bugs, and running it exercises procfs, per-process directories, +# uname, statfs, getpwuid, terminal detection by walking ppid, and an ANSI +# renderer -- all at once, and it notices when any of them lies. +# +# **It is built unpatched.** patches/ is empty and should stay that way: when +# fastfetch cannot detect something the right answer is to give the system the +# thing it is looking for, because every other program looks for the same +# things. What it could not find on the first run became work in the kernel and +# in sysroot/etc, not sed lines here. + +include ../mk/port.mk + +FF_VERSION := 2.30.0 +FF_URL := https://github.com/fastfetch-cli/fastfetch/archive/refs/tags/$(FF_VERSION).tar.gz +FF_SHA256 := 5047f925e480e065e8b28da1e6cc5b31ffdc1ad205ec74a9ea709fb5bcaacd8a + +TARBALL := $(DISTDIR)/fastfetch-$(FF_VERSION).tar.gz + +# Linux UAPI headers. musl deliberately ships none -- a musl toolchain is +# normally paired with a separate linux-headers install -- and fastfetch's +# Linux detection includes linux/ethtool.h and friends directly. Overridable +# because the path is a property of the build host, not of this port. +LINUX_HEADERS ?= $(shell for d in /usr/include /nix/store/*-linux-headers-*/include; do \ + test -f "$$d/linux/ethtool.h" && { echo "$$d"; break; }; done) + +# gcc rather than port.mk's clang: this is the one port whose upstream expects +# a GNU-ish driver, and the two disagree about -print-libgcc-file-name. +HOSTCC_FF ?= gcc + +# The compiler's own headers, which -nostdinc also removes. cpuid.h lives here, +# not in libc: it is emitted by the compiler and has no musl equivalent. +GCC_INC := $(shell $(HOSTCC_FF) -print-file-name=include) +LIBGCC := $(shell $(HOSTCC_FF) -print-libgcc-file-name) + +# Every optional feature off. All 29 files that call dlopen are in optional +# detection modules, and ENABLE_THREADS=OFF removes the single pthread_create -- +# which matters because SchOS's clone() does not share an address space. +FF_OFF := VULKAN WAYLAND XCB_RANDR XCB XRANDR X11 DRM DRM_AMDGPU GIO DCONF \ + DBUS XFCONF SQLITE3 RPM IMAGEMAGICK7 IMAGEMAGICK6 CHAFA ZLIB EGL \ + GLX OSMESA OPENCL FREETYPE PULSE DDCUTIL DIRECTX_HEADERS ELF \ + THREADS LIBZFS PCIACCESS SYSTEM_YYJSON LTO + +$(TARBALL): | $(DISTDIR) + curl -fsSL -o $@ $(FF_URL) + sh $(SHA256CHECK) "$(FF_SHA256)" "$@" + +download: $(TARBALL) + +$(SRCDIR): $(TARBALL) + mkdir -p $(PORTDIR) + tar -xzf $< -C $(PORTDIR) + mv $(PORTDIR)/fastfetch-$(FF_VERSION) $@ + +extract: $(SRCDIR) + +# A toolchain file rather than a pile of -D flags on the command line: CMake +# only honours CMAKE_*_INIT variables when it creates the cache, so they have to +# be in place before the first configure. Reconfiguring an existing build +# directory silently ignores them, which costs an afternoon to notice. +$(BUILDDIR)/toolchain.cmake: | $(SRCDIR) + @mkdir -p $(BUILDDIR) + @test -n "$(LINUX_HEADERS)" || { \ + echo "fastfetch: no linux/ethtool.h found -- set LINUX_HEADERS=" >&2; exit 1; } + @printf '%s\n' \ + 'set(CMAKE_SYSTEM_NAME Linux)' \ + 'set(CMAKE_SYSTEM_PROCESSOR x86_64)' \ + 'set(CMAKE_C_COMPILER $(HOSTCC_FF))' \ + 'set(CMAKE_C_FLAGS_INIT "-nostdinc -isystem $(LINUX_HEADERS) -isystem $(GCC_INC) -isystem $(MUSL)/include -D__SCHOS__ $(CFLAGS_BT)")' \ + 'set(CMAKE_EXE_LINKER_FLAGS_INIT "-static -nostdlib -L$(MUSL)/lib $(MUSL)/lib/crt1.o $(MUSL)/lib/crti.o")' \ + 'set(CMAKE_C_STANDARD_LIBRARIES "$(MUSL)/lib/libc.a $(LIBGCC) $(MUSL)/lib/libc.a $(MUSL)/lib/crtn.o")' \ + 'set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)' \ + > $@ + +# libc appears twice on the link line on purpose: libgcc pulls symbols back out +# of it (__popcountdi2 is the one that shows up), and a static link resolves +# left to right. +$(BUILDDIR)/fastfetch: $(BUILDDIR)/toolchain.cmake + cd $(BUILDDIR) && cmake $(SRCDIR) \ + -DCMAKE_TOOLCHAIN_FILE=$(BUILDDIR)/toolchain.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + $(foreach o,$(FF_OFF),-DENABLE_$(o)=OFF) + $(MAKE) -C $(BUILDDIR) fastfetch + +build: $(BUILDDIR)/fastfetch + +install: $(BUILDDIR)/fastfetch | $(SYSROOT)/bin + install -m 0755 $(BUILDDIR)/fastfetch $(SYSROOT)/bin/fastfetch + +clean: + rm -rf $(PORTDIR) + +distclean: clean + rm -f $(TARBALL) diff --git a/ports/fastfetch/patches/.gitkeep b/ports/fastfetch/patches/.gitkeep new file mode 100644 index 0000000..e69de29