summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8ef73bc97f6576bc7e8aba520ea4e3c6059e8fb7 (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
# Maintainer: Nikos Toutountzoglou <nikos dot toutou at protonmail dot com>
# Contributor: Josef Miegl <josef@miegl.cz>
# Contributor: Xavier Devlamynck <magicrhesus@ouranos.be>

pkgname=kamailio
pkgver=6.0.0
pkgrel=1
pkgdesc="SIP Server for large VoIP and real-time communication platforms"
arch=('x86_64')
url="https://www.kamailio.org"
license=('GPL-2.0-or-later')
depends=(
  'bash'
  'glibc'
  'python'
  'readline'
)
makedepends=(
  'autoconf'
  'bison'
  'clang'
  'coreutils'
  'flex'
  'gcc'
  'make'
  'pkg-config'
  'sed'
  'cmake'
)
optdepends=(
  'freeradius: for RADIUS support'
  'jansson: for JSON support'
  'libevent: for asynchronous event handling'
  'libmicrohttpd: for embedded HTTP server support'
  'mariadb: for MariaDB database support'
  'memcached: for in-memory caching'
  'mongodb: for MongoDB database support'
  'mysql: for MySQL database support'
  'radcli: for RADIUS client support'
  'redis: for in-memory data structure store'
  'rtpengine: for media proxy support'
  'libxmlrpc: for XML-RPC protocol support'
)
backup=("etc/${pkgname}/kamailio.cfg"
        "etc/${pkgname}/kamctlrc")
source=("https://www.kamailio.org/pub/${pkgname}/latest/src/${pkgname}-${pkgver}_src.tar.gz"
        "${pkgname}.sysusers")
sha256sums=('63aa84802ada0908353afd2ea4f47347ca6af86c22813122496a980bc7a3a867'
            'e2ad5c2f3213f2ce7de9524da378d062525ce99e2b401590ec0394c521a3d0c8')

_kamodules() {
  local groups=("MOD_LIST_BASIC" "MOD_LIST_EXTRA" "MOD_LIST_DB")
  local modules=()
  for group in "${groups[@]}"; do
    modules+=($(cmake --build . --target list_modules -- -DCMAKE_BUILD_GROUP=${group}))
  done
  printf "%s " "${modules[@]}"
}

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  local modules="$(_kamodules)"
  # Generate build config files with the necessary modules
  cmake -S . -B build -DINCLUDE_MODULES="$modules" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DCMAKE_INSTALL_BINDIR=/usr/bin \
    -DCMAKE_INSTALL_SBINDIR=/usr/bin \
    -DCMAKE_INSTALL_SYSCONFDIR=/etc \
    -DCMAKE_INSTALL_DATADIR=/usr/share \
    -DCMAKE_INSTALL_DOCDIR=/usr/share/doc/kamailio \
    -DCMAKE_INSTALL_MANDIR=/usr/share/man

  # Update systemd service file paths
  sed -i \
    -e "s#ExecStart=/usr/sbin/${pkgname}#ExecStart=/usr/bin/${pkgname}#g" \
    -e "s#EnvironmentFile=-/etc/sysconfig/${pkgname}#EnvironmentFile=-/etc/default/${pkgname}#g" \
    pkg/${pkgname}/obs/${pkgname}.service
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}/build"
  make all
  make man
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}/build"
  DESTDIR="${pkgdir}" make install

  # Remove empty man directories
  find "${pkgdir}/usr/share/man" -type d -empty -delete

  # Install license, systemd service, sysusers, and tmpfiles
  install -Dm644 "${srcdir}/${pkgname}-${pkgver}/COPYING" \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 "${srcdir}/${pkgname}-${pkgver}/pkg/${pkgname}/obs/${pkgname}.service" \
    "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
  install -Dm644 "${srcdir}/${pkgname}.sysusers" \
    "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
  install -Dm644 "${srcdir}/${pkgname}-${pkgver}/pkg/${pkgname}/obs/${pkgname}.tmpfiles" \
    "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
}

# vim:set ts=2 sw=2 et: