diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2016-12-28 13:51:20 -0500 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2016-12-28 16:14:39 -0500 |
commit | c0db06c6c8be34bf2a15d6f52b15ffa3df4c8f96 (patch) | |
tree | 3b506109fa6caabf8ef61ea371cf758f04ad69b6 | |
parent | 74cd00a5a3fb1a8cd1d0d50d78d29846b3bff5c4 (diff) | |
download | 4.9-rt-patches-c0db06c6c8be34bf2a15d6f52b15ffa3df4c8f96.tar.gz |
4.9-rt: add script to auto create bisect branches
Sample usage:
mkdir rt-test
cd rt-test
# clone mainline or clone from a local copy with >=4.9 tags in it.
git clone /path/to/my/existing/mainline/linux linux-rt-bisect
git clone git://git.kernel.org/pub/scm/linux/kernel/git/paulg/4.9-rt-patches.git
cd linux-rt-bisect
../4.9-rt-patches.git/scripts/create-branches.sh
-rwxr-xr-x | scripts/create-branches.sh | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/scripts/create-branches.sh b/scripts/create-branches.sh new file mode 100755 index 00000000000000..b9da8a8e65f778 --- /dev/null +++ b/scripts/create-branches.sh @@ -0,0 +1,157 @@ +#!/bin/bash + +# Create an -rt branch on top of each incremental merge in mainline by Linus. + +# Assumes patches for merge "v4.x-gabcdef" are on tag "rt-v4.x-gabcdef" in +# the $PATCHES repo. + +START=v4.8 +END=v4.9 +RC=8 + +# Collect path info and then clone ourselves and fork. +if [ -z "$KERNEL" ]; then + echo "Path to existing mainline kernel repo where you want the rt bisect branches." + echo -n "(e.g. \"/home/paul/git/linux-rt-bisect\") Default is \"./\": " + read KERNEL + if [ -z "$KERNEL" ]; then + KERNEL="./" + fi + + KERNEL=`readlink -f $KERNEL` + if [ ! -d "$KERNEL"/.git ]; then + echo Entry $KERNEL does not appear to be a git repo + exit 1 + fi + + PATCHES=`dirname $0 | sed 's/scripts/patches/'` + PATCHES=`readlink -f $PATCHES` + + # We'll check out tags where we don't exist; so copy ourselves. + SCRIPT=`mktemp` + echo '#!/bin/bash' > $SCRIPT + echo SCRIPT=$SCRIPT >> $SCRIPT + echo KERNEL=$KERNEL >> $SCRIPT + echo PATCHES=$PATCHES >> $SCRIPT + cat $0 | grep -v '^#!/bin/bash' >> $SCRIPT + chmod +x $SCRIPT + exec $SCRIPT +fi + +MERGES=`mktemp` +DMERGES=`mktemp` +MAPPING=`mktemp` +LOG=`mktemp` + +echo Logging debug and errors to $LOG +# echo Mapping of merges to patch tags in $MAPPING + +cd $PATCHES > $LOG 2>&1 +if [ $? != 0 ]; then + echo Can not cd into $PATCHES + exit 1 +fi + +git checkout $END-rt >> $LOG 2>&1 +if [ $? != 0 ];then + echo Checkout of $END-rt in $PATCHES failed + exit 1 +fi + +if [ ! -f $PATCHES/series ]; then + echo Can not find series file in $PATCHES + exit 1 +fi + +cd $KERNEL >> $LOG 2>&1 +if [ $? != 0 ]; then + echo Can not cd into $KERNEL + exit 1 +fi + +# Sanity check +git rev-parse $START >> $LOG 2>&1 +if [ $? != 0 ]; then + echo Cant resolve $START in $KERNEL + exit 1 +fi +git rev-parse $END >> $LOG 2>&1 +if [ $? != 0 ]; then + echo Cant resolve $END in $KERNEL + exit 1 +fi + +echo "Getting merges.." +git log --oneline --merges --author=Torvalds --reverse ^$START $END-rc1 | awk '{print $1}' > $MERGES + +# post rc1 we dont do it per merge, just per rc tag. +for i in `seq $RC` ; do echo $END-rc$i >> $MERGES ; done +echo $END >> $MERGES +MCOUNT=`cat $MERGES | wc -l` + +echo -n "Describing $MCOUNT merges" +for i in `cat $MERGES` ; do + git describe $i >> $DMERGES + echo -n . +done +echo done. + +echo $START $START.0-rt > $MAPPING +PTAG=rt-START.0 + +cd $PATCHES +# echo "Mapping $MCOUNT merges to patch repo tags." +for i in `cat $DMERGES` ; do + + git tag | grep -q $i + + if [ $? = 0 ]; then # patch tag match for this merge + PTAG=rt-$i + fi + + echo $i $PTAG >> $MAPPING +done + +HERE=1 +for i in `cat $DMERGES` ; do + + PTAG=`grep "^$i " $MAPPING | awk '{print $2}'` + echo "[$HERE/$MCOUNT] Applying $PTAG to $i in $KERNEL" >> $LOG + + cd $PATCHES + git checkout $PTAG >> $LOG 2>&1 + if [ $? != 0 ];then + echo Checkout of $PTAG in $PATCHES failed + exit 1 + fi + + cd $KERNEL + git checkout -b $i-rt $i >> $LOG 2>&1 + if [ $? != 0 ];then + echo New branch of $i-rt in $KERNEL failed + exit + fi + + COUNT=`cat $PATCHES/series | grep '^[a-zA-Z0-9_]' | wc -l` + echo "[$HERE/$MCOUNT] Applying $PTAG ($COUNT patches) to $i baseline" + for i in `cat $PATCHES/series | grep '^[a-zA-Z0-9_]'`; do + git am $PATCHES/$i >> $LOG 2>&1 + if [ $? != 0 ]; then + echo Git am of $PATCHES/$i failed + exit 1 + fi + done + + HERE=$[$HERE+1] +done + +cd $PATCHES +git checkout $END-rt >> $LOG 2>&1 +cd $KERNEL + +# rm -f $LOG +rm -f $MERGES +rm -f $DMERGES +rm -f $MAPPING +# Finally, remove ourselves. +rm -f $SCRIPT |