blob: 9cdaf37412aff3ebadfe117ab3a304a7966078a9 [file] [log] [blame]
#!/bin/bash
#
# LTSI helper script to generate a git tree from the quilt LTSI tree
#
# Copyright 2012 Greg Kroah-Hartman
# Copyright 2012 Linux Foundation
#
# Licensed under the GPLv2 only.
#
#
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/patches\.*/*\.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=`echo $START|sed 's/^.*patches\./patches./'`
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