zaptel 1.2 package
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Sat Sep 17 00:24:38 UTC 2005
Hi
Here's a patch against current svn for a zaptel 1.2 package. It also
includes most of my modifications (genzaptelconf, etc.) . There is a
"bristuff_head" patch included but not added by default which should
probably work, but is useless without the support in Asterisk and
libpri.
OTOH, one could use zaptel 1.2 with Asterisk (/libpri) 1.0.
--
Tzafrir Cohen icq#16849755 +972-50-7952406
tzafrir.cohen at xorcom.com http://www.xorcom.com
-------------- next part --------------
Index: debian/control
===================================================================
--- debian/control (revision 764)
+++ debian/control (working copy)
@@ -2,8 +2,8 @@
Section: comm
Priority: optional
Maintainer: Debian VoIP Team <pkg-voip-maintainers at lists.alioth.debian.org>
-Uploaders: Kilian Krause <kilian at debian.org>, Jose Carlos Garcia Sogo <jsogo at debian.org>, Mark Purcell <msp at debian.org>, Santiago Garcia Mantinan <manty at debian.org>, Santiago Ruano Rincon <santiago at unicauca.edu.co>
-Build-Depends: debhelper (>> 4.0.4), libnewt-dev, dpatch (>= 2.0.9), bzip2, docbook-utils
+Uploaders: Kilian Krause <kilian at debian.org>, Jose Carlos Garcia Sogo <jsogo at debian.org>, Mark Purcell <msp at debian.org>, Santiago Garcia Mantinan <manty at debian.org>, Santiago Ruano Rincon <santiago at unicauca.edu.co>, Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Build-Depends: debhelper (>> 4.0.4), libnewt-dev, dpatch (>= 2.0.9), bzip2
Standards-Version: 3.6.2
Package: zaptel
@@ -16,10 +16,6 @@
interface cards (X100P, T400P, E400P, S100P, S100U).
.
Includes ztcfg and zttool utils.
- .
- This package includes bristuff from http://www.junghanns.net/asterisk/
- .
- Upstream: http://www.asterisk.org
Package: libtonezone1
Section: libs
@@ -47,7 +43,3 @@
This package contains the source code for zaptel kernel module providing
device drivers for various telephony hardware, including the Wildcard
series of interface cards (X100P, T400P, E400P, S100P, S100U).
- .
- This package includes bristuff from http://www.junghanns.net/asterisk/
- .
- Upstream: http://www.asterisk.org
Index: debian/ztspeed.8
===================================================================
--- debian/ztspeed.8 (revision 0)
+++ debian/ztspeed.8 (revision 0)
@@ -0,0 +1,26 @@
+.TH ztspeed 8 "2005-06-25"
+.SH NAME
+ztspeed \(em A generic speed test
+.SH SYNOPSIS
+.B ztspeed
+
+.SH DESCRIPTION
+.B ztspeed
+runs a simple 100% CPU loop for 5 seconds to see how many loops are
+performed. Used to measure how much CPU zaptel \fBreally\fR is taking.
+
+.SH OPTIONS
+None. Nothing else to see.
+
+.SH SEE ALSO
+zttool(8), ztmonitor(8), zttest(8), ztcfg(8), asterisk(8).
+
+.SH AUTHOR
+
+This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL.
Index: debian/patches/Makefile_uname.dpatch
===================================================================
--- debian/patches/Makefile_uname.dpatch (revision 0)
+++ debian/patches/Makefile_uname.dpatch (revision 0)
@@ -0,0 +1,76 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## Makefile_unamem.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Removes unnecessary calls to uname -r and uname -m . Use UNAME_M
+## DP: and KVERS/KVERS_MAJ instead.
+## DP: Impact: Minimal: fixes a possible incorrect behaviour (try version
+## DP: no. 2.6.2-4) and will also consider 2.5 as linux26 BUILDVER .
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/Makefile /tmp/dpep.bCdlfz/zaptel-1.2.0-0beta1/Makefile
+--- zaptel-1.2.0-0beta1/Makefile 2005-09-10 21:02:05.516656400 +0300
++++ /tmp/dpep.bCdlfz/zaptel-1.2.0-0beta1/Makefile 2005-09-10 21:03:04.254605145 +0300
+@@ -7,6 +7,11 @@
+ BASEADDR=0xd0000
+
+ HOSTCC=gcc
++ifeq ($(DEB_HOST_GNU_TYPE),)
++UNAME_M:=$(shell uname -m)
++else
++UNAME_M:=$(DEB_HOST_GNU_TYPE)
++endif
+ # If you want to build for a kernel other than the current kernel, set KVERS
+ ifndef KVERS
+ KVERS:=$(shell uname -r)
+@@ -19,11 +24,16 @@
+ KSRC:=$(shell for dir in $(KSRC_SEARCH_PATH); do if [ -d $$dir ]; then echo $dir; break; fi; done)
+ endif
+ endif
++KVERS_MAJ:=$(shell echo $(KVERS) | cut -d. -f1-2)
+ KINCLUDES:=$(KSRC)/include
+
+ CFLAGS+=-I. -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
+-CFLAGS_PPC:=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
+-CFLAGS_X86-64:=$(shell if uname -m | grep -q x86_64; then echo "-m64"; fi)
++ifneq (,$(findstring ppc,$(UNAME_M)))
++CFLAGS_PPC:=-fsigned-char
++endif
++ifneq (,$(findstring x86_64,$(UNAME_M)))
++CFLAGS_X86-64:=-m64
++endif
+ CFLAGS+=$(CFLAGS_PPC) $(CFLAGS_X64-64)
+ LCFLAGS=-fPIC $(CFLAGS) -DBUILDING_TONEZONE
+ KFLAGS=-I$(KINCLUDES) -O6
+@@ -32,9 +42,15 @@
+ ifneq (,$(wildcard $(KINCLUDES)/linux/modversions.h))
+ KFLAGS+=-DMODVERSIONS -include $(KINCLUDES)/linux/modversions.h
+ endif
+-KFLAGS_PPC:=$(shell if uname -m | grep -q ppc; then echo "-msoft-float -fsigned-char"; fi)
++ifneq (,$(findstring ppc,$(UNAME_M)))
++KFLAGS_PPC:=-msoft-float -fsigned-char
++endif
+ KFLAGS+=$(KFLAGS_PPC)
+-KFLAGS+=$(shell if uname -r | grep -q 2.4; then if uname -m | grep -q x86_64; then echo "-mcmodel=kernel"; fi; fi)
++ifeq ($(KVERS_MAJ),2.4)
++ ifneq (,$(findstring x86_64,$(UNAME_M)))
++ KFLAGS+=-mcmodel=kernel
++ endif
++endif
+
+ #
+ # Features are now configured in zconfig.h
+@@ -49,10 +65,10 @@
+ CONFIG_FILE=$(INSTALL_PREFIX)/etc/zaptel.conf
+ CFLAGS+=-DZAPTEL_CONFIG=\"$(CONFIG_FILE)\"
+
+-ifeq (2.6,$(shell echo $(KVERS) | cut -d. -f1-2))
+- BUILDVER:=linux26
+-else
++ifeq ($(KVERS_MAJ),2.4)
+ BUILDVER:=linux24
++else
++ BUILDVER:=linux26
+ endif
+
+ ifeq ($(BUILDVER),linux26)
Property changes on: debian/patches/Makefile_uname.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/Makefile_pscmd.dpatch
===================================================================
--- debian/patches/Makefile_pscmd.dpatch (revision 0)
+++ debian/patches/Makefile_pscmd.dpatch (revision 0)
@@ -0,0 +1,30 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## Makefile_pscmd.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Removes some unneeded and incorrect cruft, IMHO. See note below.
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/Makefile /tmp/dpep.Erjape/zaptel-1.2.0-0beta1/Makefile
+--- zaptel-1.2.0-0beta1/Makefile 2005-09-08 08:39:30.000000000 +0300
++++ /tmp/dpep.Erjape/zaptel-1.2.0-0beta1/Makefile 2005-09-08 08:45:25.000000000 +0300
+@@ -93,14 +93,11 @@
+ endif
+ endif
+
+-ifeq (${BUILDVER},linux24)
+-#We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4
+-DYNFS:=$(shell ps ax | grep -v grep | grep -q devfsd && echo "yes")
+-endif
+-ifeq (${BUILDVER},linux26)
+-#Tests for newer linux-2.6 udev support
+-DYNFS:=$(shell ps ax | grep -v grep | grep udevd && echo "yes")
+-endif
++# This is not related to the version that we build. Rather, to the
++# version that we runs. If we build for 2.4 using 2.4 headers on a 2.6
++# system with udev mounted on /dev , no point in installing files to /dev
++# because they'll be wiped at next reboot.
++DYNFS=$(shell ps ax | grep -v grep | grep -qw 'devfsd\|udevd' && echo "yes")
+
+ CHKCONFIG:=$(shell sh -c 'type -p chkconfig' 2> /dev/null)
+ ifndef CHKCONFIG
Property changes on: debian/patches/Makefile_pscmd.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/Makefile_targets.dpatch
===================================================================
--- debian/patches/Makefile_targets.dpatch (revision 0)
+++ debian/patches/Makefile_targets.dpatch (revision 0)
@@ -0,0 +1,62 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## Makefile_modules.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Adds targets modules, programs, install-modules and install-programs to
+## DP: allow separate installation of the programs and the modules
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/Makefile /tmp/dpep.Im0qyt/zaptel-1.2.0-0beta1/Makefile
+--- zaptel-1.2.0-0beta1/Makefile 2005-09-10 16:33:32.350010029 +0300
++++ /tmp/dpep.Im0qyt/zaptel-1.2.0-0beta1/Makefile 2005-09-10 16:34:00.908020091 +0300
+@@ -118,6 +118,16 @@
+ endif
+ MODULESO:=$(MODULES:%=%.o)
+ MODULESKO:=$(MODULES:%=%.ko)
++ifeq ($(BUILDVER),linux26)
++MODULES_BUILD:=$(MODULESKO)
++else
++MODULES_BUILD:=$(MODULESO)
++endif
++
++BIN_DIR:=$(INSTALL_PREFIX)/sbin
++LIB_DIR:=$(INSTALL_PREFIX)/usr/lib
++INC_DIR:=$(INSTALL_PREFIX)/usr/include
++MOD_DIR:=$(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc
+
+ ifneq (,$(wildcard /usr/include/newt.h))
+ ZTTOOL:=zttool
+@@ -129,7 +139,11 @@
+ #PRIMARY=wcfxo
+ PWD:=$(shell pwd)
+
+-all: $(BUILDVER) $(LIBTONEZONE_SO) manpages
++all: modules $(LIBTONEZONE_SO) manpages
++
++programs: $(BINS)
++
++modules: $(BUILDVER)
+
+ linux24: $(MODULESO) $(BINS)
+
+@@ -411,6 +425,20 @@
+ echo "Not CVS"; \
+ fi
+
++# make should *fail* and not silently succeed if a program did not build
++install-programs: $(BINS) $(LIBTONEZONE) libtonezone.a
++ install -d $(BIN_DIR)
++ install $(BINS) $(BIN_DIR)
++ install -d $(LIB_DIR)
++ install -m 755 $(LIBTONEZONE) libtonezone.a $(LIB_DIR)
++ install -d $(INC_DIR)/linux
++ install -m 644 tonezone.h $(INC_DIR)
++ install -m 644 zaptel.h torisa.h $(INC_DIR)/linux
++
++install-modules: $(MODULES_BUILD)
++ install -d $(MOD_DIR)
++ install -m 644 $(MODULES_BUILD) $(MOD_DIR)
++
+ clean:
+ rm -f torisatool makefw tor2fw.h radfw.h
+ rm -f ${BINS}
Property changes on: debian/patches/Makefile_targets.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/Makefile_deps_kern.dpatch
===================================================================
--- debian/patches/Makefile_deps_kern.dpatch (revision 0)
+++ debian/patches/Makefile_deps_kern.dpatch (revision 0)
@@ -0,0 +1,58 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## Makefile_deps.dpatch by <tzafrir at localhost>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Remove unnecessary dependencies of kernel modules.
+## DP: Patch has no functional effect as the rule below already adds
+## DP: dependency on zaptel.h .
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/Makefile /tmp/dpep.rNhZ36/zaptel-1.2.0-0beta1/Makefile
+--- zaptel-1.2.0-0beta1/Makefile 2005-09-10 18:55:11.896928235 +0300
++++ /tmp/dpep.rNhZ36/zaptel-1.2.0-0beta1/Makefile 2005-09-10 18:55:36.631914930 +0300
+@@ -136,38 +136,22 @@
+
+ tests: patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest
+
+-tor2.o: tor2-hw.h tor2fw.h zaptel.h
+-
+-zaptel.o: zaptel.h digits.h arith.h sec.h mec.h sec-2.h mec2.h mec3.h zconfig.h
+-
+-torisa.o: zaptel.h torisa.h
+-
+-wcusb.o: wcusb.h zaptel.h
+-
+-wcfxsusb.o: wcfxsusb.h zaptel.h
+-
+-wcfxo.o: zaptel.h
+-
+-wct1xxp.o: zaptel.h
++tor2.o: tor2-hw.h tor2fw.h
+
+-wcte11xp.o: zaptel.h
++zaptel.o: digits.h arith.h sec.h mec.h sec-2.h mec2.h mec3.h zconfig.h
+
+-ztd-loc.o: zaptel.h
++torisa.o: torisa.h
+
+-wct4xxp.o: zaptel.h
++wcusb.o: wcusb.h
+
+-wctdm.o: zaptel.h wctdm.h
++wcfxsusb.o: wcfxsusb.h
+
+-pciradio.o: zaptel.h radfw.h
++wctdm.o: wctdm.h
+
+-wcs3200p.o: zaptel.h
++pciradio.o: radfw.h
+
+ ztdummy.o: ztdummy.h
+
+-ztdynamic.o: zaptel.h
+-
+-ztd-eth.o: zaptel.h
+-
+ $(MODULESO): %.o: %.c zaptel.h
+ $(HOSTCC) $(KFLAGS) -o $@ -c $<
+
Property changes on: debian/patches/Makefile_deps_kern.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/fxotune_tmpfile.dpatch
===================================================================
--- debian/patches/fxotune_tmpfile.dpatch (revision 0)
+++ debian/patches/fxotune_tmpfile.dpatch (revision 0)
@@ -0,0 +1,23 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## fxotune_tmpfile.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fixes insecure temporary file handling in fxotune (in detect mode, -i)
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/fxotune.c /tmp/dpep.sF8yv8/zaptel-1.2.0-0beta1/fxotune.c
+--- zaptel-1.2.0-0beta1/fxotune.c 2005-09-10 20:34:45.299697146 +0300
++++ /tmp/dpep.sF8yv8/zaptel-1.2.0-0beta1/fxotune.c 2005-09-10 20:35:06.309170971 +0300
+@@ -303,9 +303,10 @@
+ float acim_results[16];
+
+
+- outfile = fopen("/tmp/fxotune.vals", "w");
++ outfile = tmpfile();
+ if (!outfile) {
+- fprintf(stdout, "Cannot create /tmp/txotune.vals\n");
++ fprintf(stdout, "Cannot create temporary file: %d (%s)\n",
++ errno, strerror(errno));
+ return -1;
+ }
+
Property changes on: debian/patches/fxotune_tmpfile.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/Makefile_deps_utils.dpatch
===================================================================
--- debian/patches/Makefile_deps_utils.dpatch (revision 0)
+++ debian/patches/Makefile_deps_utils.dpatch (revision 0)
@@ -0,0 +1,107 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## Makefile_progdeps.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Clean dependencies and build flags of misc. utils
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/Makefile /tmp/dpep.GxuAYU/zaptel-1.2.0-0beta1/Makefile
+--- zaptel-1.2.0-0beta1/Makefile 2005-09-10 17:14:59.442470186 +0300
++++ /tmp/dpep.GxuAYU/zaptel-1.2.0-0beta1/Makefile 2005-09-10 18:43:28.224686623 +0300
+@@ -109,7 +109,10 @@
+ ifneq (,$(wildcard /usr/include/newt.h))
+ ZTTOOL:=zttool
+ endif
+-BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
++BINS:=ztcfg sethdlc-new ztmonitor ztspeed $(ZTTOOL) zttest fxotune
++UTILS:=tor2ee ztspeed zttool ztmonitor sethdlc-new \
++ usbfxstest fxstest fxotune fxsdump ztdiag
++UTILSO:=$(UTILS:%=%.o)
+
+ #PRIMARY=wcfxsusb
+ PRIMARY=torisa
+@@ -173,8 +176,7 @@
+
+ tor2ee.o: tor2-hw.h
+
+-tor2ee: tor2ee.o
+- $(CC) $(CFLAGS) -o $@ $^ -lpci
++tor2ee: LDFLAGS+=-lpci
+
+ zonedata.lo: zonedata.c
+ $(CC) -c $(LCFLAGS) -o $@ $^
+@@ -194,8 +196,7 @@
+ radfw.h: makefw pciradio.rbt
+ ./makefw pciradio.rbt radfw > radfw.h
+
+-gendigits: gendigits.o
+- $(CC) -o $@ $^ -lm
++gendigits: LDFLAGS+=-lm
+
+ zaptel.c: tones.h
+
+@@ -207,23 +208,10 @@
+
+ ztmonitor.o: ztmonitor.c zaptel.h
+
+-ztspeed.o: ztspeed.c
+- $(CC) -o $@ -c $^
+-
+-zttool: zttool.o
+- $(CC) -o $@ $^ -lnewt
+-
+-ztmonitor: ztmonitor.o
+- $(CC) -o $@ $^
+-
+-ztspeed: ztspeed.o
+- $(CC) -o $@ $^
+-
+-sethdlc-new: sethdlc-new.o
+- $(CC) -o $@ $^
+-
+-sethdlc-new.o: sethdlc-new.c
+- $(CC) -o $@ -c $(CFLAGS) -I$(KINCLUDES) $^
++ztspeed: CFLAGS=
++ztspeed.o: CFLAGS=
++zttool: LDFLAGS+=-lnewt
++sethdlc-new.o: CFLAGS+=-I$(KINCLUDES)
+
+ libtonezone.a: $(TZOBJS)
+ ar rcs libtonezone.a $^
+@@ -248,26 +236,20 @@
+ complex.o: complex.cc
+ $(CC) -o $@ -c $^
+
+-usbfxstest.o: usbfxstest.c
+- $(CC) -o $@ -g -c $^
+-
+-usbfxstest: usbfxstest.o
+- $(CC) -o $@ $^ -lzap
+-
+-fxstest: fxstest.o $(LIBTONEZONE_SO)
+- $(CC) -o $@ $^ -lm
+-
+-fxotune: fxotune.o
+- $(CC) -o $@ $^ -lm
+-
+-fxsdump: fxsdump.o
+- $(CC) -o $@ $^ -lm
++usbfxstest: LDFLAGS+=-lzap
++fxstest: $(LIBTONEZONE_SO)
++fxstest: LDFLAGS+=-lm
++fxotune: LDFLAGS+=-lm
++fxsdump: LDFLAGS+=-lm
+
+ stackcheck: checkstack $(BUILDVER)
+ ./checkstack *.o
+
+-ztdiag: ztdiag.o
+- $(CC) -o $@ $^
++$(UTILS): %: %.o
++ $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
++
++$(UTILSO): %.o: %.c
++ $(CC) $(CFLAGS) -o $@ -c $<
+
+ devices:
+ ifndef DYNFS
Property changes on: debian/patches/Makefile_deps_utils.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/Makefile_man.dpatch
===================================================================
--- debian/patches/Makefile_man.dpatch (revision 0)
+++ debian/patches/Makefile_man.dpatch (revision 0)
@@ -0,0 +1,35 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## Makefile_man.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: use implicit rules for man pages generation
+
+ at DPATCH@
+diff -urNad zaptel-1.2.0-0beta1/Makefile /tmp/dpep.Gfmetd/zaptel-1.2.0-0beta1/Makefile
+--- zaptel-1.2.0-0beta1/Makefile 2005-09-09 13:11:24.000000000 +0300
++++ /tmp/dpep.Gfmetd/zaptel-1.2.0-0beta1/Makefile 2005-09-10 13:34:20.793721137 +0300
+@@ -297,20 +297,10 @@
+
+ manpages: doc/ztcfg.8.gz doc/ztmonitor.8.gz doc/zttool.8.gz
+
+-doc/ztcfg.8.gz: doc/ztcfg.sgml
+- rm -f doc/ztcfg.8.gz
+- docbook2man -o doc doc/ztcfg.sgml
+- gzip doc/ztcfg.8
+-
+-doc/zttool.8.gz: doc/zttool.sgml
+- rm -f doc/zttool.8.gz
+- docbook2man -o doc doc/zttool.sgml
+- gzip doc/zttool.8
+-
+-doc/ztmonitor.8.gz: doc/ztmonitor.sgml
+- rm -f doc/ztmonitor.8.gz
+- docbook2man -o doc doc/ztmonitor.sgml
+- gzip doc/ztmonitor.8
++doc/%.8.gz: doc/%.sgml
++ rm -f $@
++ docbook2man -o doc $<
++ gzip doc/$*.8
+
+ install: all devices
+ install -D -m 755 ztcfg $(INSTALL_PREFIX)/sbin/ztcfg
Property changes on: debian/patches/Makefile_man.dpatch
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/patches/00list
===================================================================
--- debian/patches/00list (revision 764)
+++ debian/patches/00list (working copy)
@@ -1,7 +1,13 @@
-01_ztdummy.dpatch
-#bristuff-0.2.0-RC8n.dpatch
-zaphfc_gcc4.dpatch
-Makefile.dpatch
-rtai.dpatch
-ztcfg_init.dpatch
-zaphfc_0.2.0-RC8n_florz-8.dpatch
+Makefile_deps_kern
+Makefile_deps_utils
+Makefile_uname
+Makefile_pscmd
+Makefile_targets
+Makefile_man
+fxotune_tmpfile
+#Makefile.dpatch
+# this one depends on "Makefile":
+#bristuff_Makefile.dpatch
+#zone-head.dpatch
+#ukcid.dpatch
+#bristuff.dpatch
Index: debian/zaptel-modules.postrm
===================================================================
--- debian/zaptel-modules.postrm (revision 0)
+++ debian/zaptel-modules.postrm (revision 0)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# not stopping on error: in the worst case depmod won't be run.
+#set -e
+
+if [ "`uname -r`" = "_KVERS_" ] && [ -x depmod ]; then
+ depmod -a
+fi
+
+#DEBHELPER#
Index: debian/docs
===================================================================
--- debian/docs (revision 764)
+++ debian/docs (working copy)
@@ -1 +1,5 @@
+README
+README.fxotune
README.fxsusb
+README.Linux26
+README.udev
Index: debian/genzaptelconf
===================================================================
--- debian/genzaptelconf (revision 0)
+++ debian/genzaptelconf (revision 0)
@@ -0,0 +1,667 @@
+#! /bin/bash
+
+# genzaptelconf: generate as smartly as you can:
+# /etc/zaptel.conf
+# /etc/asterisk/zapata-channels.conf (to be #include-d into zapata.conf)
+# update:
+# /etc/default/zaptel (list of modules to load)
+#
+# Copyright (C) 2005 by Xorcom <support at xorcom.com>
+#
+# Note that this script is explicitly does not the definition of
+# "enhancements to Asterisk" or "contributions to Asterisk" from
+# http://www.digium.com/disclaimer.txt and is thus not disclaimed and may
+# not be distributed with a non-GPL license.
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+#
+# If you have any technical questions, contact
+# Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+# $Id:$
+#
+
+# The script uses a number of bash-specific features
+# TODO: either ditch them or convert to perl
+
+# /etc/default/zaptel may override the following variables
+VERSION=0.3.5
+lc_country=us
+#method=ls
+#method=ks
+base_exten=6000
+
+ZAPCONF_FILE=/etc/zaptel.conf
+ZAPATA_FILE=/etc/asterisk/zapata-channels.conf
+ZAPTEL_BOOT=/etc/default/zaptel
+exten_base_dir=/etc/asterisk/extensions-phones.d
+exten_defs_file=/etc/asterisk/extensions-defs.conf
+ztcfg_cmd=ztcfg
+
+# a temporary directory. Created when the switch -r is parsed on getopts
+# and deleted in the end on update_extensions_defs
+tmp_dir=
+
+# read default configuration from /etc/default/zaptel
+if [ -r $ZAPTEL_BOOT ]; then . $ZAPTEL_BOOT; fi
+
+# work around a bug (that was already fixed) in the installer:
+if [ "$lc_country" = '' ]; then lc_country=us; fi
+
+ALL_MODULES="zaphfc qozap wctdm wcfxo wcfxs pciradio tor2 torisa wct1xxp wct4xxp wcte11xp wcusb ztd_eth ztdummy"
+force_stop_ast=no
+do_detect=no
+do_unload=no
+verbose=no
+rapid_extens=''
+# global: current extension number in extensions list. Should only be
+# changed in print_pattern:
+rapid_cur_exten=1
+# set the TRUNK in extensidialplan dialplan defs file rapid_conf_mode=no
+
+die() {
+ echo "$@" >&2
+ exit 1
+}
+
+say() {
+ if [ "$verbose" = no ]; then
+ return
+ fi
+ echo "$@" >&2
+}
+
+run_ztcfg() {
+ if [ "$verbose" = no ]; then
+ $ztcfg_cmd "$@"
+ else
+ say "Reconfiguring identified channels"
+ $ztcfg_cmd -vv "$@"
+ fi
+}
+
+do_update() {
+ if [ ! -d `dirname ${ZAPTEL_BOOT}` ]
+ then
+ return
+ fi
+ sed -i.bak "s/^$1=.*\$/$1=\"$2\"/" ${ZAPTEL_BOOT}
+ if ! grep -q "^$1=" ${ZAPTEL_BOOT}; then
+ echo "$1=\"$2\"" >> ${ZAPTEL_BOOT}
+ fi
+}
+
+update_extensions_defs() {
+ if [ "$rapid_conf_mode" = 'yes' ]
+ then
+ say "DEBUG: Updating dialplan defs file $exten_defs_file"
+ if [ "`echo $tmp_dir/fxo_* | grep -v '*'`" != '' ]
+ then
+ trunk_nums=`cat $tmp_dir/fxo_* | sort -n | xargs`
+ say "Configuring TRUNK to be [first of] zaptel channels: $trunk_nums"
+ trunk_dev=`echo $trunk_nums| sed -e 's/ /\\\\\\&/g' -e 's/[0-9a-zA-Z]\+/Zap\\\\\\/&/g'`
+ echo >&2 sed -i "s/^TRUNK.*=>.*/TRUNK => $trunk_dev/" $exten_defs_file
+ sed -i "s/^TRUNK.*=>.*/TRUNK => $trunk_dev/" $exten_defs_file
+ if ! grep -q "^TRUNK =>" $exten_defs_file; then
+ trunk_dev=`echo $trunk_nums| sed -e 's/ /&/g' -e 's/[0-9a-zA-Z]*/Zap\\/&/g'`
+ echo "TRUNK => $trunk_dev" >> $exten_defs_file
+ fi
+ else
+ say "Warning: No FXO channel for trunk. Moving on."
+ fi
+ if [ "`echo $tmp_dir/fxs_* | grep -v '*'`" != '' ]
+ then
+ fxs_nums=`cat $tmp_dir/fxs_* | sort -n | xargs`
+ zap_nums=`grep '^[^;].*Zap/\${CHAN_ZAP_' $exten_base_dir/*.conf | \
+ sed -e 's/.*Zap\/\${CHAN_ZAP_\([0-9]*\)}.*/\1/' | sort -u | xargs`
+ say "Configuring channels: $fxs_nums as channel placeholders: $zap_nums"
+ j=1
+ for i in $zap_nums
+ do
+ chan=`echo $fxs_nums | awk "{print \\$$i}"`
+ if [ "$chan" = '' ]
+ then
+ # if the result is empty, we probably got past the last one.
+ # bail out.
+ say "Warning: No FXS channel for CHAN_ZAP_$i. Moving on"
+ break
+ fi
+ say "DEBUG: setting channel $chan to placeholder $i"
+ if grep -q "^CHAN_ZAP_$i " $exten_defs_file
+ then
+ sed -i -e "s/^CHAN_ZAP_$i .*/CHAN_ZAP_$i => Zap\/$chan/" $exten_defs_file
+ else
+ echo "CHAN_ZAP_$i => Zap/$chan" >> $exten_defs_file
+ fi
+ done
+ fi
+ # cleaning up the temp dir
+ fi
+ if [ -d "$tmp_dir" ]; then rm -rf "$tmp_dir"; fi
+}
+
+usage() {
+ program=`basename $0`
+
+ echo >&2 "$program: generate zaptel.conf (version $VERSION)"
+ echo >&2 "usage:"
+ echo >&2 " $program [-sdv] [-m k|l|g] [-c <country_code>] [-r |-e <base_exten>] "
+ echo >&2 " $program [-sdv] -l"
+ echo >&2 " $program -su"
+ echo >&2 " $program -h (this screen)"
+ echo >&2 ""
+ echo >&2 "Options:"
+ echo >&2 " -c CODE: set the country code (default: $lc_country)"
+ echo >&2 " -e NUM: set the base extension number (default: $base_exten)"
+ echo >&2 " -m: set signalling method (gs/ks/ls, default: $method)"
+ echo >&2 " -l: output a list of detected channels instead of zaptel.conf"
+ echo >&2 " -d: Perform hardware detection -- update /etc/default/zaptel"
+ echo >&2 " -u: Unload zaptel modules"
+ echo >&2 " -v: verbose"
+ echo >&2 " -s: Don't fail if asterisk is running. Stop it"
+ echo >&2 " -r: rapid configuration mode: configure Zaptel FXS channels from "
+ echo >&2 " existing Rapid extension files. FXOs will all be TRUNK "
+}
+
+# $1: channel number
+print_pattern() {
+ local chan=$1
+ local sig=$2 #fxs/fxo
+ local mode=$3
+ case "$mode" in
+ zaptel) echo "${sig}$method=$chan" ;;
+ list) echo $chan $sig;;
+ zapata)
+ echo "signalling=${sig}_$method"
+ if [ "$sig" = 'fxo' ]
+ then
+ # to preconfigure channel 1's extension to 550, set
+ # chan_1_exten=550
+ # in, e.g, /etc/default/zaptel
+ var_name=`echo chan_${chan}_exten`
+ cfg_exten=`echo ${!var_name} | tr -d -c 0-9`
+ var_name=`echo chan_${chan}_vmbox`
+ cfg_vmbox=`echo ${!var_name} | tr -d -c 0-9`
+ var_name=`echo chan_${chan}_cntxt`
+ cfg_cntxt=`echo ${!var_name} | tr -d -c 0-9`
+
+ # if option -E was given, get configuration from current extension
+ if [ "$rapid_conf_mode" = 'yes' ]
+ then
+ rap_exten=`echo $rapid_extens |awk "{print \\$$rapid_cur_exten}"`
+ if [ "$rap_exten" != '' ]
+ then
+ rap_cfgfile="$exten_base_dir/$rap_exten.conf"
+ if [ -r "$rap_exten" ]
+ then
+ cfg_exten=$rap_exten
+ # the vmbox is the third parameter to stdexten
+ rap_vmbox=`grep '^[^;].*Macro(stdexten' $rap_exten | cut -d, -f3 \
+ | cut -d')' -f1 | tr -d -c '0-9 at a-zA-Z'`
+ if [ "$rap_vmbox" ]!= '' ; then cfg_vmbox=$rap_vmbox; fi
+ fi
+ fi
+ rapid_cur_exten=$(($rapid_cur_exten + 1))
+ fi
+
+ if [ "$cfg_exten" = '' ]
+ then # No extension number set for this channel
+ exten=$(($chan+$base_exten))
+ else # use the pre-configured extension number
+ exten=$cfg_exten
+ fi
+ # is there any real need to set 'mailbox=' ?
+ if [ "x$cfg_vmbox" = x ]
+ then # No extension number set for this channel
+ vmbox=$exten
+ else # use the pre-configured extension number
+ vmbox=$cfg_vmbox
+ fi
+ echo "callerid=\"Channel $chan\" <$exten>"
+ echo "mailbox=$exten"
+ else # we have may have set it. So reset it:
+ echo "callerid=\"\" <0>"
+ echo "mailbox="
+ echo "cidsignalling=v23"
+ case $line in
+ *WCFXO*) echo "cidstart=history";;
+ *) echo "cidstart=polarity";; #a TDM400
+ esac
+ echo ";;; line=\"$line\""
+ fi
+
+ echo "channel => $chan"
+ echo ""
+
+ # Keep a note of what channels we have identified
+ say "DEBUG: adding to channels list: channel: $chan, sig: $sig"
+ case "$sig" in
+ fxs)
+ echo $chan >$tmp_dir/fxo_$chan
+ say "DEBUG: FXO list now contains: `cat $tmp_dir/fxo_* |xargs`"
+ ;;
+ fxo)
+ echo $chan >$tmp_dir/fxs_$chan
+ say "DEBUG: FXS list now contains: `cat $tmp_dir/fxs_* |xargs`"
+ ;;
+ esac
+ ;;
+ esac
+
+}
+
+# the number of channels from /proc/zaptel
+# must always print a number as its output.
+count_proc_zap_lines() {
+ # if zaptel is not loaded there are 0 channels:
+ if [ ! -d /proc/zaptel ]; then echo '0'; return; fi
+
+ (
+ for file in `echo /proc/zaptel/* |grep -v '\*'`
+ do sed -e 1,2d $file # remove the two header lines
+ done
+ ) | wc -l # the total number of lines
+}
+
+load_modules() {
+ say "Test Loading modules:"
+ for i in zaptel $ALL_MODULES
+ do
+ if [ "$i" = ztdummy ]; then
+ continue # No hardware to detect
+ fi
+ lines_before=`count_proc_zap_lines`
+ args="${i}_args"
+ eval "args=\$$args"
+ # a module is worth listing if it:
+ # a. loaded successfully, and
+ # b. added channels lines under /proc/zaptel/*
+ if /sbin/modprobe $i $args 2> /dev/null && \
+ [ $lines_before -lt `count_proc_zap_lines` ]
+ then
+ probed_modules="$probed_modules $i"
+ say " ok $i $args"
+ else
+ say " - $i $args"
+ fi
+ done
+}
+
+
+unload_modules() {
+ if
+ pids="$(pgrep asterisk)"
+ [ "$pids" != '' ]
+ then
+ die "Before unloading -- STOP asterisk (pids=$pids)."
+ fi
+ say "Unloading zaptel modules:"
+ modlist=''
+ for i in $ALL_MODULES zaptel
+ do
+ if lsmod | grep "^$i *" > /dev/null; then
+ modlist="$modlist $i"
+ say -n "$i "
+ fi
+ done
+ /sbin/modprobe -r $modlist
+ say ''
+}
+
+detect() {
+ unload_modules
+ load_modules
+ modlist="$probed_modules"
+ #for i in $ALL_MODULES
+ #do
+ # if lsmod | grep "^$i *" > /dev/null; then
+ # modlist="$modlist $i"
+ # fi
+ #done
+ modlist="$(echo $modlist)" # clean spaces
+ if [ "$modlist" = '' ]; then
+ modlist=ztdummy # Fallback
+ fi
+ say "Updating '${ZAPTEL_BOOT}'"
+ do_update ZAPTEL_MODS "$modlist"
+}
+
+check_tdm_sigtype() {
+ chan_num=$1
+ sig_type=$2
+ mode=$3
+
+ case "$sig_type" in
+ fxs)chan_sig_type=fxo;;
+ fxo)chan_sig_type=fxs;;
+ esac
+
+# print_pattern $chan_num $chan_sig_type $mode
+
+ $ztcfg_cmd -c <(print_pattern $chan_num $chan_sig_type zaptel) 2>/dev/null \
+ || return 1
+ if head -c1 /dev/zap/$chan_num >/dev/null 2>/dev/null
+ then
+ print_pattern $chan_num $chan_sig_type $mode
+ return 0
+ else
+ return 1
+ fi
+}
+
+# output a list of extensions that need a channel
+get_rapid_extens() {
+ if [ "$rapid_conf_mode" = 'yes' ]
+ then
+ rapid_extens=`grep -l '^[^;].*Zap/\${CHAN_ZAP_' $exten_base_dir/*.conf 2>/dev/null | \
+ rev | cut -d/ -f1 | cut -d. -f2- | rev | xargs`
+ say "Need to configure extensions: $rapid_extens"
+ fi
+}
+
+genconf() {
+ local mode=$1
+
+ # reset FXO list (global)
+ #say "DEBUG: resetting channels lists"
+ rm -f $tmp_dir/fx{s,o}_*
+
+ if [ "$mode" = 'zapata' ]
+ then
+ rem_char=';'
+ else
+ rem_char='#'
+ fi
+
+ spanlist=`echo /proc/zaptel/* | grep -v '\*'`
+
+ #if [ "$spanlist" == "" ]; then
+ # die "No zapata interfaces in /proc/zaptel"
+ #fi
+
+
+ case "$mode" in
+ zaptel)
+ cat <<EOF
+# Autogenerated by $0 -- do not hand edit
+# Zaptel Configuration File
+#
+# This file is parsed by the Zaptel Configurator, ztcfg
+#
+
+# It must be in the module loading order
+
+EOF
+ ;;
+ zapata)
+ cat <<EOF
+; Autogenerated by $0 -- do not hand edit
+; Zaptel Channels Configurations (zapata.conf)
+;
+; This is not intended to be a complete zapata.conf. Rather, it is intended
+; to be #include-d by /etc/zapata.conf that will include the global settings
+;
+EOF
+ ;;
+ esac
+
+ # For each line in the spanlist: see if it represents a channel.
+ # if it does, test that the channel is usable.
+ # we do that by configuring it (using ztcfg with a 1-line config file)
+ # and then trying to read 1 byte from the device file.
+ #
+ # The '<(command)' syntax creates a temporary file whose content is is the
+ # output of 'command'.
+ #
+ # This approach failed with the T1 card we have: the read operation simply
+ # hung.
+ #
+ # Another problem with such an approach is how to include an existing
+ # configuration file. For instance: how to include some default settings.
+ #
+ # Maybe an 'include' directive should be added to zaptel.conf ?
+ #cat $spanlist |
+ for procfile in $spanlist
+ do
+ span_num=`basename $procfile`
+ # the first line is the title line. It states the model name
+ # the second line is empty
+ title=`head -n 1 $procfile`
+ echo ""
+ # stuff that needs to be remembered accross lines (for PRI support)
+ echo "$rem_char $title"
+ echo '-1' >$tmp_dir/span_begin
+ echo '-1' >$tmp_dir/span_end
+ echo '1' >$tmp_dir/span_timing
+ echo '1' >$tmp_dir/span_lbo
+ echo '' >$tmp_dir/span_framing
+ echo 'ami' >$tmp_dir/span_coding
+ echo '' >$tmp_dir/span_switchtype
+ echo '' >$tmp_dir/span_signalling
+
+ # The rest of the lines are per-channel lines
+ sed -e 1,2d $procfile | \
+ while read line
+ do
+ # in case this is a real channel.
+ chan_num=`echo $line |awk '{print $1}'`
+ case "$line" in
+ *WCTDM/*)
+ # this can be either FXS or FXO
+ check_tdm_sigtype $chan_num fxs $mode || \
+ check_tdm_sigtype $chan_num fxo $mode || \
+ echo "$rem_char channel $chan_num, WCTDM, inactive."
+ ;;
+ *WCFXO/*)
+ check_tdm_sigtype $chan_num fxo $mode || \
+ echo "$rem_char channel $chan_num, WCFXO, inactive."
+ ;;
+ *ZTHFC*/*|*ztqoz*/*|*WCT1/*) # should also be used for other PRI channels
+ if [ "`cat $tmp_dir/span_begin`" = "-1" ]
+ then
+ echo $chan_num >$tmp_dir/span_begin
+ echo $span_num >$tmp_dir/span_num
+ case "$line" in
+ *ZTHFC*/*|*ztqoz*/*)
+ echo 'ccs' >$tmp_dir/span_framing
+ echo 'euroisdn' >$tmp_dir/span_switchtype
+ echo 'bri_net_ptmp' >$tmp_dir/span_signalling
+ ;;
+ *WCT1/*)
+ echo 'esf' >$tmp_dir/span_framing
+ echo 'b8zs' >$tmp_dir/span_coding
+ echo 'national' >$tmp_dir/span_switchtype
+ echo 'pri_cpe' >$tmp_dir/span_signalling
+ ;;
+ esac
+ fi
+ # span_lastd is always the one before last
+ # channel. span_bchan is the last:
+ echo $chan_num >$tmp_dir/span_end
+ ;;
+ '') ;; # Empty line (after span header)
+ *) echo "$rem_char ??: $line";;
+ esac
+ done
+ if [ "`cat $tmp_dir/span_begin`" != -1 ]
+ then # write PRI span ocnfig:
+ # read files to variables:
+ for suffix in num begin end timing lbo framing \
+ coding switchtype signalling
+ do
+ eval span_$suffix=`cat $tmp_dir/span_$suffix`
+ done
+ # exactly the same logic is used in asterisk's chan_zap.c.
+ # aslo not that $(( )) is bash-specific
+ case "$((1+ $span_end - $span_begin))" in
+ 3|24) #BRI or T1
+ dchan=$span_end
+ bchans="$span_begin-$(($span_end-1))"
+ ;;
+ 31) #E1
+ dchan="$(($span_begin+15))"
+ bchans="$span_begin-$(($span_begin+14)),$(($span_begin+16))-$span_end"
+ ;;
+ esac
+ case "$mode" in
+ zaptel)
+ echo span=$span_num,$span_timing,$span_lbo,$span_framing,$span_coding
+ echo bchan=$bchans
+ echo dchan=$dchan
+ ;;
+ zapata)
+ echo "switchtype = $span_switchtype"
+ echo "signalling = $span_signalling"
+ echo "channel => $bchans"
+ ;;
+ list)
+ echo BRI/PRI: chans: $bchans, control: $dchan
+ ;;
+ esac
+ fi
+ done
+
+ if [ "$mode" = 'zaptel' ]
+ then
+ cat <<EOF
+
+# Global data
+
+EOF
+ echo "loadzone = $loadzone"
+ echo "defaultzone = $defaultzone"
+ fi
+
+ if [ "$mode" = 'zapata' ] || [ "$mode" = 'list' ]
+ then
+ update_extensions_defs
+ fi
+}
+
+while getopts 'c:de:E:hlm:rsuv' arg
+do
+ case "$arg" in
+ e) # guarantee that it is a number:
+ new_base_exten=`echo $OPTARG | tr -d -c 0-9`
+ if [ "x$new_base_exten" != x ]; then base_exten=$new_base_exten; fi
+ ;;
+ c) lc_country=`echo $OPTARG | tr -d -c a-z` ;;
+ d) do_detect=yes ;;
+ u) do_unload=yes ;;
+ v) verbose=yes ;;
+ l) mode='list' ;;
+ m)
+ case "$OPTARG" in
+ k|l|g)method=${OPTARG}s ;;
+ *) echo >&2 "unknown signalling method ${OPTARG}s, defaulting to \"$method\"";;
+ esac
+ ;;
+ s) force_stop_ast=yes ;;
+ r)
+ rapid_conf_mode=yes
+ ;;
+ h) usage; exit 0;;
+ *) echo >&2 "unknown parameter -$arg, Aborting"; usage; exit 1;;
+ esac
+done
+shift $(( $OPTIND-1 ))
+if [ $# != 0 ]; then
+ echo >&2 "$0: too many parameters"
+ usage
+ exit 1
+fi
+
+tmp_dir=`mktemp -d genzaptelconf.XXXXXX` || \
+ die "$0: failed to create temporary directory. Aborting"
+
+
+case "$lc_country" in
+ # the list was generated from the source of zaptel:
+ #grep '{.*[0-9]\+,.*"[a-z][a-z]"' zonedata.c | cut -d'"' -f 2 | xargs |tr ' ' '|'
+ us|au|fr|nl|uk|fi|es|jp|no|at|nz|it|gr|tw|cl|se|be|sg|il|br|hu|lt|pl|za|pt|ee|mx|in|de|ch|dk|cz|cn):;;
+ de)lc_country=us;; # used in earlier versions that did not have 'de'
+ *)
+ lc_country=us
+ echo >&2 "unknown country-code $lc_country, defaulting to \"us\""
+ ;;
+esac
+# any reason for loadzone and defaultzone to be different? If so, this is
+# the place to make that difference
+loadzone=$lc_country
+defaultzone=$loadzone
+
+# Choose reasonable default for signaling method (by country)
+if [ "" = "$method" ]; then
+ case "$lc_country" in
+ il) method=ls ;;
+ *) method=ks ;;
+ esac
+fi
+
+# make sure asterisk is not in our way
+if [ "$force_stop_ast" = 'yes' ]
+then
+ /etc/init.d/asterisk stop 1>&2
+else
+ if ps auxww |grep asterisk | grep -v -- -r | grep -q -v grep
+ then
+ echo >&2 "Asterisk is already running. Configuration left untouched"
+ echo >&2 "You can use the option -s to shut down Asterisk for the"
+ echo >&2 "duration of the detection."
+ exit 1
+ fi
+fi
+
+if [ "$do_unload" = yes ]
+then
+ unload_modules
+ exit
+fi
+
+if [ "$do_detect" = yes ]
+then
+ detect
+fi
+
+if [ "$mode" = list ]; then
+ genconf list
+else
+ get_rapid_extens
+ say "Generating '${ZAPCONF_FILE}'"
+ mv "${ZAPCONF_FILE}" "${ZAPCONF_FILE}.bak"
+ genconf zaptel > "${ZAPCONF_FILE}"
+ say "Generating '${ZAPATA_FILE}'"
+ mv "${ZAPATA_FILE}" "${ZAPATA_FILE}.bak"
+ genconf zapata > "${ZAPATA_FILE}"
+ run_ztcfg
+fi
+
+if [ "$force_stop_ast" = 'yes' ]
+then
+ /etc/init.d/asterisk start 1>&2
+fi
+
+# if in verbose mode: verify that asterisk is running
+if [ "$verify" != 'no' ]
+ then
+ say "Checking channels configured in Asterisk:"
+ sleep 1 # give it some time. This is enough on our simple test server
+ if [ -x ast-cmd ]
+ then
+ ast-cmd cmd "zap show channels"
+ else
+ asterisk -rx "zap show channels"
+ fi
+fi
Property changes on: debian/genzaptelconf
___________________________________________________________________
Name: svn:executable
+ *
Index: debian/zaptel.init
===================================================================
--- debian/zaptel.init (revision 0)
+++ debian/zaptel.init (revision 0)
@@ -0,0 +1,69 @@
+#! /bin/sh
+#
+# skeleton example file to build /etc/init.d/ scripts.
+# This file should be used to construct scripts for /etc/init.d.
+#
+# Written by Miquel van Smoorenburg <miquels at cistron.nl>.
+# Modified for Debian
+# by Ian Murdock <imurdock at gnu.ai.mit.edu>.
+#
+# Version: @(#)skeleton 1.9 26-Feb-2001 miquels at cistron.nl
+#
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/sbin/ztcfg
+NAME=zaptel
+DESC="Zaptel cards initial configuration"
+
+test -x $DAEMON || exit 0
+test -r /etc/zaptel.conf || exit 0
+
+# Include am defaults if available
+if [ -f /etc/default/zaptel ] ; then
+ . /etc/default/zaptel
+fi
+
+# defined in /etc/default/zaptel
+# ZAPTEL_MODS is a list of modules to be loaded at startup
+
+set -e
+
+case "$1" in
+ start|reload)
+ echo -n "$DESC: "
+ #for module in $ZAPTEL_MODS
+ #do
+ # modprobe $module
+ #done
+
+ # if no zaptel module loaded: load ztdummy. other modules should have
+ # been loaded by now
+ # The first holds if zaptel is not loaded at all. The second: if
+ # zaptel is loaded but no other module is.
+ if [ ! -d /proc/zaptel ] || ! echo /proc/zaptel/* | grep -v '\*'| grep -q .
+ then modprobe ztdummy || true # will fail if there is no module package
+ fi
+ if [ -r /etc/fxotune.conf ] && [ -x fxotune ]; then
+ fxotune -s
+ fi
+
+ # configure existing modules:
+ $DAEMON $DAEMON_OPTS
+ echo "$NAME."
+ ;;
+ stop)
+ : # do nothing
+ ;;
+ force-reload|restart)
+ # there's no 'stop'
+ $0 start
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $N {start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
Index: debian/zaptel.install
===================================================================
--- debian/zaptel.install (revision 764)
+++ debian/zaptel.install (working copy)
@@ -1,4 +0,0 @@
-etc/zaptel.conf
-sbin
-usr/share/doc/zaptel/examples
-usr/share/lintian/overrides/zaptel
Index: debian/zaptel-modules.postinst
===================================================================
--- debian/zaptel-modules.postinst (revision 0)
+++ debian/zaptel-modules.postinst (revision 0)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# not stopping on error: in the worst case depmod won't be run.
+#set -e
+
+if [ "`uname -r`" = "_KVERS_" ] ; then
+ depmod -a
+fi
+
+#DEBHELPER#
Index: debian/rules
===================================================================
--- debian/rules (revision 764)
+++ debian/rules (working copy)
@@ -7,6 +7,7 @@
# This is the debhelper compatibility version to use.
export DH_COMPAT=3
+USE_BRISTUFF=0
-include /usr/share/dpatch/dpatch.make
@@ -16,7 +17,9 @@
## MODULE-ASSISTANT STUFF
# prefix of the target package name
-PACKAGE=zaptel-modules
+PREFIX:=zaptel
+SKPG:=$(PREFIX)-source
+PACKAGE:=$(PREFIX)-modules
# modifieable for experiments or debugging m-a
MA_DIR ?= /usr/share/modass
# load generic variable handling
@@ -24,6 +27,8 @@
# load default rules
-include $(MA_DIR)/include/common-rules.make
+MOD_EXAMPLES_DIR:=modexamples
+
kdist_clean: clean-unpatched
kdist_config: prep-deb-files
@@ -32,15 +37,23 @@
dh_testdir
dh_testroot
dh_clean -k
- make modules KERNEL_SOURCES=$(KSRC) MODVERSIONS=detect KERNEL=linux-$(KVERS) ZAPTELDIR="$(CURDIR)" LINUXINCLUDE="-Iinclude -I/usr/src/modules/zaptel"
- make install-modules DESTDIR=$(CURDIR)/debian/$(PKGNAME)
-
+ make modules KERNEL_SOURCES=$(KSRC) MODVERSIONS=detect KERNEL=linux-$(KVERS)
+ make install-modules INSTALL_PREFIX=$(CURDIR)/debian/$(PKGNAME)
+ifeq (2.6,$(shell echo $(KVERS) | cut -d. -f1-2))
+ # The 2.6 modules are way too big. This is only in kernel 2.6
+ find debian/$(PKGNAME)/lib/modules -name '*.ko' |xargs strip -g
+endif
# dh_installdocs
dh_installdebconf
dh_installchangelogs
dh_compress
dh_fixperms
dh_installdeb
+ # Note: I don't want to edit the file in the debian/ directory itself.
+ # I figure that there must be existing fuctionality in dpkg/debhelper. How?
+ sed -i -e 's/_KVERS_/$(KVERS)/' \
+ debian/$(PKGNAME)/DEBIAN/postinst \
+ debian/$(PKGNAME)/DEBIAN/postrm
dh_gencontrol -- -v$(VERSION)
dh_md5sums
dh_builddeb --destdir=$(DEB_DESTDIR)
@@ -50,19 +63,17 @@
configure: configure-stamp
configure-stamp: patch-stamp
dh_testdir
+ touch $@
- touch configure-stamp
-
build: build-indep-stamp build-arch-stamp
build-arch-stamp: configure-stamp
dh_testdir
$(MAKE) programs
+ touch $@
- touch build-arch-stamp
-
build-indep-stamp:
- touch build-indep-stamp
+ touch $@
clean: clean-unpatched unpatch
clean-unpatched:
@@ -71,9 +82,10 @@
rm -f build-*-stamp configure-stamp
# Add here commands to clean up after the build process.
+ rm -rf $(MOD_EXAMPLES_DIR)
-$(MAKE) clean
- rm -f debian/manpage.links debian/manpage.refs debian/*.8
+ #rm -f debian/manpage.links debian/manpage.refs debian/*.8
dh_clean
@@ -84,28 +96,21 @@
dh_testroot
dh_clean -k -a
dh_installdirs -a
+
+ # Add here commands to install the package into debian/tmp
+
+ $(MAKE) install-programs INSTALL_PREFIX=debian/tmp
+ /sbin/ldconfig -n debian/tmp/usr/lib
+ dh_install -a --sourcedir=debian/tmp sbin
+
+ # make sure genzaptelconf is executable
+ chmod +x debian/genzaptelconf
+ dh_install -a debian/genzaptelconf usr/sbin
+ dh_install -a debian/$(PREFIX).lintian \
+ usr/share/lintian/overrides/$(PREFIX)
- $(MAKE) install-programs DESTDIR=debian/tmp
-
- install -d debian/tmp/etc
- install -m 644 zaptel.conf.sample debian/tmp/etc/zaptel.conf
-
- install -d -m 755 debian/tmp/usr/share/lintian/overrides/
- install -m 644 debian/zaptel.lintian debian/tmp/usr/share/lintian/overrides/zaptel
-
- # make sure we do ship some documentation on how to deal with zaphfc
- install -d -m 755 debian/tmp/usr/share/doc/zaptel/examples/zaphfc
- install -d -m 755 debian/tmp/usr/share/doc/zaptel/examples/qozap
- install -m 644 zaphfc/*.conf* debian/tmp/usr/share/doc/zaptel/examples/zaphfc
- install -m 644 qozap/*.conf* debian/tmp/usr/share/doc/zaptel/examples/qozap
-
- install -m 644 README.udev debian/tmp/usr/share/doc/zaptel/
-
- dh_install -a --sourcedir=debian/tmp
-
- # Makefile leaves behind .a file
- install -m 644 libtonezone.a debian/libtonezone-dev/usr/lib/
-
+TARPARDIR=debian/tmp
+TARDIR=$(TARPARDIR)/modules/$(PREFIX)
install-indep: build-indep-stamp
dh_testdir
dh_testroot
@@ -113,25 +118,40 @@
dh_installdirs -i
# driver source code
- install -m 644 Makefile *.c *.h *.rbt debian/zaptel-source/usr/src/modules/zaptel
- install -m 644 zaphfc/* debian/zaptel-source/usr/src/modules/zaptel/zaphfc
- install -m 644 qozap/* debian/zaptel-source/usr/src/modules/zaptel/qozap
- install -m 644 zaphfc-florz/* debian/zaptel-source/usr/src/modules/zaptel/zaphfc-florz
- install -m 644 zaptel.h debian/zaptel-source/usr/include/linux/
- install -m 644 torisa.h debian/zaptel-source/usr/include/linux/
-
+ mkdir -p $(TARDIR)/debian
+ cp Makefile *.c *.h *.rbt $(TARDIR)/
+ifeq (1,$(USE_BRISTUFF))
+ cp -r zaphfc qozap cwain $(TARDIR)/
+endif
+ dh_install -i zaptel.h torisa.h usr/include/linux/
+
# Packaging infrastructure
- install -m 644 debian/*-modules.* debian/changelog debian/copyright \
- debian/control debian/control.modules.in \
- debian/zaptel-source/usr/src/modules/zaptel/debian
- #debian/zaptel-modules.postinst \
+ cp -r debian/*-modules.* debian/rules debian/changelog debian/copyright\
+ debian/control \
+ debian/control.modules.in \
+ $(TARDIR)/debian/
+ mv $(TARDIR)/debian/zaptel-modules.postinst $(TARDIR)/debian/postinst
+ cp debian/zaptel-modules.postinst $(TARDIR)/debian/postinst
+ cp debian/zaptel-modules.postrm $(TARDIR)/debian/postrm
- install -m 755 debian/rules \
- debian/zaptel-source/usr/src/modules/zaptel/debian
+ tar cjf debian/$(PREFIX)-source/usr/src/$(PREFIX).tar.bz2 \
+ -C $(TARPARDIR) modules
+ifeq (1,$(USE_BRISTUFF))
+ set -e; for module in qozap zaphfc; do \
+ mkdir -p $(MOD_EXAMPLES_DIR)/$$module; \
+ cp -a $$module/*.conf* $(MOD_EXAMPLES_DIR)/$$module; \
+ done
+else
+ mkdir -p $(MOD_EXAMPLES_DIR)/bristuff_stub
+endif
+
+ #rm -rf modules
- cd debian/zaptel-source/usr/src && \
- tar c modules | bzip2 -9 > zaptel.tar.bz2 && rm -rf modules
-
+ # TODO: this rmdir should not be required! (Tzafrir)
+ #rmdir debian/zaptel-source/usr/share/modass/overrides/zaptel
+ #dh_install -i debian/$(PREFIX)-source.modass \
+ # usr/share/modass/overrides/$(PREFIX)
+
# Build architecture-independent files here.
binary-indep: build install-indep
dh_testdir
@@ -152,16 +172,19 @@
dh_testdir
dh_testroot
- install -m644 debian/zaptel.modprobe.d debian/zaptel/etc/modprobe.d/zaptel
+ #install -m644 debian/$(PREFIX).modprobe.d debian/$(PREFIX)/etc/modprobe.d/$(PREFIX)
- docbook2man -o debian/ debian/ztcfg.sgml
- docbook2man -o debian/ debian/ztmonitor.sgml
- docbook2man -o debian/ debian/zttool.sgml
+ #docbook2man -o debian/ debian/ztcfg.sgml
+ #docbook2man -o debian/ debian/ztmonitor.sgml
+ #docbook2man -o debian/ debian/zttool.sgml
dh_installdocs -a
- dh_installman -a debian/ztmonitor.8 debian/ztcfg.8 debian/zttool.8
- #dh_installinit --update-rcd-params="defaults 15 30"
- dh_installexamples -a
+ dh_installman -a doc/ztmonitor.8.gz doc/ztcfg.8.gz doc/zttool.8.gz \
+ debian/genzaptelconf.8 debian/zttest.8 debian/ztspeed.8 \
+ debian/fxotune.8
+ # should be removed, eventually. Still left for compatibility
+ dh_installinit --update-rcd-params="defaults 15 30"
+ dh_installexamples -a zaptel.conf.sample $(MOD_EXAMPLES_DIR)/*
dh_installmodules -a
dh_installchangelogs -a ChangeLog
dh_link -a
Index: debian/control.modules.in
===================================================================
--- debian/control.modules.in (revision 764)
+++ debian/control.modules.in (working copy)
@@ -3,7 +3,7 @@
Priority: extra
Maintainer: Debian VoIP Team <pkg-voip-maintainers at lists.alioth.debian.org>
Uploaders: Kilian Krause <kk at verfaction.de>, Jose Carlos Garcia Sogo <jsogo at debian.org>, Mark Purcell <msp at debian.org>, Santiago Garcia Mantinan <manty at debian.org>, Santiago Ruano Rincon <santiago at unicauca.edu.co>
-Build-Depends: debhelper (>> 3.0.0)
+Build-Depends: debhelper (>> 3.0.0), bzip2
Standards-Version: 3.6.1.1
Package: zaptel-modules-_KVERS_
Index: debian/fxotune.8
===================================================================
--- debian/fxotune.8 (revision 0)
+++ debian/fxotune.8 (revision 0)
@@ -0,0 +1,66 @@
+.TH FXOTUNE 8 "September 10th, 2005" "Xorcom Rapid Asterisk" "Linux Programmer's Manual"
+.SH NAME
+.B fxotune
+\(em automatically tune FXO channels on a Digium TDM400 card
+.SH SYNOPSIS
+.B fxotune -i
+.I <dialstr>
+\(em detect
+
+.B fxotune -s
+\(em load settings
+
+.SH DESCRIPTION
+.B fxotune
+is a script that fine-tune parameters of the FXO modules of the TDM400
+card. Whene run in
+.I detect
+mode (-i) it detects and tunes all the FXO channels of such cards. It
+needs a dial string after which the line(s) will give dial tone.
+
+It writes settings to a configuration file (/etc/fxotune.conf , name
+is hardwired) from which it can be loaded (e.g: at startup) using -s .
+
+
+.SH OPTIONS
+.B -i
+.RS
+.I dialstr
+Start detecting optimal settings.
+.I dialstr
+Is a number needed to dial to get a dial tone.
+The test can take several minutes, and must be performed when Asterisk
+is not running.
+
+For example:
+.RS
+fxotune -i 9
+.RE
+if you need to dial 9 for an external line. If you always get a line, you
+can simply use any digit.
+.RE
+
+.B -s
+.RS
+Load settings from the last test. Used at startup.
+.RE
+
+.SH FILES
+.I /etc/fxotune.conf
+.RS
+The configuration file generated by fxotune in detect mode and from which
+configuration is loaded when
+.B -s
+is used.
+
+.SH SEE ALSO
+ztcfg(8), zttool(8), ztmonitor(8), asterisk(8).
+
+.SH AUTHOR
+This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL.
Index: debian/zaptel.install___
===================================================================
--- debian/zaptel.install___ (revision 764)
+++ debian/zaptel.install___ (working copy)
@@ -1,4 +1 @@
-etc/zaptel.conf
sbin
-usr/share/doc/zaptel/examples
-usr/share/lintian/overrides/zaptel
Index: debian/zttest.8
===================================================================
--- debian/zttest.8 (revision 0)
+++ debian/zttest.8 (revision 0)
@@ -0,0 +1,45 @@
+.TH zttest 8 "2005-06-25"
+.SH "NAME"
+zttest \(em Test if the zaptel timer provides timely response
+.SH "SYNOPSIS"
+.B zttest
+.I [ -v ]
+
+.SH "DESCRIPTION"
+.B zttest
+zttest runs a timing test in a loop and prints the result of each loop.
+The test is as follows:
+
+It reads 8192 bytes from the zaptel timer device (\fI/dev/zap/pseudo\fR).
+This should take exactly 8000 ms . It uses calls to
+.I gettimeofday(2)
+before and after that read to check that indeed exactly 8000ms have passed.
+
+Values of 100% and 99.99% Are normally considered a definite
+.I pass.
+Values of 99.98% and 99.97% are probably OK as well.
+
+.SH OPTIONS
+.B -v
+.RS
+Be more verbose: print one line per test.
+.RE
+
+.SH FILES
+.B /dev/zap/pseudo
+.RS
+.RE
+The device file used to access the zaptel timer.
+
+.SH SEE ALSO
+zttool(8), ztmonitor(8), ztspeed(8), ztcfg(8), asterisk(8). gettimeofday(2)
+
+.SH AUTHOR
+
+This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL.
Index: debian/genzaptelconf.8
===================================================================
--- debian/genzaptelconf.8 (revision 0)
+++ debian/genzaptelconf.8 (revision 0)
@@ -0,0 +1,186 @@
+.TH GENZAPTELCONF 8 "July 18th, 2005" "Xorcom Rapid Asterisk" "Linux Programmer's Manual"
+.SH "NAME"
+.B genzaptelconf
+-- generates zaptel configuration (TDM adaptors)
+.SH SYNOPSIS
+.PP
+.B genzaptelconf
+[-sdv] [-m k|l] [-c <country_code>] [-r |-e <base_exten>]
+
+.B genzaptelconf
+[-sdv] -l -- only list to standard output
+
+.B genzaptelconf
+-su -- only unload zaptel modules
+
+.B genzaptelconf
+-h -- Help screen
+
+.SH DESCRIPTION
+.B genzaptelconf
+is a script to detect zaptel devices (currently mostly TDM cards are
+supported). It generates both
+.I /etc/zaptel.conf
+and
+.I /etc/asterisk/zapata-channels.conf
+
+.I PRI
+and
+.I BRI
+(HFC, with ZapHFC) cards are basically identified as well. However the span
+configiration is a default that I only hope is sane. Looking for feedback
+
+.SH OPTIONS
+.B -c
+.I country_code
+.RS
+A two-letter country code. Sets the country-code for the zonezone
+entries in
+.I zaptel.conf
+, The default is the value of
+.I lc_country
+from
+.I /etc/default/zaptel
+and failing that, "us".
+.RE
+
+.B -d
+.RS
+Also try to detect modules. Unloads all zaptel modules and loads them
+one by one. Considers a module useful if it loaded successfully and if
+loading it has generated at least one zapata channel.
+
+The list of detected modules is written as the value of
+.I ZAPTEL_MODS
+in
+.I /etc/default/zaptel
+.RE
+
+.B -e
+.I base_exten_num
+.RS
+Configure channel
+.I i as extension
+.I exten_num
++
+.I i .
+This is mostly for the caller-id values. Crude, but may be good enough.
+See also
+.I -r
+.RE
+
+.B -l
+.RS
+Only list deceted channels and their signalling. Don't write
+configuration files. Note, however that
+.I -ld
+will still rewrite the modules line in
+.I /etc/default/zaptel
+(see
+.I -d
+above).
+.RE
+
+.B -m k|l
+.RS
+Sets the signalling mode: Kewlstart or Loopstart. By default the
+signalling mode is ks for any country other than Israel (il), where it is
+ls .
+
+Alternatively set the value of
+.I method
+in
+.I /etc/default/zaptel
+.RE
+
+.B -r
+.RS
+Try to guess a useful
+.I zapata-channels
+configuration for Xorcom Rapid .
+.RE
+
+.B -s
+.RS
+Stop asterisk for the duration of the test. The detection will only
+work if nobody uses the zaptel channels:
+
+* To allow unloading of modules
+
+* to allow reading configuration files.
+
+By default the script will check if asterisk is running and alert if so.
+This option tells the script to stop asterisk (if it was running) and to
+try to start it after the end of the test.
+.RE
+
+.B -v
+.RS
+Be verbose. lists the detected modules if
+.I -d
+is used. Lists detected channls. In the end tries to connect to asterisk
+to get a list of configured zaptel channels.
+.RE
+.SH FILES
+.I /etc/zaptel.conf
+.RS
+The configuration file used by
+.I ztcfg
+to configure zaptel devices. re-written by
+.I genzaptelconf
+.RE
+
+.I /etc/zaptel.conf.bak
+.RS
+When
+.I zaptel.conf
+The original zaptel.conf
+.RE
+
+.I /etc/asterisk/zapata.conf
+.RS
+The configuration file of Asterisk's
+.I chan_zap.
+Not modified directly by
+.I genzaptelconf.
+If you want genzaptelconf's setting to take effect, add the following line at the end of
+.I zapata.conf:
+.RS
+#include "zapata-channels.conf"
+.RE
+.RE
+
+.I /etc/asterisk/zapata-channels.conf
+.RS
+This is the snippet of
+.I chan_zap
+configuration file that
+.I genzaptelconf generates.
+.RE
+
+.I /etc/asterisk/zapata-channels.conf.bak
+.RS
+The backup copy of
+.I zapata-channels.conf
+.RE
+
+.I /etc/default/zaptel
+.RS
+This file holds configuration for both
+.I genzaptelconf
+and
+.I /etc/init.d/zaptel
+ .
+.RE
+
+.SH "SEE ALSO"
+ztcfg(8) asterisk(8).
+
+.SH "AUTHOR"
+This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL.
Index: debian/README.Debian
===================================================================
--- debian/README.Debian (revision 764)
+++ debian/README.Debian (working copy)
@@ -22,5 +22,15 @@
Please, read README.udev for more info about this topic.
+
+Bristuff
+--------
+Currently disabled until we have a version for HEAD.
+
+
+fxotune
+-------
+See README.fxotune. Still needs to be integrated into the init.d script.
+
-- Debian VoIP Team <pkg-voip-maintainers at lists.alioth.debian.org>
--- 26th March 2005
+-- 13th September 2005
More information about the Pkg-voip-maintainers
mailing list