#!/bin/bash email=$1 patch=/tmp/$$.patch tempfile=/tmp/item_menu.$$ KERNEL_SOURCE=/home/cmaiolin/Source/kernel/linux.pristine/ clear_repo(){ dialog --clear --yesno \ " Wanna reset the git tree?" 0 0 if [ $? -eq 0 ]; then git reset --hard fi } diff_patch(){ UPSTREAM_PATCH=/tmp/upstream.patch UPSTREAM_COMMIT=/tmp/upstream.commit #get commit from message cat $1 | grep "^commit"| awk '{for (I=1;I<=NF;I++) if ($I == "commit") {print $(I+1)};}' | sed 's/)//' > $UPSTREAM_COMMIT # commit probably cherry-picked if [ -z `cat $UPSTREAM_COMMIT` ]; then cat $1 | grep "commit"| awk '{for (I=1;I<=NF;I++) if ($I == "commit") {print $(I+1)};}' | sed 's/)//' > $UPSTREAM_COMMIT fi #COMMIT=`cat $1 | grep "commit"| awk '{for (I=1;I<=NF;I++) if ($I == "commit") {print $(I+1)};}' | awk -F'|' '{print $1}' | sed 's/)//'` COMMIT=`cat $UPSTREAM_COMMIT |head -1` echo $COMMIT #Extract upstream patch echo "Entering source" cd $KERNEL_SOURCE echo "Extracting patch" git format-patch --stdout -1 $COMMIT > $UPSTREAM_PATCH echo $UPSTREAM_PATCH cd - echo "STARTING DIFF" vimdiff $patch $UPSTREAM_PATCH rm $UPSTREAM_PATCH $UPSTREAM_COMMIT } apply_patch(){ repolist=$(ls $sources | awk '{print $1,$1}') dialog --clear --menu "Select repository to apply the patch" 0 0 20 $repolist 2> $tempfile #"Select repository to apply the patch" 30 60 20 $repolist 2> $tempfile repo=`cat $tempfile` echo $repo cd $sources/$repo git apply $patch #diff_patch clear_repo } clear_env(){ rm -rf $tempfile rm -rf $patch } ###main cat $email | formail -I "" > $patch diff_patch $patch #cat $email | formail -I "" | awk '/^---/{p=1}p' > /tmp/patch.patch rm $patch #apply_patch #clear_env