I’m working on a driver for the M4i.4420-x8 digitizer cards from Spectrum Instrumentation (called spcm4). I’m using their provided source code for a kernel module.
The goal is to create a RPM package containing a kernel module loaded/updated/rebuild via akmods.
This RPM then should be installed during rpm-ostree compose tree
when building my own image (tree).
Installing after the fact with all dependencies present works like a charm, but including the RPM inside my fedora-silverblue.yaml does not work → Dependency issue .
Here is the error I get when I run rpm-ostree compose tree --add-metadata-string="version=..." fedora-silverblue.yaml
:
Running post scripts...done
error: Running %post for spcm4-akmod: bwrap(/bin/sh): Child process killed by signal 1
[...]
spcm4-akmod.post: Building /usr/src/akmods/spcm4-kmod-3.04.20609-2.fc38.src.rpm for kernel 6.3.8-200.fc38.x86_64
spcm4-akmod.post: warning: user fabian does not exist - using root
spcm4-akmod.post: warning: group fabian does not exist - using root
spcm4-akmod.post: warning: user fabian does not exist - using root
spcm4-akmod.post: warning: group fabian does not exist - using root
spcm4-akmod.post: warning: user fabian does not exist - using root
spcm4-akmod.post: warning: group fabian does not exist - using root
spcm4-akmod.post: Installing /usr/src/akmods/spcm4-kmod-3.04.20609-2.fc38.src.rpm
spcm4-akmod.post: Building target platforms: x86_64
spcm4-akmod.post: Building for target x86_64
spcm4-akmod.post: setting SOURCE_DATE_EPOCH=1686873600
spcm4-akmod.post: warning: Could not canonicalize hostname: fedora-fabian
spcm4-akmod.post: error: Failed build dependencies:
spcm4-akmod.post: /usr/bin/kmodtool is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
spcm4-akmod.post: elfutils-libelf-devel is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
spcm4-akmod.post: gcc is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
spcm4-akmod.post: kernel-devel-uname-r = 6.3.8-200.fc38.x86_64 is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
spcm4-akmod.post: make is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
spcm4-akmod.post: tar is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
spcm4-akmod.post: unifdef is needed by spcm4-kmod-3.04.20609-2.fc38.x86_64
How do I make sure akmods
finds the required build dependencies during the post script stage of my RPM? I even added them to my spmc4-spec.akmods as Requires(post)
and it still does not solve it.
fedora-silverblue.yaml
include: fedora-common-ostree.yaml
ref: fedora/38/${basearch}/silverblue
rojig:
name: fedora-silverblue
summary: "Some summary"
license: GPLv3
packages:
- fedora-release-silverblue
- spcm4-akmod
repos:
- fedora-38
- fedora-38-updates
- my-rpm-repo-38
documentation: false
spcm4-kmod.spec
%global buildforkernels akmod
%global debug_package %{nil}
%define kmod_name spcm4
Name: %{kmod_name}-kmod
Version: 3.04.20609
Release: 2%{?dist}
Summary: Kernel module for the M4i.4420-x8 digitizer from Spectrum Instrumentation
Distribution: Fedora
Group: System Environment/Kernel
License: GPLv3
URL: TODO
Vendor: TODO
Packager: TODO
Source0: %{kmod_name}-%{version}.tgz
Source11: spcm4-kmodtool-excludekernel-filterfile
ExclusiveArch: x86_64
BuildRequires: %{_bindir}/kmodtool
%{?fedora:BuildRequires: unifdef}
BuildRequires: gcc
BuildRequires: make
BuildRequires: elfutils-libelf-devel
BuildRequires: tar
Requires: libstdc++
# kmodtool does its magic here
%{expand:%(kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }
%description
This package provides a kernel module for the M4i.4420-x8 digitizer from Spectrum Instrumentation with akmods support.
%prep
# error out if there was something wrong with kmodtool
%{?kmodtool_check}
# print kmodtool output for debugging purposes:
kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null
# Make sure the source code is available
cp %{_sourcedir}/%{kmod_name}-%{version}.tgz .
tar zxvf %{kmod_name}-%{version}.tgz
# Ensure the expected version exists. Else fail.
if [ ! -d "%{kmod_name}-%{version}" ]; then
echo "Directory '%{kmod_name}-%{version}' does not exist. This means there is a different version of the driver available than the version this script was build for."
exit 1
fi
# Prepare for all kernel versions
for kernel_version in %{?kernel_versions} ; do
cp -a %{kmod_name}-%{version} _kmod_build_${kernel_version%%___*}
done
# Ensure the correct libstdc++ is present
for p in /usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib; do
FOUND=$(find $p -name "libstdc++.so.6" 2>/dev/null | wc -l)
if [ $FOUND -gt 0 ]; then
LIBPATH=$p
STDLIB_VERS="stdc++6"
break;
fi
FOUND=$(find $p -name "libstdc++.so.5" 2>/dev/null | wc -l)
if [ $FOUND -gt 0 ]; then
LIBPATH=$p
STDLIB_VERS="stdc++5"
break;
fi
done
%build
for kernel_version in %{?kernel_versions} ; do
pushd _kmod_build_${kernel_version%%___*}
%{__make} -C m4i_krnl_linux %{?_smp_mflags} V=1 M=$PWD
popd
done
%install
# udev Rules
install -d -m 755 $RPM_BUILD_ROOT/etc/udev/rules.d/
install -m 644 spcm4-%{version}/scripts/99-spcm4.rules $RPM_BUILD_ROOT/etc/udev/rules.d/
# Library
install -d -m 755 $RPM_BUILD_ROOT/usr/lib64/
install -m 755 spcm4-%{version}/libs/spcm_linux_64bit_stdc++6.so $RPM_BUILD_ROOT/usr/lib64/libspcm_linux.so
# Kernel Module
for kernel_version in %{?kernel_versions}; do
mkdir -p %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/
install -D -m 755 -t %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/ $(find _kmod_build_${kernel_version%%___*}/ -name '*.ko')
done
%{?akmod_install}
%files
%attr(0644, root, root) /etc/udev/rules.d/99-spcm4.rules
%attr(0755, root, root) /usr/lib64/libspcm_linux.so
%changelog
spcm4-akmod.spec
%define kmod_name spcm4
Name: %{kmod_name}-akmod
Version: 3.04.20609
Release: 2%{?dist}
Summary: Kernel module (akmod) for the M4i.4420-x8 digitizer from Spectrum Instrumentation
Distribution: Fedora
Group: System Environment/Kernel
License: GPLv3
URL: TODO
Vendor: TODO
Packager: TODO
ExclusiveArch: x86_64
# Indirect compile kmod requirements
%{?fedora:Requires(post): unifdef}
Requires(post): %{_bindir}/kmodtool
Requires(post): gcc
Requires(post): make
Requires(post): elfutils-libelf-devel
Requires(post): tar
Requires(post): /bin/sh
# Direct requirements
Requires: akmods
Requires: kmodtool
Requires: /bin/sh
Requires: libstdc++
Provides: %{name} = %{version}-%{release}
Provides: %{kmod_name}-kmod = %{version}-%{release}
%description
This package provides a kernel module for the M4i.4420-x8 digitizer from Spectrum Instrumentation with akmods support.
%prep
# Ensure the spec file for the kmod source exists. Else fail.
if [ ! -f "%{_specdir}/spcm4-kmod.spec" ]; then
echo ""
exit 1
fi
%build
# Build the kmod source RPM
rpmbuild -bs %{_specdir}/%{kmod_name}-kmod.spec
# Ensure the correct version has been build
if [ ! -f "%{_srcrpmdir}/%{kmod_name}-kmod-%{version}-%{release}.src.rpm" ]; then
echo "Unable to find '%{_srcrpmdir}/%{kmod_name}-kmod-%{version}-%{release}.src.rpm' Was building the kmod source RPM successfull?"
exit 1
fi
%install
# Kernel Module
install -d -m 755 $RPM_BUILD_ROOT/usr/src/akmods
install -m 644 %{_srcrpmdir}/%{kmod_name}-kmod-%{version}-%{release}.src.rpm $RPM_BUILD_ROOT/usr/src/akmods/
pushd $RPM_BUILD_ROOT/usr/src/akmods
ln -s %{kmod_name}-kmod-%{version}-%{release}.src.rpm %{kmod_name}-kmod.latest
popd
%files
%attr(0644, root, root) /usr/src/akmods/%{kmod_name}-kmod-%{version}-%{release}.src.rpm
/usr/src/akmods/%{kmod_name}-kmod.latest
%post -p /bin/sh
[ -x /usr/sbin/akmods-ostree-post ] && /usr/sbin/akmods-ostree-post %{kmod_name} /usr/src/akmods/%{kmod_name}-kmod-%{version}-%{release}.src.rpm
%posttrans -p /bin/sh
nohup /usr/sbin/akmods --from-akmod-posttrans --akmod %{kmod_name} &> /dev/null &
%changelog