fw-clean.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. #
  3. # Version 1.0.1 Build 11
  4. #
  5. # fw-clean.sh - multi-language support script
  6. # Remove all firmware output files from lang folder.
  7. #
  8. #############################################################################
  9. # Change log:
  10. # 21 June 2018, XPila, Initial
  11. # 11 Sep. 2018, XPila, Lang update, french translation
  12. # resized reserved space
  13. # 18 Oct. 2018, XPila, New lang, arduino 1.8.5 - fw-clean.sh and lang-clean.sh fix
  14. # 10 Dec. 2018, jhoblitt, make all shell scripts executable
  15. # 26 Jul. 2019, leptun, Fix shifted languages. Use \n and \x0a
  16. # 14 Sep. 2019, 3d-gussner, Prepare adding new language
  17. # 01 Mar. 2021, 3d-gussner, Move `Dutch` language parts
  18. # 22 Mar. 2021, 3d-gussner, Move Dutch removing part to correct loaction
  19. # 17 Dec. 2021, 3d-gussner, Use one config file for all languages
  20. # 11 Jan. 2022, 3d-gussner, Added version and Change log
  21. # colored output
  22. # Use `git rev-list --count HEAD fw-clean.sh`
  23. # to get Build Nr
  24. # 25 Jan. 2022, 3d-gussner, Update documentation
  25. #############################################################################
  26. # Config:
  27. if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
  28. if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo "$(tput setaf 1)Config NG!$(tput sgr0)" >&2; exit 1; fi
  29. if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
  30. LANGUAGES+=" $COMMUNITY_LANGUAGES"
  31. fi
  32. echo "$(tput setaf 2)fw-clean.sh started$(tput sgr0)" >&2
  33. echo "fw-clean languages:$(tput setaf 2)$LANGUAGES$(tput sgr0)" >&2
  34. result=0
  35. rm_if_exists()
  36. {
  37. if [ -e $1 ]; then
  38. echo -n "$(tput sgr0) removing $(tput sgr0) '$1'..." >&2
  39. if rm $1; then
  40. echo "$(tput setaf 2)OK$(tput sgr0)" >&2
  41. else
  42. echo "$(tput setaf 1)NG!$(tput sgr0)" >&2
  43. result=1
  44. fi
  45. fi
  46. }
  47. rm_if_exists text.sym
  48. rm_if_exists progmem1.sym
  49. rm_if_exists progmem1.lss
  50. rm_if_exists progmem1.hex
  51. rm_if_exists progmem1.chr
  52. rm_if_exists progmem1.var
  53. rm_if_exists progmem1.txt
  54. rm_if_exists textaddr.txt
  55. rm_if_exists firmware.bin
  56. rm_if_exists firmware.hex
  57. rm_if_exists progmem.out
  58. rm_if_exists textaddr.out
  59. rm_if_exists update_lang.out
  60. rm_if_exists lang.bin
  61. rm_if_exists lang.hex
  62. for lang in $LANGUAGES; do
  63. rm_if_exists firmware_$lang.hex
  64. rm_if_exists update_lang_$lang.out
  65. done
  66. if [ $result -eq 0 ]; then
  67. echo "$(tput setaf 2)fw-clean.sh finished with success$(tput sgr0)" >&2
  68. else
  69. echo "$(tput setaf 1)fw-clean.sh finished with errors!$(tput sgr0)" >&2
  70. fi
  71. case "$-" in
  72. *i*) echo "press enter key"; read ;;
  73. esac
  74. exit $result