KBFX – an alternative to T-Menu
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #! /bin/sh
  2. CMAKE_OPT_PREFIX_KDE3="-DCMAKE_INSTALL_PREFIX:PATH=`tde-config --prefix 2>/dev/null` "
  3. CMAKE_OPT_PREFIX_KDE4="-DCMAKE_INSTALL_PREFIX:PATH=`kde4-config --prefix 2>/dev/null` "
  4. CMAKE_OPT_PREFIX=""
  5. MAKE_VERBOSE=""
  6. USE_STRIGI_SEARCH=""
  7. MENUDRAKE=""
  8. KDE4=""
  9. ACTION="install"
  10. NOCHECK=0
  11. build_state="touch kbfx_build"
  12. command_line_args=$@
  13. eval "which kbfxconfigapp > /dev/null 2>&1" && kbfx_installed="1" || kbfx_installed="0"
  14. color_ok="\\033[1;32m"
  15. color_error="\\033[1;31m"
  16. color_normal="\\033[0;39m"
  17. color_warn="\\033[1;33m"
  18. prog_action(){
  19. echo
  20. echo -e "$color_ok $@ $color_normal"
  21. }
  22. prog_err(){
  23. echo
  24. echo -e "$color_error ERROR doing $@ $color_normal\n"
  25. }
  26. confirm() {
  27. printf "$color_warn %s (Y)es/(N)o? [%s]$color_normal " "$1" "$2"
  28. unset user_input
  29. answer="$2"
  30. read user_input
  31. if [ "$user_input" = "y" -o "$user_input" = "Y" -o "$user_input" = "YES" -o "$user_input" = "Yes" -o "$user_input" = "yes" ]; then
  32. answer="Y"
  33. fi
  34. if [ "$user_input" = "n" -o "$user_input" = "N" -o "" = "NO" -o "$user_input" = "No" -o "$user_input" = "no" ]; then
  35. answer="N"
  36. fi
  37. }
  38. parse_command_line() {
  39. if [ "$#" -eq 0 ]; then
  40. return 0
  41. fi
  42. while [ "$1" != "${1##-}" ]; do
  43. case $1 in
  44. --verbose|-v)
  45. MAKE_VERBOSE="VERBOSE=1"
  46. shift 1
  47. ;;
  48. --prefix|-p)
  49. if [ -n "$2" -a "$2" = "${2##-}" ]; then
  50. t=0
  51. stop=0
  52. s=""
  53. for p in $@
  54. do
  55. t=$[t+1]
  56. if [ $t -gt 1 -a "$p" = "${p##-}" -a $stop -eq 0 ]; then
  57. s="$s$p "
  58. fi
  59. if [ $t -gt 1 -a "$p" != "${p##-}" ]; then
  60. stop=$[t-1]
  61. fi
  62. done
  63. if [ $stop -eq 0 ]; then
  64. stop=$[t-1]
  65. fi
  66. if [ -n "$s" ]; then
  67. s=${s%%[ ]}
  68. CMAKE_OPT_PREFIX="-DCMAKE_INSTALL_PREFIX:PATH='$s' "
  69. fi
  70. shift $stop
  71. else
  72. shift 1
  73. return 1
  74. fi
  75. ;;
  76. --strigi|-s)
  77. USE_STRIGI_SEARCH="-DUSE_STRIGI:BOOL=TRUE"
  78. shift 1
  79. ;;
  80. --menudrake-off|-m)
  81. MENUDRAKE="-DUSE_MENUDRAKE:BOOL=FALSE"
  82. shift 1
  83. ;;
  84. --kde4|-k)
  85. KDE4="-DUSE_KDE4:BOOL=TRUE"
  86. shift 1
  87. ;;
  88. --uninstall|-u)
  89. ACTION="uninstall"
  90. shift 1
  91. ;;
  92. --nocheck|-n)
  93. NOCHECK=1
  94. shift 1
  95. ;;
  96. *)
  97. if [ "$#" -ge 1 ]; then
  98. return 1
  99. fi
  100. return 0
  101. ;;
  102. esac
  103. done
  104. }
  105. show_usage(){
  106. echo
  107. echo -e "$color_warn Usage: \n\t build.sh \t [(-v|--verbose) Be verbose when compiling (default: no)] \n\t\t\t [(-u|--uninstall) Uninstall KBFX (default: no)] \n\t\t\t [(-p|--prefix) Install prefix (default: KDE prefix)] \n\t\t\t [(-s|--strigi) Compile strigi search plugin (default: no)] \n\t\t\t [(-m|-menudrake-off) Don't use menudrake in Mandriva (default: auto)] \n\t\t\t [(-k|--kde4) Compile for KDE4 (default: no)] \n\t\t\t [(-n|--nocheck) Do not check for old KBFX versions (default: check)] $color_normal"
  108. echo
  109. }
  110. parse_command_line $command_line_args
  111. if [ "$?" -eq 1 ]; then
  112. prog_err "build.sh"
  113. show_usage
  114. exit 1
  115. fi
  116. show_usage
  117. if [ "$ACTION" = "install" ]
  118. then {
  119. if [ $kbfx_installed -eq 1 -a $NOCHECK -eq 0 ] ; then
  120. echo
  121. echo -e "$color_error \n\t You have KBFX installed in your \$PATH!\n\t In order to compile the new version you HAVE TO REMOVE the old KBFX first!\n $color_normal"
  122. exit 1
  123. fi
  124. if [ -d build ] ; then
  125. echo
  126. echo -e "$color_warn Directory 'build' exists! Using it...$color_normal"
  127. echo -e "$color_error If 'build.sh' fails, try removing the directory 'build' and run 'build.sh' again! $color_normal"
  128. else
  129. mkdir build
  130. fi
  131. cd build
  132. if [ "$CMAKE_OPT_PREFIX" = "" ]
  133. then {
  134. if [ "$KDE4" = "" ]
  135. then {
  136. CMAKE_OPT_PREFIX=$CMAKE_OPT_PREFIX_KDE3
  137. }
  138. else {
  139. CMAKE_OPT_PREFIX=$CMAKE_OPT_PREFIX_KDE4
  140. }
  141. fi
  142. }
  143. fi
  144. CMAKE_OPT="$CMAKE_OPT_PREFIX $KDE4 $MENUDRAKE $USE_STRIGI_SEARCH"
  145. prog_action "Doing CMake configure..."
  146. echo $CMAKE_OPT
  147. eval "cmake ../ $CMAKE_OPT"
  148. if [ $? -ne 0 ]; then
  149. prog_err "CMake configure..."
  150. exit 1
  151. fi
  152. prog_action "Doing make..."
  153. make $MAKE_VERBOSE
  154. if [ $? -ne 0 ]; then
  155. prog_err "make..."
  156. exit 1
  157. fi
  158. eval $build_state
  159. prog_action "Success building KBFX...\n"
  160. confirm "Do you want to install KBFX?" "Y"
  161. if [ "$answer" = "Y" ]
  162. then
  163. sucommand="make install"
  164. after_su="touch kbfx_install_user"
  165. if [ `whoami` != 'root' ]
  166. then {
  167. confirm "To install KBFX as 'root', answer 'Yes'. To install as '`whoami`', answer 'No'" "N"
  168. if [ "$answer" = "Y" ]
  169. then {
  170. sucommand="su root -c 'make install'"
  171. after_su="touch kbfx_install_root"
  172. }
  173. fi
  174. }
  175. fi
  176. prog_action "Doing 'make install'..."
  177. eval $sucommand
  178. if [ $? -ne 0 ]; then
  179. prog_err "make install..."
  180. exit 1
  181. fi
  182. eval $after_su
  183. echo
  184. echo -e "$color_warn NOTE: If you have used a custom prefix for your install (-p or --prefix option for script), \n you should add '$s' to your \$TDEDIRS environment variable\n and '$s/lib' to your \$LD_LIBRARY_PATH environment variable!\n $color_normal"
  185. fi
  186. }
  187. else {
  188. if [ -d build ]
  189. then
  190. cd build
  191. else
  192. echo
  193. echo -e "$color_error \n\t Directory 'build' DOES NOT exist!\n\t You HAVE NOT used 'build.sh' script for installing KBFX! \n\t Uninstall CAN NOT continue!\n $color_normal"
  194. exit 1
  195. fi
  196. if [ -f kbfx_install_user ]
  197. then
  198. sucommand="make uninstall"
  199. after_su="rm -f kbfx_install_user"
  200. elif [ -f kbfx_install_root ]
  201. then
  202. sucommand="su root -c 'make uninstall'"
  203. after_su="rm -f kbfx_install_root"
  204. elif [ -f kbfx_build ]
  205. then
  206. echo
  207. echo -e "$color_error \n\t KBFX IS NOT installed! \n\t Uninstall CAN NOT continue!\n $color_normal"
  208. exit 1
  209. else
  210. echo
  211. echo -e "$color_error \n\t You HAVE NOT used 'build.sh' script for installing KBFX! \n\t Uninstall CAN NOT continue!\n $color_normal"
  212. exit 1
  213. fi
  214. prog_action "Uninstalling..."
  215. eval $sucommand
  216. if [ $? -ne 0 ]; then
  217. prog_err "uninstall..."
  218. exit 1
  219. fi
  220. eval $after_su
  221. }
  222. fi
  223. prog_action "All actions ended successfully...\n"