summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 54aa101c24c730f2150e59bbdc80c4458abaae95 (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
# Maintainer: David Matson <gitcoder at outlook dot com>
pkgname=freeswitch-core
pkgver=1.6.19
pkgrel=1
pkgdesc='A scalable, open source telephony platform'
arch=('i686' 'x86_64')
url='https://freeswitch.org/'
license=('MPL')
depends=('libedit' 'speex' 'openssl-1.0')
makedepends=('libjpeg-turbo' 'yasm')
optdepends=()
provides=('freeswitch')
conflicts=('freeswitch')
source=("https://files.freeswitch.org/releases/freeswitch/freeswitch-$pkgver.tar.xz"
        'freeswitch.service'
        'modules.conf')
sha256sums=('e8d271a0d876ba4cca551682af0a4f5047bfd79438fcebdcc17d00711c04a8ff'
            '7eff153fdae3c99cd884c654335b32f484df5cb7e624bd6adc630372ea83e573'
            'SKIP')

declare -A _mod_depends
_mod_depends=(['ldns']='mod_enum'
              ['postgresql-libs']='mod_cdr_pg_csv'
              ['unixodbc']='mod_odbc_cdr')

declare -A _mod_makedepends
_mod_makedepends=(['alsa-lib']='mod_alsa'
                  ['hiredis']='mod_hiredis'
                  ['imagemagick']='mod_imagick'
                  ['ladspa']='mod_ladspa'
                  ['lame']='mod_shout'
                  ['libmemcached']='mod_memcache'
                  ['libmongoc']='mod_mongo'
                  ['libmp4v2']='mod_mp4 mod_mp4v2'
                  ['libshout']='mod_shout'
                  ['libsndfile']='mod_sndfile'
                  ['libyaml']='mod_yaml'
                  ['lua']='mod_lua'
                  ['mono']='mod_managed'
                  ['mpg123']='mod_shout'
                  ['opal-stable']='mod_opal'
                  ['opus']='mod_opus'
                  ['portaudio']='mod_portaudio mod_portaudio_stream'
                  ['ptlib-stable']='mod_opal'
                  ['python2']='mod_python mod_v8'
                  ['soundtouch']='mod_soundtouch'
                  ['unixodbc']='mod_odbc_cdr'
                  ['vlc']='mod_vlc')

declare -A _mod_optdepends
_mod_optdepends=(['hiredis']='mod_hiredis'
                 ['imagemagick']='mod_imagick'
                 ['ldns']='mod_enum'
                 ['libjpeg-turbo']='mod_spandsp'
                 ['libmemcached']='mod_memcache'
                 ['libmongoc']='mod_mongo'
                 ['libmp4v2']='mod_mp4 mod_mp4v2'
                 ['libsndfile']='mod_sndfile'
                 ['lua']='mod_lua'
                 ['mono']='mod_managed'
                 ['mpg123']='mod_shout'
                 ['opus']='mod_opus'
                 ['perl']='mod_perl'
                 ['portaudio']='mod_portaudio mod_portaudio_stream'
                 ['soundtouch']='mod_soundtouch'
                 ['vlc']='mod_vlc')

mod_enabled() {
  if [[ "${srcdir}" ]]; then
    _path="${srcdir}"/modules.conf
  else
    _path=modules.conf
  fi

  grep -Eq "^[a-z_]+/$1$" ${_path}
}

for _dep in "${!_mod_depends[@]}"; do
  _mods=(${_mod_depends[$_dep]})

  for _mod in "${_mods[@]}"; do
    if [[ ! " ${depends} " =~ " ${_mod} " ]] && mod_enabled "${_mod}"; then
      depends+=("${_dep}")
    fi
  done
done

for _dep in "${!_mod_makedepends[@]}"; do
  _mods=(${_mod_makedepends[$_dep]})

  for _mod in "${_mods[@]}"; do
    if [[ ! " ${makedepends} " =~ " ${_mod} " ]] && mod_enabled "${_mod}"; then
      makedepends+=("${_dep}")
    fi
  done
done

for _dep in "${!_mod_optdepends[@]}"; do
  _mods=(${_mod_optdepends[$_dep]})
  _dep_mods=()

  for _mod in "${_mods[@]}"; do
    if mod_enabled "${_mod}"; then
      _dep_mods+=("${_mod}")
    fi
  done

  if [[ ${#_dep_mods[@]} -eq 1 ]]; then
    optdepends+=("${_dep}: for ${_dep_mods[0]} module")
  elif [[ ${#_dep_mods[@]} -gt 0 ]]; then
    _dep_list="${_dep_mods[@]}"
    optdepends+=("${_dep}: for ${_dep_list// / and } modules")
  fi
done

build() {
  cd "freeswitch-$pkgver"

  _mod_options=()

  if mod_enabled 'mod_cdr_pg_csv'; then
    _mod_options+=('--enable-core-pgsql-support')
  fi

  if mod_enabled 'mod_odbc_cdr'; then
    _mod_options+=('--enable-core-odbc-support')
  fi

  if mod_enabled 'mod_python'; then
    _mod_options+=('--with-python=/usr/bin/python2')
  fi

  # Work around FreeSWITCH bug FS-10257
  export CFLAGS="${CFLAGS} -Wno-parentheses -Wno-deprecated-declarations"

  # Use OpenSSL 1.0 until upstream supports 1.1.
  export PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig
  export CFLAGS="${CFLAGS} -I /usr/include/openssl-1.0"

  cp "${srcdir}"/modules.conf .

  ./configure \
    --enable-optimization \
    --disable-debug \
    --prefix=/usr \
    --localstatedir=/var \
    --sysconfdir=/etc \
    --with-rundir=/run \
    --with-logfiledir=/var/log/freeswitch \
    --with-cachedir=/var/cache/freeswitch \
    --with-imagesdir=/usr/share/freeswitch/images \
    ${_mod_options[@]}

  make
}

package() {
  cd "freeswitch-$pkgver"

  make DESTDIR="$pkgdir/" install

  rmdir "${pkgdir}"/run
  rm -r "${pkgdir}"/etc/freeswitch/*

  if mod_enabled 'mod_perl'; then
    mkdir -p "${pkgdir}"/usr/lib/perl5
    mv "${pkgdir}"/usr/perl "${pkgdir}"/usr/lib/perl5/vendor_perl
  fi

  if ! mod_enabled 'mod_xml_rpc'; then
    rm -r "${pkgdir}"/usr/share/freeswitch/htdocs/*
    rm -r "${pkgdir}"/usr/share/freeswitch/fonts/*
    rm -r "${pkgdir}"/usr/share/freeswitch/images/*
  fi

  if ! mod_enabled 'mod_xml_cdr'; then
    rmdir "${pkgdir}"/var/log/freeswitch/xml_cdr
  fi

  if [ -e "${pkgdir}"/usr/share/freeswitch/grammar/model/communicator/ ]; then
    chown root:root \
      "${pkgdir}"/usr/share/freeswitch/grammar/model/communicator/*
  fi

  install -Dm644 "${srcdir}"/freeswitch.service \
    "${pkgdir}"/usr/lib/systemd/system/freeswitch.service
}