@@ -912,9 +912,14 @@ install_prereq() {
912912 PREREQ_PACKAGES=" "
913913 RHEL_MAJOR_VERSION_8=0
914914 printf " Installing prerequisites for %s..." " $OS_DIST_INFO "
915+ # Even if we are just installing DAHDI (without Asterisk), $CHAN_DAHDI should be set to 1 at this point.
915916 # libnewt-dev is needed for newt, which dahdi_tool requires. If it's not available, it won't get built.
917+ # dwarves is needed for pahole, which DAHDI Linux install needs for BTF generation
916918 if [ " $PAC_MAN " = " apt-get" ]; then
917- PREREQ_PACKAGES=" $PREREQ_PACKAGES git patch gcc pkg-config autoconf automake m4 libtool build-essential libnewt-dev"
919+ PREREQ_PACKAGES=" $PREREQ_PACKAGES git patch gcc pkg-config autoconf automake m4 libtool build-essential"
920+ if [ " $CHAN_DAHDI " = " 1" ]; then
921+ PREREQ_PACKAGES=" $PREREQ_PACKAGES libnewt-dev dwarves"
922+ fi
918923 if [ " $1 " = " 1" ]; then
919924 PREREQ_PACKAGES=" $PREREQ_PACKAGES curl subversion libcurl4-openssl-dev"
920925 if [ " $ENHANCED_INSTALL " = " 1" ]; then
@@ -933,26 +938,38 @@ install_prereq() {
933938 if [ -f /etc/redhat-release ] && [ " $RHEL_MAJOR_VERSION " = " 8" ]; then # RHEL or Rocky Linux major version 8
934939 RHEL_MAJOR_VERSION_8=1
935940 fi
936- PREREQ_PACKAGES=" $PREREQ_PACKAGES git patch gcc gcc-c++ pkg-config autoconf automake m4 libtool newt-devel"
941+ PREREQ_PACKAGES=" $PREREQ_PACKAGES git patch gcc gcc-c++ pkg-config autoconf automake m4 libtool"
942+ if [ " $CHAN_DAHDI " = " 1" ]; then
943+ PREREQ_PACKAGES=" $PREREQ_PACKAGES newt-devel dwarves"
944+ fi
937945 if [ " $1 " = " 1" ]; then
938946 PREREQ_PACKAGES=" $PREREQ_PACKAGES subversion libuuid-devel libxml2-devel sqlite-devel"
939947 if [ $RHEL_MAJOR_VERSION_8 -eq 0 ]; then
940948 PREREQ_PACKAGES=" $PREREQ_PACKAGES libedit-devel" # Required on Fedora, may fail initially on Rocky Linux 8.9
941949 fi
942950 fi
943951 elif [ " $PAC_MAN " = " zypper" ]; then
944- PREREQ_PACKAGES=" $PREREQ_PACKAGES git-core make patch gawk subversion bzip2 gcc-c++ newt-devel"
952+ PREREQ_PACKAGES=" $PREREQ_PACKAGES git-core make patch gawk subversion bzip2 gcc-c++"
953+ if [ " $CHAN_DAHDI " = " 1" ]; then
954+ PREREQ_PACKAGES=" $PREREQ_PACKAGES newt-devel dwarves"
955+ fi
945956 if [ " $1 " = " 1" ]; then
946957 # TODO Some of these should be in Asterisk's install_prereq script
947958 PREREQ_PACKAGES=" $PREREQ_PACKAGES libedit-devel libuuid-devel libxml2-devel sqlite3-devel"
948959 fi
949960 elif [ " $PAC_MAN " = " pacman" ]; then
950- PREREQ_PACKAGES=" $PREREQ_PACKAGES git make patch gcc pkg-config autoconf automake m4 libtool libnewt"
961+ PREREQ_PACKAGES=" $PREREQ_PACKAGES git make patch gcc pkg-config autoconf automake m4 libtool"
962+ if [ " $CHAN_DAHDI " = " 1" ]; then
963+ PREREQ_PACKAGES=" $PREREQ_PACKAGES libnewt dwarves"
964+ fi
951965 if [ " $1 " = " 1" ]; then
952966 PREREQ_PACKAGES=" $PREREQ_PACKAGES subversion libedit"
953967 fi
954968 elif [ " $PAC_MAN " = " pkg" ]; then
955- PREREQ_PACKAGES=" $PREREQ_PACKAGES git gmake newt"
969+ PREREQ_PACKAGES=" $PREREQ_PACKAGES git gmake"
970+ if [ " $CHAN_DAHDI " = " 1" ]; then
971+ PREREQ_PACKAGES=" $PREREQ_PACKAGES newt dwarves"
972+ fi
956973 if [ " $1 " = " 1" ]; then
957974 PREREQ_PACKAGES=" $PREREQ_PACKAGES curl subversion e2fsprogs-libuuid sqlite3 xmlstarlet libsysinfo"
958975 if [ " $ENHANCED_INSTALL " = " 1" ]; then
@@ -1674,6 +1691,29 @@ install_dahdi() {
16741691 fi
16751692 fi
16761693
1694+ # Avoid "Skipping BTF generation for ... due to unavailability of vmlinux"
1695+ # Worked around by copying vmlinux to another location:
1696+ if [ -f /sys/kernel/btf/vmlinux ]; then
1697+ cp /sys/kernel/btf/vmlinux /usr/lib/modules/` uname -r` /build/
1698+ else
1699+ echoerr " Couldn't find vmlinux... BTF generation may be skipped during driver install..."
1700+ fi
1701+
1702+ # Fix missing resolve_btfids
1703+ # https://github.com/aircrack-ng/rtl8188eus/issues/263#issuecomment-1715699688
1704+ # Fixed by commenting out lines 61-63
1705+ KERNEL_MM=$( uname -r | cut -d' .' -f1-2 )
1706+ KBUILD_DIR=" /usr/lib/linux-kbuild-${KERNEL_MM} "
1707+ MODFINAL_FILE=" ${KBUILD_DIR} /scripts/Makefile.modfinal"
1708+ if [ -f " $MODFINAL_FILE " ]; then
1709+ sed -n 61,63p $MODFINAL_FILE
1710+ # phreak_tree_patch $MODFINAL_FILE "modfinal.diff"
1711+ phreak_nontree_patch $MODFINAL_FILE " https://raw.githubusercontent.com/InterLinked1/phreakscript/refs/heads/btf/patches/modfinal.diff"
1712+ sed -n 61,63p $MODFINAL_FILE
1713+ else
1714+ echoerr " Could not determine path to Makefile.modfinal"
1715+ fi
1716+
16771717 # Requests to downloads.digium.com usually use IPv4, but sometimes use IPv6
16781718 # This is problematic on GitHub Action Runners, which have IPv6 disabled,
16791719 # and won't let you enable it
@@ -3454,6 +3494,7 @@ elif [ "$cmd" = "freepbx" ]; then
34543494 install_freepbx
34553495elif [ " $cmd " = " dahdi" ]; then
34563496 assert_root
3497+ CHAN_DAHDI=1 # This is used by the pre-req install process to install DAHDI-specific prereqs.
34573498 install_prereq 0 # Install basic build requirements
34583499 install_dahdi
34593500elif [ " $cmd " = " wanpipe" ]; then
0 commit comments