Whamcloud - gitweb
LU-2473 ldiskfs: Reorganize ldiskfs kernel patches
[fs/lustre-release.git] / build / clearpatches.sh
index 1f28746..3731839 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/bash
 PROG=$(basename $0)
 [ "$1" = "-h" -o "$1" = "--help" ] && echo "usage: $PROG [patch dir]" && exit 0
-[ "$1" = "-d" ] && shift && DELETE="git rm" || DELETE="echo"
-[ "$1" = "-v" ] && shift && VERBOSE="echo" || VERBOSE=":"
+[ "$1" = "-d" ] && shift && DELETE="git rm" || DELETE="echo Unused"
+[ "$1" = "-v" ] && shift && VERBOSE="echo Checking" || VERBOSE=":"
 
 [ "$1" ] && BASEDIR="$1"
 BASEDIR=${BASEDIR:-lustre/kernel_patches}
@@ -13,9 +13,14 @@ PATCHPATH=${PATCHPATH:-$BASEDIR/patches}
 [ ! -d "$SERIESPATH" ] && echo "$PROG: missing series '$SERIESPATH'" && exit 2
 [ ! -d "$PATCHPATH" ] && echo "$PROG: missing patches '$PATCHPATH'" && exit 3
 
-for PATCH in $(ls $PATCHPATH | egrep -v "CVS|~$|.orig|.rej"); do
+CANONICAL_SERIESPATH=$(readlink -f ${SERIESPATH})
+pushd $PATCHPATH > /dev/null
+for PATCH in $(find -name "*.patch"); do
+       # Remove the leading "./"
+       PATCH=${PATCH##./}
        $VERBOSE $PATCH
-       if ! grep -q $PATCH $SERIESPATH/*.series ; then
-               $DELETE $PATCHPATH/$PATCH
+       if ! grep -q -e "^$PATCH" $CANONICAL_SERIESPATH/*.series ; then
+               $DELETE $PATCH
        fi
 done
+popd > /dev/null