Skip to content

Commit bac82c0

Browse files
committed
build,compat: do not patch git tracked sources; apply compat patch in build subdir instead
Split the build process in ./drbd/. `Makefile` calls the stages, no surprise there. `Kbuild` is used to prepare the build directory, calculate the compat.h, and copy over the `Kbuild.drbd` template. `Kbuild` again is used to calculate the compat.patch using spatch via `Makefile.spatch`, and applies it, generating the patched files in build-dir. build-dir `Kbuild` (from the `Kbuild.drbd` template) is then used to build the module in build-dir. `make compat.h` Use Kbuild to generate a `build-$(KERNELRELEASE)/` subdirectory. Create a `build-current/` symlink, so a naive `make install` will work. Copy over a `Kbuild` from the `Kbuild.drbd` template. Generate `drbd_buildtag.c`. Generate `compat.h` (relevant recipes moved to `Makefile.compat`). `make spatch` Find a `compat.patch` in our `cocci_cache`, and symlink from there. Or use coccinelle spatch (or spatch-as-a-service aka SPAAS) to generate or fetch such a patch (and put it into the cocci_cache for later re-use). See also `Makefile.spatch`, which now also includes some paranoia: double check md5sum of compat.h with the path it was found under. This now passes the parameters to `gen_compat_patch.sh` via bash variables. That script now always shows spatch .stderr output, if any, even for spatch "success" (exit code 0). `make prep` Provide a list of "expected" source files in Kbuild.drbd-module-sources. Use a new `splitdiff.pl` to split that into individual patches. This has the side effect of using only the _last_ patch, should coccinelle put several patches for the same file in the compat.patch. It seems to do that for headers. Apply, and re-diff, filter through `annotate-diff-with-original-file-position-pragmas.pl` and apply again. Annotates the patched file with original source file names and line numbers, respectively with the name of the compat patch and the line number therein for patched lines, and generate single dummy hunks with only that annotation for "expected" files that remain unchanged. This way compiler error messages will point to the original sources. `make kbuild` Implicitly calls prep stage first, then use Kbuild to build the modules from the generated sources. `make install` is now also using Kbuild `modules_install` target instead of the handcrafted recipe we had before.
1 parent ca25a85 commit bac82c0

12 files changed

+835
-266
lines changed

.gitignore

+10-21
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,14 @@
1010
*.o
1111
*.o.*
1212

13-
drbd/drbd.ko
14-
drbd/drbd.ko.unsigned
15-
drbd/drbd_transport_tcp.ko
16-
drbd/drbd_transport_tcp.ko.unsigned
17-
drbd/drbd_transport_tcp.mod.c
18-
drbd/drbd_transport_rdma.ko
19-
drbd/drbd_transport_rdma.ko.unsigned
20-
drbd/drbd_transport_rdma.mod.c
21-
drbd/*.mod
22-
drbd/.*.cmd
23-
drbd/.compat_test.*/
24-
drbd/.config.*.timestamp
25-
drbd/.kernel.config.gz
26-
drbd/.drbd_kernelrelease
27-
drbd/.drbd_kernelrelease.new
28-
drbd/.drbd_git_revision
29-
drbd/.tmp_versions
30-
drbd/Module.symvers
13+
drbd/tags
14+
drbd/cscope.out
15+
drbd/build-*/
3116
drbd/compat*.h
32-
drbd/drbd.mod.c
33-
drbd/drbd_buildtag.c
34-
drbd/modules.order
17+
drbd/compat*.patch
18+
drbd/.drbd_git_revision
19+
drbd/dummy-for-compat-h.c
20+
drbd/dummy-for-patch.c
21+
22+
/drbd-kmod_rhel.spdx
23+
/drbd-kmod_sles.spdx

Makefile

+4-7
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,11 @@ module: check-kdir check-submods
129129
install:
130130
$(MAKE) -C drbd install
131131

132-
unpatch:
133-
$(MAKE) -C drbd unpatch
134-
135-
clean: unpatch
132+
clean:
136133
@ set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
137-
rm -f *~
134+
rm -f *~ ; rm -rf tmp.km-deb.*
138135

139-
distclean: unpatch
136+
distclean:
140137
@ set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i distclean; done
141138
rm -f *~ .filelist
142139

@@ -338,7 +335,7 @@ endif
338335
ifdef DEBBUILD
339336
.PHONY: km-deb
340337
km-deb: check-submods distclean drbd/.drbd_git_revision
341-
D=$$(mktemp -p . -d); \
338+
D=$$(mktemp -p . -d tmp.km-deb.XXXXXXXXXX); \
342339
( git ls-files --recurse-submodules ; \
343340
echo drbd/.drbd_git_revision ) | cpio -pvmd "$$D" ; \
344341
( cd "$$D" && $(DEBBUILD) -i -us -uc -b ) && rm -rf "$$D"

0 commit comments

Comments
 (0)