%global _debugsource_packages 0 %global _debuginfo_packages 0 %global debug_package %{nil} %global corefreq_version 2.0.8 Name: corefreq Version: %{corefreq_version} Release: 25.alpha1%{?dist} Summary: CPU monitoring software with akmod kernel module License: GPL-2.0-only URL: https://github.com/cyring/CoreFreq Source0: %{url}/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz # systemd modules-load configuration Source1: corefreq.modules-load.conf # systemd service unit for the daemon Source2: corefreqd.service # Custom Makefile for building kernel module via akmods Source3: Makefile.akmod # Spec file template for the kmod SRPM Source4: corefreq-kmod.spec.in # Akmod BuildRequires BuildRequires: kmodtool BuildRequires: akmods BuildRequires: gcc make rpm-build BuildRequires: systemd-rpm-macros BuildRequires: kernel-devel # Runtime Requirements Requires: systemd Suggests: mokutil # Require the akmod package which provides the kernel module source Requires: akmod-%{name} >= %{version} # Generate akmod metadata %{expand:%(kmodtool --target %{_target_cpu} --kmodname %{name} --pattern ".*" --akmod 2>/dev/null) } %description CoreFreq is a CPU monitoring software designed for 64-bit Processors. This package provides the user-space tools and the akmod source for the 'corefreqk' kernel module with full automation including Secure Boot support. %package -n akmod-%{name} Summary: Akmod package for %{name} kernel module(s) Requires: kmodtool Requires: akmods # This provides a virtual dependency for other packages to require a kmod Provides: %{name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release} %description -n akmod-%{name} This package provides the akmod package for the %{name} kernel modules. %prep %autosetup -n CoreFreq-%{version} -p1 cp Makefile Makefile.orig cp %{SOURCE3} Makefile %build # Build userspace tools only; kernel module is built by akmods make %{?_smasm_mflags} userspace %install # --- Install userspace binaries --- install -D -m 0755 build/corefreqd %{buildroot}%{_bindir}/corefreqd install -D -m 0755 build/corefreq-cli %{buildroot}%{_bindir}/corefreq-cli # --- Install systemd unit and modules-load config --- install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/corefreqd.service install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/modules-load.d/corefreq.conf # --- Create akmod SRPM --- install -d %{buildroot}%{_usrsrc}/akmods/ SRPM_TOPDIR=$(mktemp -d) mkdir -p "$SRPM_TOPDIR"/{SOURCES,SPECS} sed -e 's|@COREFREQ_VERSION@|%{corefreq_version}|g' \ -e 's|@RELEASE@|1%{?dist}|g' \ %{SOURCE4} > "$SRPM_TOPDIR"/SPECS/corefreq-kmod.spec tar -czf "$SRPM_TOPDIR"/SOURCES/corefreq-kmod-%{version}.tar.gz \ --transform "s|^CoreFreq-%{version}|corefreq-kmod-%{version}|" \ -C %{_builddir} \ CoreFreq-%{version} rpmbuild -bs \ --define "_topdir $SRPM_TOPDIR" \ "$SRPM_TOPDIR"/SPECS/corefreq-kmod.spec install -m 0644 "$SRPM_TOPDIR"/SRPMS/*.src.rpm %{buildroot}%{_usrsrc}/akmods/ SRPM_NAME=$(basename "$SRPM_TOPDIR"/SRPMS/*.src.rpm) ln -s "$SRPM_NAME" %{buildroot}%{_usrsrc}/akmods/%{name}-kmod.latest rm -rf "$SRPM_TOPDIR" %post # Display MOK enrollment instructions if Secure Boot is enabled if [ -d /sys/firmware/efi/efivars ]; then if mokutil --sb-state 2>/dev/null | grep -q "SecureBoot enabled"; then if ! mokutil --list-enrolled 2>/dev/null | grep -q "CN=akmods"; then cat << 'EOF' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔐 SECURE BOOT DETECTED - MOK ENROLLMENT REQUIRED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ To use CoreFreq with Secure Boot, enroll the akmods signing key: sudo mokutil --import /etc/pki/akmods/certs/public_key.der Then REBOOT and follow the MOK Manager instructions. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ EOF fi fi fi %systemd_post corefreqd.service # Enable the service to start on boot systemctl enable corefreqd.service >/dev/null 2>&1 || true # User information message echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo " CoreFreq has been installed." echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" echo " The kernel module will be built automatically. The service" echo " will start on the next boot, or once the module is loaded." echo "" echo " Check build status: journalctl -u akmods.service" echo " Check daemon status: systemctl status corefreqd.service" echo " Use CLI: corefreq-cli" echo "" %preun %systemd_preun corefreqd.service %postun %systemd_postun_with_restart corefreqd.service %post -n akmod-%{name} # Trigger the initial build asynchronously after installation if command -v at >/dev/null 2>&1 && systemctl is-active --quiet atd; then echo "%{_bindir}/akmods --akmod %{name} --kernels \"\$(uname -r)\"" | at now + 1 minute 2>/dev/null || { nohup sh -c 'sleep 10; %{_bindir}/akmods --akmod %{name} --kernels "$(uname -r)"' >/dev/null 2>&1 & } else nohup sh -c 'sleep 10; %{_bindir}/akmods --akmod %{name} --kernels "$(uname -r)"' >/dev/null 2>&1 & fi echo "Kernel module compilation scheduled." %preun -n akmod-%{name} if [ $1 -eq 0 ]; then # Last package removal # Clean up kmod files for all installed kernels for kver in $(find /lib/modules -name "corefreqk.ko" -exec dirname {} \; 2>/dev/null | sed 's|.*/modules/||;s|/.*||' | sort -u); do rm -rf "/lib/modules/$kver/extra/corefreq" "/lib/modules/$kver/updates/corefreqk.ko" 2>/dev/null || true /sbin/depmod -a "$kver" 2>/dev/null || true done # Clean up modules-load configuration rm -f %{_sysconfdir}/modules-load.d/corefreq.conf fi %files %license LICENSE %doc README.md %{_bindir}/corefreq-cli %{_bindir}/corefreqd %{_unitdir}/corefreqd.service %{_sysconfdir}/modules-load.d/corefreq.conf %files -n akmod-%{name} %{_usrsrc}/akmods/corefreq-kmod-%{version}-*.src.rpm %{_usrsrc}/akmods/corefreq-kmod.latest %changelog * Wed Oct 29 2025 Package Maintainer - 2.0.8-25 - Refactor to use systemd-modules-load for module management - Removed custom monitor service for a simpler, more robust design