@@ -319,6 +319,8 @@ elif [ "$OS_DIST_INFO" = "openSUSE Tumbleweed" ]; then
319
319
PAC_MAN=" zypper"
320
320
elif [ -r /etc/arch-release ]; then
321
321
PAC_MAN=" pacman"
322
+ elif [ -r /etc/alpine-release ]; then
323
+ PAC_MAN=" apk"
322
324
elif [ ! -f /etc/debian_version ]; then # Default is Debian
323
325
echoerr " Support for this platform ($OS_DIST_INFO ) is limited... use at your own risk..."
324
326
@@ -360,6 +362,8 @@ update_packages() {
360
362
zypper update -y
361
363
elif [ " $PAC_MAN " = " pacman" ]; then
362
364
pacman -Syu --noconfirm
365
+ elif [ " $PAC_MAN " = " apk" ]; then
366
+ apk update
363
367
elif [ " $PAC_MAN " = " pkg" ]; then
364
368
pkg install -y
365
369
pkg upgrade -y
@@ -374,11 +378,13 @@ install_package() {
374
378
if [ " $PAC_MAN " = " apt-get" ]; then
375
379
apt-get install -y $1
376
380
elif [ " $PAC_MAN " = " yum" ]; then
377
- yum install -y $1
381
+ yum install -y --allowerasing $1
378
382
elif [ " $PAC_MAN " = " zypper" ]; then
379
383
zypper install -y $1
380
384
elif [ " $PAC_MAN " = " pacman" ]; then
381
385
pacman -Sy --noconfirm $1
386
+ elif [ " $PAC_MAN " = " apk" ]; then
387
+ apk add $1
382
388
elif [ " $PAC_MAN " = " pkg" ]; then
383
389
pkg install -y $1
384
390
else
@@ -398,6 +404,8 @@ if ! which "which" > /dev/null; then
398
404
install_package " which"
399
405
elif [ " $PAC_MAN " = " pacman" ]; then
400
406
install_package " which"
407
+ elif [ " $PAC_MAN " = " apk" ]; then
408
+ install_package " apk"
401
409
fi
402
410
if ! which " which" > /dev/null; then
403
411
echoerr " which is still not installed?"
@@ -414,11 +422,17 @@ ensure_installed() {
414
422
ensure_installed " wget"
415
423
416
424
# Wget2 does not support --show-progress, uses --force-progress instead
417
- WGET_VERSION=$( wget --version | head -n 1 )
418
- if [ " ${WGET_VERSION#* " Wget2" } " != " $WGET_VERSION " ]; then
419
- WGET=" $WGET --force-progress"
420
- else
421
- WGET=" $WGET --show-progress"
425
+ if [ " $PAC_MAN " = " apk" ]; then
426
+ # Alpine's wget is part of BusyBox and doesn't have any progress options anyways
427
+ WGET=" $WGET "
428
+ fi
429
+ if [ " $WGET " = " " ]; then
430
+ WGET_VERSION=$( wget --version | head -n 1 )
431
+ if [ " ${WGET_VERSION#* " Wget2" } " != " $WGET_VERSION " ]; then
432
+ WGET=" $WGET --force-progress"
433
+ else
434
+ WGET=" $WGET --show-progress"
435
+ fi
422
436
fi
423
437
424
438
if [ " $OS_DIST_INFO " = " Sangoma Linux" ]; then # the FreePBX distro...
@@ -431,6 +445,13 @@ if ! which "getopt" > /dev/null; then
431
445
fi
432
446
ensure_installed " hostname"
433
447
448
+ AST_CONFIGURE_FLAGS=" --with-jansson-bundled"
449
+ if [ " $PAC_MAN " = " apk" ]; then
450
+ AST_CONFIGURE_FLAGS=" $AST_CONFIGURE_FLAGS --without-pjproject-bundled --without-execinfo"
451
+ else
452
+ AST_CONFIGURE_FLAGS=" $AST_CONFIGURE_FLAGS --with-pjproject-bundled" # default
453
+ fi
454
+
434
455
phreakscript_info () {
435
456
printf " %s" " Hostname: "
436
457
hostname
@@ -972,6 +993,15 @@ install_prereq() {
972
993
if [ " $1 " = " 1" ]; then
973
994
PREREQ_PACKAGES=" $PREREQ_PACKAGES subversion libedit"
974
995
fi
996
+ elif [ " $PAC_MAN " = " apk" ]; then
997
+ PREREQ_PACKAGES=" $PREREQ_PACKAGES build-base git"
998
+ if [ " $CHAN_DAHDI " = " 1" ]; then
999
+ PREREQ_PACKAGES=" $PREREQ_PACKAGES autoconf automake m4 libtool newt-dev"
1000
+ fi
1001
+ if [ " $1 " = " 1" ]; then
1002
+ PREREQ_PACKAGES=" $PREREQ_PACKAGES libedit-dev libxml2-dev subversion"
1003
+ PREREQ_PACKAGES=" $PREREQ_PACKAGES util-linux-dev" # uuid development
1004
+ fi
975
1005
elif [ " $PAC_MAN " = " pkg" ]; then
976
1006
PREREQ_PACKAGES=" $PREREQ_PACKAGES git gmake"
977
1007
if [ " $CHAN_DAHDI " = " 1" ]; then
@@ -994,9 +1024,6 @@ install_prereq() {
994
1024
if [ " $PAC_MAN " = " yum" ]; then
995
1025
# Stop on RHEL systems without an active subscription since packages are failing to install
996
1026
if ! which git > /dev/null; then
997
- if [ -f /etc/redhat-release ]; then
998
- echoerr " Subscription required to use RHEL package manager"
999
- fi
1000
1027
die " Git does not appear to be installed"
1001
1028
fi
1002
1029
if [ " $1 " = " 1" ]; then
@@ -1350,7 +1377,7 @@ install_testsuite_itself() {
1350
1377
}
1351
1378
1352
1379
configure_devmode () {
1353
- ./configure --enable-dev-mode --with-jansson-bundled --with-pjproject-bundled
1380
+ ./configure --enable-dev-mode $AST_CONFIGURE_FLAGS
1354
1381
if [ $? -ne 0 ]; then
1355
1382
exit 2
1356
1383
fi
@@ -1739,6 +1766,32 @@ install_dahdi() {
1739
1766
install_package " kmod kernel-source"
1740
1767
elif [ " $PAC_MAN " = " pacman" ]; then
1741
1768
install_package " kmod linux-headers"
1769
+ elif [ " $PAC_MAN " = " apk" ]; then
1770
+ install_package " linux-headers linux-lts-dev"
1771
+ apk search linux-headers
1772
+ ls -la /usr/src
1773
+ KERNEL_HEADERS_DETECTED_VER=$( ls /usr/src/ | grep linux-headers | cut -d' -' -f3- )
1774
+ kernel_ver=$( uname -r | cut -d' .' -f1-5 )
1775
+ if [ " $KERNEL_HEADERS_DETECTED_VER " != " $kernel_ver " ]; then
1776
+ echoerr " Kernel headers mismatch present? ($KERNEL_HEADERS_DETECTED_VER != $kernel_ver )"
1777
+ if [ " $AUTOSET_KVERS " = " 1" ]; then
1778
+ printf " Auto-setting KVERS=%s\n" " $KERNEL_HEADERS_DETECTED_VER "
1779
+ KVERS=" $KERNEL_HEADERS_DETECTED_VER "
1780
+ fi
1781
+ if [ " $KVERS " != " " ]; then
1782
+ # Kernel version override for GitHub CI builds
1783
+ ksrc_dir=$( ls /usr/src/ | grep linux-headers | grep " ${KVERS} " | head -n 1 | tr -d ' \n' )
1784
+ printf " Kernel source dir: %s\n" " $ksrc_dir "
1785
+ new_ksrc=" /usr/src/${ksrc_dir} "
1786
+ if [ " $new_ksrc " == " " ]; then
1787
+ printf " Installed kernels:\n"
1788
+ ls /usr/src/ | grep linux-headers
1789
+ die " Couldn't autodetermine KSRC from KVERS"
1790
+ fi
1791
+ printf " Setting KSRC to %s\n" " $new_ksrc "
1792
+ export KSRC=" $new_ksrc "
1793
+ fi
1794
+ fi
1742
1795
elif [ " $PAC_MAN " = " pkg" ]; then
1743
1796
echoerr " DAHDI is not supported on FreeBSD! Proceed at your own risk!"
1744
1797
sleep 2
@@ -2416,7 +2469,7 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
2416
2469
2417
2470
if [ $AST_MAJOR_VER -lt 21 ]; then
2418
2471
if [ " $EXTERNAL_CODECS " = " 1" ]; then
2419
- phreak_nontree_patch " main/translate.c" " translate.diff" " https://issues.asterisk.org/jira/secure/attachment/60464/ translate.diff" # Bug fix to translation code
2472
+ phreak_nontree_patch " main/translate.c" " translate.diff" " https://issues-archive .asterisk.org/attachments/29/ASTERISK-29455/00- translate.diff" # Bug fix to translation code
2420
2473
else
2421
2474
# WARNING: This will cause a crash due to ABI incompatibility if any external codecs are used. Use the older translate.diff patch in that case.
2422
2475
# This has been merged into master, but for the above reason will not appear in Asterisk until v21 when new binary codec modules are created for external codecs.
@@ -2961,6 +3014,12 @@ get_source() {
2961
3014
if [ " $OS_DIST_INFO " = " FreeBSD" ]; then
2962
3015
freebsd_port_patches
2963
3016
fi
3017
+ if [ " $PAC_MAN " = " apk" ]; then
3018
+ custom_fuzzy_patch " 10-musl-mutex-init.patch" " https://git.alpinelinux.org/aports/plain/main/asterisk/10-musl-mutex-init.patch"
3019
+ custom_fuzzy_patch " 20-musl-astmm-fix.patch" " https://git.alpinelinux.org/aports/plain/main/asterisk/20-musl-astmm-fix.patch"
3020
+ custom_fuzzy_patch " 40-asterisk-cdefs.patch" " https://git.alpinelinux.org/aports/plain/main/asterisk/40-asterisk-cdefs.patch"
3021
+ custom_fuzzy_patch " 41-asterisk-ALLPERMS.patch" " https://git.alpinelinux.org/aports/plain/main/asterisk/41-asterisk-ALLPERMS.patch"
3022
+ fi
2964
3023
}
2965
3024
2966
3025
# Minimum argument check
@@ -3182,12 +3241,15 @@ elif [ "$cmd" = "make" ]; then
3182
3241
if [ " $FILE_PATH " = " /usr/local/sbin/phreaknet" ]; then
3183
3242
die " PhreakScript is already installed, to reinstall, execute 'make' using the new script, e.g. ./phreaknet.sh make"
3184
3243
fi
3244
+ if [ ! -d /usr/local/sbin ]; then # Doesn't exist out of the box on Alpine Linux
3245
+ mkdir /usr/local/sbin
3246
+ fi
3185
3247
ln -nsf $FILE_PATH /usr/local/sbin/phreaknet
3186
3248
if [ $? -eq 0 ]; then
3187
3249
echo " PhreakScript added to path."
3188
3250
else
3189
- echo " PhreakScript could not be added to path. Is it already there?"
3190
- echo " If it's not, move the source file (phreaknet.sh) to /usr/local/src and try again"
3251
+ echoerr " PhreakScript could not be added to path. Is it already there?"
3252
+ echoerr " If it's not, move the source file (phreaknet.sh) to /usr/local/src and try again"
3191
3253
fi
3192
3254
elif [ " $cmd " = " man" ]; then
3193
3255
cd /tmp
@@ -3321,10 +3383,26 @@ elif [ "$cmd" = "install" ]; then
3321
3383
fi
3322
3384
./contrib/scripts/install_prereq install
3323
3385
3386
+ if [ " $PAC_MAN " = " apk" ]; then
3387
+ # No bundled pjproject for Alpine Linux
3388
+ cd /usr/src
3389
+ PJPROJECT_VER=" 2.15.1"
3390
+ $WGET https://github.com/pjsip/pjproject/archive/refs/tags/$PJPROJECT_VER .tar.gz
3391
+ tar -zxvf $PJPROJECT_VER .tar.gz && rm $PJPROJECT_VER .tar.gz
3392
+ cd pjproject-$PJPROJECT_VER
3393
+ ./configure --prefix=/usr --enable-shared --enable-ext-sound --disable-opencore-amr --disable-pjsua2 CFLAGS=" -O2 -DNDEBUG"
3394
+ make dep
3395
+ echo " export LDFLAGS += -lexecinfo" > user.mak # for backtrace using musl
3396
+ make
3397
+ make install
3398
+ ldconfig
3399
+ cd $AST_SOURCE_PARENT_DIR /$AST_SRC_DIR
3400
+ fi
3401
+
3324
3402
if [ " $DEVMODE " = " 1" ]; then
3325
3403
configure_devmode
3326
3404
else
3327
- ./configure --with-jansson-bundled --with-pjproject-bundled
3405
+ ./configure $AST_CONFIGURE_FLAGS
3328
3406
fi
3329
3407
if [ $? -ne 0 ]; then
3330
3408
exit 2
@@ -3441,28 +3519,27 @@ elif [ "$cmd" = "install" ]; then
3441
3519
sed -i " " -e ' s|WRAP_LIBC_MALLOC|ASTMM_LIBC ASTMM_REDIRECT|g' addons/mp3/interface.c # for format_mp3
3442
3520
sed -i " " -e ' s|\\s|s|g' build_tools/make_xml_documentation # fix sed command in this script to remove the backslash for BSD sed
3443
3521
$AST_MAKE " ASTLDFLAGS=-lcrypt -lsysinfo" main
3444
- if [ $? -eq 0 ]; then
3445
- $AST_MAKE -j$( nproc) # compile Asterisk. This is the longest step, if you are installing for the first time. Also, don't let it take over the server.
3446
- fi
3447
- else
3522
+ fi
3523
+
3524
+ if [ " $PAC_MAN " = " apk" ]; then
3525
+ $AST_MAKE -j$( nproc) ASTCFLAGS=" -w" utils # for astdb2sqlite3.c, #warning usage of non-standard #include <sys/cdefs.h> is deprecated [-Werror=cpp]
3526
+ $AST_MAKE -j$( nproc) ASTCFLAGS=" -w" addons # for format_mp3, error: #warning redirecting incorrect #include <sys/signal.h> to <signal.h> [-Werror=cpp]
3527
+ $AST_MAKE -j$( nproc) ASTCFLAGS=" -w" main # for ast_expr2.c, #warning usage of non-standard #include <sys/cdefs.h> is deprecated [-Werror=cpp]
3528
+ $AST_MAKE -j$( nproc) ASTCFLAGS=" -w" channels # XXX: Temporary, for chan_dahdi.c:7840:18: error: unused variable 'x' [-Werror=unused-variable]
3529
+ fi
3530
+
3531
+ # Compile Asterisk. This is the longest step, if you are installing for the first time.
3532
+ if [ $? -eq 0 ]; then
3448
3533
$AST_MAKE -j$( nproc) main # compile 'main' subdirectory first
3449
- if [ $? -eq 0 ] ; then
3450
- $AST_MAKE -j $( nproc ) # compile Asterisk. This is the longest step, if you are installing for the first time. Also, don't let it take over the server.
3451
- fi
3534
+ fi
3535
+ if [ $? -eq 0 ] ; then
3536
+ $AST_MAKE -j $( nproc )
3452
3537
fi
3453
3538
3454
3539
if [ $? -ne 0 ]; then
3455
3540
gcc -v
3456
3541
$AST_MAKE # Finish compiling antyhing that would build successfully, from the parallel build, so the noisy build only builds the offending target
3457
3542
$AST_MAKE NOISY_BUILD=1 # show actual compilation command that failed, with no parallelism
3458
- # if [ ! -f channels/chan_dahdi.o ]; then
3459
- # echoerr "Compilation of chan_dahdi failed?" # Only suggest this if we got around to compiling some channel drivers to begin with
3460
- # ls -la /usr/include/dahdi
3461
- # # Debug failed chan_dahdi compilation
3462
- # # chan_dahdi.c:7677:18: error: unused variable 'x' [-Werror=unused-variable]
3463
- # # 7677 | int res, x;
3464
- # sed -n 7677,7800p channels/chan_dahdi.c
3465
- # fi
3466
3543
if [ " $DEVMODE " = " 1" ] && [ -f doc/core-en_US.xml ]; then # run just make validate-docs for doc validation
3467
3544
$XMLSTARLET val -d doc/appdocsxml.dtd -e doc/core-en_US.xml # by default, it doesn't tell you whether the docs failed to validate. So if validation failed, print that out.
3468
3545
fi
0 commit comments