Whamcloud - gitweb
LU-2446 build: Update Whamcloud copyright messages to Intel
[fs/lustre-release.git] / build / 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"
5 [ "$1" = "-v" ] && shift && VERBOSE="echo" || 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 for PATCH in $(ls $PATCHPATH | egrep -v "CVS|~$|.orig|.rej"); do
17         $VERBOSE $PATCH
18         if ! grep -q $PATCH $SERIESPATH/*.series ; then
19                 $DELETE $PATCHPATH/$PATCH
20         fi
21 done