rpm: build kernel modules via DKMS on the target - #1788
Open
Arondight wants to merge 4 commits into
Open
Conversation
…ubpackage Mirror the DEB packaging: ship DKMS source to /usr/src/ and build the kernel modules on the target at install time instead of compiling them for a specific kernel at package build time. The build host no longer needs kernel-devel/kernel-headers. spec: - DKMS source tree + dkms.conf (heredoc); %post/%preun modules do dkms add/install/remove with --rpm_safe_upgrade on add+remove (per dkms(8)) - drop the kernel-version-specific subpackage and weak-modules/depmod logic (DKMS builds per-kernel natively) - build only userspace in %build; scrub OCF-synced headers and utils manpages so the DKMS tree ships source-only pckgen.sh: - build only casadm (<MAKE_BUILD> -> make -C casadm, matching DEB) - remove now-dead RPM kernel-version machinery (check_kernel_version, KVER/kernel-devel/libelf/util substitutions, unused *_PKG_NAME vars) Split opencas_exporter into a conditional subpackage controlled by %bcond_with exporter (off by default; --with-exporter to enable) so the default build does not pull in golang or go module downloads. spec: conditional BuildRequires/subpackage/%build/%install/%files pckgen.sh: --with-exporter/--without-exporter plumbed to rpmbuild/mock via EXPORTER_OPT; go dep check for non-mock builds Co-authored-by: GLM-5.2 Signed-off-by: 秦凡东 <qinfandong@kylinos.cn>
- modules RPM dropped from packages/ on non-mock builds (noarch lands in RPMS/noarch/, only RPMS/$ARCH/* was moved) — move RPMS/*/*.rpm. - DKMS build failed at install: ./configure hard-failed on `check_util go` (go only builds the optional exporter) — downgrade go to a warning. - dkms.conf MAKE[0] bare "-j" clobbered dkms's "-j<ncpu>" (last -j wins, bare -j = unlimited) — drop it; dkms provides -j<ncpu>. - kmod->dkms upgrade orphaned open-cas-linux-modules_k<kernelver> (name varies per kernel, can't Obsoletes) — %posttrans detached worker (setsid, polls dnf/zypper/yum for lock release) rpm -e --nodeps --noscripts the orphans + deletes stale weak-updates symlinks. Guarded (no-op on fresh). - %preun drops dkms's original_module archive before `dkms remove` so it doesn't restore orphan .ko on uninstall. - %post builds all installed kernels (not just running) so a fallback kernel isn't left without modules after a CAS upgrade. - Don't mask dkms build failure: `dkms install -k running || exit 1` (fail-visible); keep || : on dkms add (re-add returns 3) and other-kernel builds. dkms install returns 0 for "already installed" so reinstalls work. - modules package Requires: dkms only (dkms pulls gcc/make/kernel-devel transitively; drop redundant Requires(post)/Requires(preun)). - Escape %%bcond_with in a comment (silence macro-in-comment warning). - Keep --rpm_safe_upgrade on dkms add+remove (dkms(8): safe RPM upgrades). Tested on kernels 6.6.0-32.7/32.21/32.22: fresh install, clean uninstall, dkms->dkms upgrade, multi-kernel build, kmod->dkms upgrade (orphan auto-removed, weak-updates cleaned), kmod->dkms then uninstall (no .ko restored), dkms.conf audit. All pass. Co-authored-by: GLM-5.2 Signed-off-by: 秦凡东 <qinfandong@kylinos.cn>
Signed-off-by: 秦凡东 <qinfandong@kylinos.cn>
Signed-off-by: 秦凡东 <qinfandong@kylinos.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switches RPM packaging from prebuilt kmod modules (one per-kernel subpackage, built on the host) to DKMS source built on the target at install time. The build host no longer needs kernel-devel. opencas_exporter is split into an optional subpackage (--with-exporter, off by default) so the default build doesn't pull golang.
Tested on multi kernels: fresh install, clean uninstall, dkms→dkms upgrade, multi-kernel build, kmod→dkms upgrade, kmod→dkms + uninstall, reinstall. All Pass.