wct4xxp: Moving the transmit short detection behind debug module param.

This needs some more testing before it's on by default.  If the card is
otherwise functioning, these messages may be confusing to the user.  If
the card is not functioning, the driver can be reloaded with debug to
check for this condition.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9205 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Shaun Ruffell
2010-08-27 21:59:27 +00:00
commit bf3fe05dfb
265 changed files with 190229 additions and 0 deletions

168
build_tools/builder Executable file
View File

@@ -0,0 +1,168 @@
#!/bin/sh
# build_test - a build testing script
#
# Copyright (C) 2008 by Xorcom <support@xorcom.com>
#
# 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
#
# Setup:
#
# 0. Copy this script under build_tools/ and
#
# chmod +x build_tools/builder
#
# 1. Make sure you have git and sqlite3 installed. If the sqlite3 binary
# is called differently, fix the line "SQLITE=" in the script or in
# build_tools/test_build.conf .
#
# 2. Run:
#
# ./build_tools/test_kernel_git init /path/to/some/dir
#
# /path/to/some/dir must exist . This will download a recent kernel
# git repository to /path/to/some/dir/linux-2.6 . Use
# './build_tools/test_kernel_git update' to pull a fresh update there.
#
# 3. Run:
#
# ./build_tools/builder init
#
#
# Usage:
#
# ./build_tools build
#
# The past results are in a sqlite database in the logs subdirectory. For
# a simple list of results:
#
# ./build_tools report
#
# You can also look at the build log for a specific build in the logs
# directory.
BIN_DIR=`dirname $0`
BASE_DIR=`dirname $BIN_DIR`
SQLITE=sqlite3
HOSTS="localhost"
LOGS_DIR="$BASE_DIR/logs"
DB=$LOGS_DIR/builds.db
BUILD_SCRIPT=$BIN_DIR/test_kernel_git
KERNELS_localhost="2.6.12 2.6.18 2.6.25"
usage() {
me=`basename $0`
echo "$me: test building Zaptel/DAHDI with various kernels"
echo ""
echo "Usage: $0 command <optional parameters>"
echo " init Create results directory and database."
echo " build [<kernels>] Run the test builds. The default list: "
echo " $KERNELS_localhost"
echo " report [<filter>] Print all results [matching <filter>]"
echo " Default is to print all the resaults."
echo ""
echo "Filters:"
echo " failed: Only failed tests."
echo " fail_type <type> Where fail_type matches <type>."
echo " 2.6* Only builds for a matching kernel version."
echo " Else: Match a string from the build name, which "
echo " is essentially the time it started."
echo ""
}
set -e
if [ -r $BIN_DIR/test_build.conf ]; then . $BIN_DIR/test_build.conf; fi
# Runs the test script, logs the result, and fails if the test command
# has failed.
build_and_check() {
test_name="$1"
test_cmd="$2"
log_file="$3"
results_str="$4"
fail_type=''
set +e
$BUILD_SCRIPT $test_cmd >$log_file 2>&1
rc=$?
set -e
if [ $rc != 0 ]; then
fail_type="$test_name"
echo "$results_str, $rc, '$fail_type', '$log_file');" | $SQLITE $DB
fi
return $rc
}
build_zaptel() {
build_name="$1"
host="$2"
kvers="$3"
log_base="build__${build_name}__${host}__${kvers}"
log_base_full="$LOGS_DIR/$log_base"
log_file="$log_base_full.log"
results_str="INSERT INTO results VALUES ('$build_name', '$host', '$kvers'"
# Due to 'set -e' a failed test exists the script.
build_and_check setver "setver $kvers" "$log_file" "$results_str"
build_and_check clean "test clean" "$log_file" "$results_str"
build_and_check build "build" "$log_file" "$results_str"
# If we got here, all was well.
echo "$results_str, 0, 'complete', '$log_file');" | $SQLITE $DB
}
case "$1" in
init)
mkdir -p $LOGS_DIR
cat <<EOF | $SQLITE $DB
CREATE TABLE runs(name TEXT PRIMARY KEY, time INTEGER DEFAULT CURRENT_TIMESTAMP, driver_ver TEXT);
CREATE TABLE results(name TEXT, system TEXT, kvers TEXT, result INTEGER, fail_type TEXT, log TEXT);
EOF
mkdir -p $LOGS_DIR
;;
build)
cd $BASE_DIR
shift
if [ "$*" != '' ]; then KERNELS_localhost="$*"; fi
driver_ver=`$BUILD_SCRIPT version_driver`
build_name=`date '+%Y%m%d-%H%M%si'`
echo "INSERT INTO runs (name, driver_ver) VALUES ('$build_name', '$driver_ver');" | $SQLITE $DB
for host in $HOSTS; do
eval kernels="\$KERNELS_$host"
for kvers in $kernels; do
build_zaptel $build_name $host $kvers
done
done
;;
report)
case "$2" in
'') where='1=1' ;;
failed) where='result != 0' ;;
fail_type) where="fail_type like \"%$3%\"" ;;
2.6*) where="kvers like \"$2%\"" ;;
*) where="name like \"%$2%\"" ;;
esac
echo "select * from results where $where;" | $SQLITE $DB
;;
*)
usage
echo >&2 "$0: Unknown command '$1'. Aborting."
exit 1
esac

80
build_tools/genmodconf Executable file
View File

@@ -0,0 +1,80 @@
#!/bin/sh
# this script makes an attempt to build a proper set of rules
# for loading the DAHDI modules and automatically running dahdi_xcfg
#
# it accepts two parameters:
# the root prefix to be used for finding/creating the files
# the list of module names being installed
#
# the process is as follows:
#
# the file can be located at /etc/modprobe.conf (combined with all
# other rules), /etc/modprobe.d/dahdi (DAHDI only) or /etc/modules.d/dahdi
# (DAHDI only)
#
# when the file is DAHDI rules only, then we don't preserve the existing
# contents of the file; the system administrator can put desired options and
# overrides in a separate file with a name that appears earlier in the sort
# order, so there is no need to edit the file produced by this script
#
# when the file is combined with all other rules, then we make a backup
# of it and remove all the old DAHDI rules we can find, replacing them with
# new ones
#
# in addition, versions of module-init-tools 3.2.0 and later
# have the ability to pass module parameters specified on the modprobe command
# line to commands in 'install' rules, thus keeping them from being lost, so
# we try to determine what version is installed and take advantage of that
toolver=`/sbin/modprobe --version 2>/dev/null| awk '{print $3}' | cut -d. -f2 | cut -d- -f1`
if [ ${toolver} -ge 2 ]; then
cmdopts=\$CMDLINE_OPTS
fi
if [ -d ${1}/etc/modprobe.d ]; then
target=${1}/etc/modprobe.d/dahdi
elif [ -d ${1}/etc/modules.d ]; then
target=${1}/etc/modules.d/dahdi
elif [ -f ${1}/etc/modprobe.conf ]; then
target=${1}/etc/modprobe.conf
combined=1
elif [ -f ${1}/etc/conf.modules ]; then
target=${1}/etc/conf.modules
combined=1
else
echo No suitable location for module rules can be found... exiting.
exit 1
fi
if [ -n "${combined}" ]; then
if [ -f ${target} ]; then
mv ${target} ${target}.bak
cat ${target}.bak | grep -v "alias char-major-250" | grep -v "alias char-major-196" > ${target}
fi
else
if [ -f ${target} ]; then
mv ${target} ${target}.bak
fi
echo "# automatically generated file; do not edit" > ${target}
fi
echo Building ${target}...
for mod in ${2}; do
if ! grep -q "install ${mod} " ${target}; then
echo "install ${mod} /sbin/modprobe --ignore-install ${mod} ${cmdopts} && /sbin/ztcfg" >> ${target}
fi
done
if [ -z "${combined}" ]; then
echo "***"
echo "*** WARNING:"
echo "*** If you had custom settings in ${target},"
echo "*** they have been moved to ${target}.bak."
echo "***"
echo "*** In the future, do not edit ${target}, but"
echo "*** instead put your changes in another file"
echo "*** in the same directory so that they will not"
echo "*** be overwritten by future DAHDI updates."
echo "***"
fi

40
build_tools/genudevrules Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/sh
ver=`udevinfo -V | cut -f3 -d" "`
if [ -z "${ver}" ]; then
# Not found - try udevadm
ver=`udevadm info -V | cut -f3 -d" "`
if [ -z "${ver}" ]; then
# nobody has that old version, anyway.
ver=54
fi
fi
# udev versions prior to 055 use a single '=' for matching key values
# udev versions 055 and later support '==' for that purpose, and versions
# beyond 092 will probably make it mandatory
#
# very old versions of udev required naming rules and permissions rules to be
# in separate files, but it's not clear at what version number that changed
if [ ${ver} -gt 54 ]; then
match="=="
else
match="="
fi
cat <<EOF
# udev rules to generate the /dev/dahdi device files (if not yet provided
# by your distribution):
KERNEL${match}"dahdictl", NAME="dahdi/ctl"
KERNEL${match}"dahditranscode", NAME="dahdi/transcode"
KERNEL${match}"dahditimer", NAME="dahdi/timer"
KERNEL${match}"dahdichannel", NAME="dahdi/channel"
KERNEL${match}"dahdipseudo", NAME="dahdi/pseudo"
KERNEL${match}"dahdi[0-9]*", NAME="dahdi/%n"
# DAHDI devices with ownership/permissions for running as non-root
SUBSYSTEM${match}"dahdi", OWNER="asterisk", GROUP="asterisk", MODE="0660"
EOF

48
build_tools/kernel-cp Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/sh
# A simple wrapper to the kernel.org script checkpatch.pl
# Usage:
#
# svn diff | ./build_tools/kernel-cp -
# ./build_tools/kernel-cp my.diff
# ./build_tools/kernel-cp --file drivers/dahdi/wctdm.c
mydir=`dirname $0`
check_patch_dir="$mydir/cp"
rel_path="scripts/checkpatch.pl"
check_patch="$mydir/checkpatch.pl"
URL='http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=scripts/checkpatch.pl;hb=HEAD'
# Required files in directories in the tree
SUBDIRS="fs ipc lib arch init scripts drivers kernel Documentation include"
set -e
if [ "$1" = 'download' ]; then
if [ -x "$check_patch" ]; then
exit 0
fi
wget -O "$check_patch" "$URL"
if [ `wc -c <"$check_patch"` -lt 1000 ]; then
# already downloaded
# FIXME: redirection fails on downloading and you get a
# short HTML file as your "script".
echo >&2 "$0: Error: Download failed".
exit 1
fi
chmod +x "$check_patch"
exit 0
fi
if [ ! -x "$check_patch" ]; then
echo >&2 "Script $check_patch not found. Download it?"
echo >&2 ""
echo >&2 " $0 download"
exit 1
fi
exec $check_patch --no-tree --no-signoff "$@"

63
build_tools/kernel-doc Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/sh
# a wrapper to kernel-doc from the kernel source tree
#
# Copyright (C) 2009 by Xorcom <support@xorcom.com>
#
# 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
# For 'man' version: build_tools/kernel-doc -f man | man -l -
files="drivers/dahdi/dahdi-base.c"
format="html"
kernel="/lib/modules/`uname -r`/build"
usage() {
me=`basename $0`
cat <<EOF
$me: wrapper around the kernel's kernel-doc script
Extracts kernel-doc from $files .
$me [options]
Options:
-f --format: Alternative output format (man, text, docbook. Default: html)
-k --kernel: kernel source tree. Default: $kernel .
EOF
}
options=`getopt -o f:hk: --long format:,help,kernel: -- "$@"`
if [ $? != 0 ] ; then echo >&2 "Terminating..." ; exit 1 ; fi
eval set -- "$options"
while true ; do
case "$1" in
-f|--format) format="$2"; shift ;;
-h|--help) usage; exit 0;;
-k|--kernel) kernel="$2"; shift ;;
--) shift ; break ;;
esac
shift;
done
if [ "$*" != '' ]; then
files="$*" #FIXME: spaces
fi
script="$kernel/scripts/kernel-doc"
$script -$format $files

323
build_tools/live_dahdi Executable file
View File

@@ -0,0 +1,323 @@
#!/bin/sh
LINUX_DIR=${LINUX_DIR:=.}
TOOLS_DIR=${TOOLS_DIR:=../dahdi-tools}
DYNAMIC_LOC="${DYNAMIC_LOC:-no}"
DESTDIR=$PWD/live
KVERS=${KVERS:-`uname -r`}
XPP_SYNC=${XPP_SYNC:-auto}
AST_SCRIPT=${AST_SCRIPT:-/etc/init.d/asterisk}
# Use this file to pass options to modules:
PERLLIBDIR=`perl -V:sitelib | cut -d "'" -f 2`
EXTRA_MODS="crc_ccitt"
# Manual list of modules. They will be loaded by insmod.
# If reside in a subdir, add it explicitly.
MODULES_LOAD="${MODULES_LOAD:-dahdi dahdi_echocan_mg2}"
# this one *is* resolved recusively.
# the only reason to set a different value is if you use hpec / oslec,
# as Zaptel depends on them.
REMOVE_MODULES="${REMOVE_MODULES:-dahdi}" # "dahdi oslec"?
if [ -r $DESTDIR/live.conf ]; then . $DESTDIR/live.conf; fi
MODULES_DIR="$DESTDIR/lib/modules/$KVERS/dahdi"
if [ ! -d "$LINUX_DIR" ]; then
echo >&2 "$0:dahdi-linux dir '$LINUX_DIR' does not exits. Aborting".
exit 1
fi
if [ ! -d "$TOOLS_DIR" ]; then
echo >&2 "$0:dahdi-tools dir '$TOOLS_DIR' does not exits. Aborting".
exit 1
fi
set -e
LINUX_DIR_FULL=`(cd $LINUX_DIR; pwd)`
TOOLS_DIR_FULL=`(cd $TOOLS_DIR; pwd)`
# Give priority to our installed binaries:
PATH=$DESTDIR/sbin:$DESTDIR/usr/sbin:$PATH
export PATH
# TODO: If you already use PERL5DIR, please fix this part:
PERL5LIB="$DESTDIR/$PERLLIBDIR"
export PERL5LIB
# used in xpp_fxloader:
FIRMWARE_DIR="$DESTDIR/usr/share/dahdi"
export FIRMWARE_DIR
ASTRIBANK_TOOL="$DESTDIR/usr/sbin/astribank_tool"
export ASTRIBANK_TOOL
ASTRIBANK_HEXLOAD="$DESTDIR/usr/sbin/astribank_hexload"
export ASTRIBANK_HEXLOAD
# make sure Astribank initialization scripts are from our tree.
xpp_ARGS="$xpp_ARGS initdir=$FIRMWARE_DIR"
#dahdi_ARGS="$dahdi_ARGS initdir=$FIRMWARE_DIR"
if [ "$DYNAMIC_LOC" = 'yes' ]; then
MODULES_LOAD="$MODULES_LOAD dahdi_dynamic dahdi_dynamic_loc"
fi
# the same as xpp/utils/dahdi_drivers .
# With the remote mode, I can't rely on files in the source directory.
dahdi_drivers() {
perl -MDahdi::Hardware -e '
my @drivers = Dahdi::Hardware->drivers;
print join(" ", @drivers);
'
}
# Add modules for existing hardware on the system for the list of
# modules to load.
#
# As module loading is manual with insmod, some manual fixes are needed.
set_modules_to_load() {
for mod in `dahdi_drivers`; do
case "$mod" in
xpp_usb)
MODULES_LOAD="$MODULES_LOAD xpp/xpp xpp/xpd_fxs"
MODULES_LOAD="$MODULES_LOAD xpp/xpd_fxo xpp/xpd_pri"
if [ -r "$MODULES_DIR/xpp/xpd_bri.ko" ]; then
MODULES_LOAD="$MODULES_LOAD xpp/xpd_bri"
fi
MODULES_LOAD="$MODULES_LOAD xpp/xpp_usb"
;;
wctdm24xxp | wcte12xp)
# FIXME: better automation of the voicebus
# dependency:
MODULES_LOAD="$MODULES_LOAD voicebus/dahdi_voicebus $mod/$mod"
EXTRA_MODS="$EXTRA_MODS firmware_class"
;;
wct4xxp | wcte12xp | wctc4xp | wcb4xxp)
MODULES_LOAD="$MODULES_LOAD $mod/$mod"
;;
wanpipe)
: # requires different handling
;;
*)
MODULES_LOAD="$MODULES_LOAD $mod"
;;
esac
done
}
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
# intended to replace all the the three functions below if user has
# installed the dahdi-perl utilities.
xpp_startup() {
# do nothing if there are no astribank devices:
if ! grep -q connected /proc/xpp/xbuses 2>/dev/null; then return 0; fi
echo "Waiting for Astribank devices to initialize:"
"$FIRMWARE_DIR/waitfor_xpds" # Asusmes a recent dahdi-tools
# overriding locales for the above two, as perl can be noisy
# when locales are missing.
# No register all the devices if they didn't auto-register:
LC_ALL=C dahdi_registration on
# this one could actually be run after dahdi_cfg:
LC_ALL=C xpp_sync "$XPP_SYNC"
}
# recursively unload a module and its dependencies, if possible.
# where's modprobe -r when you need it?
# inputs: module to unload.
# returns: the result from
unload_module() {
module="$1"
line=`lsmod 2>/dev/null | grep "^$1 " || :`
if [ "$line" = '' ]; then return; fi # module was not loaded
set -- $line
# $1: the original module, $2: size, $3: refcount, $4: deps list
mods=`echo $4 | tr , ' '`
ec_modules=""
# xpp_usb keeps the xpds below busy if an xpp hardware is
# connected. Hence must be removed before them:
case "$module" in xpd_*) mods="xpp_usb $mods";; esac
for mod in $mods; do
case "$mod" in
dahdi_echocan_*)
ec_modules="$mod $ec_modules"
;;
*)
# run in a subshell, so it won't step over our vars:
(unload_module $mod)
;;
esac
done
# Now that all the other dependencies are unloaded, we can unload the
# dahdi_echocan modules. The drivers that register spans may keep
# references on the echocan modules before they are unloaded.
for mod in $ec_modules; do
(unload_module $mod)
done
rmmod $module
}
load_dynamic() {
if [ "$DYNAMIC_LOC" != yes ]; then return; fi
local conf_file="$DESTDIR/etc/dahdi/dynamic.conf"
if [ ! -r "$conf_file" ]; then
cat <<EOF >"$conf_file"
dynamic=loc,1:0,5,0
dynamic=loc,1:1,5,0
EOF
fi
dahdi_cfg -c "$conf_file"
}
unload_dynamic() {
if [ "$DYNAMIC_LOC" != yes ]; then return; fi
local conf_file="$DESTDIR/etc/dahdi/dynamic.conf"
if [ ! -r "$conf_file" ]; then return; fi
dahdi_cfg -c "$conf_file" -s || :
}
genconf() {
GENCONF_PARAMETERS=$DESTDIR/etc/dahdi/genconf_parameters \
DAHDI_CONF_FILE=$DESTDIR/etc/dahdi/system.conf \
DAHDI_MODS_FILE=$DESTDIR/etc/dahdi/modules \
CHAN_DAHDI_CHANNELS_FILE=$DESTDIR/etc/asterisk/dahdi-channels.conf \
dahdi_genconf
if [ "$DYNAMIC_LOC" = yes ]; then
cat "$DESTDIR/etc/dahdi/dynamic.conf" >>"$DESTDIR/etc/dahdi/system.conf"
fi
dahdi_cfg -c $DESTDIR/etc/dahdi/system.conf
# TODO: fxotune, hpec
}
run_asterisk() {
$AST_SCRIPT start
}
usage() {
me=`basename $0`
echo "$me: Run DAHDI in a test environment"
echo 'Version: $Id$'
echo ''
echo "Usage: equivalent of:"
echo "$me configure ./configure"
echo "$me install make install"
echo "$me config make config"
echo "$me unload /etc/init.d/dahdi stop"
echo "$me load /etc/init.d/dahdi start"
echo "$me reload /etc/init.d/dahdi restart"
echo "$me xpp-firm (Reset and load xpp firmware)"
echo "$me genconf dahdi_genconf; dahdi_cfg"
echo "$me asterisk /etc/init.d/asterisk start"
echo "$me rsync TARGET (copy filea to /tmp/live in host TARGET)"
echo "$me exec COMMAND (Run COMMAND in 'live' environment)"
echo ""
echo "dahdi-linux: $LINUX_DIR"
echo "dahdi-tools: $TOOLS_DIR"
}
case "$1" in
configure)
shift
cd "$TOOLS_DIR"; ./configure --with-dahdi="$LINUX_DIR_FULL" "$@"
;;
install)
shift
cd "$LINUX_DIR"; make install DESTDIR=$DESTDIR "$@"
cd "$TOOLS_DIR_FULL"; make install DESTDIR=$DESTDIR DYNFS=yes "$@"
;;
config)
shift
cd "$TOOLS_DIR"; make config DESTDIR=$DESTDIR "$@"
mkdir -p $DESTDIR/etc/asterisk
cat >"$FIRMWARE_DIR/live-init.conf" <<EOF
PATH="$PATH" # FIXME: add to existing \$PATH?
export PATH
dahdiconfdir="${DESTDIR}/etc/dahdi"
export dahdiconfdir
EOF
;;
rsync)
if [ $# -ne 2 ]; then
echo >&2 "$0: Error: rsync requires a target parameter".
exit 1
fi
# copy the script itself and the installed directory to the
# target host:
rsync -ai "$0" $DESTDIR "$2:/tmp/"
;;
unload)
# OK for Asterisk not to be running. TODO: a better test?
$AST_SCRIPT stop || :
unload_dynamic
for mod in $REMOVE_MODULES; do
unload_module $mod
done
;;
load)
# TODO: Find a way to use modprobe.
# Or implement a way to pass arguments to modules here (yuck)
set_modules_to_load
for mod in $EXTRA_MODS; do
modprobe $mod || : # FIXME: Make this optional?
done
for module in $MODULES_LOAD; do
eval module_args="\$`basename ${module}`_ARGS"
insmod $MODULES_DIR/$module.ko $module_args
done
xpp_startup
load_dynamic
genconf
# or find a way to reuse init.d start sequence.
# TODO: A local copy of Asterisk, configured with dahdi_gnconf.
# doable, but trickier.
run_asterisk
;;
genconf)
genconf
;;
asterisk)
run_asterisk
;;
reload)
$0 unload
$0 load
;;
exec)
if [ $# -lt 2 ]; then
# No command given: start a subshell in the environemnt
# of the "live" system:
echo >&2 "$0: Error: exec requires a command to run"
exit 1
fi
# Command given: run it:
shift
"$@"
;;
xpp-firm)
# Still broken. Needs to be run several times.
# set XPP_HOTPLUG_DISABLED=yes in /etc/dahdi/init.conf
XPP_FIRMWARE_DIR=$FIRMWARE_DIR \
"$FIRMWARE_DIR/xpp_fxloader" reset
sleep 5
XPP_FIRMWARE_DIR=$FIRMWARE_DIR \
"$FIRMWARE_DIR/xpp_fxloader" load
;;
help|'')
usage
;;
*)
echo >&2 "$0: Error: incorrect command \"$1\". Aborting"
usage
exit 1
esac

67
build_tools/make_static_devs Executable file
View File

@@ -0,0 +1,67 @@
#!/bin/sh
set -e
# make_static_devs: create static device files for DAHDI
# Copyright (C) 2010 by Xorcom <support@xorcom.com>
#
# 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
# In most cases DAHDI device files are generated by udev,
# but there would be cases where you'd want to just have static device
# files. Note that if you do use udev, that static device files will be
# essentially deleted.
BASE_DIR="/dev/dahdi"
usage() {
me=`basename $0`
echo "$me: Generate static DAHDI device files"
echo ""
echo "Usage:"
echo " $me [-h] [-d base_dir]"
echo " -d base_dir: create under base_dir (default: $BASE_DIR)"
echo " -h: this help message."
}
mknod_safe() {
if [ -c $1 ]; then return; fi
mknod "$@"
}
while getopts 'd:h' opt; do
case "$opt" in
h) usage; exit 0;;
d) BASE_DIR="$OPTARG";;
\?) usage; exit 1;;
esac
done
mkdir -p "$BASE_DIR"
mknod_safe "${BASE_DIR}/ctl" c 196 0
mknod_safe "${BASE_DIR}/transcode" c 196 250
mknod_safe "${BASE_DIR}/timer" c 196 253
mknod_safe "${BASE_DIR}/channel" c 196 254
mknod_safe "${BASE_DIR}/pseudo" c 196 255
# The following are not used by Asterisk itself nowadays. Some DAHDI
# users still find it simpler to open them directly rather than using
# /dev/dahdi/channel and the DAHDI_SPECIFY ioctl .
for i in `seq 249`; do
mknod_safe ${BASE_DIR}/$i c 196 $i
done

56
build_tools/make_version Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/sh
if [ -f ${1}/.version ]; then
cat ${1}.version
elif [ -f ${1}/.svnrevision ]; then
echo SVN-`cat ${1}/.svnbranch`-r`cat ${1}/.svnrevision`
elif [ -d .svn ]; then
PARTS=`LANG=C svn info ${1} | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/${2}/:: | sed -e 's:/: :g'`
BRANCH=0
TEAM=0
REV=`svnversion -c ${1} | cut -d: -f2`
if [ "${PARTS}" = "trunk" ]
then
echo SVN-'trunk'-r${REV}
exit 0
fi
for PART in $PARTS
do
if [ ${BRANCH} != 0 ]
then
RESULT="${RESULT}-${PART}"
break
fi
if [ ${TEAM} != 0 ]
then
RESULT="${RESULT}-${PART}"
continue
fi
if [ "${PART}" = "branches" ]
then
BRANCH=1
RESULT="branch"
continue
fi
if [ "${PART}" = "tags" ]
then
BRANCH=1
RESULT="tag"
continue
fi
if [ "${PART}" = "team" ]
then
TEAM=1
continue
fi
done
echo SVN-${RESULT##-}-r${REV}
fi

9
build_tools/make_version_h Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
cat << END
/*
* version.h
* Automatically generated
*/
#define DAHDI_VERSION "${DAHDIVERSION}"
END

101
build_tools/test_kernel_git Executable file
View File

@@ -0,0 +1,101 @@
#!/bin/sh
set -e
GIT_URL=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
CONF_FILE=build_tools/git_test.conf
usage() {
me=`basename $0`
echo "$me: test building DAHDI vs. kernel from git"
echo "Usage:"
echo " $me checkout <kerneldir> Pull a kernel version into <kerneldir>"
echo " $me update Update (pull) the kernel tree."
echo " $me setver <kernel_ver> Set the kernel version"
echo " $me versions Print available versions"
echo " $me version Print current (kernel) version"
echo " $me version_driver Print the version of DAHDI"
echo " $me build Test-build"
echo " $me git <git command> Run <git command>"
echo ""
echo " $me versions [pattern] List available versions."
}
# Set a variable in $CONF_FILE
# The format of CONF_FILE is assumed to be:
# VAR=value
# in shell syntax. "value" may be quoted.
# "value should not contain a '|' character.
set_var() {
var="$1"
val="$2"
if grep -q "^$var=" $CONF_FILE 2>/dev/null; then
sed -i -e "s|^$var=.*|$var=\"$val\"|" $CONF_FILE
else
echo "$var=\"$val\"" >>$CONF_FILE
fi
}
if [ -r "$CONF_FILE" ]; then . "$CONF_FILE"; fi
if echo "$CONF_FILE" | grep -qv '^/'; then
# make CONF_FILE an absolute path:
CONF_FILE="$PWD/$CONF_FILE"
fi
command="$1"
case "$command" in
checkout)
kernel_dir="$2"
cd "$kernel_dir"
git clone $GIT_URL
set_var kernel_dir "$kernel_dir/linux-2.6"
;;
update)
cd "$kernel_dir"
git pull
;;
git)
cd "$kernel_dir"
shift
git "$@"
;;
versions)
cd "$kernel_dir"
git tag -l $2 | cut -c2-
;;
version)
cd "$kernel_dir"
echo "Configured: $kernel_ver"
echo -n "Actual: "
git describe | cut -c2-
;;
version_driver)
version_h=include/dahdi/version.h
make $version_h >/dev/null
awk -F'"' '/DAHDI_VERSION/{print $2}' $version_h
;;
setver)
kernel_ver="$2"
tag="v$kernel_ver"
cd "$kernel_dir"
git-reset --hard "$tag"
make distclean
make defconfig modules_prepare
set_var kernel_ver "$kernel_ver"
;;
test|build)
# you can pass extra parameters to the make command in
# two ways:
# 1. Set the value of MAKE_PARAMS in git_test.conf .
# 2. Any extra command-line parameter.
shift
make KSRC="$kernel_dir" KVERS=$kernel_ver $MAKE_PARAMS "$@"
;;
*)
echo "$0: no such command $command. Aborting."
usage
exit 1
;;
esac

64
build_tools/uninstall-modules Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/sh
# This script takes two arguments: a top-level module name, and a kernel version string
#
# It will search the entire /lib/modules directory tree for the given kernel version,
# and find all modules that are dependent (even indirectly) on the specified module.
# After producing that list, it will remove all those modules.
base="${1}"
deptree="${base}"
rmlist=""
founddep=1
checkmod() {
SAVEIFS="${IFS}"
IFS=","
modname=`basename ${1}`
modname=${modname%.ko}
if test "${modname}" = "${base}"; then
rmlist="${rmlist} ${1}"
IFS="${SAVEIFS}"
return
fi
for dep in `modinfo -F depends ${1}`; do
for mod in ${deptree}; do
if test "${dep}" = "${mod}"; then
addit=1
for checkmod in ${deptree}; do
if test "${checkmod}" = "${modname}"; then
addit=0
break
fi
done
if test "${addit}" = "1"; then
deptree="${deptree},${modname%.ko}"
rmlist="${rmlist} ${1}"
founddep=1
fi
fi
done
done
IFS="${SAVEIFS}"
}
while test "${founddep}" = "1"; do
founddep=0
find /lib/modules/${2}/misc -name \*.ko -print > /tmp/modlist.$$ 2> /dev/null
find /lib/modules/${2}/extra -name \*.ko -print >> /tmp/modlist.$$ 2> /dev/null
find /lib/modules/${2}/zaptel -name \*.ko -print >> /tmp/modlist.$$ 2> /dev/null
find /lib/modules/${2}/dahdi -name \*.ko -print >> /tmp/modlist.$$ 2> /dev/null
exec 9<&0 < /tmp/modlist.$$
while read mod; do
checkmod ${mod}
done
exec 0<&9 9<&-
rm /tmp/modlist.$$
done
if test -n "${rmlist}"; then
for mod in ${rmlist}; do
rm -f ${mod}
done
fi