2022-04-06 19:28:12 +01:00
|
|
|
{ stdenv, lib, fetchurl, fetchsvn, fetchFromGitHub,
|
2018-11-21 09:57:31 +00:00
|
|
|
jansson, libedit, libxml2, libxslt, ncurses, openssl, sqlite,
|
2020-11-24 15:29:28 +00:00
|
|
|
util-linux, dmidecode, libuuid, newt,
|
2022-04-06 19:28:12 +01:00
|
|
|
lua, speex, libopus, opusfile, libogg,
|
|
|
|
srtp, wget, curl, iksemel, pkg-config,
|
|
|
|
autoconf, libtool, automake,
|
2022-05-24 12:49:28 +01:00
|
|
|
python39, writeScript,
|
2022-04-06 19:28:12 +01:00
|
|
|
withOpus ? true,
|
2016-12-28 22:04:58 +00:00
|
|
|
}:
|
2015-04-16 18:42:17 +01:00
|
|
|
|
2017-02-02 14:11:54 +00:00
|
|
|
let
|
2019-08-13 22:52:01 +01:00
|
|
|
common = {version, sha256, externals}: stdenv.mkDerivation {
|
2017-02-02 14:11:54 +00:00
|
|
|
inherit version;
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "asterisk";
|
2017-02-02 14:11:54 +00:00
|
|
|
|
2018-11-21 09:57:31 +00:00
|
|
|
buildInputs = [ jansson libedit libxml2 libxslt ncurses openssl sqlite
|
|
|
|
dmidecode libuuid newt
|
|
|
|
lua speex
|
2022-04-06 19:28:12 +01:00
|
|
|
srtp wget curl iksemel ]
|
|
|
|
++ lib.optionals withOpus [ libopus opusfile libogg ];
|
|
|
|
nativeBuildInputs = [ util-linux pkg-config autoconf libtool automake ];
|
2017-02-02 14:11:54 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
# We want the Makefile to install the default /var skeleton
|
|
|
|
# under ${out}/var but we also want to use /var at runtime.
|
|
|
|
# This patch changes the runtime behavior to look for state
|
|
|
|
# directories in /var rather than ${out}/var.
|
|
|
|
./runtime-vardirs.patch
|
2022-04-06 19:28:12 +01:00
|
|
|
] ++ lib.optional withOpus "${asterisk-opus}/asterisk.patch";
|
2017-02-02 14:11:54 +00:00
|
|
|
|
2017-04-26 11:31:56 +01:00
|
|
|
postPatch = ''
|
2020-10-07 17:02:37 +01:00
|
|
|
echo "PJPROJECT_CONFIG_OPTS += --prefix=$out" >> third-party/pjproject/Makefile.rules
|
2017-04-26 11:31:56 +01:00
|
|
|
'';
|
|
|
|
|
2017-02-02 14:11:54 +00:00
|
|
|
src = fetchurl {
|
2018-06-28 19:43:35 +01:00
|
|
|
url = "https://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
|
2017-02-02 14:11:54 +00:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# The default libdir is $PREFIX/usr/lib, which causes problems when paths
|
|
|
|
# compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
|
|
|
|
|
|
|
|
# Copy in externals to avoid them being downloaded;
|
|
|
|
# they have to be copied, because the modification date is checked.
|
|
|
|
# If you are getting a permission denied error on this dir,
|
|
|
|
# you're likely missing an automatically downloaded dependency
|
|
|
|
preConfigure = ''
|
|
|
|
mkdir externals_cache
|
2018-11-21 09:57:31 +00:00
|
|
|
|
|
|
|
${lib.concatStringsSep "\n"
|
|
|
|
(lib.mapAttrsToList (dst: src: "cp -r --no-preserve=mode ${src} ${dst}") externals)}
|
|
|
|
|
|
|
|
${lib.optionalString (externals ? "addons/mp3") "bash contrib/scripts/get_mp3_source.sh || true"}
|
2017-02-02 14:11:54 +00:00
|
|
|
|
|
|
|
chmod -w externals_cache
|
2022-04-06 19:28:12 +01:00
|
|
|
${lib.optionalString withOpus ''
|
|
|
|
cp ${asterisk-opus}/include/asterisk/* ./include/asterisk
|
|
|
|
cp ${asterisk-opus}/codecs/* ./codecs
|
|
|
|
cp ${asterisk-opus}/formats/* ./formats
|
|
|
|
''}
|
|
|
|
./bootstrap.sh
|
2017-02-02 14:11:54 +00:00
|
|
|
'';
|
2020-10-07 17:02:37 +01:00
|
|
|
|
2017-02-02 14:11:54 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--libdir=\${out}/lib"
|
|
|
|
"--with-lua=${lua}/lib"
|
|
|
|
"--with-pjproject-bundled"
|
|
|
|
"--with-externals-cache=$(PWD)/externals_cache"
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
make menuselect.makeopts
|
2018-11-21 09:57:31 +00:00
|
|
|
${lib.optionalString (externals ? "addons/mp3") ''
|
|
|
|
substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
|
|
|
|
''}
|
2022-04-06 19:28:12 +01:00
|
|
|
${lib.optionalString withOpus ''
|
|
|
|
substituteInPlace menuselect.makeopts --replace 'codec_opus_open_source ' ""
|
|
|
|
substituteInPlace menuselect.makeopts --replace 'format_ogg_opus_open_source ' ""
|
|
|
|
''}
|
2017-02-02 14:11:54 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# Install sample configuration files for this version of Asterisk
|
|
|
|
make samples
|
2020-10-07 17:02:37 +01:00
|
|
|
${lib.optionalString (lib.versionAtLeast version "17.0.0") "make install-headers"}
|
2017-02-02 14:11:54 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-02-02 14:11:54 +00:00
|
|
|
description = "Software implementation of a telephone private branch exchange (PBX)";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://www.asterisk.org/";
|
2021-04-18 13:56:15 +01:00
|
|
|
license = licenses.gpl2Only;
|
2017-02-02 14:12:33 +00:00
|
|
|
maintainers = with maintainers; [ auntie DerTim1 yorickvp ];
|
2017-02-02 14:11:54 +00:00
|
|
|
};
|
2015-04-16 18:42:17 +01:00
|
|
|
};
|
|
|
|
|
2022-05-24 12:49:49 +01:00
|
|
|
pjproject_2_12 = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.12/pjproject-2.12.tar.bz2";
|
|
|
|
hash = "sha256-T3q4r/4WCAZCNGnULxMnNKH9wEK7gkseV/sV8IPasHQ=";
|
2018-11-21 09:57:31 +00:00
|
|
|
};
|
|
|
|
|
2017-02-23 20:40:37 +00:00
|
|
|
mp3-202 = fetchsvn {
|
2020-04-01 02:11:51 +01:00
|
|
|
url = "http://svn.digium.com/svn/thirdparty/mp3/trunk";
|
2018-11-07 08:41:55 +00:00
|
|
|
rev = "202";
|
2017-02-23 20:40:37 +00:00
|
|
|
sha256 = "1s9idx2miwk178sa731ig9r4fzx4gy1q8xazfqyd7q4lfd70s1cy";
|
|
|
|
};
|
|
|
|
|
2022-04-06 19:28:12 +01:00
|
|
|
asterisk-opus = fetchFromGitHub {
|
|
|
|
owner = "traud";
|
|
|
|
repo = "asterisk-opus";
|
|
|
|
# No releases, points to master as of 2022-04-06
|
|
|
|
rev = "a959f072d3f364be983dd27e6e250b038aaef747";
|
|
|
|
sha256 = "sha256-CASlTvTahOg9D5jccF/IN10LP/U8rRy9BFCSaHGQfCw=";
|
|
|
|
};
|
|
|
|
|
2021-08-07 12:37:01 +01:00
|
|
|
# auto-generated by update.py
|
|
|
|
versions = lib.mapAttrs (_: {version, sha256}: common {
|
|
|
|
inherit version sha256;
|
|
|
|
externals = {
|
2022-05-24 12:49:49 +01:00
|
|
|
"externals_cache/pjproject-2.12.tar.bz2" = pjproject_2_12;
|
2021-08-07 12:37:01 +01:00
|
|
|
"addons/mp3" = mp3-202;
|
|
|
|
};
|
2021-11-03 12:43:23 +00:00
|
|
|
}) (lib.importJSON ./versions.json);
|
2021-08-07 12:37:01 +01:00
|
|
|
|
2022-05-24 12:49:28 +01:00
|
|
|
updateScript_python = python39.withPackages (p: with p; [ packaging beautifulsoup4 requests ]);
|
|
|
|
updateScript = writeScript "asterisk-update" ''
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
exec ${updateScript_python}/bin/python ${toString ./update.py}
|
|
|
|
'';
|
|
|
|
|
2021-08-07 12:37:01 +01:00
|
|
|
in {
|
2022-04-05 17:46:14 +01:00
|
|
|
# Supported releases (as of 2022-04-05).
|
2020-10-07 17:02:37 +01:00
|
|
|
# Source: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions
|
|
|
|
# Exact version can be found at https://www.asterisk.org/downloads/asterisk/all-asterisk-versions/
|
2018-11-21 09:57:31 +00:00
|
|
|
#
|
|
|
|
# Series Type Rel. Date Sec. Fixes EOL
|
|
|
|
# 16.x LTS 2018-10-09 2022-10-09 2023-10-09
|
2020-10-26 13:10:29 +00:00
|
|
|
# 18.x LTS 2020-10-20 2024-10-20 2025-10-20
|
2022-04-05 17:46:14 +01:00
|
|
|
# 19.x Standard 2021-11-02 2022-11-02 2023-11-02
|
2021-08-07 12:37:01 +01:00
|
|
|
asterisk-lts = versions.asterisk_18;
|
2022-04-05 17:46:14 +01:00
|
|
|
asterisk-stable = versions.asterisk_19;
|
2022-05-24 12:49:49 +01:00
|
|
|
asterisk = versions.asterisk_19.overrideAttrs (o: {
|
2022-05-24 12:49:28 +01:00
|
|
|
passthru = (o.passthru or {}) // { inherit updateScript; };
|
|
|
|
});
|
2020-10-26 13:10:29 +00:00
|
|
|
|
2021-08-07 12:37:01 +01:00
|
|
|
} // versions
|