X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=build%2Fclearpatches.sh;h=37318393af037ba8b4ff1bf83185eab9c29fa407;hb=187a94923310521cc0dd37e52a461a1fd3c3b27a;hp=de31352b8375df7ea82fec4885036f6dc369f9ac;hpb=85be04a556acc0d0cd83de7579c81d73a8f449db;p=fs%2Flustre-release.git diff --git a/build/clearpatches.sh b/build/clearpatches.sh old mode 100644 new mode 100755 index de31352..3731839 --- a/build/clearpatches.sh +++ b/build/clearpatches.sh @@ -1,12 +1,26 @@ -SERIESPATH=./series -PATCHESPATH=./patches -NOUSEPATH=./nousepatches +#!/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 Unused" +[ "$1" = "-v" ] && shift && VERBOSE="echo Checking" || VERBOSE=":" -#mkdir -p $NOUSEPATH -for PATCH in `ls $PATCHESPATH | grep -v CVS` ; do - #echo $PATCH - if ! grep -rq $PATCH $SERIESPATH ; then - echo "$PATCH" - #mv $PATCHESPATH/$PATCH $NOUSEPATH +[ "$1" ] && BASEDIR="$1" +BASEDIR=${BASEDIR:-lustre/kernel_patches} +SERIESPATH=${SERIESPATH:-$BASEDIR/series} +PATCHPATH=${PATCHPATH:-$BASEDIR/patches} + +[ ! -d "$BASEDIR" ] && echo "$PROG: missing base directory '$BASEDIR'" && exit 1 +[ ! -d "$SERIESPATH" ] && echo "$PROG: missing series '$SERIESPATH'" && exit 2 +[ ! -d "$PATCHPATH" ] && echo "$PROG: missing patches '$PATCHPATH'" && exit 3 + +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 -e "^$PATCH" $CANONICAL_SERIESPATH/*.series ; then + $DELETE $PATCH fi done +popd > /dev/null