summaryrefslogtreecommitdiff
path: root/bin/mutt_hooks.sh
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2024-05-31 10:55:57 +0200
committerCarlos Maiolino <[email protected]>2024-05-31 10:55:57 +0200
commitc24810c3d5f07c076241b8fd5d912c1136c2cf80 (patch)
tree6c1f906de6212897559a28260d28670233988dd8 /bin/mutt_hooks.sh
parent47b7016ed5ac6dd8efc041060d62e632e937a6d2 (diff)
Add a few extra scripts and move them to bin/
Diffstat (limited to 'bin/mutt_hooks.sh')
-rwxr-xr-xbin/mutt_hooks.sh77
1 files changed, 77 insertions, 0 deletions
diff --git a/bin/mutt_hooks.sh b/bin/mutt_hooks.sh
new file mode 100755
index 0000000..36ecbf6
--- /dev/null
+++ b/bin/mutt_hooks.sh
@@ -0,0 +1,77 @@
+#!/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