From 4fb419d0b3f43b202426d6239500a1b9a4e76fa3 Mon Sep 17 00:00:00 2001 From: chwe17 Date: Fri, 31 Aug 2018 02:28:53 +0200 Subject: [PATCH] new Feature: -U | --upgrade: - create PR (BOOT=NO) followed by apt udate && apt upgrade and Reboot - after reboot you'll promted to the tests you've to do in the first shell you'll open (same User) fix: - credentials are only once needed for a Pull Request during normal usage of createreport.sh --- createreport.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/createreport.sh b/createreport.sh index 712c105..3d7acda 100755 --- a/createreport.sh +++ b/createreport.sh @@ -55,6 +55,7 @@ checkLocalconfig () { } createReport () { + VERSION=$(cat /etc/armbian-release | grep VERSION= | cut -c 9-) checkLocalconfig git checkout master git pull origin master @@ -77,15 +78,75 @@ createReport () { read -p 'Do you want to push this changes upstream and send a PR to armbian? [YES/NO]: ' happy case $happy in yes|Yes|YES|y|Y) - git commit + read -p 'Commitmessage: ' MESSAGE + git commit -m "${BOARD}-${BRANCH}: ${VERSION} ${MESSAGE}" hub fork git push -u $(git remote -v | awk '{print $1}' | grep -vEw origin | tail -n -1) $(date +%Y%m%d)-$BOARD-$BRANCH - hub pull-request + hub pull-request -m "${BOARD}-${BRANCH}: ${VERSION} ${MESSAGE}" ;; *) git reset --hard HEAD echo "Aborted" - exit 1 + exit 0 + ;; + esac +} + +pullRequestUpgrade () { + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + BOARD=$(cat /etc/armbian-release | grep BOARD= | cut -c 7-) + BRANCH=$(cat /etc/armbian-release | grep BRANCH= | cut -c 8-) + VERSION_BEFORE=$(cat /etc/armbian-release | grep VERSION= | cut -c 9-) + echo "Update from: "$VERSION_BEFORE + apt update && sudo apt upgrade + VERSION_AFTER=$(cat /etc/armbian-release | grep VERSION= | cut -c 9-) + git checkout -b $(date +%Y%m%d)-$BOARD-$BRANCH + echo 'BOOT=no' > ${BOARD}-${BRANCH}.report + echo "VERSION="$VERSION_AFTER >> ${BOARD}-${BRANCH}.report + echo "KERNEL= - " >> ${BOARD}-${BRANCH}.report + echo "NETWORK=no" >> ${BOARD}-${BRANCH}.report + echo "WIRELESS=no" >> ${BOARD}-${BRANCH}.report + echo "HDMI=no" >> ${BOARD}-${BRANCH}.report + echo "USB=no" >> ${BOARD}-${BRANCH}.report + echo "DVFS=no" >> ${BOARD}-${BRANCH}.report + echo "ARMBIANMONITOR=no" >> ${BOARD}-${BRANCH}.report + git add -A + git commit -m "Upgrade from : ${VERSION_BEFORE} to ${VERSION_AFTER}" + git push -u $(git remote -v | awk '{print $1}' | grep -vEw origin | tail -n -1) $(date +%Y%m%d)-$BOARD-$BRANCH + hub pull-request -m "Upgrade from : ${VERSION_BEFORE} to ${VERSION_AFTER}" + echo "bash ${DIR}/createreport.sh -R" >> /home/$(whoami)/.bashrc + sudo reboot +} + +afterRestart () { + BOARD=$(cat /etc/armbian-release | grep BOARD= | cut -c 7-) + BRANCH=$(cat /etc/armbian-release | grep BRANCH= | cut -c 8-) + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + sed -i '/createreport.sh/d' /home/$(whoami)/.bashrc + cd $DIR + echo "yes=works no=don't work NT=not tested NA=not populated" + echo 'BOOT=yes' > ${BOARD}-${BRANCH}.report + cat /etc/armbian-release | grep VERSION >> ${BOARD}-${BRANCH}.report + echo "KERNEL="$(uname -r) >> ${BOARD}-${BRANCH}.report + read -p 'NETWORK: ' netw && echo 'NETWORK='$netw >> ${BOARD}-${BRANCH}.report + read -p 'WIRELESS: ' wlan && echo 'WIRELESS='$wlan >> ${BOARD}-${BRANCH}.report + read -p 'HDMI: ' hdmi && echo 'HDMI='$hdmi >> ${BOARD}-${BRANCH}.report + read -p 'USB: ' usb && echo 'USB='$usb >> ${BOARD}-${BRANCH}.report + read -p 'DVFS: ' dvfs && echo 'DVFS='$dvfs >> ${BOARD}-${BRANCH}.report + echo "ARMBIANMONITOR="$(sudo armbianmonitor -u | head -n -2 | cut -c 54-) >> ${BOARD}-${BRANCH}.report + echo "===================================================" + git add -A + git diff --cached + read -p 'Do you want to push this changes upstream and send a PR to armbian? [YES/NO]: ' happy + case $happy in + yes|Yes|YES|y|Y) + git commit + git push -u $(git remote -v | awk '{print $1}' | grep -vEw origin | tail -n -1) $(date +%Y%m%d)-$BOARD-$BRANCH + ;; + *) + git reset --hard HEAD + echo "Aborted, you can restart the Report with ./createreport.sh -R" + exit 0 ;; esac } @@ -175,6 +236,10 @@ case $1 in echo -e " commitrights${NC} to this repo can use this function)." echo "-u|--update Update masters branch of your fork (this is not needed for a" echo " proper working script, only for cosmetic housekeeping)" + echo "-U|--upgrade Creates a PR, followed by apt update & apt upgrade and reboot" + echo " you'll be prompted to the board check the next time you log" + echo " into the console. The PR will be marked as not booting until" + echo " you finish the tests!" echo "-d|--delete Lists and deletes remote branches in your fork (with yes/no" echo " prompt, only for cosmetic housekeeping)" echo "* create PR with your tests" @@ -196,6 +261,24 @@ case $1 in git pull origin master git push $(git remote -v | awk '{print $1}' | grep -vEw origin | tail -n -1) master ;; + -U|--upgrade) + echo -e "Do you want to upgrade your board?" + read -p '[Yes/No]: ' yn + if [[ $yn =~ ^[Yy](es)?$ ]] + then + git checkout master && git pull + checkDependencies + checkLocalconfig + #we try to fork it again in case you execute this script on a board/computer which wasn't used for PRs yet + hub fork + pullRequestUpgrade + else + exit 0 + fi + ;; + -R) + afterRestart + ;; -d|--delete) echo "list and delete remotebranches of your fork" git checkout master @@ -217,5 +300,3 @@ case $1 in createReport ;; esac - -