diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2012-09-28 11:12:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-12-05 14:49:54 -0800 |
commit | a7e5346839dd849ad2acd933b2a7f6c3e07c2519 (patch) | |
tree | 6c39c02db7d44315e6239980b617991004c1be00 | |
parent | 60a37be9323aa56fbac807c19f480c7d9605fb02 (diff) | |
download | ltsi-kernel-a7e5346839dd849ad2acd933b2a7f6c3e07c2519.tar.gz |
scripts: make generate_git do something
Generate a git tree from the ltsi queue of patches, by
only using git commands.
Support a quasi intelligent auto resume feature in the case
where a patch fails to apply, by using the upstream ID (if
present) to determine the current patch used for the HEAD
commit. If that fails, use a diffstat comparison to try
and find the current patch.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rwxr-xr-x | scripts/generate_git | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/scripts/generate_git b/scripts/generate_git index 3c09e7acaca40..cb1053d2ef881 100755 --- a/scripts/generate_git +++ b/scripts/generate_git @@ -9,4 +9,121 @@ # # -echo "Not implemented yet, check back soon." +UPSTREAM="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" +if [ "$1" = "-a" ]; then + AUTORESUME=1 + shift +fi + +DIR=`dirname $0 |sed 's/scripts$//'` +SERIES=$DIR/series + +if [ -z "$SERIES" ]; then + echo Cant find series file at $SERIES + exit 1 +fi + +if [ -n "$2" ];then + START=$2 +fi + +diffstat --help > /dev/null 2>&1 +if [ $? != 0 ]; then + echo It appears you dont have diffstat installed. + echo Please install it. + exit 1 +fi + +if [ ! -d .git ]; then + echo There does not appear to be a git tree in this dir. + echo You need a copy of: + echo $UPSTREAM + echo as a baseline. + exit 1 +fi + +KVER=`cat $DIR/KERNEL_VERSION` +git rev-parse -q --verify v$KVER > /dev/null +if [ $? != 0 ]; then + echo There is no \"v$KVER\" in this git repository. Perhaps pull from: + echo $UPSTREAM + echo to get this tag? + exit 1 +fi + +if [ -n "$AUTORESUME" ]; then + PARENT=`git show|grep ommit|grep 'pstream\|herry\|tip'|sed 's/.* \([0-9a-f]\+\).*/\1/'` + CLEN=`echo $PARENT|wc -c` + if [ $CLEN -ne 41 ]; then + echo Failed to autodetect resume point -- no parent ID + echo falling back to diffstat detection + DS1=`mktemp` + DS2=`mktemp` + git show | diffstat -p0 > $DS1 + for i in $DIR/*\.patch ; do + cat $i | diffstat -p0 > $DS2 + cmp -s $DS1 $DS2 + if [ $? = 0 ]; then + START=$i + break + fi + done + rm $DS1 $DS2 + if [ -z "$START" ]; then + echo diffstat detection failed + exit 1 + fi + fi + + if [ -z "$START" ]; then + START=`grep -l $PARENT $DIR/patches.*/*` + fi + + if [ -z "$START" ]; then + echo Failed to autodetect resume point - no matching filename + echo for patch that created current HEAD commit $PARENT + exit 1 + fi + + START=`basename $START` + echo resuming from current \"$START\" +fi + +if [ -z "$START" ]; then + echo creating branch "$KVER-ltsi" + git checkout -b $KVER-ltsi v$KVER + if [ $? != 0 ]; then + echo Creation of branch $KVER-ltsi failed + exit 1 + fi +fi + +COUNT=`cat $SERIES | grep '^[a-zA-Z0-9_]'|wc -l` +APPLIED=0 + +for i in `cat $SERIES | grep '^[a-zA-Z0-9_]'` +do + + APPLIED=$[$APPLIED+1] + + if [ -n "$START" ]; then + if [ "$START" != "$i" ];then + continue + else + START="" + continue + fi + fi + + if [ ! -f "$DIR/$i" ];then + echo $DIR/$i doesnt exist + break + fi + + echo -n "($APPLIED/$COUNT) " + git am $DIR/$i + if [ $? != 0 ];then + echo git am of $i failed. STBU. + exit 1 + fi +done |