cifsd-team / ksmbd

ksmbd kernel server(SMB/CIFS server)
151 stars 23 forks source link

[Enhancement] dkms build support #518

Open linuxrrze opened 3 years ago

linuxrrze commented 3 years ago

Hi there! I was just listening to the Samba XP presentation about ksmbd. So I tried to build it for my Ubuntu system which worked quite nice (for the current kernel).

However it'd be even better to support dkms to make building external kernel modules even easier (and make them survive kernel updates). (About dkms: https://wiki.kubuntu.org/Kernel/Dev/DKMSPackaging).

There are only minor modifications to the Makefile necessary (and an additional dkms.conf).

Just in case your're interested:

dkms.conf:

PACKAGE_NAME="ksmbd"
PACKAGE_VERSION="0.1"
CLEAN="make clean"
MAKE[0]="make all KVERSION=$kernelver"
BUILT_MODULE_NAME[0]="ksmbd"
DEST_MODULE_LOCATION[0]="/updates"
AUTOINSTALL="yes"

In the Makefile basically only the $(shell uname -r) part needs to be replaced with $(KVERSION) and the else/endif needs to be relocated.

namjaejeon commented 3 years ago

Hi Marcel,

Okay, Could you please provide the patch for this ? You can send the patch to the list(linux-cifsd-devel@lists.sourceforge.net) if you have tested it on your environment.

linuxrrze commented 3 years ago

Problem with dkms and the current Makefile is, that dkms provides the environment variable KERNELRELEASE and with that triggers the "in-kernel-tree" build routine (that fails - at least for me. However I don't know how this is supposed to work).

For now this config works for me (Ubuntu 20.04), but only because dkms omits KERNELRELEASE in this specific setup (removing the "CONFIG_SMB_SERVER=m" makes dkms add the environment variable and results in a failure).

dkms.conf:

PACKAGE_NAME="cifsd"
PACKAGE_VERSION="3.3.9"
CLEAN="make -C . KDIR=${kernel_source_dir} V=1 clean"
MAKE="CONFIG_SMB_SERVER=m make -C . KDIR=${kernel_source_dir} V=1"
BUILT_MODULE_NAME[0]="ksmbd"
DEST_MODULE_LOCATION[0]="/updates"
AUTOINSTALL="yes"

Maybe someone more familiar with the build process can provide a cleaner solution.

And here's how it works:

cd /usr/src
wget https://github.com/cifsd-team/cifsd/archive/refs/tags/3.3.9.tar.gz
tar xzf 3.3.9.tar.gz
cp /tmp/dkms.conf /usr/src/cifsd-3.3.9/dkms.conf
dkms add -m cifsd -v 3.3.9
dkms build -m cifsd -v 3.3.9 -k 5.4.0-72-generic
dkms install -m cifsd -v 3.3.9 -k 5.4.0-72-generic
namjaejeon commented 3 years ago

Let me check it. If you give me your mail address, I will add your signoff-by to dkms patch.