install.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # ULib is only built during installation as a dependency sanity check
  22. #sudo apt-get update
  23. sudo apt-get install libmysqlclient-dev libsqlite3-dev
  24. # Create a run directory for ULIB
  25. [ ! -e ${ULIB_INSTALLED_FILE} -a -d ${IROOT}/ULib ] && rm -rf ${IROOT}/ULib*
  26. if [ ! -d "$ULIB_ROOT" ]; then
  27. mkdir -p $ULIB_ROOT
  28. fi
  29. # Add a simple configuration file to it
  30. cd $ULIB_ROOT
  31. if [ ! -f "benchmark.cfg" ]; then
  32. cat <<EOF >benchmark.cfg
  33. userver {
  34. PORT 8080
  35. PREFORK_CHILD 8
  36. LISTEN_BACKLOG 8192
  37. MAX_KEEP_ALIVE 8192
  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. # AVOID "configure: error: newly created file is older than distributed files! Check your system clock"
  50. find . -exec touch {} \;
  51. ./configure --prefix=$ULIB_ROOT \
  52. --disable-static \
  53. --with-mysql --with-sqlite3 \
  54. --without-ssl --without-pcre --without-expat \
  55. --without-libz --without-libuuid --without-magic \
  56. --enable-static-orm-driver='mysql sqlite' --enable-static-server-plugin=http
  57. # --enable-debug \
  58. make install
  59. # 3. Compile usp pages for benchmark
  60. cd src/ulib/net/server/plugin/usp
  61. make db.la fortune.la json.la plaintext.la query.la update.la
  62. # Check that compilation worked
  63. if [ ! -e .libs/db.so ]; then
  64. exit 1
  65. fi
  66. mkdir -p $ULIB_DOCUMENT_ROOT
  67. cp .libs/db.so .libs/fortune.so .libs/json.so .libs/plaintext.so .libs/query.so .libs/update.so $ULIB_DOCUMENT_ROOT
  68. cd $IROOT
  69. cp -r ULib-1.4.2/tests/examples/benchmark/FrameworkBenchmarks/ULib/db $ULIB_ROOT
  70. touch ${ULIB_INSTALLED_FILE}