@@ -253,6 +253,7 @@ DAHDI_OLD_DRIVERS=0
253253DAHDI_DISABLE_VPMADT032=0
254254EMPULSE=1 # Automatically enable EMPULSE, cause why not?
255255DAHDI_WANPIPE=0 # wanpipe only needed for Sangoma cards
256+ OPENR2=0 # Install OpenR2
256257DEVMODE=0
257258TEST_SUITE=0
258259FORCE_INSTALL=0
@@ -2244,6 +2245,16 @@ install_dahdi() {
22442245 fi
22452246 fi
22462247
2248+ if [ " $OPENR2 " = " 1" ]; then
2249+ if [ " $OFFLINE_INSTALL " = " 1" ]; then
2250+ cd $AST_SOURCE_PARENT_DIR
2251+ cp -r $OFFLINE_DIR /openr2 .
2252+ else
2253+ get_openr2_source
2254+ fi
2255+ build_openr2
2256+ fi
2257+
22472258 if [ " $OFFLINE_INSTALL " = " 1" ]; then
22482259 cp -r $OFFLINE_DIR /dahlin-offline .
22492260 else
@@ -2620,6 +2631,49 @@ build_sccp() {
26202631 fi
26212632}
26222633
2634+ get_openr2_source () {
2635+ cd $AST_SOURCE_PARENT_DIR
2636+ # The OpenR2 repo is currently stagnant, so if it's present, then just use the latest 'develop' HEAD and apply any needed patches
2637+ if [ -d openr2 ]; then
2638+ cd openr2
2639+ git checkout .
2640+ git clean -df
2641+ else
2642+ git clone --depth 1 " https://github.com/moises-silva/openr2.git"
2643+ cd openr2
2644+ fi
2645+ }
2646+
2647+ build_openr2 () {
2648+ cd $AST_SOURCE_PARENT_DIR
2649+ if [ ! -d openr2 ]; then
2650+ die " openr2 source directory not found"
2651+ fi
2652+ cd openr2
2653+ git_patch " openr2.diff"
2654+ # r2test fails to install during 'make install', so skip it
2655+ ./configure --prefix=/usr --without-r2test
2656+ # This will initially fail, due to the fix needed below
2657+ $AST_MAKE -j$( nproc) CFLAGS=-Wno-pedantic
2658+ # src/libopenr2.la won't exist when we start compiling, but it will exist by this point
2659+ sed -i " s/inherited_linker_flags=''/inherited_linker_flags=' -shared'/g" src/libopenr2.la # otherwise it will fail when linking
2660+ # Now, we can finish the job:
2661+ $AST_MAKE CFLAGS=-Wno-pedantic
2662+ if [ $? -ne 0 ]; then
2663+ die " Failed to build OpenR2"
2664+ fi
2665+ # Without --without-r2test, this may return non-zero due to r2test missing
2666+ $AST_MAKE install
2667+ if [ $? -ne 0 ]; then
2668+ die " Failed to install OpenR2"
2669+ fi
2670+ # If this symbol isn't exported, then HAVE_OPENR2 will not be defined for Asterisk later
2671+ readelf -s /usr/lib64/libopenr2.so | grep " openr2_chan_new"
2672+ if [ $? -ne 0 ]; then
2673+ echoerr " libopenr2.so does not appear to export openr2_chan_new, OpenR2 build may be incomplete"
2674+ fi
2675+ }
2676+
26232677# Instantiate an instance of the PhreakScript repository, if not already present
26242678# This is necessary since this script file is designed to be able to be used standalone,
26252679# without the rest of the repository necessarily being present.
@@ -3395,7 +3449,7 @@ else
33953449fi
33963450
33973451FLAG_TEST=0
3398- 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,disable-vpmadt032,experimental,extcodecs,g72x,fast,freepbx,generic,autokvers,lightweight,api-key:,rotate,audit,boilerplate,upstream:,manselect,minimal,vanilla,wanpipe,offline,noupdate -- " $@ " )
3452+ 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,disable-vpmadt032,experimental,extcodecs,g72x,fast,freepbx,generic,autokvers,lightweight,api-key:,rotate,audit,boilerplate,upstream:,manselect,minimal,vanilla,wanpipe,openr2, offline,noupdate -- " $@ " )
33993453VALID_ARGUMENTS=$?
34003454if [ " $VALID_ARGUMENTS " != " 0" ]; then
34013455 usage
@@ -3452,6 +3506,7 @@ while true; do
34523506 --minimal ) ENHANCED_INSTALL=0; shift ;;
34533507 --vanilla ) EXTRA_FEATURES=0; shift ;;
34543508 --wanpipe ) DAHDI_WANPIPE=1; shift ;;
3509+ --openr2 ) OPENR2=1; shift ;;
34553510 --offline ) OFFLINE_INSTALL=1; shift ;;
34563511 --noupdate ) PACMAN_NOUPDATE=1; shift ;;
34573512 # -- means the end of the arguments; drop this, and break out of the while loop
@@ -3727,6 +3782,9 @@ elif [ "$cmd" = "offline" ]; then
37273782 if [ " $CHAN_SCCP " = " 1" ]; then
37283783 get_sccp_source
37293784 fi
3785+ if [ " $OPENR2 " = " 1" ]; then
3786+ get_openr2_source
3787+ fi
37303788 echog " Offline installation source prepared in $AST_SOURCE_PARENT_DIR - copy this directory to target system for offline installation"
37313789 ls $AST_SOURCE_PARENT_DIR
37323790elif [ " $cmd " = " install" ]; then
0 commit comments