aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk/APKBUILD
blob: c3d50e6c0f8ebcb8e6a1c2b51b0fa1768dac2698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Timo Teras <timo.teras@iki.fi>
# Maintainer: Timo Teras <timo.teras@iki.fi>
pkgname=asterisk
pkgver=18.2.2
pkgrel=0
pkgdesc="Modular Open Source PBX System"
pkgusers="asterisk"
pkggroups="asterisk"
url="https://www.asterisk.org/"
arch="all"
license="GPL-2.0-only WITH OpenSSL-Exception"
options="!check"  # Test suite is separate, and require separate build
makedepends="findutils tar bsd-compat-headers libtool
	ncurses-dev popt-dev newt-dev zlib-dev libedit-dev tiff-dev curl-dev
	openssl-dev lua-dev libcap-dev jansson-dev util-linux-dev
	sqlite-dev postgresql-dev unixodbc-dev freetds-dev mariadb-connector-c-dev
	alsa-lib-dev pjproject-dev dahdi-tools-dev libpri-dev libsrtp-dev
	spandsp-dev libresample speex-dev speexdsp-dev libogg-dev
	bluez-dev libxml2-dev imap-dev unbound-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-pgsql $pkgname-odbc
	$pkgname-tds $pkgname-fax $pkgname-sample-config:config:noarch
	$pkgname-sounds-moh:sound_moh:noarch $pkgname-sounds-en:sound_en:noarch
	$pkgname-mobile $pkgname-curl:_curl $pkgname-srtp $pkgname-dahdi
	$pkgname-speex $pkgname-alsa $pkgname-cdr-mysql:cdr_mysql $pkgname-openrc"

_download="https://downloads.asterisk.org/pub/telephony/asterisk/releases"
source="$_download/asterisk-$pkgver.tar.gz
	https://dev.alpinelinux.org/~tteras/asterisk-addon-mp3-r201.patch.gz
	10-musl-mutex-init.patch
	20-musl-astmm-fix.patch
	30-asterisk-mariadb.patch
	40-asterisk-cdefs.patch
	asterisk.initd
	asterisk.confd
	asterisk.logrotate"

# secfixes:
#   18.2.2-r0:
#     - CVE-2019-15297
#   18.2.1-r0:
#     - CVE-2021-26712
#     - CVE-2021-26713
#     - CVE-2021-26717
#     - CVE-2021-26906
#   18.1.1-r0:
#     - CVE-2020-35652
#     - CVE-2020-35776
#   18.0.1-r0:
#     - CVE-2020-28327
#   16.6.2-r0:
#     - CVE-2019-18610
#     - CVE-2019-18790
#   16.5.1-r0:
#     - CVE-2019-15297
#     - CVE-2019-15639
#   16.4.1-r0:
#     - CVE-2019-12827
#   16.3.0-r0:
#     - CVE-2019-7251
#   15.7.1-r0:
#     - CVE-2018-19278

prepare() {
	default_prepare
	update_config_guess

	# asteriskssl does not have direct references to libssl, but looks up
	# symbols from it using dlsym(RTLD_NEXT), so use --no-as-needed for it.
	sed -i -e 's/ASTSSL_LIBS:=$(OPENSSL_LIB)/ASTSSL_LIBS:=-Wl,--no-as-needed $(OPENSSL_LIB) -Wl,--as-needed/g' main/Makefile
}

build() {
	SHA1SUM="$PWD"/build_tools/sha1sum-sh ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--libdir=/usr/lib \
		--localstatedir=/var \
		--disable-xmldoc \
		--enable-permanent-dlopen \
		--with-gsm=internal \
		--with-popt \
		--with-z \
		--with-newt \
		--with-unixodbc \
		--with-postgres \
		--with-tds \
		--with-dahdi \
		--with-pri \
		--with-tonezone \
		--with-resample \
		--with-sqlite3 \
		--with-speex \
		--with-asound \
		--without-x11 \
		--without-pjproject-bundled \
		--with-spandsp \
		--with-bluetooth \
		--with-libcurl \
		--with-libedit \
		--with-srtp \
		--with-imap=system \
		CFLAGS="$CFLAGS -DENABLE_SRTP_AES_256"

	# get default modules to build
	rm -f menuselect.makeopts
	make menuselect.makeopts

	# and add the non-default modules we need
	./menuselect/menuselect \
		--enable chan_mobile \
		--enable app_meetme \
		--enable cdr_mysql \
		--disable BUILD_NATIVE \
		--enable IMAP_STORAGE \
		menuselect.makeopts

	# build
	make LDCONFIG=
}

