Skip to content

Commit 288704a

Browse files
committed
build: test for working coccinelle instead of version
We used a strict version check, which was for outdated, and also not necessarily sufficient, as we saw with the two different 1.1.1 spatch versions shipped in Ubuntu and Fedora. Instead, we use a separate script that checks that spatch can actually parse the patches, which is more robust than the version check.
1 parent 43dac88 commit 288704a

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,8 @@ check-compat:
347347
drbd/drbd-kernel-compat/check_patch_names.cocci \
348348
drbd/drbd-kernel-compat/gen_patch_names.c
349349

350-
COCCI_PATCHES := $(patsubst drbd/drbd-kernel-compat/cocci/%.cocci,%,$(wildcard drbd/drbd-kernel-compat/cocci/*.cocci))
351-
352350
.PHONY: cocci-syntax
353351
cocci-syntax: $(addprefix cocci-syntax-,$(COCCI_PATCHES))
354-
355-
cocci-syntax-%: drbd/drbd-kernel-compat/cocci/%.cocci
356-
@spatch --very-quiet --parse-cocci $^ >/dev/null && echo " COCCISYNTAX OK $$(basename $^)" || { echo " COCCISYNTAX FAIL $$(basename $^)" ; exit 1 ; }
352+
@drbd/drbd-kernel-compat/spatch_works.sh $(wildcard drbd/drbd-kernel-compat/cocci/*.cocci)
357353

358354
Makefile: ;

drbd/drbd-kernel-compat/gen_compat_patch.sh

+5-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
#!/bin/bash
22

3-
MIN_SPATCH_VERSION=1.0.8
43
[[ ${V:-0} != [02] ]] && set -x
54

65
# to be passed in via environment
76
: ${sources[@]?}
87
: ${compat_patch?}
98
: ${chksum?}
109

11-
# test if the version $1 is greater (more recent) than $2.
12-
function version_gt() {
13-
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
14-
}
15-
16-
function spatch_is_recent() {
17-
ver=$(spatch --version | head -1 | sed -rn 's/^spatch version ([[:digit:]]\.[[:digit:]]\.[[:digit:]]).*/\1/p')
18-
! version_gt $MIN_SPATCH_VERSION $ver
19-
}
20-
2110
function die_no_spatch() {
2211
echo "ERROR: no suitable spatch found in \$PATH. Install package 'coccinelle'!"
2312
exit 1
@@ -37,11 +26,11 @@ if test -e .compat_patches_applied; then
3726
rm -f .compat_patches_applied
3827
fi
3928

40-
if ! spatch_is_recent; then
41-
echo "INFO: spatch not recent enough, need spatch version >= $MIN_SPATCH_VERSION"
29+
if ! drbd-kernel-compat/spatch_works.sh drbd-kernel-compat/cocci/*.cocci >/dev/null 2>&1 ; then
30+
echo "INFO: available spatch is not compatible with at least one patch"
4231
fi
4332

44-
if hash spatch && spatch_is_recent; then
33+
if hash spatch && drbd-kernel-compat/spatch_works.sh drbd-kernel-compat/cocci/*.cocci >/dev/null 2>&1 ; then
4534
K=$(cat $incdir/kernelrelease.txt || echo unknown kernel release)
4635
echo " GENPATCHNAMES "$K
4736
gcc -I $incdir -o $incdir/gen_patch_names -std=c99 drbd-kernel-compat/gen_patch_names.c
@@ -120,15 +109,15 @@ else
120109
if test -e ../.git; then
121110
echo " INFO: not trying spatch-as-a-service because you are trying"
122111
echo " to build DRBD from a git checkout. Please install a suitable"
123-
echo " version of coccinelle (>1.0.8) or try building from a"
112+
echo " version of coccinelle (>=1.2) or try building from a"
124113
echo " release tarball."
125114
die_no_spatch
126115
fi
127116

128117
if [[ $SPAAS != true ]]; then
129118
echo " INFO: spatch-as-a-service was disabled by your package"
130119
echo " maintainer (\$SPAAS = false). Install a suitable version"
131-
echo " of coccinelle (>1.0.8) or allow spatch-as-a-service by"
120+
echo " of coccinelle (>=1.2) or allow spatch-as-a-service by"
132121
echo " setting \$SPAAS = true"
133122
die_no_spatch
134123
fi
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
for PATCH in "$@"; do
4+
spatch --very-quiet --parse-cocci "$PATCH" >/dev/null && echo " COCCISYNTAX OK $(basename "$PATCH")" || { echo " COCCISYNTAX FAIL $(basename "$PATCH")" ; exit 1 ; }
5+
done

0 commit comments

Comments
 (0)