|
@@ -17,23 +17,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
-while getopts c:u:f:?h flag
|
|
|
+while getopts c:u:f:m:g:?h flag
|
|
|
do
|
|
|
case "${flag}" in
|
|
|
c) check_flag=${OPTARG};;
|
|
|
u) update_flag=${OPTARG};;
|
|
|
f) force_flag=${OPTARG};;
|
|
|
+ m) mk404_flag=${OPTARG};;
|
|
|
+ g) graphics_flag=${OPTARG};;
|
|
|
?) help_flag=1;;
|
|
|
h) help_flag=1;;
|
|
|
esac
|
|
|
done
|
|
|
echo "$check_flag"
|
|
|
echo "$update_flag"
|
|
|
+echo "$force_flag"
|
|
|
+echo "$mk404_flag"
|
|
|
+echo "$graphics_flag"
|
|
|
|
|
|
|
|
|
|
|
|
OS_FOUND=$( command -v uname)
|
|
|
-
|
|
|
case $( "${OS_FOUND}" | tr '[:upper:]' '[:lower:]') in
|
|
|
linux*)
|
|
|
TARGET_OS="linux"
|
|
@@ -122,14 +126,82 @@ if [ ! -d $MK404_PATH ]; then
|
|
|
git clone $MK404_URL $MK404_PATH
|
|
|
fi
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
cd $MK404_PATH
|
|
|
-git submodule init
|
|
|
-git submodule update
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if [ "$force_flag" == "1" ]; then
|
|
|
+ check_flag=1
|
|
|
+ update_flag=1
|
|
|
+fi
|
|
|
+if [ "$update_flag" == "1" ]; then
|
|
|
+ check_flag=1
|
|
|
+fi
|
|
|
+if [ "$check_flag" == "1" ]; then
|
|
|
+ if [ -d $MK404_BUILD_PATH ]; then
|
|
|
+ cd $MK404_BUILD_PATH
|
|
|
+ MK404_current_version=$( command ./MK404 --version | grep "MK404" | cut -f 4 -d " ")
|
|
|
+ cd $MK404_PATH
|
|
|
+ else
|
|
|
+ echo "Cannot check current version as it has not been build."
|
|
|
+ fi
|
|
|
+
|
|
|
+ MK404_local_GIT_COMMIT_HASH=$(git log --pretty=format:"%H" -1)
|
|
|
+
|
|
|
+ MK404_local_GIT_COMMIT_NUMBER=$(git rev-list HEAD --count)
|
|
|
+
|
|
|
+ MK404_remote_GIT_COMMIT_HASH=$(git ls-remote --heads $(git config --get remote.origin.url) | grep "refs/heads/master" | cut -f 1)
|
|
|
+
|
|
|
+ MK404_remote_GIT_COMMIT_NUMBER=$(git rev-list origin/master --count)
|
|
|
+
|
|
|
+ echo "Current version : $MK404_current_version"
|
|
|
+ echo ""
|
|
|
+ echo "Current local hash : $MK404_local_GIT_COMMIT_HASH"
|
|
|
+ echo "Current local commit nr : $MK404_local_GIT_COMMIT_NUMBER"
|
|
|
+ if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
|
|
|
+ echo "$(tput setaf 1)"
|
|
|
+ else
|
|
|
+ echo "$(tput sgr 0)"
|
|
|
+ fi
|
|
|
+ echo "Current remote hash : $MK404_remote_GIT_COMMIT_HASH"
|
|
|
+ echo "Current remote commit nr: $MK404_remote_GIT_COMMIT_NUMBER"
|
|
|
+ echo "$(tput sgr 0)"
|
|
|
+
|
|
|
+
|
|
|
+ if [[ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" && -z "$update_flag" ]]; then
|
|
|
+ echo "$(tput setaf 2)Update is availible.$(tput sgr 0)"
|
|
|
+ read -t 10 -n 1 -p "$(tput setaf 3)Update now Y/n$(tput sgr 0)" update_answer
|
|
|
+ if [ "$update_answer" == "Y" ]; then
|
|
|
+ update_flag=1
|
|
|
+ fi
|
|
|
+ echo ""
|
|
|
+ fi
|
|
|
+fi
|
|
|
+
|
|
|
+if [ "$update_flag" == "1" ]; then
|
|
|
+ if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
|
|
|
+ echo ""
|
|
|
+ git fetch --all
|
|
|
+ read -t 10 -p "$(tput setaf 2)Updating MK404 !$(tput sgr 0)"
|
|
|
+ echo ""
|
|
|
+ git reset --hard origin/master
|
|
|
+ read -t 10 -p "$(tput setaf 2)Compiling MK404 !$(tput sgr 0)"
|
|
|
+ echo ""
|
|
|
+ force_flag=1
|
|
|
+ fi
|
|
|
+fi
|
|
|
|
|
|
|
|
|
mkdir -p $MK404_BUILD_PATH
|
|
|
if [[ ! -f "$MK404_BUILD_PATH/Makefile" || "$force_flag" == "1" ]]; then
|
|
|
+
|
|
|
+ git submodule init
|
|
|
+ git submodule update
|
|
|
cmake -B$MK404_BUILD_PATH -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"
|
|
|
fi
|
|
|
|
|
@@ -149,8 +221,3 @@ if [[ ! -f "$MK404_BUILD_PATH/Prusa_MK3S_SDcard.bin" || "$force_flag" == "1" ]];
|
|
|
cmake --build $MK404_BUILD_PATH --config Release --target Prusa_MK3MMU2_SDcard.bin
|
|
|
fi
|
|
|
|
|
|
-
|
|
|
-if [ "$check_flag" == "1" ]; then
|
|
|
- current_version=$( command ./MK404 --version | grep "MK404" | cut -f 4 -d " ")
|
|
|
- echo "Current version: $current_version"
|
|
|
-fi
|