install.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # --------------------------------------------------------------------------------------------------------
  3. # install.sh
  4. # --------------------------------------------------------------------------------------------------------
  5. # toolset/run-tests.py --install server --test ULib-mysql --type all --verbose
  6. # toolset/run-tests.py --install server --test ULib-sqlite --type all --verbose
  7. # --------------------------------------------------------------------------------------------------------
  8. # TROOT - Path of this test's directory
  9. # IROOT - Path of this test's install directory ($FWROOT/installs or $FWROOT/installs/pertest/<test-name>)
  10. # --------------------------------------------------------------------------------------------------------
  11. # INFO:root:Running installation for ULib
  12. # INSTALL:
  13. # export TROOT=$FWROOT/ULib &&
  14. # export IROOT=$FWROOT/installs &&
  15. # . $FWROOT/toolset/setup/linux/bash_functions.sh &&
  16. # . $FWROOT/ULib/install.sh (cwd=$FWROOT//installs)
  17. # --------------------------------------------------------------------------------------------------------
  18. ULIB_VERSION=1.4.2
  19. ULIB_ROOT=$IROOT/ULib
  20. ULIB_DOCUMENT_ROOT=$ULIB_ROOT/ULIB_DOCUMENT_ROOT
  21. # Check if ULib is already installed
  22. ULIB_INSTALLED_FILE="$IROOT/ULib-${ULIB_VERSION}.installed"
  23. RETCODE=$(fw_exists $ULIB_INSTALLED_FILE)
  24. [ ! "$RETCODE" == 0 ] || { return 0; }
  25. # Create a run directory for ULIB
  26. [ ! -e $ULIB_INSTALLED_FILE -a -d $IROOT/ULib ] && rm -rf $IROOT/ULib*
  27. if [ ! -d "$ULIB_ROOT" ]; then
  28. mkdir -p $ULIB_ROOT
  29. fi
  30. # AVOID "fatal error: postgres_fe.h: No such file or directory"
  31. sudo apt-get install -y postgresql-server-dev-all
  32. # Add a simple configuration file to it
  33. cd $ULIB_ROOT
  34. if [ ! -f "benchmark.cfg" ]; then
  35. cat <<EOF >benchmark.cfg
  36. userver {
  37. PORT 8080
  38. PREFORK_CHILD 4
  39. TCP_LINGER_SET -1
  40. LISTEN_BACKLOG 256
  41. ORM_DRIVER "mysql pgsql sqlite"
  42. DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
  43. }
  44. EOF
  45. fi
  46. # 1. Download ULib
  47. cd $IROOT
  48. fw_get -o ULib-${ULIB_VERSION}.tar.gz https://github.com/stefanocasazza/ULib/archive/v${ULIB_VERSION}.tar.gz
  49. fw_untar ULib-${ULIB_VERSION}.tar.gz
  50. # 2. Compile application (userver_tcp)
  51. cd ULib-$ULIB_VERSION
  52. # Check for the compiler support (We want at least g++ 4.8)
  53. CC=gcc # C compiler command
  54. CXX=g++ # C++ compiler command
  55. gcc_version=`g++ -dumpversion`
  56. case "$gcc_version" in
  57. 3*|4.0*|4.1*|4.2*|4.3*|4.4*|4.5*|4.6*|4.7*)
  58. CC='gcc-4.9'
  59. CXX='g++-4.9'
  60. ;;
  61. esac
  62. export CC CXX
  63. # AVOID "configure: error: newly created file is older than distributed files! Check your system clock"
  64. find . -exec touch {} \;
  65. USP_FLAGS="-DAS_cpoll_cppsp_DO" \
  66. ./configure --prefix=$ULIB_ROOT \
  67. --disable-static --disable-examples \
  68. --with-mysql --with-pgsql --with-sqlite3 \
  69. --without-ssl --without-pcre --without-expat \
  70. --without-libz --without-libuuid --without-magic --without-libares \
  71. --enable-static-orm-driver='mysql pgsql sqlite' --enable-static-server-plugin=http
  72. # --enable-debug \
  73. #USP_LIBS="-ljson" \
  74. make install
  75. cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db $ULIB_ROOT
  76. cd examples/userver
  77. make install
  78. # 3. Compile usp pages for benchmark
  79. cd ../../src/ulib/net/server/plugin/usp
  80. make db.la fortune.la json.la plaintext.la query.la update.la
  81. # Check that compilation worked
  82. if [ ! -e .libs/db.so ]; then
  83. exit 1
  84. fi
  85. mkdir -p $ULIB_DOCUMENT_ROOT
  86. cp .libs/db.so .libs/fortune.so .libs/json.so .libs/plaintext.so .libs/query.so .libs/update.so $ULIB_DOCUMENT_ROOT
  87. touch $ULIB_INSTALLED_FILE