OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /v/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-src Date: 22-Mar-2008 21:08:38 Branch: HEAD Handle: 2008032220083700 Modified files: openpkg-src/asterisk asterisk.spec asterisk.txt Log: initial ODBC (+SQLite) support Summary: Revision Changes Path 1.64 +39 -1 openpkg-src/asterisk/asterisk.spec 1.37 +40 -0 openpkg-src/asterisk/asterisk.txt ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/asterisk/asterisk.spec ============================================================================ $ cvs diff -u -r1.63 -r1.64 asterisk.spec --- openpkg-src/asterisk/asterisk.spec 22 Mar 2008 15:59:15 -0000 1.63 +++ openpkg-src/asterisk/asterisk.spec 22 Mar 2008 20:08:37 -0000 1.64 @@ -55,6 +55,7 @@ %option with_lua no %option with_jabber no %option with_imap no +%option with_odbc no # list of sources Source0: http://downloads.digium.com/pub/asterisk/releases/asterisk-%{V_asterisk}.tar.gz @@ -112,6 +113,10 @@ BuildPreReq: iksemel PreReq: iksemel %endif +%if "%{with_odbc}" == "yes" +BuildPreReq: unixodbc, sqlite, sqlite::with_odbc = yes +PreReq: unixodbc, sqlite, sqlite::with_odbc = yes +%endif AutoReq: no AutoReqProv: no @@ -299,6 +304,11 @@ %else --without-imap \ %endif +%if "%{with_odbc}" == "yes" + --with-odbc=%{l_prefix} \ +%else + --without-odbc \ +%endif --without-netsnmp \ --without-isdnnet \ --without-misdn \ @@ -308,7 +318,6 @@ --without-asound \ --without-oss \ --without-qt \ - --without-odbc \ --without-sqlite \ --without-postgres \ --without-tds \ @@ -413,6 +422,10 @@ %if "%{with_sqlite}" == "no" [ ".$name" = ".cdr_sqlite3_custom.conf" ] && continue %endif +%if "%{with_odbc}" == "no" + [ ".$name" = ".res_odbc.conf" ] && continue + [ ".$name" = ".func_odbc.conf" ] && continue +%endif (echo ""; cat %{SOURCE asterisk.txt}; echo "") |\ sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name %{l_shtool} install -c -m 644 %{l_value -s -a} \ @@ -437,6 +450,26 @@ rm -rf $RPM_BUILD_ROOT %post +%if "%{with_odbc}" == "yes" + # after install, optionally link into ODBC and create database + if $RPM_INSTALL_PREFIX/bin/odbcinst -q -s -n "asterisk-sqlite" >/dev/null 2>&1; then + : + else + ( echo "[asterisk-sqlite]" + echo "Description = Asterisk SQLite Database" + echo "Driver = SQLite3" + echo "Database = $RPM_INSTALL_PREFIX/var/asterisk/run/asterisk.db" + echo "Timeout = 2000" + ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "asterisk-sqlite" -r >/dev/null 2>&1 || true + fi + if [ ! -f $RPM_INSTALL_PREFIX/var/asterisk/run/asterisk.db ]; then + ( umask 007 + echo "CREATE TABLE map (key STRING, val STRING);" |\ + $RPM_INSTALL_PREFIX/bin/sqlite3 $RPM_INSTALL_PREFIX/var/asterisk/run/asterisk.db + chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/asterisk/run/asterisk.db >/dev/null 2>&1 || true + ) || exit $? + fi +%endif # after upgrade, restart service [ $1 -eq 2 ] || exit 0 eval `%{l_rc} asterisk status 2>/dev/null` @@ -444,6 +477,11 @@ exit 0 %preun +%if "%{with_odbc}" == "yes" + # before erase, optionally unlink from ODBC and destroy database + $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "asterisk-sqlite" >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/asterisk/run/asterisk.db >/dev/null 2>&1 || true +%endif # before erase, stop service and remove log files [ $1 -eq 0 ] || exit 0 %{l_rc} asterisk stop 2>/dev/null @@ . patch -p0 <<'@@ .' Index: openpkg-src/asterisk/asterisk.txt ============================================================================ $ cvs diff -u -r1.36 -r1.37 asterisk.txt --- openpkg-src/asterisk/asterisk.txt 22 Mar 2008 15:58:06 -0000 1.36 +++ openpkg-src/asterisk/asterisk.txt 22 Mar 2008 20:08:37 -0000 1.37 @@ -685,6 +685,46 @@ stutter = 425+400 </file> +<file name="res_odbc.conf"> +;; +;; res_odbc.conf -- Asterisk ODBC resource configuration +;; + +[ENV] + +[asterisk-sqlite] +enabled = no +dsn = asterisk-sqlite +username = +password = +pre-connect = no +sanitysql = SELECT 1 +;idlecheck = 3600 +backslash_is_escape = yes +share_connections = yes +limit = 10 + +</file> +<file name="func_odbc.conf"> +;; +;; func_odbc.conf -- Asterisk ODBC dialplan function configuration +;; + +[SQL] +prefix = ODBC +dsn = asterisk-sqlite +readsql = ${ARG1} + +[MAP] +prefix = ODBC +dsn = asterisk-sqlite + ; Set(<variable_name>=${ODBC_MAP(<key>)}) +readsql = SELECT val FROM map WHERE key='${SQL_ESC(${ARG1})}' + ; Set(ODBC_MAP(<key>)=<value>) +writesql = UPDATE map SET val='${SQL_ESC(${VAL1})}' WHERE key='${SQL_ESC(${ARG1})}' +escapecommas = no + +</file> <file name="asterisk.pem"> -----BEGIN CERTIFICATE----- MIIDNjCCAp+gAwIBAgIBATANBgkqhkiG9w0BAQQFADCBqTELMAkGA1UEBhMCWFkx @@ . ______________________________________________________________________ OpenPKG http://openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org