Skip to content

Commit

Permalink
Build a statically linked version of kmod
Browse files Browse the repository at this point in the history
By providing a statically linked kmod, containers can mount it
and load kernel modules without compatibility issues
  • Loading branch information
vigh-m committed May 23, 2024
1 parent 62f1453 commit 43e0f60
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/kmod/kmod.spec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ cp COPYING COPYING.LGPL
cp tools/COPYING COPYING.GPL

%build

mkdir static-build
pushd static-build

%define _configure ../configure
export LDFLAGS="-static -lz -lzstd"
export CFLAGS="%{_cross_cflags} -static"

%cross_configure \
--with-zlib \
--with-zstd \
--without-openssl

%make_build LDFLAGS="-all-static"

popd

%define _configure ./configure
export LDFLAGS="%{_cross_ldflags}"
export CFLAGS="%{_cross_cflags}"

%cross_configure \
--with-zlib \
--with-zstd \
Expand All @@ -44,6 +65,11 @@ done
install -d %{buildroot}%{_cross_sbindir}
ln -s ../bin/kmod %{buildroot}%{_cross_sbindir}/modprobe

pushd static-build
install -d %{buildroot}%{_cross_libexecdir}
cp tools/kmod %{buildroot}%{_cross_libexecdir}/kmod
popd

%files
%license COPYING.LGPL COPYING.GPL
%{_cross_attribution_file}
Expand All @@ -56,6 +82,7 @@ ln -s ../bin/kmod %{buildroot}%{_cross_sbindir}/modprobe
%{_cross_bindir}/rmmod
%{_cross_sbindir}/modprobe
%{_cross_libdir}/*.so.*
%{_cross_libexecdir}/kmod
%exclude %{_cross_datadir}/bash-completion
%exclude %{_cross_mandir}

Expand Down

0 comments on commit 43e0f60

Please sign in to comment.