Browse Source

PF-build.sh:
- Add sort of variants. Request from @leptun
- Add Arduino IDE 1.8.19 as an option
- Allow upper and lower case. Request from @TojikCZ

MK404-build.sh:
- Allow upper and lower case. Request by @TojikCZ
- Add update option to release OR devel

3d-gussner 3 years ago
parent
commit
256c3f453b
2 changed files with 71 additions and 31 deletions
  1. 60 24
      MK404-build.sh
  2. 11 7
      PF-build.sh

+ 60 - 24
MK404-build.sh

@@ -10,7 +10,7 @@
 # 3. Install latest updates with 'sudo apt-get upgrade'
 # 
 #
-# Version: 1.0.0-Build_13
+# Version: 1.0.0-Build_14
 # Change log:
 # 11 Feb 2021, 3d-gussner, Inital
 # 11 Feb 2021, 3d-gussner, Optional flags to check for updates
@@ -22,6 +22,8 @@
 # 18 Jun 2021, 3d-gussner, Added -g 3 and 4 for more details extrusion lines
 # 18 Jun 2021, 3d-gussner, Check for updates is default. Fix update if internet connection is lost.
 # 21 Jun 2021, 3d-gussner, Change board_flash argument to 'y' and firmware_version to 'f'
+# 25 Jan 2021, 3d-gussner, Allow upper and lower case in selection
+#                          Add update option to release OR devel
 
 #### Start: Failures
 failures()
@@ -74,7 +76,7 @@ while getopts c:f:g:m:n:p:u:x:y:?h flag
 # '?' 'h' argument usage and help
 if [ "$help_flag" == "1" ] ; then
 echo "***************************************"
-echo "* MK404-build.sh Version: 1.0.0-Build_13 *"
+echo "* MK404-build.sh Version: 1.0.0-Build_14 *"
 echo "***************************************"
 echo "Arguments:"
 echo "$(tput setaf 2)-c$(tput sgr0) Check for update"
@@ -98,7 +100,7 @@ echo "  -g : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' l
 echo "  -m : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes '$(tput setaf 2)2$(tput sgr0)' with MMU2"
 echo "  -n : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes"
 echo "  -p : '$(tput setaf 2)MK25$(tput sgr0)', '$(tput setaf 2)MK25S$(tput sgr0)', '$(tput setaf 2)MK3$(tput sgr0)' or '$(tput setaf 2)MK3S$(tput sgr0)'"
-echo "  -u : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes '"
+echo "  -u : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' release ', '$(tput setaf 2)2$(tput sgr0)' devel '"
 echo "  -x : '$(tput setaf 2)8$(tput sgr0)',$(tput setaf 2)16$(tput sgr0)',$(tput setaf 2)32$(tput sgr0)' or '$(tput setaf 2)64$(tput sgr0)' Kb."
 echo "  -y : '$(tput setaf 2)256$(tput sgr0)','$(tput setaf 2)384$(tput sgr0)','$(tput setaf 2)512$(tput sgr0)','$(tput setaf 2)1024$(tput sgr0)''$(tput setaf 2)32M$(tput sgr0)'"
 echo
@@ -170,9 +172,8 @@ fi
 #Start: Check if new build is selected
 if [ "$new_build_flag" == "1" ]; then
     check_flag=1
-    update_flag=1
 fi
-if [ "$update_flag" == "1" ]; then
+if [[ "$update_flag" == "1" || "$update_flag" == "2" ]]; then
     check_flag=1
 fi
 #End: Check if new build is selected
@@ -196,11 +197,13 @@ if [ ! -z $firmware_version_flag ]; then
     if [ ! -z $MK404_PRINTER_TEMP ]; then
         MK404_PRINTER=MK25S
     fi
+elif [[ ! -z $new_build_flag || ! -z $update_flag || ! -z $check_flag ]]; then
+        echo "continue"
 else
     failures 8
 fi
 
-if [ -z "$MK404_PRINTER" ]; then
+if [[ -z $MK404_PRINTER && -z $new_build_flag && -z $update_flag && -z $check_flag ]]; then
     failures 9
 fi
 
@@ -232,7 +235,7 @@ if [ ! -z $mk404_printer_flag ]; then
     fi
 fi
 
-if [ -z $MK404_PRINTER ]; then
+if [[ -z $MK404_PRINTER && -z $new_build_flag && -z $update_flag && -z $check_flag ]]; then
     failures 10
 fi
 
@@ -399,38 +402,58 @@ if [ "$check_flag" == "1" ]; then
 # Get latest release
     MK404_release_url=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/$MK404_owner/$MK404_project/releases/latest)
     MK404_release_tag=$(basename $MK404_release_url)
