Skip to content

Commit 6c82101

Browse files
committed
install: Add option to install radio modules.
Add an option (--rpt) to install the radio modules (e.g. app_rpt, etc.). These modules used to be in the Asterisk tree, but were removed in commit asterisk/asterisk@4585000 and a few other commits. The modules are currently being maintained in a third-party repo, and this option pulls the files into the source tree. If the test suite is being installed in conjunction with this option, the radio tests are also added to the test suite.
1 parent adab607 commit 6c82101

File tree

1 file changed

+70
-11
lines changed

1 file changed

+70
-11
lines changed

phreaknet.sh

+70-11
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ CHAN_SIP=0
242242
ENHANCED_CHAN_SIP=0
243243
SIP_CISCO=0
244244
CHAN_SCCP=0
245+
RPT_MODULES=0
245246
CHAN_DAHDI=0
246247
DAHDI_OLD_DRIVERS=0
247248
EMPULSE=1 # Automatically enable EMPULSE, cause why not?
@@ -606,6 +607,7 @@ Options:
606607
--lightweight install: Only install basic, required modules for basic Asterisk functionality
607608
--alsa install: Ensure ALSA library detection exists in the build system. This does NOT readd the deprecated/removed chan_alsa module.
608609
--cisco install: Add full support for Cisco Call Manager phones (chan_sip only)
610+
--rpt install: Add radio repeater modules
609611
--sccp install: Install chan_sccp channel driver (Cisco Skinny)
610612
--drivers install: Also install DAHDI drivers removed in 2018
611613
--generic install: Use generic kernel headers that do not match the installed kernel version
@@ -951,13 +953,16 @@ install_prereq() {
951953
PREREQ_PACKAGES="$PREREQ_PACKAGES libnewt-dev dwarves"
952954
fi
953955
if [ "$1" = "1" ]; then
954-
PREREQ_PACKAGES="$PREREQ_PACKAGES curl subversion libcurl4-openssl-dev"
956+
PREREQ_PACKAGES="$PREREQ_PACKAGES curl subversion libcurl4-openssl-dev libvpb1"
955957
if [ "$ENHANCED_INSTALL" = "1" ]; then
956958
PREREQ_PACKAGES="$PREREQ_PACKAGES dnsutils bc mpg123 ntp tcpdump festival"
957959
fi
958960
if [ "$DEVMODE" = "1" ]; then
959961
PREREQ_PACKAGES="$PREREQ_PACKAGES xmlstarlet" # only needed in developer mode for doc validation.
960962
fi
963+
if [ "$RPT_MODULES" = "1" ]; then
964+
PREREQ_PACKAGES="$PREREQ_PACKAGES libusb-dev"
965+
fi
961966
fi
962967
PREREQ_PACKAGES="$PREREQ_PACKAGES libedit-dev" # Ubuntu also needs this package
963968
# apt-get install libcurl3-gnutls=7.64.0-4+deb10u2 # fix git clone not working: upvoted comment at https://superuser.com/a/1642989
@@ -1378,6 +1383,12 @@ install_testsuite_itself() {
13781383
fi
13791384

13801385
add_phreak_testsuite
1386+
if [ "$RPT_MODULES" = "1" ]; then
1387+
# Add radio tests
1388+
cd $AST_SOURCE_PARENT_DIR/testsuite
1389+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/tests/apps/tests_apps.diff
1390+
cp -r $AST_SOURCE_PARENT_DIR/app_rpt/tests/apps/rpt tests/apps
1391+
fi
13811392
printf "%s\n" "Asterisk Test Suite installation complete"
13821393
}
13831394

@@ -1499,9 +1510,12 @@ dahdi_patch() {
14991510

15001511
git_patch() {
15011512
printf "Applying git patch: %s\n" "$1"
1513+
if [ "$GIT_REPO_PATH" = "" ]; then
1514+
die "Variable GIT_REPO_PATH is empty... bug!"
1515+
fi
15021516
cp "$GIT_REPO_PATH/patches/$1" "/tmp/$1"
15031517
if [ $? -ne 0 ]; then
1504-
die "File $1 does not exist"
1518+
die "File $GIT_REPO_PATH/patches/$1 does not exist"
15051519
fi
15061520
git apply "/tmp/$1"
15071521
if [ $? -ne 0 ]; then
@@ -2333,8 +2347,6 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
23332347
### Inject custom PhreakNet patches to add additional functionality and features.
23342348
### If/when/as these are integrated upstream, they will be removed from this function.
23352349

2336-
instantiate_repo
2337-
23382350
cd $AST_SOURCE_PARENT_DIR/$2
23392351

23402352
## Add Standalone PhreakNet Modules
@@ -2959,6 +2971,9 @@ get_source() {
29592971
printf "chan_sip was not natively present in this version of Asterisk\n"
29602972
ENHANCED_CHAN_SIP=1 # chan_sip isn't present anymore, we need to readd it ourselves (if we're going to build chan_sip at all)
29612973
fi
2974+
2975+
instantiate_repo
2976+
29622977
if [ "$CHAN_SIP" = "1" ]; then # somebody still wants chan_sip, okay...
29632978
if [ "$ENHANCED_CHAN_SIP" != "1" ]; then
29642979
echoerr "chan_sip is deprecated and was removed in Asterisk 21. Consider migrating to chan_pjsip at your convenience."
@@ -2970,9 +2985,40 @@ get_source() {
29702985
./chan_sip_reinclude.sh
29712986
fi
29722987
fi
2988+
if [ "$RPT_MODULES" = "1" ]; then
2989+
ALSA=1 # ALSA support in the build system is required for the USB radio channel drivers
2990+
modprobe snd-pcm-oss # /dev/dsp1 needs to exist for chan_simpleusb and chan_usbradio to work
2991+
grep "snd-pcm-oss" /etc/modules
2992+
if [ $? -ne 0 ]; then
2993+
echo "snd-pcm-oss" >> /etc/modules # load module at startup for USB
2994+
fi
2995+
if [ -d $AST_SOURCE_PARENT_DIR/app_rpt ]; then
2996+
cd $AST_SOURCE_PARENT_DIR/app_rpt
2997+
git pull
2998+
else
2999+
cd $AST_SOURCE_PARENT_DIR
3000+
git clone --depth 1 https://github.com/AllStarLink/app_rpt.git
3001+
fi
3002+
cd $AST_SOURCE_PARENT_DIR/$AST_SRC_DIR
3003+
# Patch in the radio modules
3004+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/apps/Makefile.diff
3005+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/channels/Makefile.diff
3006+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/res/Makefile.diff
3007+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/utils/Makefile.diff
3008+
mkdir apps/app_rpt
3009+
mkdir channels/xpmr
3010+
cp $AST_SOURCE_PARENT_DIR/app_rpt/apps/*.c apps
3011+
cp $AST_SOURCE_PARENT_DIR/app_rpt/apps/app_rpt/* apps/app_rpt
3012+
cp $AST_SOURCE_PARENT_DIR/app_rpt/channels/*.c $AST_SOURCE_PARENT_DIR/app_rpt/channels/*.h channels
3013+
cp $AST_SOURCE_PARENT_DIR/app_rpt/channels/xpmr/* channels/xpmr
3014+
cp $AST_SOURCE_PARENT_DIR/app_rpt/configs/samples/*.conf.sample configs/samples
3015+
cp $AST_SOURCE_PARENT_DIR/app_rpt/include/asterisk/*.h include/asterisk
3016+
cp $AST_SOURCE_PARENT_DIR/app_rpt/res/*.c $AST_SOURCE_PARENT_DIR/app_rpt/res/*.in res
3017+
cp $AST_SOURCE_PARENT_DIR/app_rpt/utils/*.c utils
3018+
fi
29733019
if [ "$ALSA" = "1" ]; then
29743020
# chan_alsa was removed in Asterisk 21, and with it, the support for ALSA lib detection in the build system. Add it back if needed.
2975-
lines=$(grep "HAVE_ALSA" include/asterisk/autoconfig.h | wc -l)
3021+
lines=$(grep "HAVE_ALSA" include/asterisk/autoconfig.h.in | wc -l)
29763022
if [ $lines -eq 0 ]; then
29773023
printf "Patching build system to detect ALSA library\n"
29783024
git_patch "alsa.diff"
@@ -3024,7 +3070,7 @@ else
30243070
fi
30253071

30263072
FLAG_TEST=0
3027-
PARSED_ARGUMENTS=$(getopt -n phreaknet -o bc:u:dfhostu:v:w -l backtraces,cc:,dahdi,force,flag-test,help,sip,testsuite,user:,version:,weaktls,alsa,cisco,sccp,clli:,debug:,devmode,disa:,drivers,experimental,extcodecs,fast,freepbx,generic,autokvers,lightweight,api-key:,rotate,audit,boilerplate,upstream:,manselect,minimal,vanilla,wanpipe -- "$@")
3073+
PARSED_ARGUMENTS=$(getopt -n phreaknet -o bc:u:dfhostu:v:w -l backtraces,cc:,dahdi,force,flag-test,help,sip,testsuite,user:,version:,weaktls,alsa,cisco,rpt,sccp,clli:,debug:,devmode,disa:,drivers,experimental,extcodecs,fast,freepbx,generic,autokvers,lightweight,api-key:,rotate,audit,boilerplate,upstream:,manselect,minimal,vanilla,wanpipe -- "$@")
30283074
VALID_ARGUMENTS=$?
30293075
if [ "$VALID_ARGUMENTS" != "0" ]; then
30303076
usage
@@ -3057,6 +3103,7 @@ while true; do
30573103
--alsa ) ALSA=1; shift ;;
30583104
--audit ) PKG_AUDIT=1; shift ;;
30593105
--cisco ) SIP_CISCO=1; shift ;;
3106+
--rpt ) RPT_MODULES=1; shift ;;
30603107
--sccp ) CHAN_SCCP=1; shift ;;
30613108
--boilerplate ) BOILERPLATE_SOUNDS=1; shift ;;
30623109
--clli ) PHREAKNET_CLLI=$2; shift 2;;
@@ -3373,7 +3420,6 @@ elif [ "$cmd" = "install" ]; then
33733420
# Install Pre-Reqs
33743421
if [ "$PAC_MAN" = "apt-get" ]; then
33753422
printf "%s %d" "libvpb1 libvpb1/countrycode string" "$AST_CC" | debconf-set-selections -v
3376-
apt-get install -y libvpb1
33773423
fi
33783424
./contrib/scripts/install_prereq install
33793425

@@ -3466,7 +3512,7 @@ elif [ "$cmd" = "install" ]; then
34663512
# Now explicitly enable things we probably want.
34673513
# Core
34683514
menuselect/menuselect --enable app_bridgeaddchan --enable app_channelredirect --enable app_chanspy --enable app_confbridge --enable app_dial --enable app_exec menuselect.makeopts
3469-
menuselect/menuselect --enable app_flash --enable app_mixmonitor --enable app_originate --enable app_playback --enable app_playtones --enable app_read menuselect.makeopts
3515+
menuselect/menuselect --enable app_flash --enable app_mixmonitor --enable app_originate --enable app_playback --enable app_playtones --enable app_read --enable app_userevent menuselect.makeopts
34703516
menuselect/menuselect --enable chan_bridge_media --enable chan_dahdi --enable chan_iax2 --enable chan_pjsip menuselect.makeopts
34713517
menuselect/menuselect --enable codec_a_mu --enable codec_dahdi --enable codec_ulaw menuselect.makeopts
34723518
menuselect/menuselect --enable format_pcm --enable format_sln --enable format_wav menuselect.makeopts
@@ -3558,6 +3604,19 @@ elif [ "$cmd" = "install" ]; then
35583604
fi
35593605
$AST_MAKE install # actually install modules and binary
35603606

3607+
if [ "$RPT_MODULES" = "1" ]; then
3608+
# Also install the radio sounds
3609+
if [ ! -d $AST_SOUNDS_DIR/rpt ]; then
3610+
printf "RPT sounds don't exist yet, adding them now...\n"
3611+
mkdir $AST_SOUNDS_DIR/rpt
3612+
cd $AST_SOUNDS_DIR/rpt
3613+
wget "http://downloads.allstarlink.org/asterisk-asl-sounds-en-ulaw.tar.gz"
3614+
# Sounds are extracted directly into the dir
3615+
tar -xvzf asterisk-asl-sounds-en-ulaw.tar.gz
3616+
rm asterisk-asl-sounds-en-ulaw.tar.gz
3617+
fi
3618+
fi
3619+
35613620
# Debugging: see where Asterisk got installed
35623621
which asterisk
35633622
which rasterisk
@@ -3774,7 +3833,7 @@ elif [ "$cmd" = "sounds" ]; then
37743833
cd /tmp
37753834
mkdir -p patfleet
37763835
cd patfleet
3777-
git clone https://github.com/hharte/PatFleet-asterisk/
3836+
git clone --depth 1 https://github.com/hharte/PatFleet-asterisk/
37783837
cd PatFleet-asterisk/pa
37793838
mv dictate/* $AST_SOUNDS_DIR/dictate
37803839
mv digits/* $AST_SOUNDS_DIR/digits
@@ -3912,7 +3971,7 @@ elif [ "$cmd" = "mkdocs" ]; then
39123971
git pull
39133972
rm -rf /tmp/documentation/temp/site
39143973
else
3915-
git clone https://github.com/asterisk/documentation.git --depth 1
3974+
git clone --depth 1 https://github.com/asterisk/documentation.git
39163975
cd documentation
39173976
fi
39183977

@@ -3937,7 +3996,7 @@ elif [ "$cmd" = "pubdocs" ]; then
39373996
if [ -d publish-docs ]; then
39383997
rm -rf publish-docs
39393998
fi
3940-
git clone https://github.com/asterisk/publish-docs.git
3999+
git clone --depth 1 https://github.com/asterisk/publish-docs.git
39414000
cd publish-docs
39424001
echo $AST_SOURCE_PARENT_DIR
39434002
printf "%s\n" "Generating Confluence markup..."

0 commit comments

Comments
 (0)