# HG changeset patch # User Michael Schloh von Bennewitz # Date 1300647791 -3600 # Node ID 263143ec0fb2ac745030c85ed40eab76e23695bd # Parent 73d852a30c9a665a2c5642169af8da1364a9e037 Update and completely overhaul packaging and build configuration. diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/asterisk.patch --- a/asterisk/asterisk.patch Sun Mar 20 20:00:02 2011 +0100 +++ b/asterisk/asterisk.patch Sun Mar 20 20:03:11 2011 +0100 @@ -1,83 +1,74 @@ -Index: Makefile ---- Makefile.orig 2010-06-10 22:35:06.000000000 +0200 -+++ Makefile 2010-07-24 11:16:19.000000000 +0200 -@@ -126,40 +126,18 @@ +Index: addons/chan_ooh323.c +diff -Nau addons/chan_ooh323.c.orig addons/chan_ooh323.c +--- addons/chan_ooh323.c.orig 2010-10-09 16:02:26.000000000 +0200 ++++ addons/chan_ooh323.c 2011-03-13 14:03:42.000000000 +0100 +@@ -23,6 +23,12 @@ - # Define standard directories for various platforms - # These apply if they are not redefined in asterisk.conf --ifeq ($(OSARCH),SunOS) -- ASTETCDIR=/var/etc/asterisk -- ASTLIBDIR=/opt/asterisk/lib -- ASTVARLIBDIR=/var/opt/asterisk -- ASTDBDIR=$(ASTVARLIBDIR) -- ASTKEYDIR=$(ASTVARLIBDIR) -- ASTSPOOLDIR=/var/spool/asterisk -- ASTLOGDIR=/var/log/asterisk -- ASTHEADERDIR=/opt/asterisk/include -- ASTSBINDIR=/opt/asterisk/sbin -- ASTVARRUNDIR=/var/run/asterisk -- ASTMANDIR=/opt/asterisk/man --else - ASTETCDIR=$(sysconfdir)/asterisk - ASTLIBDIR=$(libdir)/asterisk - ASTHEADERDIR=$(includedir)/asterisk - ASTSBINDIR=$(sbindir) -- ASTSPOOLDIR=$(localstatedir)/spool/asterisk -- ASTLOGDIR=$(localstatedir)/log/asterisk -- ASTVARRUNDIR=$(localstatedir)/run/asterisk -+ ASTSPOOLDIR=$(localstatedir)/spool -+ ASTLOGDIR=$(localstatedir)/log -+ ASTVARRUNDIR=$(localstatedir)/run - ASTMANDIR=$(mandir) --ifneq ($(findstring BSD,$(OSARCH)),) -- ASTVARLIBDIR=$(prefix)/share/asterisk -- ASTVARRUNDIR=$(localstatedir)/run/asterisk -- ASTDBDIR=$(localstatedir)/db/asterisk --else -- ASTVARLIBDIR=$(localstatedir)/lib/asterisk -- ASTDBDIR=$(ASTVARLIBDIR) --endif -+ ASTVARLIBDIR=$(localstatedir)/lib -+ ASTDBDIR=$(localstatedir)/db - ASTKEYDIR=$(ASTVARLIBDIR) --endif --ifeq ($(ASTDATADIR),) - ASTDATADIR:=$(ASTVARLIBDIR) --endif + #include "chan_ooh323.h" + #include ++#if defined __SVR4 && defined __sun ++#include ++#ifndef IPTOS_MINCOST ++#define IPTOS_MINCOST 0x02 ++#endif ++#endif - # Asterisk.conf is located in ASTETCDIR or by using the -C flag - # when starting Asterisk -@@ -259,12 +237,6 @@ - _ASTCFLAGS+=-fsigned-char - endif + #define FORMAT_STRING_SIZE 512 --ifeq ($(OSARCH),FreeBSD) -- # -V is understood by BSD Make, not by GNU make. -- BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk) -- _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi) --endif -- - ifeq ($(OSARCH),NetBSD) - _ASTCFLAGS+=-pthread -I/usr/pkg/include - endif -@@ -567,8 +539,7 @@ - fi - mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation - mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty -- mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv -- mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom -+ mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr - mkdir -p $(DESTDIR)$(ASTDATADIR)/keys - mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware - mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax +Index: addons/ooh323c/src/ooCmdChannel.c +diff -Nau addons/ooh323c/src/ooCmdChannel.c.orig addons/ooh323c/src/ooCmdChannel.c +--- addons/ooh323c/src/ooCmdChannel.c.orig 2010-03-26 00:38:58.000000000 +0100 ++++ addons/ooh323c/src/ooCmdChannel.c 2011-03-13 14:03:42.000000000 +0100 +@@ -25,6 +25,10 @@ + #include "ooCalls.h" + #include "ooCmdChannel.h" + ++#ifndef AF_LOCAL ++#define AF_LOCAL AF_UNIX ++#define PF_LOCAL PF_UNIX ++#endif + + /** Global endpoint structure */ + extern OOH323EndPoint gH323ep; +Index: addons/ooh323c/src/ooSocket.c +diff -Nau addons/ooh323c/src/ooSocket.c.orig addons/ooh323c/src/ooSocket.c +--- addons/ooh323c/src/ooSocket.c.orig 2010-03-25 22:39:04.000000000 +0100 ++++ addons/ooh323c/src/ooSocket.c 2011-03-13 14:03:42.000000000 +0100 +@@ -24,6 +24,9 @@ + + #include "ooSocket.h" + #include "ootrace.h" ++#if defined __SVR4 && defined __sun ++#include ++#endif + #if defined(_WIN32_WCE) + static int inited = 0; + #define SEND_FLAGS 0 +Index: addons/ooh323cDriver.c +diff -Nau addons/ooh323cDriver.c.orig addons/ooh323cDriver.c +--- addons/ooh323cDriver.c.orig 2010-03-26 00:38:58.000000000 +0100 ++++ addons/ooh323cDriver.c 2011-03-13 14:03:42.000000000 +0100 +@@ -27,6 +27,11 @@ + + #define SEC_TO_HOLD_THREAD 24 + ++#ifndef AF_LOCAL ++#define AF_LOCAL AF_UNIX ++#define PF_LOCAL PF_UNIX ++#endif ++ + extern struct ast_module *myself; + extern OOBOOL gH323Debug; + extern OOH323EndPoint gH323ep; Index: apps/app_backticks.c ---- apps/app_backticks.c.orig 2010-07-24 11:12:31.000000000 +0200 -+++ apps/app_backticks.c 2010-07-24 11:12:31.000000000 +0200 +diff -Nau apps/app_backticks.c.orig apps/app_backticks.c +--- apps/app_backticks.c.orig 1970-01-01 01:00:00.000000000 +0100 ++++ apps/app_backticks.c 2011-03-13 14:03:42.000000000 +0100 @@ -0,0 +1,129 @@ + +#include "asterisk.h" + -+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.53 $") ++ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.52 $") + +#include +#include @@ -204,37 +195,38 @@ +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "BACKTICKS() dialplan function"); + Index: apps/app_meetme.c ---- apps/app_meetme.c.orig 2010-06-23 23:15:53.000000000 +0200 -+++ apps/app_meetme.c 2010-07-24 11:12:31.000000000 +0200 -@@ -522,6 +522,7 @@ +diff -Nau apps/app_meetme.c.orig apps/app_meetme.c +--- apps/app_meetme.c.orig 2011-01-07 21:53:02.000000000 +0100 ++++ apps/app_meetme.c 2011-03-13 14:03:42.000000000 +0100 +@@ -604,6 +604,7 @@ CONFFLAG_DURATION_LIMIT = (1 << 30), /*! Do not write any audio to this channel until the state is up. */ CONFFLAG_NO_AUDIO_UNTIL_UP = (1 << 31), -+ CONFFLAG_USERNAME = (1 << 31), ++ CONFFLAG_USERNAME = (1 << 32), }; - enum { -@@ -531,6 +532,7 @@ - OPT_ARG_DURATION_LIMIT = 3, + /* !If set play an intro announcement at start of conference */ +@@ -617,6 +618,7 @@ OPT_ARG_MOH_CLASS = 4, - OPT_ARG_ARRAY_SIZE = 5, -+ OPT_ARG_USERNAME = 6, + OPT_ARG_INTROMSG = 5, + OPT_ARG_ARRAY_SIZE = 6, ++ OPT_ARG_USERNAME = 7, }; AST_APP_OPTIONS(meetme_opts, BEGIN_OPTIONS -@@ -563,6 +565,7 @@ +@@ -650,6 +652,7 @@ AST_APP_OPTION('1', CONFFLAG_NOONLYPERSON ), AST_APP_OPTION_ARG('S', CONFFLAG_DURATION_STOP, OPT_ARG_DURATION_STOP), AST_APP_OPTION_ARG('L', CONFFLAG_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT), + AST_APP_OPTION_ARG('n', CONFFLAG_USERNAME, OPT_ARG_USERNAME), END_OPTIONS ); - static const char *app = "MeetMe"; -@@ -2243,6 +2246,12 @@ - if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) { + static const char * const app = "MeetMe"; +@@ -2429,6 +2432,12 @@ + ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW))) { char destdir[PATH_MAX]; -+ if ( (confflags & CONFFLAG_USERNAME) ++ if (!ast_test_flag64(confflags, CONFFLAG_USERNAME) + && !ast_strlen_zero(optargs[OPT_ARG_USERNAME]) + && ast_fileexists(optargs[OPT_ARG_USERNAME], NULL, NULL)) + snprintf(destdir, sizeof(destdir), "%s", optargs[OPT_ARG_USERNAME]); @@ -243,7 +235,7 @@ snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR); if (ast_mkdir(destdir, 0777) != 0) { -@@ -2259,6 +2268,7 @@ +@@ -2445,6 +2454,7 @@ res = ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL); if (res == -1) goto outrun; @@ -251,59 +243,142 @@ } ast_mutex_lock(&conf->playlock); -Index: build_tools/make_defaults_h ---- build_tools/make_defaults_h.orig 2008-01-24 23:58:10.000000000 +0100 -+++ build_tools/make_defaults_h 2010-07-24 11:12:31.000000000 +0200 -@@ -17,7 +17,7 @@ - #define DEFAULT_PID "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.pid" - - #define DEFAULT_VAR_DIR "${INSTALL_PATH}${ASTVARLIBDIR}" --#define DEFAULT_DB "${INSTALL_PATH}${ASTDBDIR}/astdb" -+#define DEFAULT_DB "${INSTALL_PATH}${ASTDBDIR}/asterisk.db" - - #define DEFAULT_DATA_DIR "${INSTALL_PATH}${ASTDATADIR}" - #define DEFAULT_KEY_DIR "${INSTALL_PATH}${ASTDATADIR}/keys" -Index: cdr/cdr_custom.c ---- cdr/cdr_custom.c.orig 2008-11-20 18:48:58.000000000 +0100 -+++ cdr/cdr_custom.c 2010-07-24 11:12:31.000000000 +0200 -@@ -83,7 +83,7 @@ - ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno); - ast_copy_string(format, var->value, sizeof(format) - 1); - strcat(format,"\n"); -- snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name); -+ snprintf(master, sizeof(master),"%s/cdr/%s", ast_config_AST_LOG_DIR, var->name); - if (var->next) { - ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); - break; -Index: cdr/cdr_sqlite3_custom.c ---- cdr/cdr_sqlite3_custom.c.orig 2010-04-13 18:38:41.000000000 +0200 -+++ cdr/cdr_sqlite3_custom.c 2010-07-24 11:12:31.000000000 +0200 -@@ -300,7 +300,7 @@ +Index: apps/app_voicemail.c +diff -Nau apps/app_voicemail.c.orig apps/app_voicemail.c +--- apps/app_voicemail.c.orig 2011-01-07 20:58:30.000000000 +0100 ++++ apps/app_voicemail.c 2011-03-13 14:03:42.000000000 +0100 +@@ -366,6 +366,7 @@ + static char imapport[8]; + static char imapflags[128]; + static char imapfolder[64]; ++static int imapsubfold = 0; + static char imapparentfolder[64] = "\0"; + static char greetingfolder[64]; + static char authuser[32]; +@@ -2464,7 +2465,7 @@ } - /* is the database there? */ -- snprintf(filename, sizeof(filename), "%s/master.db", ast_config_AST_LOG_DIR); -+ snprintf(filename, sizeof(filename), "%s/cdr/master.db", ast_config_AST_LOG_DIR); - res = sqlite3_open(filename, &db); - if (res != SQLITE_OK) { - ast_log(LOG_ERROR, "Could not open database %s.\n", filename); -Index: chan_capi-1.1.5/Makefile ---- chan_capi-1.1.5/Makefile.orig 2010-04-06 19:33:25.000000000 +0200 -+++ chan_capi-1.1.5/Makefile 2010-07-24 11:12:31.000000000 +0200 -@@ -100,6 +100,9 @@ - CFLAGS+=-O2 - CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) - CFLAGS+=$(shell if uname -m | grep -q "ppc\|arm\|s390"; then echo "-fsigned-char"; fi) -+ifeq (${USE_OWN_LIBCAPI},yes) -+CFLAGS+=-DUSE_OWN_LIBCAPI -+endif + /* Build up server information */ +- ast_build_string(&t, &left, "{%s:%s/imap", imapserver, imapport); ++ ast_build_string(&t, &left, "{%s:%s", imapserver, imapport); - LIBS=-ldl -lpthread -lm - CC=gcc -Index: chan_capi-1.1.5/chan_capi20.h ---- chan_capi-1.1.5/chan_capi20.h.orig 2005-09-20 20:33:40.000000000 +0200 -+++ chan_capi-1.1.5/chan_capi20.h 2010-07-24 11:12:31.000000000 +0200 -@@ -8,6 +8,8 @@ + /* Add authentication user if present */ + if (!ast_strlen_zero(authuser)) +@@ -6035,6 +6036,7 @@ + /* simple. huh? */ + char sequence[10]; + char mailbox[256]; ++ char folder[256]; + int res; + + /* get the real IMAP message number for this message */ +@@ -6050,10 +6052,24 @@ + mail_setflag(vms->mailstream, sequence, "\\Unseen"); + mail_clearflag(vms->mailstream, sequence, "\\Seen"); + } +- if (!strcasecmp(mbox(vmu, NEW_FOLDER), vms->curbox) && (box == NEW_FOLDER || box == OLD_FOLDER)) { +- ast_mutex_unlock(&vms->lock); ++ ++ if ((!strcasecmp(mbox(vmu, NEW_FOLDER), vms->curbox) || \ ++ !strcasecmp(mbox(vmu, OLD_FOLDER), vms->curbox)) && \ ++ (box == NEW_FOLDER || box == OLD_FOLDER)) { /* Don't copy data, */ ++ ast_mutex_unlock(&vms->lock); /* just change Seen flag */ + return 0; ++ } else if (box != NEW_FOLDER && box != OLD_FOLDER) { /* Do copy data */ ++ if (imapsubfold == 1) /* using INBOX or subfolder */ ++ snprintf(folder, sizeof(folder), "%s%c%s", imapfolder, delimiter, mbox(vmu, box)); ++ else ++ strncpy(folder, mbox(vmu, box), sizeof(folder)); ++ int res = !mail_copy(vms->mailstream,sequence,folder); ++ ast_mutex_unlock(&vms->lock); ++ return res; ++ } else { /* Copy data to INBOX delegating new/old status to Seen flag */ ++ int res = !mail_copy(vms->mailstream,sequence,imapfolder); + } ++ + /* Create the folder if it don't exist */ + imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1); /* Get the full mailbox name */ + ast_debug(5, "Checking if folder exists: %s\n", mailbox); +@@ -10221,6 +10237,10 @@ + #ifndef IMAP_STORAGE + } else if (!cmd) { + vms.deleted[vms.curmsg] = 1; ++#else ++ } else if (!cmd && (folder_int(vms.curbox) > 1 || box > 1)) { ++ vms.deleted[vms.curmsg] = 1; /* Enforce deletion after */ ++ deleted = 1; /* successful copy op */ + #endif + } else { + vms.deleted[vms.curmsg] = 0; +@@ -11688,6 +11708,15 @@ + } else { + ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder)); + } ++ /* IMAP saved (sub)folder location policy */ ++ if ((val = ast_variable_retrieve(cfg, "general", "imapsubfold"))) { ++ if (ast_false(val)) ++ imapsubfold = 0; ++ else ++ imapsubfold = 1; ++ } else { ++ imapsubfold = 0; ++ } + if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) { + ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder)); + } +Index: apps/.moduleinfo +diff -Nau apps/.moduleinfo.orig apps/.moduleinfo +--- apps/.moduleinfo.orig 2011-02-22 23:50:32.000000000 +0100 ++++ apps/.moduleinfo 2011-03-13 14:03:42.000000000 +0100 +@@ -72,7 +72,7 @@ + + + +- no ++ yes + + + jack +@@ -127,10 +127,10 @@ + + dahdi + tonezone +- no ++ yes + + +- no ++ yes + + + +Index: build_tools/cflags.xml +diff -Nau build_tools/cflags.xml.orig build_tools/cflags.xml +--- build_tools/cflags.xml.orig 2010-02-16 16:36:53.000000000 +0100 ++++ build_tools/cflags.xml 2011-03-13 14:03:42.000000000 +0100 +@@ -26,10 +26,11 @@ + + + +- no ++ yes + + + G711_NEW_ALGORITHM ++ yes + + + G711_NEW_ALGORITHM +Index: chan_capi-1.1.5.919/chan_capi20.h +diff -Nau chan_capi-1.1.5.919/chan_capi20.h.orig chan_capi-1.1.5.919/chan_capi20.h +--- chan_capi-1.1.5.919/chan_capi20.h.orig 2011-01-07 02:29:32.000000000 +0100 ++++ chan_capi-1.1.5.919/chan_capi20.h 2011-03-13 14:03:42.000000000 +0100 +@@ -4,10 +4,13 @@ + * first. Else the checks below will fail. + */ + ++#include + #include #undef CAPI_OS_HINT @@ -312,7 +387,7 @@ #if (defined(__FreeBSD__) || defined(__OpenBSD__) || \ defined(__NetBSD__) || defined(__APPLE__)) -@@ -29,6 +31,8 @@ +@@ -29,6 +32,8 @@ #include #endif /* BSD */ @@ -321,10 +396,11 @@ #ifndef HEADER_CID #define HEADER_CID(x) ((x)->adr.adrNCCI) #endif -Index: chan_capi-1.1.5/chan_capi_utils.c ---- chan_capi-1.1.5/chan_capi_utils.c.orig 2010-04-06 19:33:25.000000000 +0200 -+++ chan_capi-1.1.5/chan_capi_utils.c 2010-07-24 11:12:31.000000000 +0200 -@@ -1087,6 +1087,9 @@ +Index: chan_capi-1.1.5.919/chan_capi_utils.c +diff -Nau chan_capi-1.1.5.919/chan_capi_utils.c.orig chan_capi-1.1.5.919/chan_capi_utils.c +--- chan_capi-1.1.5.919/chan_capi_utils.c.orig 2011-01-07 02:29:32.000000000 +0100 ++++ chan_capi-1.1.5.919/chan_capi_utils.c 2011-03-13 14:03:42.000000000 +0100 +@@ -1155,6 +1155,9 @@ { MESSAGE_EXCHANGE_ERROR error; int waitcount = 50; @@ -334,9 +410,10 @@ unsigned char manbuf[CAPI_MANUFACTURER_LEN]; _cmsg CMSG; -Index: chan_capi-1.1.5/libcapi20/capi20.c ---- chan_capi-1.1.5/libcapi20/capi20.c.orig 2010-04-06 19:33:25.000000000 +0200 -+++ chan_capi-1.1.5/libcapi20/capi20.c 2010-07-24 11:12:31.000000000 +0200 +Index: chan_capi-1.1.5.919/libcapi20/capi20.c +diff -Nau chan_capi-1.1.5.919/libcapi20/capi20.c.orig chan_capi-1.1.5.919/libcapi20/capi20.c +--- chan_capi-1.1.5.919/libcapi20/capi20.c.orig 2011-01-07 02:29:31.000000000 +0100 ++++ chan_capi-1.1.5.919/libcapi20/capi20.c 2011-03-13 14:03:42.000000000 +0100 @@ -19,8 +19,10 @@ #include #include @@ -622,26 +699,7 @@ } unsigned -@@ -993,7 +1047,7 @@ - unsigned short* tmp = (unsigned short*)buf; - - if(*tmp == CapiNoError) { -- memcpy(Buf, buf + 2, (Ctrl) ? sizeof(struct capi_profile) : 2); -+ memcpy(Buf, buf + 2, (Ctrl) ? 224 /* sizeof(struct capi_profile) */ : 2); - } - - fret = *tmp; -@@ -1002,6 +1056,9 @@ - return (fret); - } - -+#if 1 -+ return CapiMsgOSResourceErr; -+#else - ioctl_data.contr = Ctrl; - - if (ioctl(capi_fd, CAPI_GET_PROFILE, &ioctl_data) < 0) { -@@ -1018,6 +1075,7 @@ +@@ -1018,6 +1072,7 @@ sizeof(ioctl_data.profile.ncontroller)); } return CapiNoError; @@ -649,9 +707,10 @@ } /* * functions added to the CAPI2.0 spec -Index: chan_capi-1.1.5/libcapi20/convert.c ---- chan_capi-1.1.5/libcapi20/convert.c.orig 2009-07-23 16:11:08.000000000 +0200 -+++ chan_capi-1.1.5/libcapi20/convert.c 2010-07-24 11:12:31.000000000 +0200 +Index: chan_capi-1.1.5.919/libcapi20/convert.c +diff -Nau chan_capi-1.1.5.919/libcapi20/convert.c.orig chan_capi-1.1.5.919/libcapi20/convert.c +--- chan_capi-1.1.5.919/libcapi20/convert.c.orig 2011-01-07 02:29:31.000000000 +0100 ++++ chan_capi-1.1.5.919/libcapi20/convert.c 2011-03-13 14:03:42.000000000 +0100 @@ -11,7 +11,14 @@ #include #include @@ -667,9 +726,46 @@ #include "capi20.h" +Index: chan_capi-1.1.5.919/Makefile +diff -Nau chan_capi-1.1.5.919/Makefile.orig chan_capi-1.1.5.919/Makefile +--- chan_capi-1.1.5.919/Makefile.orig 2011-01-07 02:29:32.000000000 +0100 ++++ chan_capi-1.1.5.919/Makefile 2011-03-13 14:03:42.000000000 +0100 +@@ -111,6 +111,9 @@ + CFLAGS+=-O2 + CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) + CFLAGS+=$(shell if uname -m | grep -q "ppc\|arm\|s390"; then echo "-fsigned-char"; fi) ++ifeq (${USE_OWN_LIBCAPI},yes) ++CFLAGS+=-DUSE_OWN_LIBCAPI ++endif + ifeq (${DIVA_STREAMING},1) + CFLAGS += -DDIVA_STREAMING=1 + endif +Index: channels/chan_sip.c +diff -Nau channels/chan_sip.c.orig channels/chan_sip.c +--- channels/chan_sip.c.orig 2011-01-14 18:32:52.000000000 +0100 ++++ channels/chan_sip.c 2011-03-13 14:03:42.000000000 +0100 +@@ -11210,7 +11210,16 @@ + } else { + if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->theirtag)) { + /* If this is a NOTIFY, use the From: tag in the subscribe (RFC 3265) */ +- snprintf(to, sizeof(to), "<%s%s>;tag=%s", (strncasecmp(p->uri, "sip:", 4) ? "sip:" : ""), p->uri, p->theirtag); ++ if (strncasecmp(p->uri, "sip:", strlen("sip:"))) ++ if (strncasecmp(p->uri, "sips:", strlen("sips:"))) ++ if (p->socket.type == SIP_TRANSPORT_TLS) ++ snprintf(to, sizeof(to), "<%s%s>;tag=%s", "sips:", p->uri, p->theirtag); ++ else ++ snprintf(to, sizeof(to), "<%s%s>;tag=%s", "sips:", p->uri, p->theirtag); ++ else /* if (strncasecmp(p->uri, "sips:"... */ ++ snprintf(to, sizeof(to), "<%s%s>;tag=%s", "", p->uri, p->theirtag); ++ else /* if (strncasecmp(p->uri, "sip:"... */ ++ snprintf(to, sizeof(to), "<%s%s>;tag=%s", "", p->uri, p->theirtag); + } else if (p->options && p->options->vxml_url) { + /* If there is a VXML URL append it to the SIP URL */ + snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url); Index: channels/console_video.h +diff -Nau channels/console_video.h.orig channels/console_video.h --- channels/console_video.h.orig 2008-06-30 17:45:15.000000000 +0200 -+++ channels/console_video.h 2010-07-24 11:12:31.000000000 +0200 ++++ channels/console_video.h 2011-03-13 14:03:42.000000000 +0100 @@ -28,10 +28,7 @@ "console {device}" #else @@ -683,10 +779,11 @@ #define CONSOLE_VIDEO_CMDS \ "console {videodevice|videocodec" \ Index: configure ---- configure.orig 2010-06-24 01:40:16.000000000 +0200 -+++ configure 2010-07-24 11:14:22.000000000 +0200 -@@ -4530,11 +4530,6 @@ - # note- does not work on FreeBSD +diff -Nau configure.orig configure +--- configure.orig 2011-01-09 22:40:34.000000000 +0100 ++++ configure 2011-03-13 14:14:50.000000000 +0100 +@@ -4700,11 +4700,6 @@ + esac case "${host_os}" in - freebsd*) @@ -697,10 +794,316 @@ openbsd*) if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then +@@ -18227,8 +18222,8 @@ + if test -f "${IMAP_TK_DIR}/c-client/LDFLAGS"; then + imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS` + fi +- imap_libs="${IMAP_TK_DIR}/c-client/c-client.a" +- imap_include="-I${IMAP_TK_DIR}/c-client" ++ imap_libs="-limap -lssl -lcrypto -lcrypt" ++ imap_include="-DUSE_SYSTEM_IMAP -I${IMAP_TK_DIR}/include/imap" + CPPFLAGS="${CPPFLAGS} ${imap_include}" + LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}` + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -25461,14 +25456,14 @@ + else + ast_ext_lib_check_save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} " +- as_ac_Lib=`$as_echo "ac_cv_lib_lua5.1_${pbxfuncname}" | $as_tr_sh` +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -llua5.1" >&5 +-$as_echo_n "checking for ${pbxfuncname} in -llua5.1... " >&6; } ++ as_ac_Lib=`$as_echo "ac_cv_lib_lua_${pbxfuncname}" | $as_tr_sh` ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -llua" >&5 ++$as_echo_n "checking for ${pbxfuncname} in -llua... " >&6; } + if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-llua5.1 ${pbxlibdir} -lm $LIBS" ++LIBS="-llua ${pbxlibdir} -lm $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -25511,19 +25506,19 @@ + + # now check for the header. + if test "${AST_LUA_FOUND}" = "yes"; then +- LUA_LIB="${pbxlibdir} -llua5.1 -lm" ++ LUA_LIB="${pbxlibdir} -llua -lm" + # if --with-LUA=DIR has been specified, use it. + if test "x${LUA_DIR}" != "x"; then + LUA_INCLUDE="-I${LUA_DIR}/include" + fi + LUA_INCLUDE="${LUA_INCLUDE} " +- if test "xlua5.1/lua.h" = "x" ; then # no header, assume found ++ if test "xlua/lua.h" = "x" ; then # no header, assume found + LUA_HEADER_FOUND="1" + else # check for the header + ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" +- ac_fn_c_check_header_mongrel "$LINENO" "lua5.1/lua.h" "ac_cv_header_lua5_1_lua_h" "$ac_includes_default" +-if test "x$ac_cv_header_lua5_1_lua_h" = x""yes; then : ++ ac_fn_c_check_header_mongrel "$LINENO" "lua/lua.h" "ac_cv_header_lua_lua_h" "$ac_includes_default" ++if test "x$ac_cv_header_lua_lua_h" = x""yes; then : + LUA_HEADER_FOUND=1 + else + LUA_HEADER_FOUND=0 +@@ -25551,9 +25546,9 @@ + + if test "x${PBX_LUA}" = "x1" ; then + if test x"${LUA_DIR}" = x; then +- LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua5.1" ++ LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua" + else +- LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua5.1" ++ LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua" + fi + fi + +@@ -26238,7 +26233,7 @@ + pbxlibdir="-L${SQLITE_DIR}" + fi + fi +- pbxfuncname="sqlite_exec" ++ pbxfuncname="sqlite3_exec" + if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers + AST_SQLITE_FOUND=yes + else +@@ -26953,16 +26948,16 @@ + if test "x${PBX_GMIME}" != "x1" -a "${USE_GMIME}" != "no"; then + PBX_GMIME=0 + if test -n "$ac_tool_prefix"; then +- # Extract the first word of "${ac_tool_prefix}gmime-config", so it can be a program name with args. +-set dummy ${ac_tool_prefix}gmime-config; ac_word=$2 ++ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. ++ set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_path_CONFIG_GMIME+set}" = set; then : ++if test "${ac_cv_prog_PKGCONFIG+set}" = set; then + $as_echo_n "(cached) " >&6 + else +- case $CONFIG_GMIME in ++ case $PKGCONFIG in + [\\/]* | ?:[\\/]*) +- ac_cv_path_CONFIG_GMIME="$CONFIG_GMIME" # Let the user override the test with a path. ++ ac_cv_path_PKGCONFIG="$PKGCONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +@@ -26973,7 +26968,7 @@ + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then +- ac_cv_path_CONFIG_GMIME="$as_dir/$ac_word$ac_exec_ext" ++ ac_cv_path_PKGCONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +@@ -26984,10 +26979,10 @@ + ;; + esac + fi +-CONFIG_GMIME=$ac_cv_path_CONFIG_GMIME +-if test -n "$CONFIG_GMIME"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CONFIG_GMIME" >&5 +-$as_echo "$CONFIG_GMIME" >&6; } ++PKGCONFIG=$ac_cv_path_PKGCONFIG ++if test -n "$PKGCONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGCONFIG" >&5 ++$as_echo "$PKGCONFIG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } +@@ -26995,18 +26990,18 @@ + + + fi +-if test -z "$ac_cv_path_CONFIG_GMIME"; then +- ac_pt_CONFIG_GMIME=$CONFIG_GMIME +- # Extract the first word of "gmime-config", so it can be a program name with args. +-set dummy gmime-config; ac_word=$2 ++if test -z "$ac_cv_path_PKGCONFIG"; then ++ ac_pt_PKGCONFIG=$PKGCONFIG ++ # Extract the first word of "pkg-config", so it can be a program name with args. ++set dummy pkg-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_path_ac_pt_CONFIG_GMIME+set}" = set; then : ++if test "${ac_cv_path_ac_pt_PKGCONFIG+set}" = set; then : + $as_echo_n "(cached) " >&6 + else +- case $ac_pt_CONFIG_GMIME in ++ case $ac_pt_PKGCONFIG in + [\\/]* | ?:[\\/]*) +- ac_cv_path_ac_pt_CONFIG_GMIME="$ac_pt_CONFIG_GMIME" # Let the user override the test with a path. ++ ac_cv_path_ac_pt_PKGCONFIG="$ac_pt_PKGCONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +@@ -27017,7 +27012,7 @@ + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then +- ac_cv_path_ac_pt_CONFIG_GMIME="$as_dir/$ac_word$ac_exec_ext" ++ ac_cv_path_ac_pt_PKGCONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +@@ -27028,17 +27023,17 @@ + ;; + esac + fi +-ac_pt_CONFIG_GMIME=$ac_cv_path_ac_pt_CONFIG_GMIME +-if test -n "$ac_pt_CONFIG_GMIME"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CONFIG_GMIME" >&5 +-$as_echo "$ac_pt_CONFIG_GMIME" >&6; } ++ac_pt_PKGCONFIG=$ac_cv_path_ac_pt_PKGCONFIG ++if test -n "$ac_pt_PKGCONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKGCONFIG" >&5 ++$as_echo "${ECHO_T}$ac_pt_PKGCONFIG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } + fi + +- if test "x$ac_pt_CONFIG_GMIME" = x; then +- CONFIG_GMIME="No" ++ if test "x$ac_pt_PKGCONFIG" = x; then ++ PKGCONFIG="No" + else + case $cross_compiling:$ac_tool_warned in + yes:) +@@ -27046,17 +27041,15 @@ + $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} + ac_tool_warned=yes ;; + esac +- CONFIG_GMIME=$ac_pt_CONFIG_GMIME ++ PKGCONFIG=$ac_pt_PKGCONFIG + fi + else +- CONFIG_GMIME="$ac_cv_path_CONFIG_GMIME" ++ PKGCONFIG="$ac_cv_path_PKGCONFIG" + fi + +- if test ! "x${CONFIG_GMIME}" = xNo; then +- if test x"" = x ; then A=--cflags ; else A="" ; fi +- GMIME_INCLUDE=$(${CONFIG_GMIME} $A) +- if test x"" = x ; then A=--libs ; else A="" ; fi +- GMIME_LIB=$(${CONFIG_GMIME} $A) ++ if test ! "x${PKGCONFIG}" = xNo; then ++ GMIME_INCLUDE=$(${PKGCONFIG} gmime-2.4 --cflags 2>/dev/null) ++ GMIME_LIB=$(${PKGCONFIG} gmime-2.4 --libs) + if test x"#include " != x ; then + saved_cppflags="${CPPFLAGS}" + if test "x${GMIME_DIR}" != "x"; then +Index: formats/format_pcm.c +diff -Nau formats/format_pcm.c.orig formats/format_pcm.c +--- formats/format_pcm.c.orig 2010-07-26 05:27:06.000000000 +0200 ++++ formats/format_pcm.c 2011-03-13 14:03:42.000000000 +0100 +@@ -350,6 +350,7 @@ + ast_log(LOG_WARNING, "Unable to write header\n"); + return -1; + } ++ fflush(f); /* issues.asterisk.org bug 0016610 */ + return 0; + } + +Index: formats/format_wav.c +diff -Nau formats/format_wav.c.orig formats/format_wav.c +--- formats/format_wav.c.orig 2010-09-02 18:43:09.000000000 +0200 ++++ formats/format_wav.c 2011-03-13 14:03:42.000000000 +0100 +@@ -310,6 +310,7 @@ + ast_log(LOG_WARNING, "Unable to write header\n"); + return -1; + } ++ fflush(f); /* issues.asterisk.org bug 0016610 */ + return 0; + } + +Index: formats/format_wav_gsm.c +diff -Nau formats/format_wav_gsm.c.orig formats/format_wav_gsm.c +--- formats/format_wav_gsm.c.orig 2010-07-26 05:27:06.000000000 +0200 ++++ formats/format_wav_gsm.c 2011-03-13 14:03:42.000000000 +0100 +@@ -362,6 +362,7 @@ + ast_log(LOG_WARNING, "Unable to write header\n"); + return -1; + } ++ fflush(f); /* issues.asterisk.org bug 0016610 */ + return 0; + } + +Index: main/db1-ast/hash/hash.h +diff -Nau main/db1-ast/hash/hash.h.orig main/db1-ast/hash/hash.h +--- main/db1-ast/hash/hash.h.orig 2006-08-21 04:11:39.000000000 +0200 ++++ main/db1-ast/hash/hash.h 2011-03-13 14:03:42.000000000 +0100 +@@ -36,6 +36,8 @@ + * @(#)hash.h 8.3 (Berkeley) 5/31/94 + */ + ++#include ++ + /* Operations */ + typedef enum { + HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT +Index: main/db1-ast/hash/ndbm.c +diff -Nau main/db1-ast/hash/ndbm.c.orig main/db1-ast/hash/ndbm.c +--- main/db1-ast/hash/ndbm.c.orig 2006-08-21 04:11:39.000000000 +0200 ++++ main/db1-ast/hash/ndbm.c 2011-03-13 14:03:42.000000000 +0100 +@@ -49,7 +49,8 @@ + #include + #include + +-#include ++#include "../include/ndbm.h" ++#include "../include/db.h" + #include "hash.h" + + /* +Index: main/features.c +diff -Nau main/features.c.orig main/features.c +--- main/features.c.orig 2011-01-20 21:24:36.000000000 +0100 ++++ main/features.c 2011-03-13 14:03:42.000000000 +0100 +@@ -1658,6 +1658,10 @@ + snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename); + } + ++ for(x = 0; x < strlen(touch_filename); x++) { ++ if (args[x] == '/') ++ args[x] = '-'; ++ } + for(x = 0; x < strlen(args); x++) { + if (args[x] == '/') + args[x] = '-'; +@@ -1774,6 +1778,10 @@ + snprintf(args, len, "%s.%s,b", touch_filename, S_OR(touch_format, "wav")); + } + ++ for( x = 0; x < strlen(touch_filename); x++) { ++ if (args[x] == '/') ++ args[x] = '-'; ++ } + for( x = 0; x < strlen(args); x++) { + if (args[x] == '/') + args[x] = '-'; +Index: main/file.c +diff -Nau main/file.c.orig main/file.c +--- main/file.c.orig 2011-01-12 17:05:12.000000000 +0100 ++++ main/file.c 2011-03-13 14:03:42.000000000 +0100 +@@ -255,7 +255,7 @@ + char *fn = NULL; + + if (!strcmp(ext, "wav49")) +- ext = "WAV"; ++ ext = "wav"; + + if (filename[0] == '/') { + if (asprintf(&fn, "%s.%s", filename, ext) < 0) { Index: main/Makefile ---- main/Makefile.orig 2010-06-25 20:58:37.000000000 +0200 -+++ main/Makefile 2010-07-24 11:12:31.000000000 +0200 -@@ -78,10 +78,7 @@ +diff -Nau main/Makefile.orig main/Makefile +--- main/Makefile.orig 2010-12-18 00:52:04.000000000 +0100 ++++ main/Makefile 2011-03-13 14:03:42.000000000 +0100 +@@ -69,10 +69,7 @@ endif ifeq ($(OSARCH),FreeBSD) @@ -712,22 +1115,11 @@ endif ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) -Index: main/file.c ---- main/file.c.orig 2010-03-25 17:26:13.000000000 +0100 -+++ main/file.c 2010-07-24 11:12:31.000000000 +0200 -@@ -254,7 +254,7 @@ - char *fn = NULL; - - if (!strcmp(ext, "wav49")) -- ext = "WAV"; -+ ext = "wav"; - - if (filename[0] == '/') { - if (asprintf(&fn, "%s.%s", filename, ext) < 0) { Index: main/tcptls.c ---- main/tcptls.c.orig 2010-03-20 18:33:03.000000000 +0100 -+++ main/tcptls.c 2010-07-24 11:12:31.000000000 +0200 -@@ -325,6 +325,7 @@ +diff -Nau main/tcptls.c.orig main/tcptls.c +--- main/tcptls.c.orig 2010-07-09 00:08:07.000000000 +0200 ++++ main/tcptls.c 2011-03-13 14:03:42.000000000 +0100 +@@ -354,6 +354,7 @@ if (!ast_strlen_zero(cfg->cafile) || !ast_strlen_zero(cfg->capath)) { if (SSL_CTX_load_verify_locations(cfg->ssl_ctx, S_OR(cfg->cafile, NULL), S_OR(cfg->capath,NULL)) == 0) ast_verb(0, "SSL CA file(%s)/path(%s) error\n", cfg->cafile, cfg->capath); @@ -735,40 +1127,103 @@ } ast_verb(0, "SSL certificate ok\n"); +Index: main/udptl.c +diff -Nau main/udptl.c.orig main/udptl.c +--- main/udptl.c.orig 2011-02-22 23:52:11.000000000 +0100 ++++ main/udptl.c 2011-03-13 14:03:42.000000000 +0100 +@@ -98,6 +98,18 @@ + + #define UDPTL_BUF_MASK 15 + ++/*! Copied from chan_oss.c, corrects link errors: ++udptl.o: In function `calculate_local_max_datagram': ++main/udptl.c:740: undefined reference to `MIN' ++udptl.o: In function `calculate_far_max_ifp': ++main/udptl.c:770: undefined reference to `MAX' */ ++#ifndef MIN ++#define MIN(a,b) ((a) < (b) ? (a) : (b)) ++#endif ++#ifndef MAX ++#define MAX(a,b) ((a) > (b) ? (a) : (b)) ++#endif ++ + typedef struct { + int buf_len; + uint8_t buf[LOCAL_FAX_MAX_DATAGRAM]; +Index: Makefile +diff -Nau Makefile.orig Makefile +--- Makefile.orig 2011-01-12 16:57:43.000000000 +0100 ++++ Makefile 2011-03-13 14:03:42.000000000 +0100 +@@ -230,15 +230,6 @@ + _ASTCFLAGS+=-fsigned-char + endif + +-ifeq ($(OSARCH),FreeBSD) +- ifeq ($(PROC),i386) +- _ASTCFLAGS+=-march=i686 +- endif +- # -V is understood by BSD Make, not by GNU make. +- BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk) +- _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi) +-endif +- + ifeq ($(OSARCH),NetBSD) + _ASTCFLAGS+=-pthread -I/usr/pkg/include + endif Index: menuselect-tree ---- menuselect-tree.orig 2010-07-22 21:20:17.000000000 +0200 -+++ menuselect-tree 2010-07-24 11:12:31.000000000 +0200 -@@ -153,6 +153,8 @@ +diff -Nau menuselect-tree.orig menuselect-tree +--- menuselect-tree.orig 2011-02-22 23:50:45.000000000 +0100 ++++ menuselect-tree 2011-03-13 14:03:42.000000000 +0100 +@@ -38,6 +38,8 @@ - + -+ ++ + - + - -@@ -693,9 +695,9 @@ - - + +@@ -937,11 +939,11 @@ -+ yes - yes -@@ -771,6 +773,7 @@ - - - + + yes - + + +@@ -1006,7 +1008,6 @@ + + + +- yes + + + +@@ -1017,6 +1018,7 @@ + + + ++ yes + + + +@@ -1037,6 +1039,7 @@ + + + ++ yes + + Index: res/res_http_post.c ---- res/res_http_post.c.orig 2009-10-27 18:12:09.000000000 +0100 -+++ res/res_http_post.c 2010-07-24 11:12:31.000000000 +0200 +diff -Nau res/res_http_post.c.orig res/res_http_post.c +--- res/res_http_post.c.orig 2009-10-27 17:48:54.000000000 +0100 ++++ res/res_http_post.c 2011-03-13 14:03:42.000000000 +0100 @@ -122,14 +122,8 @@ ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MESSAGE_PARTIAL\n"); return; @@ -787,24 +1242,43 @@ const char *filename; Index: sounds/sounds.xml ---- sounds/sounds.xml.orig 2009-08-18 22:31:40.000000000 +0200 -+++ sounds/sounds.xml 2010-07-24 11:12:31.000000000 +0200 -@@ -4,9 +4,9 @@ - - +diff -Nau sounds/sounds.xml.orig sounds/sounds.xml +--- sounds/sounds.xml.orig 2010-10-18 23:51:23.000000000 +0200 ++++ sounds/sounds.xml 2011-03-13 14:03:42.000000000 +0100 +@@ -6,11 +6,11 @@ -+ yes - yes -@@ -82,6 +82,7 @@ - - - + + yes - + +@@ -75,7 +75,6 @@ + + + +- yes + + + +@@ -86,6 +85,7 @@ + + + ++ yes + + + +@@ -106,6 +106,7 @@ + + + ++ yes + + + diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/asterisk.patch.proxymwi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/asterisk/asterisk.patch.proxymwi Sun Mar 20 20:03:11 2011 +0100 @@ -0,0 +1,24 @@ +Index: channels/chan_sip.c +diff -Nau channels/chan_sip.c.orig channels/chan_sip.c +--- channels/chan_sip.c.orig 2011-01-14 18:32:52.000000000 +0100 ++++ channels/chan_sip.c 2011-03-13 14:34:29.000000000 +0100 +@@ -24267,6 +24267,7 @@ + /* Called with peerl lock, but releases it */ + struct sip_pvt *p; + int newmsgs = 0, oldmsgs = 0; ++ char *s = NULL; + + if (ast_test_flag((&peer->flags[1]), SIP_PAGE2_SUBSCRIBEMWIONLY) && !peer->mwipvt) + return 0; +@@ -24307,6 +24308,11 @@ + } + /* Recalculate our side, and recalculate Call ID */ + ast_sip_ouraddrfor(&p->sa, &p->ourip, p); ++ /* Set the username = mailbox and remove the context */ ++ ast_string_field_build(p, username, "%s", peer->name); ++ s = strchr(p->username, '@'); ++ if (s != NULL) ++ *s = 0; + build_via(p); + ao2_t_unlink(dialogs, p, "About to change the callid -- remove the old name"); + build_callid_pvt(p); diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/asterisk.patch.xfersips --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/asterisk/asterisk.patch.xfersips Sun Mar 20 20:03:11 2011 +0100 @@ -0,0 +1,37 @@ +Index: channels/chan_sip.c +diff -Nau channels/chan_sip.c.orig channels/chan_sip.c +--- channels/chan_sip.c.orig 2011-01-14 18:32:52.000000000 +0100 ++++ channels/chan_sip.c 2011-03-13 14:32:58.000000000 +0100 +@@ -27854,6 +27854,7 @@ + \todo Fix this function so that we wait for reply to the REFER and + react to errors, denials or other issues the other end might have. + */ ++/* MSvB: Paramater dest may be SIPS encoded, having '@' before domain */ + static int sip_sipredirect(struct sip_pvt *p, const char *dest) + { + char *cdest; +@@ -27862,7 +27863,7 @@ + cdest = ast_strdupa(dest); + + extension = strsep(&cdest, "@"); +- domain = strsep(&cdest, ":"); ++ domain = strsep(&cdest, ":"); /* MSvB: Could begin with '@' if SIPS */ + if (ast_strlen_zero(extension)) { + ast_log(LOG_ERROR, "Missing mandatory argument: extension\n"); + return 0; +@@ -27894,7 +27895,14 @@ + } + } + +- ast_string_field_build(p, our_contact, "Transfer ", extension, domain); ++ if (domain && *domain == '@') { ++ ast_log(LOG_DEBUG, "Decoding TLS incapable Asterisk SIP URI to a standard SIPS URI before redirecting via 302 Moved Temporarily\n"); ++ ast_string_field_build(p, our_contact, "Transfer ", extension, domain); ++ ++ } ++ else ++ ast_string_field_build(p, our_contact, "Transfer ", extension, domain); ++ + transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq); + + sip_scheddestroy(p, SIP_TRANS_TIMEOUT); /* Make sure we stop send this reply. */ diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/asterisk.spec --- a/asterisk/asterisk.spec Sun Mar 20 20:00:02 2011 +0100 +++ b/asterisk/asterisk.spec Sun Mar 20 20:03:11 2011 +0100 @@ -1,6 +1,6 @@ ## ## asterisk.spec -- OpenPKG RPM Package Specification -## Copyright (c) 2000-2010 OpenPKG Foundation e.V. +## Copyright (c) 2000-2009 OpenPKG Foundation e.V. ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that @@ -22,13 +22,21 @@ ## # package version -%define V_opkg 1.6.2.13 -%define V_asterisk 1.6.2.13 -%define V_asterisk_addons 1.6.2.2 -%define V_asterisk_sounds_core_en 1.4.20 -%define V_asterisk_sounds_core_de current -%define V_asterisk_sounds_extra_en 1.4.11 -%define V_chan_capi 1.1.5 +%define V_opkg 1.8.3.2 +%define V_asterisk 1.8.3.2 +%define V_asterisk_fax_digium 1.8.0_1.3.0 +%define V_asterisk_sounds_core 1.4.20 +%define V_asterisk_sounds_extra 1.4.11 +%define V_asterisk_sounds_amoogab 1.4 +%define V_asterisk_sounds_amootts current +%define V_asterisk_sounds_custom 1.0 +%define V_asterisk_sounds_mohop 2.03 +%define V_asterisk_addons_mp3dec 1 +%define V_fswitch_sounds_en 1.0.14 +%define V_fswitch_sounds_ru 1.0.12 +%define V_fswitch_music 1.0.8 +%define V_asterisk_codecs_ilbc 20110104 +%define V_chan_capi 1.1.5.919 # package information Name: asterisk @@ -41,7 +49,7 @@ Group: VoIP License: GPL Version: %{V_opkg} -Release: 20101019 +Release: 20110314 # package options %option with_dahdi no @@ -53,27 +61,56 @@ %option with_ldap no %option with_radius no %option with_sqlite no +%option with_srtp no +%option with_pgsql no %option with_lua no %option with_jabber no %option with_imap no %option with_odbc no +%option with_libpri no +%option with_esounds no +%option with_xfersips yes +%option with_proxymwi yes +%option with_smdipoll 10 # list of sources Source0: http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-%{V_asterisk}.tar.gz -Source1: http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-%{V_asterisk_addons}.tar.gz -Source2: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-alaw-%{V_asterisk_sounds_core_en}.tar.gz -Source3: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-en-alaw-%{V_asterisk_sounds_extra_en}.tar.gz -Source4: http://www.amooma.de/asterisk/sprachbausteine/asterisk-core-sounds-de-gsm-%{V_asterisk_sounds_core_de}.tar.gz -Source5: ftp://ftp.chan-capi.org/chan-capi/chan_capi-%{V_chan_capi}.tar.gz -Source6: asterisk.txt -Source7: rc.asterisk +Source1: ftp://ftp.chan-capi.org/chan-capi/chan_capi-%{V_chan_capi}.tar.gz +Source2: ftp://ftp.europalab.com/pub/sfw/machsnds/asterisk-moh-freeplay-sln16.tar.gz +Source3: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-sln16-%{V_asterisk_sounds_mohop}.tar.gz +Source4: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-sln16-%{V_asterisk_sounds_core}.tar.gz +Source5: http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en_AU-sln16-current.tar.gz +Source6: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-es-sln16-%{V_asterisk_sounds_core}.tar.gz +Source7: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-fr-sln16-%{V_asterisk_sounds_core}.tar.gz +Source8: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-en-sln16-%{V_asterisk_sounds_extra}.tar.gz +Source9: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-fr-sln16-%{V_asterisk_sounds_extra}.tar.gz +Source10: http://www.amooma.de/asterisk/sprachbausteine/asterisk-%{V_asterisk_sounds_amoogab}-de-prompts.tar.gz +Source11: http://www.amooma.de/asterisk/sprachbausteine/asterisk-core-sounds-de-gsm-current.tar.gz +Source12: ftp://ftp.europalab.com/pub/sfw/machsnds/de-digits/de-digits-%{V_asterisk_sounds_custom}.tar.bz2 +Source13: ftp://ftp.europalab.com/pub/sfw/machsnds/de-sounds/astmultisnds-de-sln16-%{V_asterisk_sounds_custom}.tar.bz2 +Source14: ftp://ftp.europalab.com/pub/sfw/machsnds/msvbsnds-sln16-%{V_asterisk_sounds_custom}.tar.bz2 +Source15: http://files.freeswitch.org/freeswitch-sounds-en-us-callie-48000-%{V_fswitch_sounds_en}.tar.gz +Source16: http://files.freeswitch.org/freeswitch-sounds-es-mx-maria-44100.tar.gz +Source17: http://files.freeswitch.org/freeswitch-sounds-ru-RU-elena-48000-%{V_fswitch_sounds_ru}.tar.gz +Source18: http://files.freeswitch.org/freeswitch-sounds-music-48000-%{V_fswitch_music}.tar.gz +Source19: http://svn.digium.com/svn/thirdparty/mp3/trunk/addons/mp3-%{V_asterisk_addons_mp3dec}.tar.gz +Source20: http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-1.8.0/x86-64/res_fax_digium-%{V_asterisk_fax_digium}-generic_64.tar.gz +Source21: http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-1.8.0/x86-32/res_fax_digium-%{V_asterisk_fax_digium}-generic_32.tar.gz +Source22: ilbc-20110104.tar.gz +Source23: asterisk.txt +Source24: rc.asterisk +Source25: wakeup.agi Patch0: asterisk.patch +Patch1: asterisk.patch.xfersips +Patch2: asterisk.patch.proxymwi # build information -BuildPreReq: OpenPKG, openpkg >= 20100101, bison, gcc, make, grep -PreReq: OpenPKG, openpkg >= 20100101, MTA -BuildPreReq: zlib, curl, openssl, ncurses, speex, popt, gmime22 -PreReq: zlib, curl, openssl, ncurses, speex, popt, gmime22 +Prefix: %{l_prefix} +BuildRoot: %{l_buildroot} +BuildPreReq: OpenPKG, openpkg >= 20040130, bison, gcc, make, grep +PreReq: OpenPKG, openpkg >= 20040130, MTA +BuildPreReq: zlib, curl, openssl, ncurses, speex, sox, popt, gmime, libxml +PreReq: zlib, curl, openssl, ncurses, speex, sox, popt, gmime, libxml %if "%{with_ogg}" == "yes" BuildPreReq: vorbis-libs PreReq: vorbis-libs @@ -89,14 +126,18 @@ BuildPreReq: sqlite PreReq: sqlite %endif +%if "%{with_srtp}" == "yes" +BuildPreReq: srtp +PreReq: srtp +%endif +%if "%{with_pgsql}" == "yes" +BuildPreReq: postgresql +PreReq: postgresql +%endif %if "%{with_lua}" == "yes" BuildPreReq: lua PreReq: lua %endif -%if "%{with_fax}" == "yes" -BuildPreReq: spandsp, tiff, jpeg, zlib -PreReq: spandsp, tiff, jpeg, zlib -%endif %if "%{with_avcodec}" == "yes" BuildPreReq: ffmpeg PreReq: ffmpeg @@ -117,15 +158,37 @@ BuildPreReq: unixodbc, sqlite, sqlite::with_odbc = yes PreReq: unixodbc, sqlite, sqlite::with_odbc = yes %endif +%if "%{with_libpri}" == "yes" +BuildPreReq: libpri > 1.4.11.5 +PreReq: libpri > 1.4.11.5 +%endif +%if "%{with_esounds}" == "yes" +BuildPreReq: sox +%endif +AutoReq: no +AutoReqProv: no %description Asterisk is a complete Private Branch Exchange (PBX) in software. - It provides all of the features you would expect from a PBX and - more. Asterisk does Voice over IP (VoIP) in many protocols. Asterisk - provides Voicemail services with Directory, Call Conferencing, - Interactive Voice Response and Call Queuing. It has support for - three-way calling, caller ID services, ADSI, SIP, etc. Asterisk - needs no additional hardware for VoIP. + It provides more than the features normally expected from a PBX, + and can transceive Voice over IP (VoIP) in many protocols. Asterisk + provides voicemail services with directory, call conferencing, + interactive voice response and call queuing as well. It has support + for three way calling, caller ID, ADSI, and SIP, and requires no + additional hardware for VoIP applications. + + This copy of Asterisk is optionally patched to allow the asterisk + server to respond to SIP/TLS transfer requests using the Transfer() + application. Should this option be chosen, the asterisk server + successfully dispatches all transfer destinations using 'SIPS' + technology by means of the standard SIP/2.0 302 Moved Temporarily + message, with a URI resembling . + + This copy of Asterisk is optionally patched as well to enclose the + correct user name in NOTIFY messages when MWI logic detects changes + in the state of Messages-Waiting. Asterisk will send NOTIFY messages + with the URI 'user@hostname' instead of simply 'hostname'. This can + be used by a external SIP proxy to route the MWI to the correct phone. %track prog asterisk = { @@ -133,26 +196,51 @@ url = http://downloads.asterisk.org/pub/telephony/asterisk/releases/ regex = asterisk-(\d+\.\d+(\.\d+)+)\.tar\.gz } - prog asterisk:addons = { - version = %{V_asterisk_addons} - url = http://downloads.asterisk.org/pub/telephony/asterisk/releases/ - regex = asterisk-addons-(\d+\.\d+(\.\d+)+)\.tar\.gz + prog asterisk:fax_digium_32 = { + version = %{V_asterisk_fax_digium} + url = http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-1.8.0/x86-32/ + regex = res_fax_digium-(__VER__)-generic_32.tar.gz\.tar\.gz } - prog asterisk:sounds_core_en = { - version = %{V_asterisk_sounds_core_en} + prog asterisk:fax_digium_64 = { + version = %{V_asterisk_fax_digium} + url = http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-1.8.0/x86-64/ + regex = res_fax_digium-(__VER__)-generic_64.tar.gz\.tar\.gz + } + prog asterisk:sounds_core = { + version = %{V_asterisk_sounds_core} url = http://downloads.asterisk.org/pub/telephony/sounds/releases/ - regex = asterisk-core-sounds-en-alaw-(\d+\.\d+(\.\d+)+)\.tar\.gz + regex = asterisk-core-sounds-en-sln16-(\d+\.\d+(\.\d+)+)\.tar\.gz } - prog asterisk:sounds_extra_en = { - version = %{V_asterisk_sounds_extra_en} + prog asterisk:sounds_extra = { + version = %{V_asterisk_sounds_extra} url = http://downloads.asterisk.org/pub/telephony/sounds/releases/ - regex = asterisk-extra-sounds-en-alaw-(\d+\.\d+(\.\d+)+)\.tar\.gz + regex = asterisk-extra-sounds-en-sln16-(\d+\.\d+(\.\d+)+)\.tar\.gz } - prog asterisk:sounds_core_de = { - version = %{V_asterisk_sounds_core_de} + prog asterisk:sounds_amootts = { + version = %{V_asterisk_sounds_amootts} url = http://www.amooma.de/asterisk/sprachbausteine/ regex = asterisk-core-sounds-de-gsm-(__VER__)\.tar\.gz } + prog asterisk:sounds_amoogab = { + version = %{V_asterisk_sounds_amoogab} + url = http://www.amooma.de/asterisk/sprachbausteine/ + regex = asterisk-(__VER__)-de-prompts\.tar\.gz + } + prog asterisk:sounds_digits = { + version = %{V_asterisk_sounds_custom} + url = ftp://ftp.europalab.com/pub/sfw/machsnds/de-digits/ + regex = de-digits-(__VER__)\.tar\.bz2 + } + prog asterisk:sounds_custom = { + version = %{V_asterisk_sounds_custom} + url = ftp://ftp.europalab.com/pub/sfw/machsnds/de-sounds/ + regex = astmultisnds-de-sln16-(__VER__)\.tar\.bz2 + } + prog asterisk:sounds_mohop = { + version = %{V_asterisk_sounds_mohop} + url = http://downloads.asterisk.org/pub/telephony/sounds/releases/ + regex = asterisk-moh-opsound-sln16-(__VER__)\.tar\.gz + } prog asterisk:chan_capi = { version = %{V_chan_capi} url = ftp://ftp.chan-capi.org/chan-capi/ @@ -162,32 +250,126 @@ %prep %setup -q -n asterisk-%{V_asterisk} %setup -q -n asterisk-%{V_asterisk} -D -T -a 1 - %setup -q -n asterisk-%{V_asterisk} -D -T -a 5 + %setup -q -n asterisk-%{V_asterisk} -D -T -a 2 +%if "%{with_fax}" == "yes" + %setup -q -n asterisk-%{V_asterisk} -D -T -a 20 + %setup -q -n asterisk-%{V_asterisk} -D -T -a 21 +%endif + ( cd addons + %{l_tar} zxf %{_sourcedir}/mp3-%{V_asterisk_addons_mp3dec}.tar.gz + ) || exit $? + ( cd codecs + %{l_tar} zxf %{_sourcedir}/ilbc-%{V_asterisk_codecs_ilbc}.tar.gz + mv ilbc-%{V_asterisk_codecs_ilbc}/* ilbc/ + rmdir ilbc-%{V_asterisk_codecs_ilbc} + ) || exit $? %patch -p0 - exit 0 - cp %{SOURCE2} %{SOURCE3} sounds/ +%if "%{with_xfersips}" == "yes" + %patch -p0 -P 1 +%endif +%if "%{with_proxymwi}" == "yes" + %patch -p0 -P 2 +%endif %{l_shtool} subst \ - -e 's;\(CORE_SOUNDS_VERSION\):=.*$;\1:=%{V_asterisk_sounds_core_en};' \ - -e 's;\(EXTRA_SOUNDS_VERSION\):=.*$;\1:=%{V_asterisk_sounds_extra_en};' \ + -e 's;\(astdatadir=.*\)\${astvarlibdir};\1${datadir};' \ + -e 's;\(astvarlibdir=.*\)/lib/asterisk;\1/asterisk/lib;' \ + -e 's;\(dir=.*{localstatedir}\)/\([^/][^/]*\)/asterisk;\1/asterisk/\2;g' \ + configure + %{l_shtool} subst \ + -e 's;-llua5\.1;-llua;' \ + -e 's;lua5\.1/lua\.h;lua/lua.h;' \ + -e 's;ffmpeg/avcodec\.h;libavcodec/avcodec.h;' \ + -e 's;\(sqlite\)\(_exec\);\13\2;g' \ + -e 's;-lradiusclient-ng;-lradiusclient;g' \ + -e 's;radiusclient-ng\.h;radiusclient.h;g' \ + -e 's;-I${IMAP_TK_DIR}/c-client;-DUSE_SYSTEM_IMAP -I${IMAP_TK_DIR}/include/imap;g' \ + -e 's;${IMAP_TK_DIR}/c-client/c-client\.a;-limap -lssl -lcrypto -lcrypt;g' \ + configure + %{l_shtool} subst \ + -e 's;\(sh\) \(bash\) ksh sh5;\2 \1;' \ + configure + %{l_shtool} subst \ + -e 's;^\(#define DEFAULT_DB .*\${ASTDBDIR}\)/astdb;\1/asterisk.db;' \ + build_tools/make_defaults_h + %{l_shtool} subst \ + -e 's; *-I/usr/local/ssl/include;;g' \ + -e 's;/opt/ssl/include;%{l_prefix}/include;g' \ + -e 's;/usr/local;%{l_prefix};g' \ + Makefile + %{l_shtool} subst \ + -e 's;\$(SUBMAKE);$(MAKE);g' \ + -e 's;\$(SILENTMAKE);$(MAKE) --quiet --no-print-directory;g' \ + -e 's;\$(MAKE_MENUSELECT); $(MAKE) -C menuselect;g' \ + Makefile + %{l_shtool} subst \ + -e 's; *-L/usr/local/ssl/lib;;g' \ + -e 's;/opt/ssl/lib;%{l_prefix}/lib;g' \ + -e 's;/usr/local;%{l_prefix};g' \ + -e 's;\(ASTLINK=\)$;\1-Wl,--export-dynamic;g' \ + -e 's;\( CFLAGS=\)"[^"]+";"%{l_cflags -O}";g' \ + main/Makefile + %{l_shtool} subst \ + -e 's;\(\)no\(\);\1yes\2;g' \ + addons/.*.moduleinfo \ + apps/.app_ivrdemo.moduleinfo \ + apps/.app_saycounted.moduleinfo \ + apps/.app_rpt.moduleinfo \ + codecs/.moduleinfo \ + utils/utils.xml \ + agi/agi.xml + %{l_shtool} subst \ + -e 's;check_expr2;check_expr;g' \ + utils/utils.xml + %{l_shtool} subst \ + -e 's;\(-DSOLARIS\);\1 -D__EXTENSIONS__=1;g' \ + main/editline/Makefile.in \ + main/db1-ast/Makefile + %{l_shtool} subst \ + -e 's;%s/astdb;%s/asterisk.db;g' \ + main/asterisk.c + %{l_shtool} subst \ + -e 's;u_int\([0-9]*\)_t;uint\1_t;g' \ + main/db1-ast/hash/hash.h + %{l_shtool} subst \ + -e 's;if \(((tmp = strchr(name\);while \1;g' \ + main/abstract_jb.c + %{l_shtool} subst \ + -e 's;\(CORE_SOUNDS_VERSION\):=.*$;\1:=%{V_asterisk_sounds_core};' \ + -e 's;\(EXTRA_SOUNDS_VERSION\):=.*$;\1:=%{V_asterisk_sounds_extra};' \ sounds/Makefile %{l_shtool} subst \ - -e 's;-lradiusclient-ng;-lradiusclient;g' \ - -e 's;radiusclient-ng\.h;radiusclient.h;g' \ - configure cdr/cdr_radius.c + -e 's;\(/etc/radiusclient-ng/radiusclient.conf\);%{l_prefix}\1;g' \ + -e 's;\(radiusclient\)-ng;\1;g' \ + cdr/cdr_radius.c \ + cel/cel_radius.c + %{l_shtool} subst \ + -e 's;\(sqlite\)\(\.h\);\13\2;g' \ + cdr/cdr_sqlite.c + %{l_shtool} subst \ + -e 's;\(#define DEFAULT_POLLING_INTERVAL\) .*;\1 %{with_smdipoll};' \ + res/res_smdi.c + %{l_shtool} subst \ + -e 's;\(ASTERISK_HEADER_DIR=\).*;\1%{l_prefix}/include;g' \ + -e 's;\(MODULES_DIR=\).*;\1%{l_prefix}/lib/asterisk/modules;g' \ + -e 's;\(CONFIG_DIR=\).*;\1%{l_prefix}/etc/asterisk;g' \ + -e 's;\(\$(MODULES_DIR)\);$(DESTDIR)\1;g' \ + -e 's;\${CONFIG_DIR};$(DESTDIR)$(CONFIG_DIR);g' \ + -e 's;^\(USE_OWN_LIBCAPI\)=yes;\1=no;' \ + chan_capi-%{V_chan_capi}/Makefile %build - # sanity check + # sanity check operating system %if "%{with_dahdi}" == "yes" dahdi_prefix="" case "%{l_platform -t}" in *-linux* ) - if [ ! -f /usr/include/linux/dahdi.h ]; then + if [ ! -f /usr/include/dahdi/user.h ]; then echo "option \"with_dahdi\" requires DAHDI Linux drivers installed" 1>&2; exit 1 fi dahdi_prefix=/usr ;; *-freebsd* ) - if [ ! -f /usr/local/include/dahdi/dahdi.h ]; then + if [ ! -f /usr/local/include/dahdi/user.h ]; then echo "option \"with_dahdi\" requires DAHDI FreeBSD drivers installed" 1>&2; exit 1 fi dahdi_prefix=/usr/local @@ -195,8 +377,15 @@ * ) echo "option \"with_dahdi\" supported under Linux and FreeBSD only" 1>&2; exit 1 ;; esac %endif + # correct platform dependent build configuration + extflg= + case "%{l_platform -t}" in + *-linux* ) + pthlibflg='-lpthread' + ;; + esac - # re-configure music-on-hold to find mpg123 + # adapt buildconf to find mpg123 (for music on hold) %if "%{with_mp3}" == "yes" mpg123="%{l_prefix}/bin/mpg123" %else @@ -207,21 +396,16 @@ -e "s;/usr/bin/mpg123;$mpg123;" \ res/res_musiconhold.c apps/app_mp3.c - # build program - %{l_shtool} subst \ - -e 's;-llua5\.1;-llua;' \ - -e 's;lua5\.1/lua\.h;lua/lua.h;' \ - -e 's;ffmpeg/avcodec\.h;libavcodec/avcodec.h;' \ - configure + # configure program ( echo "ac_cv_prog_CONFIG_GMIME=%{l_prefix}/bin/gmime-config" ) >config.cache cflags="%{l_cflags -O}" - cppflags="%{l_cppflags ncurses lua .}" + cppflags="%{l_cppflags ncurses lua}" ldflags="%{l_ldflags}" libs="" - cppflags="$cppflags `pkg-config gmime-2.0 --cflags-only-I`" - ldflags="$ldflags `pkg-config gmime-2.0 --libs-only-L`" - libs="$libs `pkg-config gmime-2.0 --libs-only-l`" + cppflags="$cppflags `pkg-config gmime-2.4 --cflags-only-I`" + ldflags="$ldflags `pkg-config gmime-2.4 --libs-only-L`" + libs="$libs `pkg-config gmime-2.4 --libs-only-l` -lssl -lcrypto" %if "%{with_ogg}" == "yes" libs="$libs -logg -lm" %endif @@ -229,7 +413,7 @@ libs="$libs -lavcodec -lavutil" %endif %if "%{with_ldap}" == "yes" - libs="$libs -lldap -llber -lssl -lcrypto" + libs="$libs -lldap -llber" %endif %if "%{with_dahdi}" == "yes" cppflags="$cppflags -I$dahdi_prefix/include" @@ -240,14 +424,18 @@ CPPFLAGS="$cppflags" \ LDFLAGS="$ldflags" \ LIBS="$libs" \ + INSTALL="%{l_shtool} install -c" \ + PTHREAD_LIBS="$pthlibflg" \ ./configure \ --cache-file=./config.cache \ --prefix=%{l_prefix} \ --mandir=%{l_prefix}/man \ --sysconfdir=%{l_prefix}/etc \ - --localstatedir=%{l_prefix}/var/asterisk \ + --localstatedir=%{l_prefix}/var \ + --datarootdir=%{l_prefix}/share/asterisk \ + --with-crypto=%{l_prefix} \ --with-curl=%{l_prefix} \ - --with-ncurses \ + --with-ncurses=%{l_prefix} \ --with-gsm="internal" \ --with-popt=%{l_prefix} \ %if "%{with_sqlite}" == "yes" @@ -255,6 +443,16 @@ %else --without-sqlite3 \ %endif +%if "%{with_srtp}" == "yes" + --with-srtp=%{l_prefix} \ +%else + --without-srtp \ +%endif +%if "%{with_pgsql}" == "yes" + --with-postgres=%{l_prefix} \ +%else + --with-postgres=no \ +%endif --with-speex=%{l_prefix} \ --with-speexdsp=%{l_prefix} \ --with-ssl=%{l_prefix} \ @@ -301,6 +499,7 @@ %endif %if "%{with_imap}" == "yes" --with-imap=%{l_prefix} \ + --disable-largefile \ %else --without-imap \ %endif @@ -309,80 +508,83 @@ %else --without-odbc \ %endif +%if "%{with_libpri}" == "yes" + --with-pri=%{l_prefix} \ +%else + --without-pri \ +%endif + --with-sounds-cache=no \ --without-netsnmp \ --without-isdnnet \ --without-misdn \ - --without-kde \ --without-nbs \ --without-newt \ --without-asound \ --without-oss \ - --without-qt \ --without-sqlite \ - --without-postgres \ --without-tds \ --without-osptk \ - --without-pri \ --without-suppserv \ --without-vpb \ --without-sdl \ --without-x11 \ --without-gtk \ --without-gtk2 - %{l_make} %{l_mflags} \ - CC="%{l_cc} $cflags -I. -I./include -I../include -I../../include $cppflags" + + # build menuselect + %{l_make} %{l_mflags -O} menuselect.makeopts + %{l_shtool} subst \ + -e 's;\(MENUSELECT_MOH=\).*;\1;' \ + -e 's;\(MENUSELECT_CORE_SOUNDS=\).*;\1;' \ + -e 's;\(MENUSELECT_EXTRA_SOUNDS=\).*;\1;' \ + menuselect.makeopts +%if "%{with_imap}" == "yes" + %{l_shtool} subst \ + -e 's;\(MENUSELECT_OPTS_app_voicemail=\).*;\1IMAP_STORAGE;' \ + menuselect.makeopts +%endif + + # build program + %{l_make} %{l_mflags -O} \ + CC="%{l_cc} $cflags -I../include -I../../include $cppflags" NOISY_BUILD=yes # build addon modules - ( cd asterisk-addons-* - ASTERISK_DIR="`pwd`/.." \ - CC="%{l_cc}" \ - CFLAGS="%{l_cflags -O}" \ - CPPFLAGS="%{l_cppflags ncurses tiff .}" \ - LDFLAGS="%{l_ldflags}" \ -%if "%{with_fax}" == "yes" - LIBS="-ltiff -ljpeg -lz -lm" \ -%else - LIBS="-lm" \ -%endif - ./configure \ - --prefix=%{l_prefix} \ - --mandir=%{l_prefix}/man \ - --sysconfdir=%{l_prefix}/etc \ - --localstatedir=%{l_prefix}/var/asterisk \ - --with-ncurses \ - --with-asterisk \ - --without-mysqlclient \ -%if "%{with_fax}" == "yes" - --with-spandsp=%{l_prefix} -%else - --without-spandsp -%endif - %{l_make} %{l_mflags} \ - CC="%{l_cc} %{l_cflags -O} -I. %{l_cppflags ncurses tiff .}" + ( cd addons + %{l_make} %{l_mflags -O} \ + CC="%{l_cc} %{l_cflags -O} -I../../include %{l_cppflags ncurses}" NOISY_BUILD=yes ASTTOPDIR=.. ) || exit $? + + # build agi programs + ( cd agi && %{l_make} %{l_mflags -O}) || exit $? + %if "%{with_capi}" == "yes" + # build capi channel ( cd chan_capi-* ln -s ../include/asterisk . ln -s ../include/asterisk.h . - %{l_make} %{l_mflags} \ + %{l_make} %{l_mflags -O} V=1 \ INSTALL_PREFIX=%{l_prefix} \ - ASTERISK_HEADER_DIR="`pwd`" + ASTERISK_HEADER_DIR="`pwd`" \ ) || exit $? %endif %install # install program + rm -rf $RPM_BUILD_ROOT %{l_make} %{l_mflags} install \ DESTDIR=$RPM_BUILD_ROOT \ INSTALL_PREFIX=%{l_prefix} # install addon modules - ( cd asterisk-addons-* + ( cd addons %{l_make} %{l_mflags} install \ + ASTTOPDIR=.. \ DESTDIR=$RPM_BUILD_ROOT \ INSTALL_PREFIX=%{l_prefix} ) || exit $? + %if "%{with_capi}" == "yes" + # install capi channel ( cd chan_capi-* %{l_make} %{l_mflags} install \ INSTALL_PREFIX=$RPM_BUILD_ROOT%{l_prefix} \ @@ -391,34 +593,163 @@ ) || exit $? %endif - # install addon sounds - %{l_shtool} mkdir -f -p -m 755 \ - $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/de - ( cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/de - %{l_gzip} -d -c %{SOURCE4} | %{l_tar} xf - - ) || exit $? +%if "%{with_fax}" == "yes" + # install fax support + case "%{l_platform -t}" in + amd64*-* ) + %{l_shtool} install -c -m 755 \ + res_fax_digium-%{V_asterisk_fax_digium}-generic_64/res_*.so \ + $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/modules/ + %{l_shtool} install -c -m 640 \ + res_fax_digium-%{V_asterisk_fax_digium}-generic_64/*.conf \ + $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/ + ;; + i?86-* ) + %{l_shtool} install -c -m 755 \ + res_fax_digium-%{V_asterisk_fax_digium}-generic_32/res_*.so \ + $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/modules/ + %{l_shtool} install -c -m 640 \ + res_fax_digium-%{V_asterisk_fax_digium}-generic_32/*.conf \ + $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/ + ;; + *-* ) + echo "Error determining hardware architecture." \ + | %{l_rpmtool} msg -b -t warn + exit 1; + ;; + esac +%endif + + ( echo 'Start of sound installation block (RPM)' +%if "%{with_esounds}" == "yes" + # install freeswitch sound prompt files, expecting + # identical sound filenames to be overwritten later + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/en + %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-en-us-callie-48000-%{V_fswitch_sounds_en}.tar.gz + subs=`( cd en/us/callie && find * -type d -prune )` + for subdir in $subs; do + mkdir $subdir + mv -f en/us/callie/$subdir/*/* ${subdir}/ + done + rm -rf en + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/es + %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-es-mx-maria-44100.tar.gz + subs=`( cd es/mx/maria && find * -type d -prune )` + for subdir in $subs; do + mkdir $subdir + mv -f es/mx/maria/$subdir/*/* ${subdir}/ + done + rm -rf es + %{l_shtool} mkdir -f -p -m 755 \ + $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ru + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ru + %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-ru-RU-elena-48000-%{V_fswitch_sounds_ru}.tar.gz + subs=`( cd ru/RU/elena && find * -type d -prune )` + for subdir in $subs; do + mkdir $subdir + mv -f ru/RU/elena/$subdir/*/* ${subdir}/ + done + rm -rf ru + + # install freeswitch music on hold files + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh + %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-music-48000-%{V_fswitch_music}.tar.gz + mv -f music/48000/* . && rm -rf music + + # convert freeswitch 48000 and 441000 KHz to 8000 Khz + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk + for highfile in `find . -name '*.wav'`; do + lowfile=`echo $highfile | sed -e 's;\(.*\)\.wav;\1.sln16;'` + %{l_prefix}/bin/sox $highfile -t raw -r 16000 -s -2 -c 1 $lowfile + rm $highfile + done +%endif + + # install australian nonversioned sound prompt files + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/en_AU + %{l_tar} zxf %{_sourcedir}/asterisk-core-sounds-en_AU-current.tar.gz + + # install main sound prompt files + #for codec in alaw ulaw g722 g729 gsm; do + for lang in en es fr; do + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/${lang} + %{l_tar} zxf %{_sourcedir}/asterisk-core-sounds-${lang}-sln16-%{V_asterisk_sounds_core}.tar.gz + done + for lang in en fr; do + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/${lang} + %{l_tar} zxf %{_sourcedir}/asterisk-extra-sounds-${lang}-sln16-%{V_asterisk_sounds_extra}.tar.gz + done + + # install special case sound files + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds + #%{l_tar} jxf %{SOURCE de-digits-%{V_asterisk_sounds_custom}.tar.bz2} + #( cd de && %{l_tar} zxf %{SOURCE asterisk-core-sounds-de-gsm-%{V_asterisk_sounds_amootts}.tar.gz} ) || exit $? + #%{l_tar} zxf %{SOURCE asterisk-%{V_asterisk_sounds_amoogab}-de-prompts.tar.gz} + #mv -f dictate/de/* de/dictate/ && rm -rf dictate/de + #mv -f digits/de/* de/digits/ && rm -rf digits/de + #mv -f letters/de/* de/letters/ && rm -rf letters/de + #mv -f phonetic/de/* de/phonetic/ && rm -rf phonetic/de + %{l_tar} jxf %{SOURCE astmultisnds-de-sln16-%{V_asterisk_sounds_custom}.tar.bz2} + %{l_tar} jxf %{SOURCE msvbsnds-sln16-%{V_asterisk_sounds_custom}.tar.bz2} + + # install additional asterisk music on hold + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh + %{l_tar} zxf %{_sourcedir}/asterisk-moh-freeplay-sln16.tar.gz + %{l_tar} zxf %{_sourcedir}/asterisk-moh-opsound-sln16-%{V_asterisk_sounds_mohop}.tar.gz + + # correct sound permissions + find $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ -type f \ + | xargs chmod 644 + find $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ -type d \ + | xargs chmod 755 + + # apply provisional workaround for bug 0016104 + # https://issues.asterisk.org/view.php?id=16104 + cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds + cd en && ln -s vm-INBOX.sln16 vm-Voicemail.sln16 + cd ../es && ln -s vm-INBOX.sln16 vm-Voicemail.sln16 + cd ../de && ln -s vm-INBOX.sln16 vm-Voicemail.sln16 + cd ../fr && ln -s vm-INBOX.sln16 vm-Voicemail.sln16 + +# # install nonstandard voicemail prompts +# %{l_shtool} mkdir -f -p -m 755 \ +# $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/voicemail/default/%{exten}/unavail +# %{l_shtool} install -c -m 660 \ +# %{_sourcedir}/ansage-%{V_ansage}.wav} \ +# $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/voicemail/default/%{exten}/unavail.wav + ) || exit $? # End of sound installation block (RPM) # strip down installation rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/autosupport >/dev/null 2>&1 || true rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/safe_asterisk >/dev/null 2>&1 || true rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/autosupport.8 >/dev/null 2>&1 || true rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/safe_asterisk.8 >/dev/null 2>&1 || true - rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/firmware >/dev/null 2>&1 || true rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/images >/dev/null 2>&1 || true - rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/.asterisk* >/dev/null 2>&1 || true - rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/en/CREDIT* >/dev/null 2>&1 || true - rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/en/CHANGES* >/dev/null 2>&1 || true - rmdir $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/es >/dev/null 2>&1 || true - rmdir $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/fr >/dev/null 2>&1 || true + rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh/CREDIT* >/dev/null 2>&1 || true + rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh/CHANGES* >/dev/null 2>&1 || true + rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/*/CREDIT* >/dev/null 2>&1 || true + rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/*/CHANGES* >/dev/null 2>&1 || true # create additional directories %{l_shtool} mkdir -f -p -m 755 \ - $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/db + $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/db \ + $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/lib/licenses \ + $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/outgoing - # post-adjust installation - strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true + # postadjust installation + strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* \ + $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/modules/* \ + $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/agi-bin/* \ + >/dev/null 2>&1 || true mv $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/agi-bin \ $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin + + # install AGI progs + ( cd agi + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + DialAnMp3.agi fastagi-test numeralize %{SOURCE wakeup.agi} \ + $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin/ + ) || exit $? for bin in $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin/*.*; do mv $bin `echo $bin | sed -e 's;\.[^.]*$;;'` done @@ -444,7 +775,7 @@ $name $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/ done - # install run-command script + # install runcommand script %{l_shtool} mkdir -f -p -m 755 \ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d %{l_shtool} install -c -m 755 %{l_value -s -a} \ @@ -453,12 +784,18 @@ # determine installation files %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ %{l_files_std} \ + '%config %{l_prefix}/var/asterisk/lib/licenses' \ '%config %attr(640,%{l_mgrp},%{l_rgrp}) %{l_prefix}/etc/asterisk/*' \ '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/asterisk' +# '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/asterisk/sounds/es/vm-Voicemail.sln16' \ +# '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/asterisk/sounds/de/vm-Voicemail.sln16' \ +# '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/asterisk/sounds/fr/vm-Voicemail.sln16' \ + %files -f files %clean + rm -rf $RPM_BUILD_ROOT %post %if "%{with_dahdi}" == "yes" @@ -495,6 +832,16 @@ ) || exit $? fi %endif +%if "%{with_fax}" == "yes" + ( echo "Asterisk has been installed with proprietary Digium fax support." + echo "The responsible module is called res_fax_digium and requires a" + echo "valid license. The license must be found in the directory" + echo "'licenses' which in turn must be found in $prefix/var/asterisk/lib" + echo "or wherever astvarlibdir has been configured in 'asterisk.conf'." + echo "" + echo "Please see http://downloads.digium.com/pub/telephony/fax/ for information." + ) | %{l_rpmtool} msg -b -t notice +%endif # after upgrade, restart service [ $1 -eq 2 ] || exit 0 eval `%{l_rc} asterisk status 2>/dev/null` @@ -509,6 +856,7 @@ rm -f $RPM_INSTALL_PREFIX/var/asterisk/log/cdr-*/* >/dev/null 2>&1 || true rm -f $RPM_INSTALL_PREFIX/var/asterisk/run/* >/dev/null 2>&1 || true rm -f $RPM_INSTALL_PREFIX/var/asterisk/spool/*/* >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/asterisk/lib/* >/dev/null 2>&1 || true rm -f $RPM_INSTALL_PREFIX/var/asterisk/db/* >/dev/null 2>&1 || true %if "%{with_odbc}" == "yes" # before erase, optionally unlink from ODBC and destroy database diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/asterisk.txt --- a/asterisk/asterisk.txt Sun Mar 20 20:00:02 2011 +0100 +++ b/asterisk/asterisk.txt Sun Mar 20 20:03:11 2011 +0100 @@ -105,7 +105,7 @@ bindaddr = 127.0.0.1 bindport = 8088 sslenable = no -slbindport = 8089 +sslbindport = 8089 sslbindaddr = 127.0.0.1 sslcert = @l_prefix@/etc/asterisk/asterisk.pem enablestatic = yes @@ -232,6 +232,58 @@ rtpend = 7089 + +;; +;; sip_notify.conf -- Asterisk NOTIFY automation from command line +;; + +; rfc3842 +; put empty "Content=>" at the end to have CRLF after last body line +[clear-mwi] +Event=>message-summary +Content-type=>application/simple-message-summary +Content=>Messages-Waiting: no +Content=>Message-Account: sip:asterisk@127.0.0.1 +Content=>Voice-Message: 0/0 (0/0) +Content=> + +; Aastra +[aastra-check-cfg] +Event=>check-sync + +[aastra-xml] +Event=>aastra-xml + +; Linksys +[linksys-cold-restart] +Event=>reboot_now + +[linksys-warm-restart] +Event=>restart_now + +; Polycom +[polycom-check-cfg] +Event=>check-sync + +; Sipura +[sipura-check-cfg] +Event=>resync + +[sipura-get-report] +Event=>report + +; Snom +[snom-check-cfg] +Event=>check-sync\;reboot=false + +[snom-reboot] +Event=>reboot + +; Cisco +[cisco-check-cfg] +Event=>check-sync + + ;; ;; extensions.conf -- Asterisk inbound & outbound call configuration diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/rc.asterisk --- a/asterisk/rc.asterisk Sun Mar 20 20:00:02 2011 +0100 +++ b/asterisk/rc.asterisk Sun Mar 20 20:03:11 2011 +0100 @@ -31,15 +31,15 @@ %stop -u @l_susr@ rcService asterisk enable yes || exit 0 rcService asterisk active no && exit 0 - ( @l_prefix@/sbin/asterisk -rx "stop gracefully" & + ( @l_prefix@/sbin/asterisk -rx "core stop gracefully" & sleep 2 - @l_prefix@/sbin/asterisk -rx "stop now" & + @l_prefix@/sbin/asterisk -rx "core stop now" & ) >/dev/null 2>&1 || true %restart -u @l_susr@ rcService asterisk enable yes || exit 0 rcService asterisk active no && exit 0 - rc asterisk stop start + @l_prefix@/sbin/asterisk -rx "core restart now" %reload -u @l_susr@ rcService asterisk enable yes || exit 0 diff -r 73d852a30c9a -r 263143ec0fb2 asterisk/wakeup.agi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/asterisk/wakeup.agi Sun Mar 20 20:03:11 2011 +0100 @@ -0,0 +1,733 @@ +#! @l_prefix@/bin/perl +# +# wakeup.agi 1.1 +# +# A wakeup agi script for Asterisk +# +# Copyright (C) 2007 +# +# Jonas Arndt +# +# This program is free software, distributed under the terms of the +# GNU General Public License v2. +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +use strict; +use Time::Local; +$|=1; +# Setup some variables +my %AGI; my $DEBUG=0; +# Some constants +my $OUTDIR="@l_prefix@/var/asterisk/spool/outgoing"; +my $WAKEDIR="@l_prefix@/var/asterisk/spool/tmp"; +my $debugfile="@l_prefix@/var/asterisk/spool/tmp/wakeup.log"; +my $DEBUGOUT = "filehandle"; +my $CALL = "filehandle"; +my $TOUCH = "/usr/bin/touch"; + +############ check_result ########## +# Use this to check the result of # +# a sent command # +# I pretty much stole this from # +# the regular agi-test.agi # +#################################### +sub checkresult { + my ($res) = @_; + my $retval; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print DEBUGOUT "FAIL ($res)\n"; + exit(1); + } elsif ($DEBUG=1) { + print DEBUGOUT "PASS ($1)\n"; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + exit(1); + } +} + + +############ send_file ############# +# Use this to send a wave file on # +# the channel # +# # +#################################### +sub send_file { + my ($myfile) = @_; + chomp($myfile); + if ($DEBUG == 1 ) { + print DEBUGOUT "Sending stream $myfile \n"; + } + print "STREAM FILE $myfile \"0123456789\"\n"; + my $result = ; + &checkresult($result); + $result =~ /result=(-?\d+)/; + return $1; +} + +############ hangup ############### +# Use this to hand up a channel # +# the channel # +# # +#################################### +sub hangup { + if ($DEBUG == 1 ) { + print DEBUGOUT "Hanging up \n"; + } + print "HANGUP \"\" \n"; + my $result = ; + &checkresult($result); +} + +############ say_number ############ +# Use this to say a number # +# over the channel # +# # +#################################### +sub say_number { + my ($mynumber) = @_; + chomp($mynumber); + if ($DEBUG == 1 ) { + print DEBUGOUT "Saying number $mynumber \n"; + } + print "SAY NUMBER $mynumber \"0123456789\"\n"; + my $result = ; + &checkresult($result); + $result =~ /result=(-?\d+)/; + return $1; +} + +############ say_digits ############ +# Use this to say a digits # +# over the channel # +# # +#################################### +sub say_digits { + my ($mynumber) = @_; + chomp($mynumber); + if ($DEBUG == 1 ) { + print DEBUGOUT "Saying digits $mynumber \n"; + } + print "SAY DIGITS $mynumber \"0123456789\"\n"; + my $result = ; + &checkresult($result); +} + +############ get_choice ############ +# Use this to receive a DTMF # +# choice from the channel # +# # +#################################### +sub get_choice { + if ($DEBUG == 1 ) { + print DEBUGOUT "Getting choice \n"; + } + print "WAIT FOR DIGIT 15000\n"; + my $result = ; + &checkresult($result); + $result =~ /result=(-?\d+)/; + return $1; +} + +############ answer ############### +# Anser the channel # +# # +#################################### +sub answer { + if ($DEBUG == 1 ) { + print DEBUGOUT "Answering the channel \n"; + } + print "ANSWER\n"; + my $result = ; + &checkresult($result); + $result =~ /result=(-?\d+)/; + return $1; +} + +######## get_data ################## +# Feed with (file, maxnumbers) # +# where file is the sound file # +# to be played and maxnumbers is # +# the maximum amount of digits to # +# allow in the answer # +#################################### +sub get_data { + my @mydata = @_; + my $myfile = $mydata[0]; + my $mymax = $mydata[1]; + if ($DEBUG == 1 ) { + print DEBUGOUT "Getting data \n"; + } + print "GET DATA $myfile 15000 $mymax \n"; + my $result = ; + &checkresult($result); + $result =~ /result=(-?\d+)/; + return $1; +} + +###### check_outstanding_calls ##### +# Are there any outstanding wakeup # +# calls for this extensions? # +# Pass the extension to the # +# function. The function returns # +# a list of files # +#################################### +sub check_outstanding_calls { + my $myext = @_; + #opendir DIR, $WAKEDIR; + opendir DIR, $OUTDIR; + my @files = grep {/$myext/} readdir(DIR); + closedir DIR; + return @files; +} + +######## get_extension ############# +# Receive the AIG variable and # +# return the extension # +#################################### +sub get_extension { + my (@aig) = @_; + if ($aig[11] == '') { + print STDERR "No extension found in function get_exension \n"; + return "FAIL"; + } + my $myext = $aig[11]; + return $myext; +} + +######## get_context ############### +# Receive the AIG variable and # +# return the context # +#################################### +sub get_context { + my (@aig) = @_; + if ($aig[8] == '') { + print STDERR "No extension found in function get_exension \n"; + return "FAIL"; + } + my $mycont = $aig[8]; + return $mycont; +} + +########### get_clid ############### +# Receive the AIG variable and # +# return the clid # +#################################### +sub get_clid { + my (@aig) = @_; + if ($aig[1] == '') { + print STDERR "No clid found in function get_clid \n"; + return "FAIL"; + } + my $myext = $aig[1]; + return $myext; +} +########### init_agi ############### +# Use this to initialize the AGI # +# variable # +# # +#################################### +sub init_agi { + while() { + chomp; + last unless length($_); + if (/^agi_(\w+)\:\s+(.*)$/) { + $AGI{$1} = $2; + } + } +} + +############ ascii2num ############# +# Removes 48 to get a number out # +# of the asciss return # +#################################### +sub ascii2num { + my ($asc) = @_; + my $ret; + $ret = $asc - 48; + return $ret; +} + + +########### Welcome ############### +# This is the welcome menu # +# # +#################################### +sub welcome { + my $ret = 0; + $ret = &send_file("welcome"); + if ($ret == 0) { + $ret = &send_file("for-wakeup-call"); + } + if ($ret == 0) { + $ret = &send_file("press-1"); + } + if ($ret == 0) { + $ret = &send_file("for-a-list-of"); + } + if ($ret == 0) { + $ret = &send_file("or"); + } + if ($ret == 0) { + $ret = &send_file("to-cancel-wakeup"); + } + if ($ret != 0) { + $ret = &ascii2num($ret); + } + if ($ret == 0) { + $ret = &get_data("press-2",1); + } + if ($ret == 1) { + $ret = &schedule_new(); + } elsif ($ret == 2) { + &manage_calls(); + } else { + $ret = &send_file("goodbye"); + } +} + +######### manage_calls ############# +# This is what is called if you # +# want to manage already scheduled # +# wakeup calls # +#################################### + +sub manage_calls { + my $checker = "false"; + my @calls; + my $del; + #my $ret; + my $hours; + my $minutes; + # Send out a welcome message and ask for return + @calls = &check_outstanding_calls($AGI{callerid}); + if ($#calls + 1 == 0) { + $del = &send_file("not-rqsted-wakeup"); + $del = &send_file("goodbye"); + } else { + foreach (@calls) { + $del = 0; + my $wakefile = $_; + my @wakeup = split /\./, $_; + my $time = $wakeup[0]; + $_ = $time; + /(^[0-9][0-9])/; + my $hours = $1; + /^[0-9][0-9]([0-9][0-9])/; + my $minutes = $1; + $del = &send_file("rqsted-wakeup-for"); + if ($del == 0) { + $del = &say_number($hours); + } + if ($del == 0) { + if ($minutes >= 10 ) { + $del = &say_number($minutes); + } elsif ($minutes > 0 && $minutes < 10) { + $del = &send_file("digits/oh"); + $del = &say_number($minutes); + } + } + if ($del == 0) { + $del = &send_file("digits/oclock"); + } + if ($del == 0) { + $del = &send_file("to-cancel-wakeup"); + } + if ($del == 0) { + $del = &send_file("press-1"); + } + if ($del == 0) { + $del = &send_file("otherwise-press"); + } + if ($del != 0) { + $del = &ascii2num($del); + } + if ($del == 0) { + $del = &get_data("digits/2",1); + } + if ($del == 1) { + my @sysargs = ("rm", "-f", "$WAKEDIR/$wakefile", "$OUTDIR/$wakefile"); + system(@sysargs) == 0 + or die "system @sysargs failed: $?"; + $del = &send_file("cancelled"); + } + } + $del = &send_file("goodbye"); + } + +} + +######## schedule_new ############## +# This is the menu to schedule a # +# a new wakeup call # +#################################### +sub schedule_new { + my $checker = "false"; + my $ret_var; + my $ret_dummy = 0; + my $time; + my $perm; + my $file; + my $calltype; + my $extension; + my $context; + my $hours; + my $minutes; + if ($DEBUG == 1 ) { + print DEBUGOUT "From schedule_new\n"; + } + while ( $checker eq "false" ) { + $ret_var = &send_file("to-rqst-wakeup-call"); + if ($ret_var != 0) { + my $tmp = &get_data("silence/1",3); + $ret_var = &ascii2num($ret_var); + $ret_var = $ret_var . $tmp; + } else { + $ret_var = &get_data("enter-a-time",4); + } +# if ($ret_var < 1300 && $ret_var >= 0100) { +# my $pm = &get_data("1-for-am-2-for-pm",1); +# if ($pm == 2 && $ret_var <= 1159) { +# $ret_var = $ret_var + 1200; +# $checker = "true"; +# } elsif ($pm == 1 && $ret_var > 1159) { +# $ret_var = $ret_var - 1200; +# # Fix the zero +# $ret_var = "00" . $ret_var; +# $checker = "true"; +# } else { +# $checker = "true"; +# } +# } elsif ($ret_var > 2359) { +# $ret_dummy = &send_file("please-try-again"); +# } else { +# $checker = "true"; +# } + if ($ret_var > 2359) { + $ret_dummy = &send_file("please-try-again"); + } else { + $checker = "true"; + } + } + $perm = 0; + $perm = &send_file("wakeup-for-one-time"); + if ($perm == 0) { + $perm = &send_file("press-1"); + } + if ($perm == 0) { + $perm = &send_file("for-a-daily-wakeup-call"); + } + if ($perm != 0) { + $perm = &ascii2num($perm); + } + if ($perm == 0) { + $perm = $perm = &get_data("press-2",1); + } + # Open the file and populate it with data + $extension = $AGI{callerid}; + $context = $AGI{context}; + if ($perm == 2) { + $file = "$WAKEDIR/$ret_var.perm.1.$extension.call"; + $calltype = "perm"; + open (CALL, '>', $file) or die "Cannot open call file for write :$!"; + } else { + $file = "$WAKEDIR/$ret_var.temp.1.$extension.call"; + $calltype = "temp"; + open (CALL, '>', $file) or die "Cannot open call file for write :$!"; + } + my $myprint = "channel: Local" . "/" . $extension . "@" . $context . "\n"; + print CALL $myprint; + print CALL "maxretries: 3\n"; + print CALL "retrytime: 60\n"; + print CALL "waittime: 60\n"; + print CALL "callerid: \"AsterPBX Weckruf\" <$AGI{extension}>\n"; + print CALL "application: AGI\n"; + print CALL "data: wakeup|$ret_var.$calltype.1.$extension.call\n"; + close ($CALL); + # Now touch the file + # Get the time variable + $time = get_time_string($ret_var); + my @command = ("$TOUCH", "-t", "$time", "${file}"); + system(@command) == 0 + or die "system @command failed: $?"; + # Move it to the OUT directory + my @command = ("mv", "${file}", "${OUTDIR}/"); + system(@command) == 0 + or die "system @command failed: $?"; + + # Stream out the wakeup + $_ = $ret_var; + /(^[0-9][0-9])/; + my $hours = $1; + /^[0-9][0-9]([0-9][0-9])/; + my $minutes = $1; + $ret_dummy = &send_file("rqsted-wakeup-for"); + $ret_dummy = &say_number($hours); + if ($minutes >= 10 ) { + &say_number($minutes); + } elsif ($minutes > 0 && $minutes < 10) { + &send_file("digits/oh"); + &say_number($minutes); + } + $ret_dummy = &send_file("digits/oclock"); + $ret_dummy = &send_file("goodbye"); + return $ret_var; +} + +######## get_time_string ########### +# This will return the time string # +# when inputing a string like # +# hhmi # +#################################### +sub get_time_string { + my ($intime) = @_; + my $minutes = substr($intime, 2, 4); + my $hours = substr($intime, 0, 2); + my $tmpepoch; + my $day; + my $month; + my $ret_val; + my $epoch = time(); + my @timedata = localtime($epoch); + # Insert the minutes and hours from input + $timedata[1] = $minutes; + $timedata[2] = $hours; + # Get tmpepoch + $tmpepoch = timelocal(@timedata); + #Now compare them + if ($tmpepoch < $epoch) { # Means it is tomorrow + $tmpepoch += 86400; # Add 24 hours + } + # Now get the new timedata + my @timedata = localtime($tmpepoch); + $minutes = $timedata[1]; + $hours = $timedata[2]; + $day = $timedata[3]; + $month = $timedata[4] + 1; + #Correct the "First hour after midnight" problem + if ($minutes < 10) { + $minutes = "0" . $minutes; + } + if ($hours < 10) { + $hours = "0" . $hours; + } + if ($day < 10) { + $day = "0" . $day; + } + if ($month < 10) { + $month = "0" . $month; + } + $ret_val = $month . $day . $hours . $minutes; + return $ret_val; +} + +############ new_time ############## +# This will return the time string # +# with a time set 10 minute into # +# the future # +# The string is # +# MMDDhhmi # +#################################### +sub new_time { + my ($input) = @_; + my @timedata; + my $minutes; + my $hours; + my $day; + my $month; + my $ret_val; + my $epoc = time(); + if ($input eq "10m") { + # add 10 minutes + $epoc += 600; + #$epoc += 120; #just for debugs + } else { + # add 24 hours + $epoc += 86400; + } + @timedata = localtime($epoc); + $minutes = $timedata[1]; + $hours = $timedata[2]; + $day = $timedata[3]; + $month = $timedata[4] + 1; + #Correct the "First hour after midnight" problem + if ($minutes < 10) { + $minutes = "0" . $minutes; + } + if ($hours < 10) { + $hours = "0" . $hours; + } + if ($day < 10) { + $day = "0" . $day; + } + if ($month < 10) { + $month = "0" . $month; + } + $ret_val = $month . $day . $hours . $minutes; + return $ret_val; +} + +########### snooze ################ +# This is the menu to snooze the # +# wakeup call # +#################################### +sub snooze { + my ($oldfile) = @_; + my $newfile; + my $extension; + my $context; + my @filestore = split (/\./, $oldfile); + my @permstore = split (/\./, $oldfile); + my $time; + my $ret_var = 0; + my $ret_dummy; + my $myprint; + # Answer the channel + &answer(); + # Is this a reoccuring call, then add 24h + if ($permstore[1] eq "perm") { + $permstore[2] += 1; #Just to get a new file name + $newfile = join(".",@permstore); + $extension = $AGI{extension}; + $context = $AGI{context}; + # Open the file + open (CALL, '>', "${WAKEDIR}/${newfile}") or die "Cannot open call file for write :$!"; + $myprint = "channel: Local" . "/" . $extension . "@" . $context . "\n"; + print CALL $myprint; + print CALL "maxretries: 3\n"; + print CALL "retrytime: 60\n"; + print CALL "waittime: 60\n"; + print CALL "callerid: \"AsterPBX Weckruf\" <$AGI{callerid}>\n"; + print CALL "application: AGI\n"; + print CALL "data: wakeup|$newfile\n"; + close ($CALL); + # Get a time 24h from now + $time = &new_time("24h"); + # Touch the file with the new time + my @command = ("$TOUCH", "-t", "$time", "${WAKEDIR}/${newfile}"); + system(@command) == 0 + or die "system @command failed: $?"; + # Now move it + my @command = ("mv", "${WAKEDIR}/${newfile}", "${OUTDIR}/${newfile}"); + system(@command) == 0 + or die "system @command failed: $?"; + } + #Replace the file name time with snooze + $filestore[1] = "snooze"; + # Also add 10 minutes to the name + $time = new_time("10m"); + $filestore[0] = substr($time, 4, 8); + # Get the new file name + $newfile = join(".",@filestore); + $ret_var = &send_file("this-is-yr-wakeup-call"); + if ($ret_var == 0 ) { + $ret_var = &send_file("to-confirm-wakeup"); + } + if ($ret_var == 0 ) { + $ret_var = &send_file("press-1"); + } + if ($ret_var == 0 ) { + $ret_var = &send_file("to-snooze-for"); + } + if ($ret_var == 0 ) { + $ret_var = &send_file("digits/10"); + } + if ($ret_var == 0 ) { + $ret_var = &send_file("minutes"); + } + if ($ret_var != 0 ) { + $ret_var = &ascii2num($ret_var); + } + if ($ret_var == 0 ) { + $ret_var = &get_data("press-2",1); + } + if ($ret_var == 2 ) { + # Populate some variables + $time = &new_time("10m"); + $extension = $AGI{extension}; + $context = $AGI{context}; + # Open the file + open (CALL, '>', "${WAKEDIR}/${newfile}") or die "Cannot open call file for write :$!"; + $myprint = "channel: Local" . "/" . $extension . "@" . $context . "\n"; + print CALL $myprint; + print CALL "maxretries: 3\n"; + print CALL "retrytime: 60\n"; + print CALL "waittime: 60\n"; + print CALL "callerid: \"AsterPBX Weckruf\" <$AGI{callerid}>\n"; + print CALL "application: AGI\n"; + print CALL "data: wakeup|$newfile\n"; + close ($CALL); + # Touch the file with the new time + my @command = ("$TOUCH", "-t", "$time", "${WAKEDIR}/${newfile}"); + system(@command) == 0 + or die "system @command failed: $?"; + # Now move it + my @command = ("mv", "${WAKEDIR}/${newfile}", "${OUTDIR}/${newfile}"); + system(@command) == 0 + or die "system @command failed: $?"; + $ret_dummy = &send_file("goodbye"); + + } elsif ($ret_var == 1) { + $ret_dummy = &send_file("goodbye"); + } else { + $ret_dummy = &send_file("goodbye"); + } + + # Stream out the wakeup + return 0; +} + +########### main program ########### +# Here goes the main program # +# # +#################################### + +my $numargs = $#ARGV + 1; +if ($DEBUG == 1) { + open (DEBUGOUT, '>', $debugfile) or die "Cannot open $debugfile for write :$!"; +} + +# Start by reading in the stuff Asterisk is sending +&init_agi(); # Comment out in case of debug outside Asterisk + +# If DEBUG is set, dump the AGI variable +if ($DEBUG == 1) { + foreach my $i (sort keys %AGI) { + print DEBUGOUT " -- $i = $AGI{$i}\n"; + } +} + +if ( $numargs == 0 ) { + &welcome(); + &hangup(); + exit(0); +} elsif ( $ARGV[0] eq "move" ) { + &move(); + &hangup(); + exit(0); +} else { + &snooze($ARGV[0]); + &hangup(); + exit(0); +} + +if ($DEBUG ==1) { + close $DEBUGOUT; +}