Skip to content

Commit da3e23c

Browse files
committed
install: Add option to install OpenR2.
Allow OpenR2, with compilation fixes, to be installed.
1 parent 46ddc6f commit da3e23c

File tree

5 files changed

+108
-4
lines changed

5 files changed

+108
-4
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ jobs:
280280
phreaknet runtests
281281
debian-12-asterisk-latest:
282282
runs-on: ubuntu-24.04
283-
name: Debian 12
283+
name: Debian 12, with OpenR2
284284
container: debian:12
285285
steps:
286286
- uses: actions/checkout@v4
287287
- name: Build DAHDI and Asterisk
288288
run: |
289289
./phreaknet.sh make
290-
GIT_REPO_PATH=${GITHUB_WORKSPACE} phreaknet install --fast --dahdi --drivers --sip --testsuite
290+
GIT_REPO_PATH=${GITHUB_WORKSPACE} phreaknet install --fast --dahdi --drivers --openr2 --sip --testsuite
291291
- name: Run tests
292292
run: |
293293
phreaknet runtests

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PhreakScript installs:
88
- DAHDI Linux 3.4.0 (with optional DAHDI install flag)
99
- DAHDI Tools 3.4.0 (with optional DAHDI install flag)
1010
- wanpipe 7.0.38 (with optional wanpipe install flag)
11+
- OpenR2, with compilation fixes (with optional install flag)
1112
- Bug fixes and stability improvements
1213
- Restores the "great purge" of DAHDI drivers that were removed in 2018 by Sangoma (either by default, or with `--drivers` flag)
1314
- Numerous DAHDI/wanpipe/LibPRI compilation fixes
@@ -34,7 +35,7 @@ PhreakScript installs:
3435
- Restored and enhanced [`chan_sip`](https://github.com/InterLinked1/chan_sip) for master / versions 21+ (removed by Sangoma) (with `--sip` flag)
3536
- Adds fax timing and parameter control to `chan_sip`
3637
- Cisco Call Manager support for `chan_sip` (with `--cisco` flag)
37-
- `chan_sccp` (improved community Skinny/SCCP channel driver), with compilation fixes (with `--sccp` flag)
38+
- `chan_sccp` (improved community Skinny/SCCP channel driver), with compilation fixes (with `--sccp` flag)
3839
- Message Send Protocol send support
3940
- Streamlined delivery of push notifications to Polycom IP phones
4041
- AGI `RECORD FILE` option to require noise before silence detection

patches/openr2.diff

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/src/r2context.c b/src/r2context.c
2+
index 36829fe..3aa71e1 100755
3+
--- a/src/r2context.c
4+
+++ b/src/r2context.c
5+
@@ -148,6 +148,7 @@ static int want_generate_default(openr2_mf_tx_state_t *state, int signal)
6+
return 1;
7+
}
8+
9+
+#if 0
10+
static const openr2_mf_read_init_func mf_read_init_default = (openr2_mf_read_init_func)openr2_mf_rx_init;
11+
static const openr2_mf_write_init_func mf_write_init_default = (openr2_mf_write_init_func)openr2_mf_tx_init;
12+
static const openr2_mf_detect_tone_func mf_detect_tone_default = (openr2_mf_detect_tone_func)openr2_mf_rx;
13+
@@ -157,6 +158,7 @@ static const openr2_mf_want_generate_func mf_want_generate_default = (openr2_mf_
14+
15+
static const openr2_alaw_to_linear_func alaw_to_linear_default = openr2_alaw_to_linear;
16+
static const openr2_linear_to_alaw_func linear_to_alaw_default = openr2_linear_to_alaw;
17+
+#endif
18+
19+
static openr2_mflib_interface_t default_mf_interface = {
20+
/* .mf_read_init */ (openr2_mf_read_init_func)openr2_mf_rx_init,
21+
diff --git a/src/r2proto.c b/src/r2proto.c
22+
index c32bc2f..0a5832d 100755
23+
--- a/src/r2proto.c
24+
+++ b/src/r2proto.c
25+
@@ -829,7 +829,7 @@ static void open_logfile(openr2_chan_t *r2chan, int backward)
26+
return;
27+
}
28+
29+
- if (!r2chan->r2context->logdir) {
30+
+ if (!r2chan->r2context->logdir[0]) {
31+
cres = getcwd(currdir, sizeof(currdir));
32+
if (!cres) {
33+
myerrno = errno;
34+
@@ -850,7 +850,7 @@ static void open_logfile(openr2_chan_t *r2chan, int backward)
35+
return;
36+
}
37+
res = snprintf(r2chan->logname, sizeof(r2chan->logname), "%s/chan-s%dc%d-%s-%04ld-%d%02d%02d%02d%02d%02d.call",
38+
- r2chan->r2context->logdir ? r2chan->r2context->logdir : currdir,
39+
+ r2chan->r2context->logdir[0] ? r2chan->r2context->logdir : currdir,
40+
r2chan->span_id, r2chan->number,
41+
backward ? "backward" : "forward",
42+
r2chan->call_count++,

phreaknet.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ directories if necessary.
370370
**--wanpipe**
371371
: Also install the Wanpipe drivers, needed for Sangoma cards
372372

373+
**--openr2**
374+
: Also install OpenR2
375+
373376
The following options may be used with the **sounds** command.
374377

375378
**--boilerplate**

phreaknet.sh

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ DAHDI_OLD_DRIVERS=0
253253
DAHDI_DISABLE_VPMADT032=0
254254
EMPULSE=1 # Automatically enable EMPULSE, cause why not?
255255
DAHDI_WANPIPE=0 # wanpipe only needed for Sangoma cards
256+
OPENR2=0 # Install OpenR2
256257
DEVMODE=0
257258
TEST_SUITE=0
258259
FORCE_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
33953449
fi
33963450

33973451
FLAG_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 -- "$@")
33993453
VALID_ARGUMENTS=$?
34003454
if [ "$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
37323790
elif [ "$cmd" = "install" ]; then

0 commit comments

Comments
 (0)