install.sh 3.2 KB

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