Skip to content

Commit ef51cfa

Browse files
authored
DAHDI Linux: Fix minor nonworking parts of installation. (#49)
* Install package needed for BTF generation. * Make vmlinux available for driver install. * Make resolve_btfids available by modifying Kbuild.
1 parent 5c172b3 commit ef51cfa

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

patches/modfinal.diff

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- /usr/lib/linux-kbuild-6.1/scripts/Makefile.modfinal.orig 2024-11-09 17:26:54.648766021 -0500
2+
+++ /usr/lib/linux-kbuild-6.1/scripts/Makefile.modfinal 2024-11-09 17:27:00.900879469 -0500
3+
@@ -58,9 +58,9 @@
4+
# Re-generate module BTFs if either module's .ko or vmlinux changed
5+
$(modules): %.ko: %.o %.mod.o $(ARCH_MODULE_LDS) $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE
6+
+$(call if_changed_except,ld_ko_o,vmlinux)
7+
-ifdef CONFIG_DEBUG_INFO_BTF_MODULES
8+
- +$(if $(newer-prereqs),$(call cmd,btf_ko))
9+
-endif
10+
+#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
11+
+# +$(if $(newer-prereqs),$(call cmd,btf_ko))
12+
+#endif
13+
14+
targets += $(modules) $(modules:.ko=.mod.o)
15+

phreaknet.sh

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 pahole"
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,28 @@ 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+
sed -n 61,63p $MODFINAL_FILE
1712+
else
1713+
echoerr "Could not determine path to Makefile.modfinal"
1714+
fi
1715+
16771716
# Requests to downloads.digium.com usually use IPv4, but sometimes use IPv6
16781717
# This is problematic on GitHub Action Runners, which have IPv6 disabled,
16791718
# and won't let you enable it
@@ -3454,6 +3493,7 @@ elif [ "$cmd" = "freepbx" ]; then
34543493
install_freepbx
34553494
elif [ "$cmd" = "dahdi" ]; then
34563495
assert_root
3496+
CHAN_DAHDI=1 # This is used by the pre-req install process to install DAHDI-specific prereqs.
34573497
install_prereq 0 # Install basic build requirements
34583498
install_dahdi
34593499
elif [ "$cmd" = "wanpipe" ]; then

0 commit comments

Comments
 (0)