Skip to content

Commit

Permalink
Merge pull request #486 from saa/sqlite_support
Browse files Browse the repository at this point in the history
Add SQLite support
  • Loading branch information
zinid committed Apr 8, 2015
2 parents c3280e9 + 15af88a commit 5a820ac
Show file tree
Hide file tree
Showing 18 changed files with 538 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -4,6 +4,8 @@
*~
\#*#
.#*
.edts
*.dump
/Makefile
/config.log
/config.status
Expand Down Expand Up @@ -38,3 +40,4 @@ XmppAddr.hrl
/dialyzer/
/test/*.beam
/logs/
/priv/sql
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,7 @@ before_install:
- sudo apt-get -qq update

install:
- sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev
- sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev libsqlite3-dev

before_script:
- mysql -u root -e "CREATE USER 'ejabberd_test'@'localhost' IDENTIFIED BY 'ejabberd_test';"
Expand Down
11 changes: 11 additions & 0 deletions Makefile.in
Expand Up @@ -43,6 +43,9 @@ SODIR = $(PRIVDIR)/lib
# /usr/lib/ejabberd/priv/msgs
MSGSDIR = $(PRIVDIR)/msgs

# /usr/lib/ejabberd/priv/sql
SQLDIR = $(PRIVDIR)/sql

# /var/lib/ejabberd/
SPOOLDIR = $(DESTDIR)@localstatedir@/lib/ejabberd

Expand Down Expand Up @@ -176,11 +179,16 @@ install: all
$(INSTALL) -d $(SODIR)
$(INSTALL) -m 644 $(DLLs) $(SODIR)
-[ -f $(SODIR)/jiffy.so ] && (cd $(PRIVDIR); ln -s lib/jiffy.so; true)
-[ -f $(SODIR)/sqlite3_drv.so ] && (cd $(PRIVDIR); ln -s lib/sqlite3_drv.so; true)
#
# Translated strings
$(INSTALL) -d $(MSGSDIR)
$(INSTALL) -m 644 priv/msgs/*.msg $(MSGSDIR)
#
# Copy lite.sql
-[ -d deps/sqlite3 ] && $(INSTALL) -d $(SQLDIR)
-[ -d deps/sqlite3 ] && $(INSTALL) -m 644 sql/lite.sql $(SQLDIR)
#
# Spool directory
$(INSTALL) -d -m 750 $(O_USER) $(SPOOLDIR)
$(CHOWN_COMMAND) -R @INSTALLUSER@ $(SPOOLDIR) >$(CHOWN_OUTPUT)
Expand Down Expand Up @@ -229,6 +237,8 @@ uninstall-binary:
rm -fr $(SODIR)
rm -f $(MSGSDIR)/*.msgs
rm -fr $(MSGSDIR)
rm -f $(SQLDIR)/*.sql
rm -fr $(SQLDIR)
rm -fr $(PRIVDIR)
rm -fr $(EJABBERDDIR)

Expand Down Expand Up @@ -310,6 +320,7 @@ test:
@echo "************************** NOTICE ***************************************"
@cat test/README
@echo "*************************************************************************"
@cd priv && ln -sf ../sql
$(REBAR) skip_deps=true ct

quicktest:
Expand Down
15 changes: 12 additions & 3 deletions configure.ac
Expand Up @@ -106,10 +106,10 @@ AC_ARG_ENABLE(mssql,
esac],[db_type=generic])

AC_ARG_ENABLE(all,
[AC_HELP_STRING([--enable-all], [same as --enable-nif --enable-odbc --enable-mysql --enable-pgsql --enable-pam --enable-zlib --enable-riak --enable-redis --enable-json --enable-elixir --enable-iconv --enable-debug --enable-lager --enable-tools (useful for Dialyzer checks, default: no)])],
[AC_HELP_STRING([--enable-all], [same as --enable-nif --enable-odbc --enable-mysql --enable-pgsql --enable-sqlite --enable-pam --enable-zlib --enable-riak --enable-redis --enable-json --enable-elixir --enable-iconv --enable-debug --enable-lager --enable-tools (useful for Dialyzer checks, default: no)])],
[case "${enableval}" in
yes) nif=true odbc=true mysql=true pgsql=true pam=true zlib=true riak=true redis=true json=true elixir=true iconv=true debug=true lager=true tools=true ;;
no) nif=false odbc=false mysql=false pgsql=false pam=false zlib=false riak=false redis=false json=false elixir=false iconv=false debug=false lager=false tools=false ;;
yes) nif=true odbc=true mysql=true pgsql=true sqlite=true pam=true zlib=true riak=true redis=true json=true elixir=true iconv=true debug=true lager=true tools=true ;;
no) nif=false odbc=false mysql=false pgsql=false sqlite=false pam=false zlib=false riak=false redis=false json=false elixir=false iconv=false debug=false lager=false tools=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-all) ;;
esac],[])

Expand Down Expand Up @@ -153,6 +153,14 @@ AC_ARG_ENABLE(pgsql,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pgsql) ;;
esac],[if test "x$pgsql" = "x"; then pgsql=false; fi])

AC_ARG_ENABLE(sqlite,
[AC_HELP_STRING([--enable-sqlite], [enable SQLite support (default: no)])],
[case "${enableval}" in
yes) sqlite=true ;;
no) sqlite=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-sqlite) ;;
esac],[if test "x$sqlite" = "x"; then sqlite=false; fi])

AC_ARG_ENABLE(pam,
[AC_HELP_STRING([--enable-pam], [enable PAM support (default: no)])],
[case "${enableval}" in
Expand Down Expand Up @@ -254,6 +262,7 @@ AC_SUBST(db_type)
AC_SUBST(odbc)
AC_SUBST(mysql)
AC_SUBST(pgsql)
AC_SUBST(sqlite)
AC_SUBST(pam)
AC_SUBST(zlib)
AC_SUBST(riak)
Expand Down
6 changes: 6 additions & 0 deletions ejabberd.yml.example
Expand Up @@ -343,6 +343,12 @@ auth_method: internal
##
## pgsql_users_number_estimate: true

##
## SQLite:
##
## odbc_type: sqlite
## odbc_database: "/path/to/database.db"

##
## ODBC compatible or MSSQL server:
##
Expand Down
6 changes: 6 additions & 0 deletions include/ejabberd.hrl
Expand Up @@ -31,6 +31,12 @@

-define(MSGS_DIR, filename:join(["priv", "msgs"])).

-define(SQL_DIR, filename:join(["priv", "sql"])).

-define(SQLITE_DB, ejabberd_sqlite).

-define(DEFAULT_SQLITE_DB_PATH, <<"/tmp/ejabberd.db">>).

-define(CONFIG_PATH, <<"ejabberd.cfg">>).

-define(LOG_PATH, <<"ejabberd.log">>).
Expand Down
2 changes: 2 additions & 0 deletions rebar.config.script
Expand Up @@ -90,6 +90,8 @@ CfgDeps = lists:flatmap(
[{p1_mysql, ".*", {git, "git://github.com/processone/mysql"}}];
({pgsql, true}) ->
[{p1_pgsql, ".*", {git, "git://github.com/processone/pgsql"}}];
({sqlite, true}) ->
[{sqlite3, ".*", {git, "git://github.com/alexeyr/erlang-sqlite3"}}];
({pam, true}) ->
[{p1_pam, ".*", {git, "git://github.com/processone/epam"}}];
({zlib, true}) ->
Expand Down

0 comments on commit 5a820ac

Please sign in to comment.