Skip to content

Commit d8dcd8f

Browse files
committed
DAHDI: Build fixes for various atypical systems.
* Slipstream unmerged patches addressing various critical build failures. * Use proper flags based on detected version of wget. This fixes builds on Fedora 40, where wget2 is present instead of wget. * Install specific kernel-devel version match if mismatched. This fixes builds on Fedora-based systems. * Manually build makefw target in DAHDI Linux if tor2 driver is present, to prevent build failing due to missing target.
1 parent 4ea6643 commit d8dcd8f

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

phreaknet.sh

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# PhreakScript
44
# (C) 2021-2024 Naveen Albert, PhreakNet, and others - https://github.com/InterLinked1/phreakscript ; https://portal.phreaknet.org ; https://docs.phreaknet.org
5-
# v1.1.6 (2024-09-16)
5+
# v1.1.7 (2024-09-19)
66

77
# Setup (as root):
88
# cd /usr/local/src
@@ -13,6 +13,7 @@
1313
# phreaknet install
1414

1515
## Begin Change Log:
16+
# 2024-09-19 1.1.7 DAHDI: Slipstream critical build fixes, fix build issues on various distros and kernels
1617
# 2024-09-16 1.1.6 DAHDI: Add patch to enable building of XPP drivers on 32-bit architectures
1718
# 2024-09-15 1.1.5 DAHDI: Massive overhaul to DAHDI stop/start/restart logic, fixes for manual span assignment
1819
# 2024-09-11 1.1.4 DAHDI: Target DAHDI 3.4.0, update patches
@@ -228,10 +229,18 @@ PAC_MAN="apt-get"
228229
AST_SOUNDS_DIR="$AST_VARLIB_DIR/sounds/en"
229230
AST_MOH_DIR="$AST_VARLIB_DIR/moh"
230231
AST_MAKE="make"
231-
WGET="wget -q --show-progress"
232+
WGET="wget -q"
232233
XMLSTARLET="/usr/bin/xmlstarlet"
233234
PATH="/sbin:$PATH" # in case su used without path
234235

236+
# Wget2 does not support --show-progress, uses --force-progress instead
237+
WGET_VERSION=$( wget --version )
238+
if [ "${WGET_VERSION#*"Wget2"}" != "$WGET_VERSION" ]; then
239+
WGET="$WGET --force-progress"
240+
else
241+
WGET="$WGET --show-progress"
242+
fi
243+
235244
# Defaults
236245
AST_CC=1 # Country Code (default: 1 - NANPA)
237246
AST_USER=""
@@ -805,6 +814,7 @@ make_keys_readable() {
805814
}
806815

