configure 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. set -e
  3. setcfg(){
  4. echo -ne " $1 [y/n]"
  5. read -sn 1 c
  6. echo -ne "\033[32;1m($c)\033[;0m"
  7. if [ "$c" == "y" ] || [ "$c" == "Y" ] ; then
  8. echo "$2=y" >> .config
  9. else
  10. echo "$2=n" >> .config
  11. fi
  12. echo
  13. }
  14. defconfig="ny"
  15. ask_cfg(){
  16. echo -e "\033[34;1mInary configure :\033[;0m"
  17. echo "#inary config file" > .config
  18. setcfg "Native language support" "NLS_SUPPORT"
  19. setcfg "Additional scripts" "ADDITIONAL_SCRIPTS"
  20. echo -e "\033[33;1m\".config\" file changed.\033[;0m"
  21. }
  22. ask_check(){
  23. echo -e "\033[34;1mInary check :\033[;0m"
  24. chkfile "/dev/null"
  25. chkfile "/usr/bin/"
  26. chkfile "/var/lib/"
  27. chkfile "/usr/lib/"
  28. chkfile "/etc/"
  29. chkcmd "python3" && chkcmd "python3.8" || chkcmd "python3.7"
  30. chkcmd "intltool-extract"
  31. chkcmd "xgettext"
  32. chkcmd "msgfmt"
  33. }
  34. chkcmd(){
  35. echo -ne "checking $1 "
  36. if which $1 &>/dev/null ; then
  37. echo -e "\033[32;1m(yes)\033[;0m"
  38. else
  39. echo -e "\033[33;1m(no)\033[;0m"
  40. echo -e "\033[32;1mERROR:\033[;0m $1 not found in \$PATH"
  41. return 1
  42. fi
  43. }
  44. chkfile(){
  45. echo -ne "checking $1 "
  46. if [ -e "$1" ] ; then
  47. echo -e "\033[32;1m(yes)\033[;0m"
  48. else
  49. echo -e "\033[33;1m(no)\033[;0m"
  50. echo -e "\033[32;1mERROR:\033[;0m $1 not found."
  51. return 1
  52. fi
  53. }
  54. yes(){
  55. while true ; do
  56. echo -ne "$1"
  57. done
  58. }
  59. usage(){
  60. cat <<EOF
  61. ./configure [OPTIONS]
  62. Options list:
  63. --yes-all : Enable all
  64. --no-all : Disable all
  65. --default : Use default config
  66. --help : Show this message
  67. --clean : Delete .config file
  68. EOF
  69. }
  70. for i in $@ ; do
  71. if [ "$i" == "--yes-all" ] ; then
  72. ask_check
  73. yes y | ask_cfg
  74. exit 0
  75. elif [ "$i" == "--no-all" ] ; then
  76. ask_check
  77. yes n | ask_cfg
  78. exit 0
  79. elif [ "$i" == "--clean" ] ; then
  80. [ -f .config ] && rm -f .config
  81. exit 0
  82. elif [ "$i" == "--default" ] ; then
  83. ask_check
  84. echo "$defconfig" | ask_cfg
  85. exit 0
  86. elif [ "$i" == "--help" ] ; then
  87. usage
  88. exit 0
  89. fi
  90. done
  91. ask_cfg