package() {
	make DESTDIR="$pkgdir" LDCONFIG_FLAGS="-n" install
	make DESTDIR="$pkgdir" install-headers

	install -d "$pkgdir"/var/run/asterisk
	install -d "$pkgdir"/var/lib/asterisk

	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.logrotate \
		"$pkgdir"/etc/logrotate.d/$pkgname

	chown -R asterisk:asterisk "$pkgdir"/var/*/asterisk
	chown -R asterisk:asterisk "$pkgdir"/etc/asterisk
	chmod -R u=rwX,g=rX,o= "$pkgdir"/etc/asterisk

	# let alpine-baselayout set permissions of /tmp
	rm -r "$pkgdir"/tmp
}

dev() {
	default_dev
	depends="asterisk"

	# move back the /usr/lib/libasteriskssl.so symlink, asterisk needs it
	# see http://bugs.alpinelinux.org/issues/6393
	mv "$subpkgdir"/usr/lib/libasteriskssl.so "$pkgdir"/usr/lib/libasteriskssl.so
}

pgsql() { amove usr/lib/asterisk/modules/*_pgsql*; }
odbc() { amove usr/lib/asterisk/modules/*_odbc*; }
tds() { amove usr/lib/asterisk/modules/*_tds*; }
fax() { amove usr/lib/asterisk/modules/*_fax*; }
mobile() { amove usr/lib/asterisk/modules/*_mobile*; }
_curl() { amove usr/lib/asterisk/modules/*_curl*; }
cdr_mysql() { amove usr/lib/asterisk/modules/*cdr_mysql*; }
srtp() { amove usr/lib/asterisk/modules/*_srtp*; }
dahdi() { amove usr/lib/asterisk/modules/*_dahdi*; }
speex() { amove usr/lib/asterisk/modules/*_speex*; }
alsa() { amove usr/lib/asterisk/modules/*_alsa*; }

config() {
	pkgdesc="Sample configuration files for asterisk"
	cd "$builddir"
	mkdir -p "$subpkgdir"/var/lib/asterisk/phoneprov
	make -j1 samples DESTDIR="$subpkgdir"

	chown -R asterisk:asterisk "$subpkgdir"/var/*/asterisk
	chown -R asterisk:asterisk "$subpkgdir"/etc/asterisk
	chmod -R u=rwX,g=rX,o= "$subpkgdir"/etc/asterisk
}

sound_moh() {
	pkgdesc="Default on-hold music files for asterisk"
	depends=
	amove var/lib/asterisk/moh
	chown -R asterisk:asterisk "$subpkgdir"/var/*/asterisk
}

sound_en() {
	pkgdesc="English sound files for asterisk"
	depends=
	amove var/lib/asterisk/sounds/en
	chown -R asterisk:asterisk "$subpkgdir"/var/*/asterisk
}

sha512sums="e15fe3c7f46d49991bcb6f6f565f15e4af0d658b4cd6b091079209dd95a8027858effdc2f2314d72ed46a73cdebc089d3c27d5cf8db50d2d21f3c317a8a4a546  asterisk-18.2.2.tar.gz
aacef3f4796fb1abd33266998b53909cb4b36e7cc5ad2f7bac68bdc43e9a9072d9a4e2e7e681bddfa31f3d04575eb248afe6ea95da780c67e4829c1e22adfe1b  asterisk-addon-mp3-r201.patch.gz
771237ba6d42ab62d914f2702234b23fd0bc8c22f2aa33b0e745c9170163c8046f6d48ecb299faab3d6fb397f1aa046421083c3cc88510c9779861c522f357dd  10-musl-mutex-init.patch
0fae11b42894ab3d405bc50e9275b9084712b482fbf9b4259ea938667fc5cbe413655f3ff83da0f607151bb2b6e49c2f741b5ada6944dbb478f076ef8d86380a  20-musl-astmm-fix.patch
616de74bdd3c4a6e899128c73e31f5ff219095d2afe321f85a51f518ec2e9dac9b63396eed8e2568c295f1beb90f9a506c72d28211a973b35185bfffd24af37e  30-asterisk-mariadb.patch
ba33f11169284f190b7dabab1da7d2751cb65d7976408db635a892fa17d7552e1660350017e7aada3464ecc7d9d6e99d6ad76d66c0036de062a386cffbc948e6  40-asterisk-cdefs.patch
0044c5db468ec8f2385d18d476f89976f6d036448583a4ef8017ce7a6f8f72105337e6b20037ffe47f561d2877fc9c86720aef23ab037df89b36dc140a5924c4  asterisk.initd
ab6b6f08ff43268cbb1abb7ed7d678949991ba495682a644bbaeb017d6adbff0a43297905fd73ae8db1786a28d5b5904f1bc253209a0e388c8a27f26c6ce14ed  asterisk.confd
7591d2faf539d05d9ee4e431c78a5e20686721fd79221ad94dffeeaff9282220b09cb9aec214bd7a8d12affaec0276c9c91e6e21af8b6712c0a9502b60b02f2b  asterisk.logrotate"