From ee7d4e2caac6b597f7440f9a01305edcc58bed20 Mon Sep 17 00:00:00 2001 From: Raboneko <119771935+raboneko@users.noreply.github.com> Date: Thu, 13 Nov 2025 15:07:49 -0800 Subject: [PATCH] add: zenergy (#7322) (#7343) --- anda/system/zenergy/akmod/anda.hcl | 10 +++ anda/system/zenergy/akmod/update.rhai | 5 ++ anda/system/zenergy/akmod/zenergy-kmod.spec | 72 +++++++++++++++++++ anda/system/zenergy/dkms/anda.hcl | 9 +++ anda/system/zenergy/dkms/dkms-zenergy.spec | 61 ++++++++++++++++ anda/system/zenergy/dkms/update.rhai | 5 ++ anda/system/zenergy/kmod-common/anda.hcl | 9 +++ .../com.github.zenergy.metainfo.xml | 30 ++++++++ anda/system/zenergy/kmod-common/update.rhai | 5 ++ anda/system/zenergy/kmod-common/zenergy.spec | 56 +++++++++++++++ 10 files changed, 262 insertions(+) create mode 100644 anda/system/zenergy/akmod/anda.hcl create mode 100644 anda/system/zenergy/akmod/update.rhai create mode 100644 anda/system/zenergy/akmod/zenergy-kmod.spec create mode 100644 anda/system/zenergy/dkms/anda.hcl create mode 100644 anda/system/zenergy/dkms/dkms-zenergy.spec create mode 100644 anda/system/zenergy/dkms/update.rhai create mode 100644 anda/system/zenergy/kmod-common/anda.hcl create mode 100644 anda/system/zenergy/kmod-common/com.github.zenergy.metainfo.xml create mode 100644 anda/system/zenergy/kmod-common/update.rhai create mode 100644 anda/system/zenergy/kmod-common/zenergy.spec diff --git a/anda/system/zenergy/akmod/anda.hcl b/anda/system/zenergy/akmod/anda.hcl new file mode 100644 index 0000000000..4c61e3c13f --- /dev/null +++ b/anda/system/zenergy/akmod/anda.hcl @@ -0,0 +1,10 @@ +project pkg { + arches = ["x86_64"] + rpm { + spec = "zenergy-kmod.spec" + } + labels { + mock = 1 + nightly = 1 + } +} diff --git a/anda/system/zenergy/akmod/update.rhai b/anda/system/zenergy/akmod/update.rhai new file mode 100644 index 0000000000..ae37ba7dd5 --- /dev/null +++ b/anda/system/zenergy/akmod/update.rhai @@ -0,0 +1,5 @@ +rpm.global("commit", gh_commit("BoukeHaarsma23/zenergy")); +if rpm.changed() { + rpm.release(); + rpm.global("commitdate", date()); +} diff --git a/anda/system/zenergy/akmod/zenergy-kmod.spec b/anda/system/zenergy/akmod/zenergy-kmod.spec new file mode 100644 index 0000000000..21f642fca4 --- /dev/null +++ b/anda/system/zenergy/akmod/zenergy-kmod.spec @@ -0,0 +1,72 @@ +# The reason why this package is a separate from the main one despite using the same sources +# is because akmods use the srpm to build the kmod package, and if the kmod package is included +# in the main package, akmods will reinstall the userspace package every time the kernel is updated. + +%if 0%{?fedora} +%global buildforkernels akmod +%global debug_package %{nil} +%endif + +%global commit 58f2fda7184fbde95033f492f7c54990552ef86f +%global commitdate 20250831 +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global modulename zenergy + +Name: %{modulename}-kmod +Version: 1.0^%{commitdate}git.%{shortcommit} +Release: 1%{?dist} +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 +Source0: %{url}/archive/%{commit}.tar.gz#/%{modulename}-%{shortcommit}.tar.gz +# AMD only makes x86_64 CPUs, They literally invented x86_64. +BuildArch: x86_64 +BuildRequires: gcc +BuildRequires: make +BuildRequires: kmodtool + +Requires: akmods +Requires: %{modulename} = %{?epoch:%{epoch}:}%{version} +Requires: %{modulename}-akmod-modules = %{?epoch:%{epoch}:}%{version} +Requires: help2man +Requires: kernel-devel +Conflicts: dkms-%{modulename} +Packager: Cappy Ishihara + +%{expand:%(kmodtool --target %{_target_cpu} --repo terra --kmodname %{modulename} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) } + +%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. + +%prep +# error out if there was something wrong with kmodtool +%{?kmodtool_check} + +# print kmodtool output for debugging purposes: +kmodtool --target %{_target_cpu} --repo terra --kmodname %{modulename} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null + +%setup -q -c -n %{modulename}-%{commit} + +find . -type f -name '*.c' -exec sed -i "s/#VERSION#/%{version}/" {} \+ + +for kernel_version in %{?kernel_versions} ; do + cp -a %{modulename}-%{commit} _kmod_build_${kernel_version%%___*} +done + +%build +for kernel_version in %{?kernel_versions} ; do + make V=1 %{?_smp_mflags} -C ${kernel_version##*___} M=${PWD}/_kmod_build_${kernel_version%%___*} VERSION=v%{version} modules +done + +%install +for kernel_version in %{?kernel_versions}; do + mkdir -p %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/ + install -D -m 755 _kmod_build_${kernel_version%%___*}/zenergy.ko %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/ + chmod a+x %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/zenergy.ko +done +%{?akmod_install} + +%changelog +%autochangelog diff --git a/anda/system/zenergy/dkms/anda.hcl b/anda/system/zenergy/dkms/anda.hcl new file mode 100644 index 0000000000..ff0dddedb9 --- /dev/null +++ b/anda/system/zenergy/dkms/anda.hcl @@ -0,0 +1,9 @@ +project pkg { + arches = ["x86_64"] + rpm { + spec = "dkms-zenergy.spec" + } + labels { + nightly = 1 + } +} diff --git a/anda/system/zenergy/dkms/dkms-zenergy.spec b/anda/system/zenergy/dkms/dkms-zenergy.spec new file mode 100644 index 0000000000..52623400be --- /dev/null +++ b/anda/system/zenergy/dkms/dkms-zenergy.spec @@ -0,0 +1,61 @@ +%global commit 58f2fda7184fbde95033f492f7c54990552ef86f +%global debug_package %{nil} +%global modulename zenergy +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global commitdate 20250831 + +Name: dkms-%{modulename} +Version: 1.0^%{commitdate}git.%{shortcommit} +Release: 1%?dist +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 +Source0: %{url}/archive/%{commit}.tar.gz#/%{name}-%{shortcommit}.tar.gz +BuildRequires: sed +BuildRequires: systemd-rpm-macros +Requires: %{modulename} = %{?epoch:%{epoch}:}%{version} +Provides: %{name}-kmod-common = %{?epoch:%{epoch}:}%{version} +BuildArch: x86_64 +Requires: dkms +Requires: help2man +Conflicts: akmod-%{modulename} +Packager: Cappy Ishihara + +%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. + + +%package akmod-modules +Summary: Modules for Akmods +Requires: akmod-%{name} +BuildArch: noarch + +%description akmod-modules +Akmods modules for the akmod-%{name} package. + +%prep +%autosetup -p1 -n %{modulename}-%{commit} +# Zenergy has no concrete version, but upstream says "1.0" in their documentation +/usr/bin/sed -i 's/@VERSION@/%{version}/g' dkms.conf + +%install +mkdir -p %{buildroot}%{_usrsrc}/%{modulename}-%{version} +cp -fr ./ %{buildroot}%{_usrsrc}/%{modulename}-%{version}/ + +%post +dkms add -m %{modulename} -v %{version} -q --rpm_safe_upgrade || : +# Rebuild and make available for the currently running kernel: +dkms build -m %{modulename} -v %{version} -q || : +dkms install -m %{modulename} -v %{version} -q --force || : + + +%files +%{_usrsrc}/%{modulename}-%{version} +%license LICENSE +%doc README.md + + +%changelog +%autochangelog diff --git a/anda/system/zenergy/dkms/update.rhai b/anda/system/zenergy/dkms/update.rhai new file mode 100644 index 0000000000..ae37ba7dd5 --- /dev/null +++ b/anda/system/zenergy/dkms/update.rhai @@ -0,0 +1,5 @@ +rpm.global("commit", gh_commit("BoukeHaarsma23/zenergy")); +if rpm.changed() { + rpm.release(); + rpm.global("commitdate", date()); +} diff --git a/anda/system/zenergy/kmod-common/anda.hcl b/anda/system/zenergy/kmod-common/anda.hcl new file mode 100644 index 0000000000..36c8d29b16 --- /dev/null +++ b/anda/system/zenergy/kmod-common/anda.hcl @@ -0,0 +1,9 @@ +project pkg { + arches = ["x86_64"] + rpm { + spec = "zenergy.spec" + } + labels { + nightly = 1 + } +} diff --git a/anda/system/zenergy/kmod-common/com.github.zenergy.metainfo.xml b/anda/system/zenergy/kmod-common/com.github.zenergy.metainfo.xml new file mode 100644 index 0000000000..dd3092c029 --- /dev/null +++ b/anda/system/zenergy/kmod-common/com.github.zenergy.metainfo.xml @@ -0,0 +1,30 @@ + + com.github.zenergy + zenergy + zenergy + Exposes the energy counters that are reported via the Running Average Power Limit (RAPL) + +

+ 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. +

+
+ https://github.com/BoukeHaarsma23/zenergy + CC0-1.0 + + GPL-2.0 + + + BoukeHaarsma23 + + + + + + platform:zenergy + cpu:type:x86,ven0002fam0017mod*:feature:* + cpu:type:x86,ven0002fam0019mod*:feature:* + cpu:type:x86,ven0002fam001Amod*:feature:* + +
\ No newline at end of file diff --git a/anda/system/zenergy/kmod-common/update.rhai b/anda/system/zenergy/kmod-common/update.rhai new file mode 100644 index 0000000000..ae37ba7dd5 --- /dev/null +++ b/anda/system/zenergy/kmod-common/update.rhai @@ -0,0 +1,5 @@ +rpm.global("commit", gh_commit("BoukeHaarsma23/zenergy")); +if rpm.changed() { + rpm.release(); + rpm.global("commitdate", date()); +} diff --git a/anda/system/zenergy/kmod-common/zenergy.spec b/anda/system/zenergy/kmod-common/zenergy.spec new file mode 100644 index 0000000000..76199c991f --- /dev/null +++ b/anda/system/zenergy/kmod-common/zenergy.spec @@ -0,0 +1,56 @@ +%global commit 58f2fda7184fbde95033f492f7c54990552ef86f +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global commitdate 20250831 + +Name: zenergy +Version: 1.0^%{commitdate}git.%{shortcommit} +Release: 1%?dist +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 +Source0: %{url}/archive/%{commit}.tar.gz#/%{name}-%{shortcommit}.tar.gz +Source1: com.github.zenergy.metainfo.xml +BuildRequires: sed +BuildRequires: systemd-rpm-macros +Requires: (akmod-%{name} = %{?epoch:%{epoch}:}%{version} or dkms-%{name} = %{?epoch:%{epoch}:}%{version}) +Provides: %{name}-kmod-common = %{?epoch:%{epoch}:}%{version} +BuildArch: noarch +Packager: Cappy Ishihara + +%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. + + +%package akmod-modules +Summary: Modules for Akmods +Requires: akmod-%{name} +BuildArch: noarch + +%description akmod-modules +Akmods modules for the akmod-%{name} package. + +%prep +%autosetup -p1 -n %{name}-%{commit} + +# Zenergy has no concrete version, but upstream says "1.0" in their documentation +/usr/bin/sed -nE 's/@VERSION@/%{version}/g' dkms.conf > %{name}.conf + +%install +install -Dm644 %{SOURCE1} %{buildroot}%{_datadir}/metainfo/com.github.zenergy.metainfo.xml + +# Akmods modules +install -Dm644 %{name}.conf -t %{buildroot}%{_modulesloaddir} + + +%files +%license LICENSE +%doc README.md +%{_datadir}/metainfo/com.github.zenergy.metainfo.xml + +%files akmod-modules +%{_modulesloaddir}/%{name}.conf + +%changelog +%autochangelog \ No newline at end of file