-# Get remote Commit_Hash
-    #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_HASH=$(git ls-remote | grep "refs/tags/$MK404_release_tag"  | cut -f 1)
-# Get remote Commit_Number
-    MK404_remote_GIT_COMMIT_NUMBER=$(git rev-list $MK404_release_tag --count)
+# Get release Commit_Hash
+    MK404_release_GIT_COMMIT_HASH=$(git ls-remote | grep "refs/tags/$MK404_release_tag"  | cut -f 1)
+# Get release Commit_Number
+    MK404_release_GIT_COMMIT_NUMBER=$(git rev-list $MK404_release_tag --count)
+# Get latest development Commit_Hash
+    MK404_devel_GIT_COMMIT_HASH=$(git for-each-ref refs/remotes/origin/master | cut -d" " -f 1)
+# Get latest development Commit_Number
+    MK404_devel_GIT_COMMIT_NUMBER=$(git rev-list refs/remotes/origin/master --count)
 # Output
     echo ""
     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
+    if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_release_GIT_COMMIT_HASH" ]; then
         echo "$(tput setaf 1)"
     else
         echo "$(tput setaf 2)"
     fi
     echo "Latest release tag      : $MK404_release_tag"
-    echo "Latest release hash     : $MK404_remote_GIT_COMMIT_HASH"
-    echo "Latest remote commit nr : $MK404_remote_GIT_COMMIT_NUMBER"
+    echo "Latest release hash     : $MK404_release_GIT_COMMIT_HASH"
+    echo "Latest release commit nr: $MK404_release_GIT_COMMIT_NUMBER"
+    if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_devel_GIT_COMMIT_HASH" ]; then
+        echo "$(tput setaf 1)"
+    else
+        echo "$(tput setaf 2)"
+    fi
+    echo "Latest devel hash       : $MK404_devel_GIT_COMMIT_HASH"
+    echo "Latest devel commit nr  : $MK404_devel_GIT_COMMIT_NUMBER"
     echo "$(tput sgr 0)"
 
 # Check for updates
-    if [ ! -z $MK404_remote_GIT_COMMIT_HASH ]; then
-        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
+    if [ ! -z $MK404_release_GIT_COMMIT_HASH ]; then
+        if [[ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_release_GIT_COMMIT_HASH" && -z "$update_flag" ]]; then
+            echo "$(tput setaf 2)Update to release is availible.$(tput sgr 0)"
+            read -t 10 -n 1 -p "$(tput setaf 3)Update to release now Y/n$(tput sgr 0)" update_answer
+            if [[ "$update_answer" == "Y" || "$update_answer" == "y" ]]; then
                 update_flag=1
             fi
             echo ""
         fi
     fi
+    if [ ! -z $MK404_devel_GIT_COMMIT_HASH ]; then
+        if [[ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_devel_GIT_COMMIT_HASH" && -z "$update_flag" ]]; then
+            echo "$(tput setaf 2)Update to devel is availible.$(tput sgr 0)"
+            read -t 10 -n 1 -p "$(tput setaf 3)Update to devel now Y/n$(tput sgr 0)" update_answer
+            if [[ "$update_answer" == "Y" || "$update_answer" == "y" ]]; then
+                update_flag=2
+            fi
+            echo ""
+        fi
+    fi
 fi
 }
 #### End: Check for updates
@@ -439,14 +462,27 @@ fi
 fetch_updates()
 {
 if [ "$update_flag" == "1" ]; then
-    if [ ! -z $MK404_remote_GIT_COMMIT_HASH ]; then
-        if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
+    if [ ! -z $MK404_release_GIT_COMMIT_HASH ]; then
+        if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_release_GIT_COMMIT_HASH" ]; then
             echo ""
             git fetch --all
-            read -t 10 -p "$(tput setaf 2)Updating MK404 !$(tput sgr 0)"
+            read -t 5 -p "$(tput setaf 2)Updating MK404 to release!$(tput sgr 0)"
             echo ""
             git reset --hard $MK404_release_tag
-            read -t 10 -p "$(tput setaf 2)Compiling MK404 !$(tput sgr 0)"
+            read -t 5 -p "$(tput setaf 2)Compiling MK404 release!$(tput sgr 0)"
+            echo ""
+            new_build_flag=1
+        fi
+    fi
+elif [ "$update_flag" == "2" ]; then
+    if [ ! -z $MK404_devel_GIT_COMMIT_HASH ]; then
+        if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_devel_GIT_COMMIT_HASH" ]; then
+            echo ""
+            git fetch --all
+            read -t 5 -p "$(tput setaf 2)Updating MK404 to devel!$(tput sgr 0)"
+            echo ""
+            git reset --hard origin/master
+            read -t 5 -p "$(tput setaf 2)Compiling MK404 devel!$(tput sgr 0)"
             echo ""
             new_build_flag=1
         fi

+ 11 - 7
PF-build.sh

@@ -56,7 +56,7 @@
 #   Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE
 #   it will use the default Arduino IDE folders and so can corrupt the build environment.
 #
-# Version: 2.0.0-Build_66
+# Version: 2.0.0-Build_67
 # Change log:
 # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt'
 # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown
@@ -166,6 +166,9 @@
 # 24 Jun 2021, 3d-gussner, Fix MK404 user interaction not to show if compiling 'All' variants
 # 24 Jun 2021, 3d-gussner, MK404 is only supported on Linux at this moment.
 # 03 Jan 2022, 3d-gussner, Remove calling lang-community.sh as not needed anymore
+# 21 Jan 2022, 3d-gussner, Sort variants
+#                          Add Arduino 1.8.19 as an option
+# 25 Jan 2022, 3d-gussner, Allow upper and lower case for MK404
 
 SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
 
@@ -221,7 +224,7 @@ while getopts b:c:d:g:h:i:j:l:m:n:o:p:v:x:y:?h flag
 # '?' 'h' argument usage and help
 if [ "$help_flag" == "1" ] ; then
 echo "***************************************"
-echo "* PF-build.sh Version: 2.0.0-Build_66 *"
+echo "* PF-build.sh Version: 2.0.0-Build_67 *"
 echo "***************************************"
 echo "Arguments:"
 echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number"
@@ -247,7 +250,7 @@ echo "  -b : '$(tput setaf 2)Auto$(tput sgr0)' needs git or a number"
 echo "  -c : '$(tput setaf 2)0$(tput sgr0)' clean up, '$(tput setaf 2)1$(tput sgr0)' keep"
 echo "  -d : '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', '$(tput setaf 2)BETA$(tput sgr0)', '$(tput setaf 2)ALPHA$(tput sgr0)', '$(tput setaf 2)DEBUG$(tput sgr0)', '$(tput setaf 2)DEVEL$(tput sgr0)' and '$(tput setaf 2)UNKNOWN$(tput sgr0)'"
 echo "  -g : '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' lite '$(tput setaf 2)2$(tput sgr0)' fancy  '$(tput setaf 2)3$(tput sgr0)' lite  with Quad_HR '$(tput setaf 2)4$(tput sgr0)' fancy with Quad_HR"
-echo "  -i : '$(tput setaf 2)1.8.5$(tput sgr0)', '$(tput setaf 2)1.8.13$(tput sgr0)'"
+echo "  -i : '$(tput setaf 2)1.8.5$(tput sgr0)', '$(tput setaf 2)1.8.13$(tput sgr0)', '$(tput setaf 2)1.8.19$(tput sgr0)'"
 echo "  -j : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes"
 echo "  -l : '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for English only"
 echo "  -m : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes '$(tput setaf 2)2$(tput sgr0)' with MMU2"
@@ -343,7 +346,7 @@ fi
 
 #Start: Check if Arduino IDE version is correct
 if [ ! -z "$IDE_flag" ]; then
-    if [[ "$IDE_flag" == "1.8.5" || "$IDE_flag" == "1.8.13" ]]; then
+    if [[ "$IDE_flag" == "1.8.5" || "$IDE_flag" == "1.8.13" || "$IDE_flag" == "1.8.19" ]]; then
         ARDUINO_ENV="${IDE_flag}"
     else
         ARDUINO_ENV="1.8.5"
@@ -818,7 +821,8 @@ if [ -z "$variant_flag" ] ; then
     while IFS= read -r -d $'\0' f; do
         options[i++]="$f"
     done < <(find Firmware/variants/ -maxdepth 1 -type f -name "*.h" -print0 )
-    select opt in "${options[@]}" "All" "Quit"; do
+    IFS=$'\n' sorted=($(sort -n <<<"${options[*]}")); unset IFS
+    select opt in "${sorted[@]}" "All" "Quit"; do
         case $opt in
             *.h)
                 VARIANT=$(basename "$opt" ".h")
@@ -1453,7 +1457,7 @@ if [[ "$output_flag" == "1" || -z "$output_flag" ]]; then
     if [[ -z "$mk404_flag" && "$variant_flag" != "All" ]]; then
         echo
         read -t 10 -n 1 -p "Do you want to start MK404? Y/$(tput setaf 2)n$(tput sgr 0)" mk404_start
-        if [ "$mk404_start" == "Y" ]; then
+        if [[ "$mk404_start" == "Y" || "$mk404_start" == "y" ]]; then
             echo
             read -t 10 -n 1 -p "Do you want to start MK404 with or without MMU2S? $(tput setaf 2)1$(tput sgr 0)/2" mk404_choose1
             if [ "$mk404_choose1" == "1" ]; then
@@ -1603,4 +1607,4 @@ done
 finish_pf-build
 if [ $TARGET_OS == "linux" ]; then
     MK404_SIM
-fi
+fi