Whamcloud - gitweb
LU-4573 tests: check all MDTs for open files
[fs/lustre-release.git] / contrib / scripts / clearpatches.sh
1 #!/bin/bash
2 PROG=$(basename $0)
3 [ "$1" = "-h" -o "$1" = "--help" ] && echo "usage: $PROG [patch dir]" && exit 0
4 [ "$1" = "-d" ] && shift && DELETE="git rm" || DELETE="echo Unused"
5 [ "$1" = "-v" ] && shift && VERBOSE="echo Checking" || VERBOSE=":"
6
7 [ "$1" ] && BASEDIR="$1"
8 BASEDIR=${BASEDIR:-lustre/kernel_patches}
9 SERIESPATH=${SERIESPATH:-$BASEDIR/series}
10 PATCHPATH=${PATCHPATH:-$BASEDIR/patches}
11
12 [ ! -d "$BASEDIR" ] && echo "$PROG: missing base directory '$BASEDIR'" && exit 1
13 [ ! -d "$SERIESPATH" ] && echo "$PROG: missing series '$SERIESPATH'" && exit 2
14 [ ! -d "$PATCHPATH" ] && echo "$PROG: missing patches '$PATCHPATH'" && exit 3
15
16 CANONICAL_SERIESPATH=$(readlink -f ${SERIESPATH})
17 pushd $PATCHPATH > /dev/null
18 for PATCH in $(find -name "*.patch"); do
19         # Remove the leading "./"
20         PATCH=${PATCH##./}
21         $VERBOSE $PATCH
22         if ! grep -q -e "^$PATCH" $CANONICAL_SERIESPATH/*.series ; then
23                 $DELETE $PATCH
24         fi
25 done
26 popd > /dev/null