use_example_configs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. #
  3. # use_example_configs [repo:]configpath
  4. #
  5. # Examples:
  6. # use_example_configs
  7. # use_example_configs Creality/CR-10/CrealityV1
  8. # use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1
  9. #
  10. # If a configpath has spaces (or quotes) escape them or enquote the path
  11. # If no branch: prefix is given use configs based on the current branch name.
  12. # e.g., For `latest-2.1.x` name the working branch something like "my_work-2.1.x."
  13. # The branch or tag must first exist at MarlinFirmware/Configurations.
  14. # The fallback branch is bugfix-2.1.x.
  15. #
  16. which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
  17. which wget >/dev/null && TOOL='wget -q -O wgot'
  18. CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
  19. case "$CURR" in
  20. bugfix-2.*.x ) BRANCH=$CURR ;;
  21. *-2.1.x|2.1.x ) BRANCH=latest-2.1.x ;;
  22. *-2.0.x|2.0.x ) BRANCH=latest-2.0.x ;;
  23. *-1.1.x|1.1.x ) BRANCH=latest-1.1.x ;;
  24. *-1.0.x|1.0.x ) BRANCH=latest-1.0.x ;;
  25. * ) BRANCH=bugfix-2.1.x ;;
  26. esac
  27. if [[ $# > 0 ]]; then
  28. IFS=: read -r PART1 PART2 <<< "$@"
  29. [[ -n $PART2 ]] && { UDIR="$PART2" ; BRANCH="$PART1" ; } \
  30. || { UDIR="$PART1" ; }
  31. RDIR="${UDIR// /%20}"
  32. echo "Fetching $UDIR configurations from $BRANCH..."
  33. EXAMPLES="examples/$RDIR"
  34. else
  35. EXAMPLES="default"
  36. fi
  37. CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$BRANCH/config/${EXAMPLES}"
  38. restore_configs
  39. cd Marlin
  40. $TOOL "$CONFIGS/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
  41. $TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
  42. $TOOL "$CONFIGS/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h
  43. $TOOL "$CONFIGS/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h
  44. rm -f wgot
  45. cd - >/dev/null