Skip to content

rpm: build kernel modules via DKMS on the target - #1788

Open
Arondight wants to merge 4 commits into
Open-CAS:masterfrom
Arondight:master
Open

rpm: build kernel modules via DKMS on the target#1788
Arondight wants to merge 4 commits into
Open-CAS:masterfrom
Arondight:master

Conversation

@Arondight

Copy link
Copy Markdown
Contributor

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.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant