Errors when trying to create a akmod

Hello, I wanted help to finish two akmods that I’ve been creating for a few days now, I grabbed a template from https://unix.stackexchange.com/questions/297769/trying-to-build-akmod-package-for-acpi-call-on-fedora-cannot-be-installed for Fedora Silverblue. The errors I got are:

   rpm-ostree(akmod-msi_ec.post)[116430]: Building /usr/src/akmods/msi_ec-kmod-13.347dadd-1.fc43.src.rpm for kernel 6.18.8-cachyos1.fc43.x86_64
   rpm-ostree(akmod-msi_ec.post)[116546]: + export CFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,>
   rpm-ostree(akmod-msi_ec.post)[116546]: + export CXXFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -spe>
   rpm-ostree(akmod-msi_ec.post)[116546]: + export FFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -sp>
   rpm-ostree(akmod-msi_ec.post)[116546]: + export FCFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + VALAFLAGS=-g
   rpm-ostree(akmod-msi_ec.post)[116546]: + export VALAFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-l>
   rpm-ostree(akmod-msi_ec.post)[116546]: + export RUSTFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + LDFLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-harde>
   rpm-ostree(akmod-msi_ec.post)[116546]: + export LDFLAGS
   rpm-ostree(akmod-msi_ec.post)[116546]: + LT_SYS_LIBRARY_PATH=/usr/lib64:
   rpm-ostree(akmod-msi_ec.post)[116546]: + export LT_SYS_LIBRARY_PATH
   rpm-ostree(akmod-msi_ec.post)[116546]: + CC=gcc
   rpm-ostree(akmod-msi_ec.post)[116546]: + export CC
   rpm-ostree(akmod-msi_ec.post)[116546]: + CXX=g++
   rpm-ostree(akmod-msi_ec.post)[116546]: + export CXX
   rpm-ostree(akmod-msi_ec.post)[116546]: + cd msi_ec-13.347dadd
   rpm-ostree(akmod-msi_ec.post)[116546]: + pwd
   rpm-ostree(akmod-msi_ec.post)[116546]: /tmp/akmodsbuild.hg6xTty3/BUILD/msi_ec-kmod-13.347dadd-build/msi_ec-13.347dadd
   rpm-ostree(akmod-msi_ec.post)[116546]: + for kernel_version in 6.18.8-cachyos1.fc43.x86_64___/usr/src/kernels/6.18.8-cachyos1.fc43.x86_64
   rpm-ostree(akmod-msi_ec.post)[116546]: + pushd _kmod_build_6.18.8-cachyos1.fc43.x86_64/
   rpm-ostree(akmod-msi_ec.post)[116546]: /var/tmp/rpm-tmp.yFoTLP: line 49: pushd: _kmod_build_6.18.8-cachyos1.fc43.x86_64/: No such file or directory
   rpm-ostree(akmod-msi_ec.post)[116546]: error: Bad exit status from /var/tmp/rpm-tmp.yFoTLP (%build)
   rpm-ostree(akmod-msi_ec.post)[116546]: RPM build errors:
   rpm-ostree(akmod-msi_ec.post)[116546]:     Unable to open sqlite database /usr/share/rpm/rpmdb.sqlite: unable to open database file
   rpm-ostree(akmod-msi_ec.post)[116546]:     cannot open Packages index using sqlite - Operation not permitted (1)
   rpm-ostree(akmod-msi_ec.post)[116546]:     cannot open Packages database in /usr/share/rpm
   rpm-ostree(akmod-msi_ec.post)[116546]:     Unable to open sqlite database /usr/share/rpm/rpmdb.sqlite: unable to open database file
   rpm-ostree(akmod-msi_ec.post)[116546]:     cannot open Packages index using sqlite - Operation not permitted (1)
   rpm-ostree(akmod-msi_ec.post)[116546]:     cannot open Packages database in /usr/share/rpm
   rpm-ostree(akmod-msi_ec.post)[116546]:     Bad exit status from /var/tmp/rpm-tmp.yFoTLP (%build)

The .spec file for the akmod is this
From my understanding the package is trying to build the kernel modules in /usr/src/, but I want it to use the Makefile of the git repo, one thing I want to say is that I don’t know that much about how to create a .spec file and I would like the help to solve this and use this “temple” for GitHub - BeardOverflow/msi-ec and GitHub - saidsay-so/acpi_ec: Kernel module to access directly to the ACPI EC.

#define buildforkernels newest
#define buildforkernels current
%define buildforkernels akmod

%define kmod_name msi_ec

%global debug_package %{nil}

Name:           %{kmod_name}-kmod
Version:        13.347dadd
Release:        1%{?dist}
Summary:        Call ACPI methods by writing to /proc

License:        GPL2
Source0:        msi-ec-13.347dadd.tar.gz

BuildRequires:  %{_bindir}/kmodtool

Requires: %{name}-kmod >= %{version}
Provides: %{name}-kmod-common = %{version}

# needed for plague to make sure it builds for i586 and i686
ExclusiveArch:  x86_64

# get the proper build-sysbuild package from the repo, which
# tracks in all the kernel-devel packages
BuildRequires:  %{_bindir}/kmodtool


# kmodtool does its magic here
%{expand:%(kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }

%description


%prep

# error out if there was something wrong with kmodtool
%{?kmodtool_check}

%autosetup -n %{kmod_name}-%{version}

# print kmodtool output for debugging purposes:
kmodtool  --target %{_target_cpu}  --repo %{repo} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null

tree ../../../

%build
pwd
for kernel_version in %{?kernel_versions}; do
    pushd _kmod_build_${kernel_version%%___*}/
        make %{?_smp_mflags} KERNEL_UNAME="${kernel_version%%___*}" modules
    popd
done

%install

rm -rf ${RPM_BUILD_ROOT}

for kernel_version in %{?kernel_versions}; do
    make install DESTDIR=${RPM_BUILD_ROOT} KMODPATH=%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}
    # install -D -m 755 _kmod_build_${kernel_version%%___*}/foo/foo.ko  ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/foo.ko
done
%{?akmod_install}

##post
###[ -x /usr/sbin/akmods-ostree-post ] && /usr/sbin/akmods-ostree-post %{kmod_name} %{_srcrpmdir}/%{name}-%{version}-%{release}.src.rpm
%post
[ -x /usr/sbin/akmods-ostree-post ] && /usr/sbin/akmods-ostree-post %{kmod_name} /usr/src/akmods/%{name}-%{version}-%{release}.src.rpm

%clean

rm -rf $RPM_BUILD_ROOT

%changelog

- Initial packaging

I created the tarballs compressing the cloned repos and I used some commands to debug, sorry for my bad English and thanks.

Hello @diegodreemurr and welcome to :fedora: !

I’m not entirely sure I fully understand what your ultimate goal is. I would suggest you look into the following topics:

My final goal is controlling the fan speed of my laptop through this app GitHub - dmitry-s93/MControlCenter: An application that allows you to change the settings of MSI laptops running Linux and for that app to work I need those two kernel modules and I know that akmods has an integration with rpm-ostree since dkms isn’t an option, that’s why I’m trying to create rpm/akmod to rebuild the module in the trasaction were / is r/w, sorry

One option is to consider building these modules during the bootable container build. It may be also possible to make an RPMs for these modules. For more information, see the links from the previous post.

Regarding the errors from your initial post, without knowing the command and the environment in which it was executed, it is unlikely that we can help.

I just realized what was wrong in my build and I’ll take a look for the bootable containers, sorry for wasting your time I apologize.