# --- FINAL FIX: Explicitly disable debug package generation --- %global _debugsource_packages 0 %global _debuginfo_packages 0 %global debug_package %{nil} %global corefreq_version 2.0.8 Name: corefreq Version: %{corefreq_version} Release: 3%{?dist} Summary: CPU monitoring software with DKMS kernel module License: GPL-2.0-only URL: https://github.com/cyring/CoreFreq # Corrected Source0 URL with on-the-fly renaming Source0: %{url}/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz # Source1 is our robust service file Source1: corefreqd.service # Source2 is our complete dkms.conf file Source2: dkms.conf BuildRequires: gcc make kernel-devel dkms kmod systemd-rpm-macros BuildRequires: openssl mokutil Requires: dkms kernel-devel openssl mokutil %description CoreFreq is a CPU monitoring software designed for 64-bit Processors. This package provides the user-space tools and the DKMS source for the 'corefreqk' kernel module, which will be automatically built, signed, and loaded. %prep %autosetup -n CoreFreq-%{version} -p1 # Copy our complete dkms.conf file into the build directory cp %{SOURCE2} . # Replace the version placeholder within it sed -i 's/@RPM_VERSION@/%{version}/' dkms.conf %build # Do NOT build the kernel module here. Only build the user-space applications. make %{?_smp_mflags} corefreqd corefreq-cli %install # 1. Install the user-space applications from the 'build' directory install -D -m 0755 build/corefreqd %{buildroot}%{_bindir}/corefreqd install -D -m 0755 build/corefreq-cli %{buildroot}%{_bindir}/corefreq-cli # 2. Install our robust, custom service file install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/corefreqd.service # 3. Manually remove the temporary build directory to clean the source tree. rm -rf build # 4. Set up the now-clean source directory for DKMS %global dkms_source_dir %{_usrsrc}/%{name}-%{version} install -d -m 755 %{buildroot}%{dkms_source_dir} cp -a . %{buildroot}%{dkms_source_dir}/ %post # NVIDIA-style fully automatic Secure Boot handling MOK_KEY_DIR="/etc/pki/corefreq" MOK_PRIV_KEY="${MOK_KEY_DIR}/private_key.priv" MOK_PUB_KEY="${MOK_KEY_DIR}/public_key.der" if [ ! -f "${MOK_PRIV_KEY}" ]; then echo "--- Secure Boot key not found. Generating a new key for CoreFreq ---" mkdir -p "${MOK_KEY_DIR}" openssl req -new -x509 -newkey rsa:2048 -keyout "${MOK_PRIV_KEY}" -outform DER -out "${MOK_PUB_KEY}" -nodes -days 36500 -subj "/CN=CoreFreq DKMS Signing Key/" >/dev/null 2>&1 echo "----------------------------------------------------------------------" echo "ATTENTION: SECURE BOOT FIRST-TIME SETUP" echo "A new key has been generated. You must now enroll it into your UEFI." echo "1. Run: sudo mokutil --import ${MOK_PUB_KEY}" echo " (You will be asked to create a password for this one-time action.)" echo "2. Reboot your computer and follow the prompts at the blue screen." echo "----------------------------------------------------------------------" fi if dkms status -m %{name} -v %{version} | grep -q installed; then dkms remove -m %{name} -v %{version} --all >/dev/null 2>&1 || : fi dkms add -m %{name} -v %{version} >/dev/null 2>&1 || : dkms autoinstall >/dev/null 2>&1 || : CURRENT_KERNEL=$(ls -t /lib/modules | head -n1) MODULE_PATH="/lib/modules/${CURRENT_KERNEL}/extra/corefreqk.ko" if [ -f "${MOK_PRIV_KEY}" ] && [ -f "${MODULE_PATH}" ]; then echo "--- Signing the CoreFreq module for kernel ${CURRENT_KERNEL} ---" /usr/src/kernels/${CURRENT_KERNEL}/scripts/sign-file sha256 "${MOK_PRIV_KEY}" "${MOK_PUB_KEY}" "${MODULE_PATH}" fi %systemd_postun_with_restart corefreqd.service %preun %systemd_preun corefreqd.service if [ $1 -eq 0 ]; then /sbin/rmmod corefreqk >/dev/null 2>&1 || : dkms remove -m %{name} -v %{version} --all >/dev/null 2>&1 || : fi %postun %systemd_postun_with_restart corefreqd.service %files %license LICENSE %doc README.md %{_bindir}/corefreq-cli %{_bindir}/corefreqd %{_unitdir}/corefreqd.service %{_usrsrc}/%{name}-%{version}/ %changelog * Sat Aug 30 2025 Sunny Yang - 2.0.8-1 - Final working version for Copr. - Disable debug packages to fix empty file error. - Manually remove build artifacts to avoid 'make clean' kernel header dependency. - Implements NVIDIA-style, fully automatic key generation and signing for Secure Boot. - Ships a robust, custom systemd service file for reliability. - Provides a custom, RPM-friendly dkms.conf file.