Skip to content

Instantly share code, notes, and snippets.

@v1993
Last active October 31, 2018 23:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save v1993/a909b29218a12d8a35377bd6ef0fbd41 to your computer and use it in GitHub Desktop.
Save v1993/a909b29218a12d8a35377bd6ef0fbd41 to your computer and use it in GitHub Desktop.
Simple STK git updater
#!/bin/bash
assetstriger=false
codetriger=false
compiler=g++
. /etc/stk-update
startupdate(){
if zenity --question --title=SuperTuxKart --text='Есть обновления SuperTuxKart. Поставить?' --icon-name=supertuxkart --ok-label=Поставить --cancel-label=Потом --modal
then
BUILD_DIR="$BASEDIR"/stk-code/cmake_build
cd $BUILD_DIR
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_COMPILER="$compiler" ..
make -j $jobscount | tee /dev/stderr | grep -o --line-buffered '\[.*\%\]' | grep --line-buffered -oE '[0-9]*' | zenity --progress --auto-kill --title="Компилятор" --text="Компиляция supertuxkart"
killall supertuxkart 2>/dev/null && sleep 5
pkexec sh -c "cd ${BUILD_DIR} && make install"
rm -f "$BASEDIR"/stk-code/needtoupdate
else
touch "$BASEDIR"/stk-code/needtoupdate
echo "Aborted." 1>/dev/stderr
return 0
fi
}
checkupdate(){
cd "$BASEDIR"/stk-assets
if [ $(svn update | wc -l) -gt 2 ]
then
assetstriger=true
fi
cd "$BASEDIR"/stk-code
old_hash=$(git rev-parse HEAD)
git pull
if [ $old_hash != $(git rev-parse HEAD) ] # Last commit is different
then
codetriger=true
fi
if $codetriger || $assetstriger
then
return 0
else
return 1
fi
}
if checkupdate || [ -e "$BASEDIR"/stk-code/needtoupdate ]
then
startupdate
fi
BASEDIR=/home/v/compile # Dir with stk-code and stk-assets inside
compiler=/usr/bin/zapcc++ # Your C++ compiler
jobscount=4 # Count of build jobs
# Hint: you can use ping for setting up distributed builds
# Manually create "$BASEDIR"/stk-code/needtoupdate to force rebuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment