Skip to content

Commit d27f16f

Browse files
committed
wanpipe: Set KBUILD_EXTRA_SYMBOLS when building.
Adopt suggestion from the Osmocom wiki[1] to set KBUILD_EXTRA_SYMBOLS to ensure module builds successfully. Also add a CI for wanpipe now that it builds. [1] https://osmocom.org/projects/retronetworking/wiki/Sangoma_Wanpipe_DAHDI
1 parent 469a6b0 commit d27f16f

File tree

2 files changed

+71
-5
lines changed

2 files changed

+71
-5
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ jobs:
179179
GIT_REPO_PATH=${GITHUB_WORKSPACE} phreaknet install --fast --dahdi --devmode --sip --vanilla --user=asterisk
180180
debian-stable-asterisk-master:
181181
runs-on: ubuntu-24.04
182-
name: Debian 12, Asterisk master branch
182+
name: Debian 12, wanpipe, Asterisk master
183183
container: debian:12
184184
steps:
185185
- uses: actions/checkout@v4
186186
- name: Build DAHDI and Asterisk
187187
run: |
188188
./phreaknet.sh make
189-
GIT_REPO_PATH=${GITHUB_WORKSPACE} phreaknet install --fast --dahdi --drivers --sip --testsuite --version=master
189+
GIT_REPO_PATH=${GITHUB_WORKSPACE} phreaknet install --fast --dahdi --drivers --wanpipe --sip --testsuite --version=master
190190
debian-dahdi-minimal:
191191
runs-on: ubuntu-24.04
192192
name: Debian 12, without libpri and libss7

phreaknet.sh

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,14 @@ get_newest_astdir() {
630630
fi
631631
}
632632

