|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +#alpha script to test a patch system for quick fixes in BAP |
| 4 | +#KM4ACK 20210805 |
| 5 | + |
| 6 | +MYPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" |
| 7 | +LOGO=${MYPATH}/logo.png |
| 8 | +DIR=/run/user/$UID |
| 9 | + |
| 10 | +#Setup temp directory for BAP patches and download patches |
| 11 | +cd $DIR |
| 12 | +git init pi-build |
| 13 | +cd pi-build |
| 14 | +git remote add -f origin https://github.com/km4ack/pi-build.git |
| 15 | +git config core.sparseCheckout true |
| 16 | +echo "/patch" >> .git/info/sparse-checkout |
| 17 | +git pull origin dev |
| 18 | + |
| 19 | +TEMP=/run/user/$UID/patch.txt |
| 20 | +MENU(){ |
| 21 | +ls -I readme -I patch $DIR/pi-build/patch > $TEMP |
| 22 | + |
| 23 | +INFO=$(PARSER='OFS="\n" {print $1}' |
| 24 | +MYTEMP=/run/user/$UID/patch1.txt |
| 25 | +tail -10 $TEMP | awk "$PARSER" | \ |
| 26 | +yad --title="Build a Pi Patch Tool" --width=500 --height=500 \ |
| 27 | + --image $LOGO --window-icon=$LOGO --image-on-top --multiple \ |
| 28 | + --center --list --text="Select a Patch to Apply" \ |
| 29 | + --column "Patch" \ |
| 30 | + --button="Exit":1 \ |
| 31 | + --button="Apply Patch":2) |
| 32 | +BUT=$? |
| 33 | + |
| 34 | +PATCH=$(echo ${INFO} | awk -F "|" '{print $1}') |
| 35 | + |
| 36 | +#cleanup and exit upon user request |
| 37 | +if [ ${BUT} = 1 ] || [ ${BUT} = 252 ];then |
| 38 | +echo "cleanup and exit Build a Pi patch tool" |
| 39 | +rm -rf $TEMP $DIR/pi-build |
| 40 | +${MYPATH}/update && exit |
| 41 | +fi |
| 42 | + |
| 43 | +#verify patch has not been applied already |
| 44 | +echo "getting patchname" |
| 45 | +PATCHNAME=$(grep PATCHNAME= $DIR/pi-build/patch/${PATCH} | sed 's/PATCHNAME=//') |
| 46 | +PATCHCHECK=$(grep ${PATCHNAME} $HOME/.config/patch) |
| 47 | + |
| 48 | +if [ -z $PATCHCHECK ]; then |
| 49 | +#apply patch & give user notice that patch has been applied |
| 50 | +echo "applying $PATCH" |
| 51 | +bash ${DIR}/pi-build/patch/${PATCH} |
| 52 | + |
| 53 | + yad --form --width=500 --text-align=center --center --title="Build-a-Pi Patch Tool" --text-align=center \ |
| 54 | + --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ |
| 55 | + --text="<b>${PATCH}</b> patch has been applied" \ |
| 56 | + --button=gtk-close |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +#rm -rf $TEMP $DIR/pi-build |
| 61 | +MENU |
| 62 | +else |
| 63 | + yad --form --width=500 --text-align=center --center --title="Build-a-Pi Patch Tool" --text-align=center \ |
| 64 | + --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ |
| 65 | + --text="<b>$PATCH</b> was applied previously\rNo need to apply again." \ |
| 66 | + --button=gtk-close |
| 67 | +#rm -rf $TEMP $DIR/pi-build |
| 68 | +MENU |
| 69 | +exit |
| 70 | +fi |
| 71 | +} |
| 72 | +MENU |
| 73 | + |
0 commit comments