33
44ROOTDIR=$( dirname $( readlink -f $0 ) ) /..
55
6+ # busybox grep does not know about --text
7+ if grep --help 2> /dev/null | grep -q -- --text; then
8+ GREP=" grep --text"
9+ else
10+ GREP=grep
11+ fi
12+
613# split preload code into internal logic and libc wrappers
714CODE_INT=` grep -B 100000 ' Overridden libc' $ROOTDIR /src/libumockdev-preload.c`
815CODE_WRAPPERS=` grep -A 100000 ' Overridden libc' $ROOTDIR /src/libumockdev-preload.c`
916
10- LIBC_OVERRIDES=` echo " $CODE_WRAPPERS " | grep --text ' ^[a-z_]\+(' | grep -v ' ^WRAP_' | cut -f1 -d' (' `
17+ LIBC_OVERRIDES=` echo " $CODE_WRAPPERS " | $GREP ' ^[a-z_]\+(' | grep -v ' ^WRAP_' | cut -f1 -d' (' `
1118
1219RET=0
1320
@@ -23,11 +30,11 @@ check_empty() {
2330}
2431
2532# internal code must not have any exported (non-static) functions
26- R=$( echo " $CODE_INT " | grep --text -B1 ' ^[a-z_]\+(' | awk ' BEGIN { RS="--\n" } !/static/ { print $0 }' )
33+ R=$( echo " $CODE_INT " | $GREP -B1 ' ^[a-z_]\+(' | awk ' BEGIN { RS="--\n" } !/static/ { print $0 }' )
2734check_empty " $R " " preload internal code part has exported function(s)"
2835
2936# wrappers must be exported
30- R=$( echo " $CODE_WRAPPERS " | grep --text -B1 ' ^[a-z_]\+(' | awk ' BEGIN { RS="--\n" } /static/ { print $0 }' )
37+ R=$( echo " $CODE_WRAPPERS " | $GREP -B1 ' ^[a-z_]\+(' | awk ' BEGIN { RS="--\n" } /static/ { print $0 }' )
3138check_empty " $R " " preload libc wrapped code part has non-exported function(s)"
3239
3340# wrappers must not have a '_' in the name, libc doesn't use that style
@@ -36,7 +43,7 @@ check_empty "$R" "preload libc wrapped code part exports function with '_'"
3643
3744# must not use wrapped functions in internal logic
3845for fn in $LIBC_OVERRIDES ; do
39- R=$( echo " $CODE_INT " | grep --text - w $fn | grep --text -Ev " (/\*|\" |libc_func|#include|^ \* ).*$fn " || true)
46+ R=$( echo " $CODE_INT " | $GREP - w $fn | $GREP -Ev " (/\*|\" |libc_func|#include|^ \* ).*$fn " || true)
4047 check_empty " $R " " preload internal code part must not use overridden libc function $fn "
4148done
4249
0 commit comments