File zenergy.spec of Package zenergy
# spec file for package zenergy
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
%define kernel_ver "$(uname -r)"
%define module_dir "%{kernel_module_directory}/%{kernel_ver}/extra"
#define _modulloaddir "/etc/modules-load.d/"
%define _modulloaddir "/usr/lib/modules-load.d/"
%define kernel_version_var %{expand:$KERNEL_VERSION}
Name: zenergy
Version: 0.1.0
Release: 0
Summary: Exposes the energy counters that are reported via the Running Average Power Limit (RAPL) Model-specific Registers (MSRs) via the hardware monitor (HWMON) sysfs interface.
License: GPL-2.0
URL: https://github.com/BoukeHaarsma23/zenergy
Source: %{name}-master-%{version}.tar.gz
Source1: 10-zenergy.conf
Patch0: kernel_6_16.patch
BuildRequires: %{kernel_module_package_buildreqs}
BuildRequires: make
BuildRequires: gcc
BuildRequires: kernel-source
BuildRequires: kernel-syms
BuildRequires: kernel-default
BuildRequires: kernel-macros
BuildRequires: module-init-tools
%{!?kernel_module_directory:%define kernel_module_directory /lib/modules}
%description
Based on AMD_ENERGY driver, but with some jiffies added so non-root users can read it safely. Exposes the energy counters that are reported via the Running Average Power Limit (RAPL) Model-specific Registers (MSRs) via the hardware monitor (HWMON) sysfs interface.
%kernel_module_package -p %{name}
%prep
%autosetup -n %{name} -p 1
%build
%make_build
#for flavor in {flavors_to_build} ; do
# rm -rf obj/$flavor
# cp -a source obj/$flavor
# pushd obj/$flavor
# sed -i -e "s,^KSRC := /lib/modules/\$(KVER)/build$,KSRC := %{_prefix}/src/linux-obj/%{_target_cpu}/$flavor," Makefile
# make_build
# popd
#done
%install
#%make_install
install -D -m 0755 %{_builddir}/%{name}/%{name}.ko %{buildroot}%{module_dir}/%{name}.ko
install -D -m 0755 %{SOURCE1} %{buildroot}%{_modulloaddir}/10-zenergy.conf
# install -d -m 0755 %{buildroot}%{module_dir}
# install -d -m 0755 %{buildroot}%{_modulloaddir}
# cp %{_builddir}/%{name}/%{name}.ko %{buildroot}%{module_dir}/%{name}.ko
#cp %{SOURCE1} %{buildroot}%{_modulloaddir}/10-zenergy.conf
#export INSTALL_MOD_PATH=%{buildroot}
#export INSTALL_MOD_DIR="extra"
##export INSTALL_MOD_DIR=%{kernel_module_package_moddir}
#kernel_version=`uname -r | sed -e "s/-[^-]*$//"`
#echo ${kernel_version}
#echo ${buildroot}
#install -D -m 0755 %{_builddir}/%{name}/%{name}.ko %{buildroot}%{kernel_module_directory}/${kernel_version}/extra/%{name}.ko
#install -d %{buildroot}/lib/modules/${kernel_version}/${INSTALL_MOD_DIR}/
#mkdir -p %{buildroot}%{kernel_module_directory}/${kernel_version}/${INSTALL_MOD_DIR}/
#install -p -m 644 %{_builddir}/%{name}/%{name}.ko %{buildroot}%{kernel_module_directory}/${kernel_version}/${INSTALL_MOD_DIR}/%{name}.ko
#for flavor in %{flavors_to_build} ; do
# pushd obj/$flavor
# install -d %{buildroot}/lib/modules/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
# mkdir -p %{buildroot}%{kernel_module_directory}/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
# install -p -m 644 zenergy.ko %{buildroot}%{kernel_module_directory}/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
# popd
#done
%files
#%defattr(-,root,root)
# here no kernel_ver
#%dir %{kernel_module_directory}
#%{kernel_module_directory}/*
#/etc/modules-load.d/10-zenergy.conf
/usr/lib/modules-load.d/10-zenergy.conf
%post
# Ensure the module is loaded after installation
#insmod %{module_dir}/%{name}.ko
#/usr/sbin/depmod -a
#/usr/sbin/modprobe %{name}.ko
echo "run: sudo depmod -a"
echo "run: sudo modprobe %{name}"
%postun
# Unload the module on package removal
#rmmod %{name}.ko
%changelog
- first SuSE version