633+
get_newest_dahlindir() {
634+
if [ "$OS_DIST_INFO" = "FreeBSD" ]; then
635+
ls -d ./*/ | cut -c 3- | grep "^dahdi-linux" | tail -1 # FreeBSD doesn't have the same GNU ls options: https://stackoverflow.com/a/31603260/
636+
else
637+
ls -d -v */ | grep "^dahdi-linux" | tail -1
638+
fi
639+
}
640+
633641
cd_ast() {
634642
cd $AST_SOURCE_PARENT_DIR
635643
AST_SRC_DIR=`get_newest_astdir`
@@ -1674,8 +1682,15 @@ install_wanpipe() {
16741682
# Note: This link needs to be updated for new versions of wanpipe
16751683
wget https://web.archive.org/web/20240708051349/https://ftp.sangoma.com/linux/current_wanpipe/${WANPIPE_SOURCE_NAME}.tgz
16761684
fi
1677-
tar xvfz ${WANPIPE_SOURCE_NAME}.tgz
16781685
WANPIPE_DIR=`tar -tzf $WANPIPE_SOURCE_NAME.tgz | head -1 | cut -f1 -d"/"`
1686+
if [ -d $WANPIPE_DIR ]; then
1687+
if [ "$FORCE_INSTALL" != "1" ]; then
1688+
die "Directory $WANPIPE_DIR already exists... specify --force to overwrite"
1689+
fi
1690+
rm -rf $WANPIPE_DIR
1691+
fi
1692+
tar xvfz ${WANPIPE_SOURCE_NAME}.tgz
1693+
16791694
cd ${WANPIPE_DIR}
16801695
if [ $? -ne 0 ]; then
16811696
die "Failed to download/extract wanpipe"
@@ -1684,12 +1699,64 @@ install_wanpipe() {
16841699
#phreak_fuzzy_patch "af_wanpipe.diff"
16851700

16861701
#./Setup dahdi --silent
1687-
./Setup install --silent # Even if Setup dahdi fails, this can work
1702+
#./Setup install --silent # Even if Setup dahdi fails, this can work
1703+
1704+
# Manually build wanpipe since using Setup, KBUILD_EXTRA_SYMBOLS isn't set and this is required or symbols will be missing.
1705+
if [ "$DAHDI_LIN_SRC_DIR" = "" ]; then
1706+
# For standalone wanpipe install, this won't have been defined since we didn't just install DAHDI. Calculate it now.
1707+
cd $AST_SOURCE_PARENT_DIR
1708+
DAHDI_LIN_SRC_DIR=`get_newest_dahlindir`
1709+
cd ${WANPIPE_DIR}
1710+
fi
1711+
1712+
# Wanpipe requires the kernel headers to build, just like DAHDI Linux does
1713+
# XXX Missing logic for other distros
1714+
if [ "$PAC_MAN" = "apt-get" ]; then
1715+
# The headers are split into the common and arch specific dirs.
1716+
# wanpipe needs stuff in both, so combine them.
1717+
ksrc_dir1=$( ls /usr/src/ | grep linux-headers | grep "common" | tail -1 | tr -d '\n' )
1718+
ksrc_dir2=$( ls /usr/src/ | grep linux-headers | grep -v "common" | tail -1 | tr -d '\n' )
1719+
wanpipe_kdir1="/usr/src/${ksrc_dir1}"
1720+
wanpipe_kdir2="/usr/src/${ksrc_dir2}"
1721+
1722+
cd $AST_SOURCE_PARENT_DIR
1723+
if [ -d wanpipe_linux_headers ]; then
1724+
rm -rf wanpipe_linux_headers
1725+
fi
1726+
# It needs to be done in this order. Start with the arch-specific version,
1727+
# then add in the common one. If we do it the other way, even with cp -R,
1728+
# .config and possibly other stuff doesn't end up copied to the combined directory.
1729+
cp -R ${wanpipe_kdir2} wanpipe_linux_headers
1730+
cp -R ${wanpipe_kdir1}/* wanpipe_linux_headers
1731+
cd ${WANPIPE_DIR}
1732+
1733+
wanpipe_kdir="/usr/src/wanpipe_linux_headers"
1734+
printf "Setting KSRC to %s\n" "${wanpipe_kdir}"
1735+
# These files better both exist!
1736+
ls -la ${wanpipe_kdir}/.config && ls -la ${wanpipe_kdir}/include/linux/proc_fs.h
1737+
if [ $? -ne 0 ]; then
1738+
echoerr "Failed to merge headers directories?"
1739+
ls -la ${wanpipe_kdir1} ${wanpipe_kdir2} ${wanpipe_kdir1}/include/linux/proc_fs.h ${wanpipe_kdir2}/include/linux/proc_fs.h
1740+
fi
1741+
fi
1742+
1743+
# Compile and install
1744+
WANPIPE_MAKE_ARGS="dahdi DAHDI_DIR=$AST_SOURCE_PARENT_DIR/$DAHDI_LIN_SRC_DIR KBUILD_EXTRA_SYMBOLS=$AST_SOURCE_PARENT_DIR/$DAHDI_LIN_SRC_DIR/drivers/dahdi/Module.symvers"
1745+
if [ "${wanpipe_kdir}" != "" ]; then
1746+
WANPIPE_MAKE_ARGS="$WANPIPE_MAKE_ARGS KDIR=${wanpipe_kdir}"
1747+
fi
1748+
$AST_MAKE -j$(nproc) $WANPIPE_MAKE_ARGS && $AST_MAKE install
1749+
if [ $? -ne 0 ]; then
1750+
# If compilation fails, show the error at the bottom
1751+
echoerr "Wanpipe compilation failed:"
1752+
$AST_MAKE $WANPIPE_MAKE_ARGS VERBOSE=1 && $AST_MAKE install
1753+
fi
16881754

16891755
if [ $? -ne 0 ]; then
16901756
echoerr "wanpipe install failed: unsupported kernel?"
16911757
# No need to cat setup_drv_compile.log here, Setup automatically does so on failure
16921758
# XXX wanpipe currently fails to compile on kernels newer than 6.1.0. See [PHREAKSCRIPT-49]
1759+
cat setup_drv_compile.log # cat for now since we aren't using ./Setup
16931760
if [ "$IGNORE_FAILURES" = "1" ]; then
16941761
printf "Installation of other items will proceed anyways...\n"
16951762
sleep 1
@@ -2118,7 +2185,6 @@ install_dahdi() {
21182185
wget https://github.com/asterisk/libss7/archive/refs/tags/${LIBSS7_VERSION}.tar.gz
21192186
tar -zxvf ${LIBSS7_VERSION}.tar.gz
21202187
rm ${LIBSS7_VERSION}.tar.gz
2121-
ls -la
21222188
cd libss7-${LIBSS7_VERSION}
21232189
$AST_MAKE && $AST_MAKE install
21242190
fi

0 commit comments

Comments
 (0)