]> git.ipfire.org Git - thirdparty/systemd.git/blame - coccinelle/run-coccinelle.sh
fix(journal-gatewayd): use relative urls (not starting with '/')
[thirdparty/systemd.git] / coccinelle / run-coccinelle.sh
CommitLineData
2d0bc684
LP
1#!/bin/bash -e
2
4a4eaade
FS
3# Exclude following paths from the Coccinelle transformations
4EXCLUDED_PATHS=(
5 "src/boot/efi/*"
6 "src/shared/linux/*"
7 "src/basic/linux/*"
8 # Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
9 "src/libsystemd/sd-bus/test-bus-vtable.c"
10)
11
12b74c38 12top="$(git rev-parse --show-toplevel)"
b3fd7b53 13iso_defs="$top/coccinelle/systemd-definitions.iso"
00bfe67f
ZJS
14args=
15
4a4eaade
FS
16# Create an array from files tracked by git...
17mapfile -t files < <(git ls-files ':/*.[ch]')
18# ...and filter everything that matches patterns from EXCLUDED_PATHS
19for excl in "${EXCLUDED_PATHS[@]}"; do
20 files=(${files[@]//$excl})
21done
22
00bfe67f 23case "$1" in
cc5549ca
ZJS
24 -i)
25 args="$args --in-place"
26 shift
27 ;;
00bfe67f 28esac
31d31f20 29
3b253ad6 30if ! parallel -h >/dev/null; then
cc5549ca
ZJS
31 echo 'Please install GNU parallel (package "parallel")'
32 exit 1
3b253ad6
ZJS
33fi
34
12b74c38 35for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do
cc5549ca
ZJS
36 echo "--x-- Processing $SCRIPT --x--"
37 TMPFILE=`mktemp`
38 echo "+ spatch --sp-file $SCRIPT $args ..."
39 parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
4a4eaade 40 spatch --iso-file $iso_defs --sp-file $SCRIPT $args ::: "${files[@]}" \
cc5549ca
ZJS
41 2>"$TMPFILE" || cat "$TMPFILE"
42 echo -e "--x-- Processed $SCRIPT --x--\n"
2d0bc684 43done