You are not logged in.

#1 2005-03-29 22:08:00

Michel
Member
From: Belgium
Registered: 2004-07-31
Posts: 286

[updated] zaptel-drivers

PKGBUILD:

pkgname=zaptel
pkgver=1.2.0
pkgrel=1
pkgdesc="Zapata Telephony Interface Driver"
url="http://asterisk.org/"
license="GPL"
#source of the kernel is required
source=(http://ftp.digium.com/pub/zaptel/$pkgname-$pkgver.tar.gz 
        Makefile-zaptel.patch 
        zaptel.install)
install=zaptel.install
depends=('coreutils')
md5sums=('4d9dc3afbe7e61c557115bd5442d3e5e' '6b67d1b91739a4b3da86e1ce7d075547' 
     '40a714812c705cff6c89a5e7f6477552')

build() {
  cd $startdir/src/$pkgname-$pkgver

  #patch enables ztdummy-driver, removes code that belongs in the zaptel.install-file <-- install-file-remove...: deleting to much - alias chat-major-196?
  patch Makefile $startdir/src/Makefile-zaptel.patch
  
  #compile-time-options to enable? MMX, ...
  make || return 1
  make INSTALL_PREFIX=$startdir/pkg install
}

Makefile-zaptel.patch:

--- Makefile    2005-11-16 19:09:29.000000000 +0100
+++ Makefile-new    2005-11-25 19:58:52.000000000 +0100
@@ -4,6 +4,8 @@
 # Copyright (C) 2001-2005 Digium, Inc.
 #
 #
+
+#change BASEADDR in the zaptel.install-file
 BASEADDR=0xd0000
 
 HOSTCC=gcc
@@ -100,9 +102,9 @@
          ztd-loc # ztdummy
 #MODULES+=wcfxsusb
 # build ztdummy by default for 2.6 kernels
-ifeq (${BUILDVER},linux26)
+#ifeq (${BUILDVER},linux26)
 MODULES+=ztdummy
-endif
+#endif
 MODULESO:=$(MODULES:%=%.o)
 MODULESKO:=$(MODULES:%=%.ko)
 
@@ -112,7 +114,8 @@
 BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
 
 #PRIMARY=wcfxsusb
-PRIMARY=torisa
+#change PRIMARY in the zaptel.install-file
+#PRIMARY=torisa
 #PRIMARY=wcfxo
 PWD:=$(shell pwd)
 
@@ -325,50 +328,50 @@
         rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxs.o; 
     fi
     install -D -m 755 $(LIBTONEZONE_SO) $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER).$(LIBTONEZONE_SO_MINOR_VER)
-    [ `id -u` = 0 ] && /sbin/ldconfig || :
-    rm -f $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO)
+    #[ `id -u` = 0 ] && /sbin/ldconfig || :
+    #rm -f $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO)
     ln -sf $(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER) $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO)
     if [ -x /usr/sbin/sestatus ] && (/usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled") ; then restorecon -v $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO); fi
     install -D -m 644 zaptel.h $(INSTALL_PREFIX)/usr/include/linux/zaptel.h
     install -D -m 644 torisa.h $(INSTALL_PREFIX)/usr/include/linux/torisa.h
     install -D -m 644 tonezone.h $(INSTALL_PREFIX)/usr/include/tonezone.h
-    install -m 644 doc/ztcfg.8 $(INSTALL_PREFIX)/usr/share/man/man8
-    install -m 644 doc/zttool.8 $(INSTALL_PREFIX)/usr/share/man/man8
-    if [ -n "$(MODCONF)" ]; then 
-        if [ -f $(MODCONF) ]; then mv -f $(MODCONF) $(MODCONF).bak ; fi; 
-        cat $(MODCONF).bak | grep -v "alias char-major-250" | 
-        grep -v "post-install torisa /sbin/ztcfg" | 
-        grep -v "post-install wcfxsusb /sbin/ztcfg" | 
-        grep -v "alias wctdm" | 
-        grep -v "post-install wctdm /sbin/ztcfg" > $(MODCONF); 
-        if ! grep "options torisa" $(MODCONF); then 
-            echo "options torisa base=$(BASEADDR)" >> $(MODCONF); 
-        fi; 
-        if ! grep "alias char-major-196" $(MODCONF); then 
-            echo "alias char-major-196 $(PRIMARY)" >> $(MODCONF); 
-        fi; 
-        for x in $(MODULES); do 
-            if ! grep -q "post-install $$x" $(MODCONF); then 
-                if ! grep -q "install $$x " $(MODCONF); then 
-                    if [ "$$x" != "zaptel" ] ; then 
-                        if [ -f zaptel.ko ]; then echo "install $$x /sbin/modprobe --ignore-install $$x && /sbin/ztcfg" >> $(MODCONF); 
-                        else echo "post-install $$x /sbin/ztcfg" >> $(MODCONF); 
-                        fi; 
-                    fi; 
-                fi; 
-            fi; 
-        done; 
-        if ! grep "ias wcfxs" $(MODCONF); then 
-            echo "alias wcfxs wctdm" >> $(MODCONF); 
-        fi; 
-        if ! grep "alias wct2xxp" $(MODCONF); then 
-            echo "alias wct2xxp wct4xxp" >> $(MODCONF); 
-        fi; 
-    fi
-    if [ -d /etc/modutils ]; then 
-        /sbin/update-modules ; 
-    fi
-    [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
+    install -D -m 644 doc/ztcfg.8 $(INSTALL_PREFIX)/usr/share/man/man8/ztcfg.8
+    install -D -m 644 doc/zttool.8 $(INSTALL_PREFIX)/usr/share/man/man8/zttool.8
+    #if [ -n "$(MODCONF)" ]; then 
+    #    if [ -f $(MODCONF) ]; then mv -f $(MODCONF) $(MODCONF).bak ; fi; 
+    #    cat $(MODCONF).bak | grep -v "alias char-major-250" | 
+    #    grep -v "post-install torisa /sbin/ztcfg" | 
+    #    grep -v "post-install wcfxsusb /sbin/ztcfg" | 
+    #    grep -v "alias wctdm" | 
+    #    grep -v "post-install wctdm /sbin/ztcfg" > $(MODCONF); 
+    #    if ! grep "options torisa" $(MODCONF); then 
+    #        echo "options torisa base=$(BASEADDR)" >> $(MODCONF); 
+    #    fi; 
+    #    if ! grep "alias char-major-196" $(MODCONF); then 
+    #        echo "alias char-major-196 $(PRIMARY)" >> $(MODCONF); 
+    #    fi; 
+    #    for x in $(MODULES); do 
+    #        if ! grep -q "post-install $$x" $(MODCONF); then 
+    #            if ! grep -q "install $$x " $(MODCONF); then 
+    #                if [ "$$x" != "zaptel" ] ; then 
+    #                    if [ -f zaptel.ko ]; then echo "install $$x /sbin/modprobe --ignore-install $$x && /sbin/ztcfg" >> $(MODCONF); 
+    #                    else echo "post-install $$x /sbin/ztcfg" >> $(MODCONF); 
+    #                    fi; 
+    #                fi; 
+    #            fi; 
+    #        fi; 
+    #    done; 
+    #    if ! grep "ias wcfxs" $(MODCONF); then 
+    #        echo "alias wcfxs wctdm" >> $(MODCONF); 
+    #    fi; 
+    #    if ! grep "alias wct2xxp" $(MODCONF); then 
+    #        echo "alias wct2xxp wct4xxp" >> $(MODCONF); 
+    #    fi; 
+    #fi
+    #if [ -d /etc/modutils ]; then 
+    #    /sbin/update-modules ; 
+    #fi
+    #[ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
     [ -f $(CONFIG_FILE) ] || install -D -m 644 zaptel.conf.sample $(CONFIG_FILE)
 
 install-udev:

zaptel.install:

# This is a default template for a post-install scriptlet.  You can
# remove any functions you don't need (and this header).

# arg 1:  the new package version
pre_install() {
  /bin/true
}

# arg 1:  the new package version
post_install() {
      #info about which driver to use with which card: http://www.voip-info.org/wiki-Asterisk+Zaptel+Installation
      declare -r local MODCONF=$(getModconf);
  
      addToModconf $MODCONF;
      
      if [ -d /etc/modutils ]; then
             echo -n "running update-modules ...";
             /sbin/update-modules ;
             echo "done";
      fi
      
      echo -n "running depmod -a ..."
      /sbin/depmod -a || /bin/false;
     echo "done";
     
     infoMessage;
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {

 declare -r local MODCONF=$(getModconf);

 removeFromModconf $MODCONF;
 addToModconf $MODCONF;

 if [ -d /etc/modutils ]; then 
     echo -n "running update-modules ...";
     /sbin/update-modules ;
     echo "done";
 fi
 echo -n "running depmod -a ...";
 /sbin/depmod -a || /bin/false;
 echo "done";

 infoMessage;
}

# arg 1:  the old package version
pre_remove() {
  /bin/true
}

# arg 1:  the old package version
post_remove() {
  declare -r local MODCONF=$(getModconf);

  removeFromModconf $MODCONF;

  if [ -d /etc/modutils ]; then
     echo -n "running update-modules ...";
     /sbin/update-modules ;
     echo "done";
  fi

  echo -n "running depmod -a ...";
  /sbin/depmod -a || /bin/false;
  echo "done";
}

#######################################

getModconf() {
    local ROOT_PREFIX="";
    
    echo $(if [ -d $ROOT_PREFIX/etc/modprobe.d ]; then echo "$ROOT_PREFIX/etc/modprobe.d/zaptel"; elif [ -d $ROOT_PREFIX/etc/modutils ]; then echo "$ROOT_PREFIX/etc/modutils/zaptel"; elif [ -f $ROOT_PREFIX/etc/modprobe.conf ]; then echo "$ROOT_PREFIX/etc/modprobe.conf"; elif [ -f $ROOT_PREFIX/etc/modules.conf ]; then echo "$ROOT_PREFIX/etc/modules.conf"; else echo $ROOT_PREFIX/etc/conf.modules ; fi);
    
    return 0;
}

# parallell modifications to /etc/modprobe.conf can cause inconsistencies! (executing pacman in parallell is not possible at the moment, but maybe in the future: file-locks - posix?).
# arg 1:    location of MODCONF
removeFromModconf() {
    declare -r local MODCONF=$1;
    
    if [ -f $MODCONF ]; then mv -f $MODCONF $MODCONF.bak ; fi
    #can "alias chat-major-196" conflict with other settings?
    cat $MODCONF.bak | grep -v "install torisa"  | grep -v "options torisa" | grep -v "alias char-major-196"  | grep -v "install tor2"  | 
      grep -v "install wcusb" | grep -v "install wcfxo" | grep -v "install wcfxs" | grep -v "install ztdynamic" | grep -v "install ztd-eth" | 
      grep -v "install wct1xxp" | grep -v "install wct4xxp" | grep -v "install wcte11xp" | grep -v "install ztdummy" | 
      grep -v "alias wctdm" | grep -v "alias wct2xxp" | grep -v "#zaptel" > $MODCONF || true
    
    rm -f $MODCONF.bak;

    return 0;
}

# arg 1: location of MODCONF
addToModconf() {
    declare -r local MODCONF=$1;
    declare -r local BASEADDR=0xd0000;
    #PRIMARY=torisa/wcfxsusb/wcfx - made ztdummy default
    declare -r local PRIMARY=ztdummy;
    #uncommented ztdummy to allow conferencing with ztdummy as timer
    local MODULES="zaptel tor2 torisa wcusb wcfxo wcfxs 
            ztdynamic ztd-eth wct1xxp wct4xxp wcte11xp ztdummy"
    #MODULES+=wcfxsusb

    echo "#zaptel" >> $MODCONF;
    if ! grep "options torisa" $MODCONF; then
        echo "options torisa base=$BASEADDR" >> $MODCONF;
    fi

    #Is this only for < 2.6.x-kernels?
    if ! grep "alias char-major-196" $MODCONF; then
           echo "alias char-major-196 $PRIMARY" >> $MODCONF;
    fi

    #Is this only for 2.6.x-kernel? $$x? install is always chosen?
    for x in $MODULES; do
        if ! grep "post-install $x" $MODCONF; then
            if ! grep "install $x " $MODCONF; then
                if [ "$x" != "zaptel" ] ; then 
                    if [ -f /lib/modules/`uname -r`/misc/zaptel.ko ]; then echo "install $x /sbin/modprobe zaptel; /sbin/modprobe --ignore-install $x && /sbin/ztcfg" >> $MODCONF;
                    else echo "post-install $x /sbin/ztcfg" >> $MODCONF;
                    fi;
                fi;
            fi;
        fi;
    done

    if ! grep "alias wctdm" $MODCONF; then 
           echo "alias wctdm wcfxs" >> $MODCONF; 
    fi
    if ! grep "alias wct2xxp" $MODCONF; then 
           echo "alias wct2xxp wct4xxp" >> $MODCONF; 
    fi

    return 0;
}

infoMessage() {
    if [[ ! $(echo $(/bin/uname -r) | cut -s -d "-" -f 1 -) < 2.5 ]]; then

        echo "==> Add these lines to your udev-configuration-file and change PBX-user to the user that has to access the zaptel device(s):";
        echo "
# Section for zaptel device
KERNEL="zapctl",     NAME="zap/ctl", GROUP="PBX-user", MODE="0770"
KERNEL="zaptimer",   NAME="zap/timer", GROUP="PBX-user", MODE="0770"
KERNEL="zapchannel", NAME="zap/channel", GROUP="PBX-user", MODE="0770"
KERNEL="zappseudo",  NAME="zap/pseudo", GROUP="PBX-user", MODE="0770"
KERNEL="zap[0-9]*",  NAME="zap/%n", GROUP="PBX-user", MODE="0770"

"   

    fi

    return 0;
}

op=$1
shift
$op $*

Offline

#2 2005-08-12 20:49:13

Michel
Member
From: Belgium
Registered: 2004-07-31
Posts: 286

Re: [updated] zaptel-drivers

No enhancements to the scripts, only an update to 1.0.9.1

Offline

#3 2005-09-17 12:19:19

Michel
Member
From: Belgium
Registered: 2004-07-31
Posts: 286

Re: [updated] zaptel-drivers

Heya,

I update this package to 1.0.9.2, update the Makefile-zaptel.patch and made some enhancements to the install-file: better removal code (alias char-major-196 -> not removing too much), updates to the AddToConf-operations, ... If another operation is editing the same file (modprobe.conf/modules.conf/...) as the removal-operation is happening, then it is possible that the file is not updated as intended.

greetings,

Michel

Offline

#4 2005-11-25 22:53:53

Michel
Member
From: Belgium
Registered: 2004-07-31
Posts: 286

Re: [updated] zaptel-drivers

update to 1.2.0

Offline

Board footer

Powered by FluxBB