@@ -630,6 +630,14 @@ get_newest_astdir() {
630
630
fi
631
631
}
632
632
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
+
633
641
cd_ast () {
634
642
cd $AST_SOURCE_PARENT_DIR
635
643
AST_SRC_DIR=` get_newest_astdir`
@@ -1674,8 +1682,15 @@ install_wanpipe() {
1674
1682
# Note: This link needs to be updated for new versions of wanpipe
1675
1683
wget https://web.archive.org/web/20240708051349/https://ftp.sangoma.com/linux/current_wanpipe/${WANPIPE_SOURCE_NAME} .tgz
1676
1684
fi
1677
- tar xvfz ${WANPIPE_SOURCE_NAME} .tgz
1678
1685
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
+
1679
1694
cd ${WANPIPE_DIR}
1680
1695
if [ $? -ne 0 ]; then
1681
1696
die " Failed to download/extract wanpipe"
@@ -1684,12 +1699,64 @@ install_wanpipe() {
1684
1699
# phreak_fuzzy_patch "af_wanpipe.diff"
1685
1700
1686
1701
# ./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
1688
1754
1689
1755
if [ $? -ne 0 ]; then
1690
1756
echoerr " wanpipe install failed: unsupported kernel?"
1691
1757
# No need to cat setup_drv_compile.log here, Setup automatically does so on failure
1692
1758
# 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
1693
1760
if [ " $IGNORE_FAILURES " = " 1" ]; then
1694
1761
printf " Installation of other items will proceed anyways...\n"
1695
1762
sleep 1
@@ -2118,7 +2185,6 @@ install_dahdi() {
2118
2185
wget https://github.com/asterisk/libss7/archive/refs/tags/${LIBSS7_VERSION} .tar.gz
2119
2186
tar -zxvf ${LIBSS7_VERSION} .tar.gz
2120
2187
rm ${LIBSS7_VERSION} .tar.gz
2121
- ls -la
2122
2188
cd libss7-${LIBSS7_VERSION}
2123
2189
$AST_MAKE && $AST_MAKE install
2124
2190
fi
0 commit comments