807816
install_prereq() {
817+
printf "%s\n" "Installing prerequisites..."
808818
if [ "$PAC_MAN" = "apt-get" ]; then
809819
# Ubuntu 22.04 prompts for restarts by default, inhibit this: https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services
810820
if [ -f /etc/needrestart/needrestart.conf ]; then
@@ -836,7 +846,7 @@ install_prereq() {
836846
apt-get install -y debconf-utils
837847
apt-get -y autoremove
838848
elif [ "$PAC_MAN" = "yum" ]; then
839-
yum install -y git patch
849+
yum install -y git patch subversion
840850
# Stop on RHEL systems without an active subscription
841851
if ! which git > /dev/null; then
842852
if [ -f /etc/redhat-release ]; then
@@ -1417,15 +1427,23 @@ install_dahdi() {
14171427
elif [ "$PAC_MAN" = "yum" ]; then
14181428
dnf install -y m4 libtool automake autoconf kernel-devel kernel-headers
14191429
dnf list installed 'kernel*'
1420-
if [ -f /etc/redhat-release ]; then
1421-
# https://access.redhat.com/discussions/4656371?tour=8
1422-
# Red Hat may install newer headers than the current system
1423-
dnf downgrade kernel-headers-$(uname -r)
1424-
ls -la /usr/src/kernels
1430+
# Fedora-based systems seem to have a newer kernel-devel present than the actual running kernel.
1431+
# This includes Red Hat, which may install newer headers than the current system: https://access.redhat.com/discussions/4656371?tour=8
1432+
# Try to detect that and fix it.
1433+
KERNEL_DEVEL_VERSION=$( dnf list installed 'kernel-devel' | grep "kernel-devel" | xargs | cut -d' ' -f2 | cut -d'.' -f1-5 )
1434+
kernel_ver=$( uname -r | cut -d'.' -f1-5 )
1435+
if [ "$KERNEL_DEVEL_VERSION" != "$kernel_ver" ]; then
1436+
echoerr "kernel-devel mismatch has been detected. Package provides $KERNEL_DEVEL_VERSION, but running kernel is $kernel_ver"
1437+
echoerr "Installing specific kernel-devel package to match..."
1438+
dnf install -y kernel-devel-$(uname -r)
1439+
rpm -qa | grep kernel
1440+
KERNEL_DEVEL_VERSION=$( dnf list installed 'kernel-devel' | grep "kernel-devel" | xargs | cut -d' ' -f2 | cut -d'.' -f1-5 )
1441+
if [ "$KERNEL_DEVEL_VERSION" != "$kernel_ver" ]; then
1442+
echoerr "kernel-devel mismatch still present?"
1443+
fi
1444+
else
1445+
echog "kernel-devel is matched with kernel. Package provides $KERNEL_DEVEL_VERSION, and running kernel is $kernel_ver"
14251446
fi
1426-
#dnf install -y kernel-headers-$(uname -r)
1427-
dnf list installed | grep kernel-headers
1428-
rpm -qa | grep kernel
14291447
else
14301448
echoerr "Unable to install potential DAHDI prerequisites"
14311449
sleep 2
@@ -1519,7 +1537,12 @@ install_dahdi() {
15191537
fi
15201538

15211539
# Merged in master, but not yet in a current release
1522-
git_custom_patch "https://github.com/asterisk/dahdi-linux/commit/d932d9fbc8b3559829a76fffcedceb78d1fc1887.diff"
1540+
git_custom_patch "https://github.com/asterisk/dahdi-linux/commit/d7bbc8a96fe767bc4eee15dd43170f298282a4c3.diff" # RHEL fixes for const struct device *dev
1541+
git_custom_patch "https://github.com/asterisk/dahdi-linux/commit/d932d9fbc8b3559829a76fffcedceb78d1fc1887.diff" # dahdi_spantype fix
1542+
1543+
# Not yet merged
1544+
git_custom_patch "https://patch-diff.githubusercontent.com/raw/asterisk/dahdi-linux/pull/57.diff" # PR 57: RHEL build fixes
1545+
git_custom_patch "https://patch-diff.githubusercontent.com/raw/asterisk/dahdi-linux/pull/58.diff" # PR 58: non-RHEL build fixes for older kernels
15231546

15241547
KERN_VER_MM=$( uname -r | cut -d. -f1-2 )
15251548
OS_DIST_2=$( printf "$OS_DIST_INFO" | cut -d' ' -f1-2)
@@ -1578,6 +1601,13 @@ install_dahdi() {
15781601
grep "WGET" drivers/dahdi/firmware/Makefile
15791602
fi
15801603

1604+
if [ "$DAHDI_OLD_DRIVERS" = "1" ]; then
1605+
# For some reason, tor2 won't compile on older kernels due to missing target for "makefw"
1606+
# But if we compile it by its full name first, that takes care of that
1607+
# TODO BUGBUG This is a build order bug that should be addressed in the build system
1608+
make $AST_SOURCE_PARENT_DIR/$DAHDI_LIN_SRC_DIR/drivers/dahdi/makefw $DAHDI_CFLAGS
1609+
fi
1610+
15811611
make -j$(nproc) $DAHDI_CFLAGS
15821612
if [ $? -ne 0 ]; then
15831613
echoerr "DAHDI Linux compilation failed, aborting install"
@@ -2833,7 +2863,6 @@ elif [ "$cmd" = "install" ]; then
28332863
# Install Pre-Reqs
28342864
printf "%s %d\n" "Starting installation with country code" $AST_CC
28352865
quell_mysql
2836-
printf "%s\n" "Installing prerequisites..."
28372866
install_prereq # This must be done before any other packages are installed since we'll skip package install checks if package manager was used recently.
28382867
if [ "$DEVMODE" = "1" ]; then
28392868
# Install the Linux headers if we can, but don't abort if we can't.
@@ -3204,6 +3233,7 @@ elif [ "$cmd" = "freepbx" ]; then
32043233
install_freepbx
32053234
elif [ "$cmd" = "dahdi" ]; then
32063235
assert_root
3236+
install_prereq # Install basic build requirements
32073237
install_dahdi
32083238
elif [ "$cmd" = "wanpipe" ]; then
32093239
assert_root

0 commit comments

Comments
 (0)