Merge pull request #22358 from yorickvP/asteriskupd

asterisk: add lts version
This commit is contained in:
Benjamin Staffin 2017-02-03 02:30:34 -05:00 committed by GitHub
commit 53e6431d61
5 changed files with 119 additions and 84 deletions

View File

@ -519,6 +519,7 @@
wyvie = "Elijah Rum <elijahrum@gmail.com>";
yarr = "Dmitry V. <savraz@gmail.com>";
yochai = "Yochai <yochai@titat.info>";
yorickvp = "Yorick van Pelt <yorickvanpelt@gmail.com>";
yurrriq = "Eric Bailey <eric@ericb.me>";
z77z = "Marco Maggesi <maggesi@math.unifi.it>";
zagy = "Christian Zagrodnick <cz@flyingcircus.io>";

View File

@ -17,7 +17,7 @@ let
allConfFiles =
cfg.confFiles //
builtins.listToAttrs (map (x: { name = x;
value = builtins.readFile (pkgs.asterisk + "/etc/asterisk/" + x); })
value = builtins.readFile (cfg.package + "/etc/asterisk/" + x); })
defaultConfFiles);
asteriskEtc = pkgs.stdenv.mkDerivation
@ -38,7 +38,7 @@ let
asteriskConf = ''
[directories]
astetcdir => /etc/asterisk
astmoddir => ${pkgs.asterisk}/lib/asterisk/modules
astmoddir => ${cfg.package}/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astdbdir => /var/lib/asterisk
astkeydir => /var/lib/asterisk
@ -47,7 +47,7 @@ let
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk
astsbindir => ${pkgs.asterisk}/sbin
astsbindir => ${cfg.package}/sbin
'';
extraConf = cfg.extraConfig;
@ -197,11 +197,17 @@ in
Additional command line arguments to pass to Asterisk.
'';
};
package = mkOption {
type = types.package;
default = pkgs.asterisk;
defaultText = "pkgs.asterisk";
description = "The Asterisk package to use.";
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.asterisk ];
environment.systemPackages = [ cfg.package ];
environment.etc.asterisk.source = asteriskEtc;
@ -234,7 +240,7 @@ in
# TODO: Make exceptions for /var directories that likely should be updated
if [ ! -e "$d" ]; then
mkdir -p "$d"
cp --recursive ${pkgs.asterisk}/"$d"/* "$d"/
cp --recursive ${cfg.package}/"$d"/* "$d"/
chown --recursive ${asteriskUser}:${asteriskGroup} "$d"
find "$d" -type d | xargs chmod 0755
fi
@ -247,8 +253,8 @@ in
# FIXME: This doesn't account for arguments with spaces
argString = concatStringsSep " " cfg.extraArguments;
in
"${pkgs.asterisk}/bin/asterisk -U ${asteriskUser} -C /etc/asterisk/asterisk.conf ${argString} -F";
ExecReload = ''${pkgs.asterisk}/bin/asterisk -x "core reload"
"${cfg.package}/bin/asterisk -U ${asteriskUser} -C /etc/asterisk/asterisk.conf ${argString} -F";
ExecReload = ''${cfg.package}/bin/asterisk -x "core reload"
'';
Type = "forking";
PIDFile = "/var/run/asterisk/asterisk.pid";

View File

@ -1,76 +1,113 @@
{ stdenv, pkgs, fetchurl, fetchgit,
{ stdenv, pkgs, lib, fetchurl, fetchgit,
jansson, libxml2, libxslt, ncurses, openssl, sqlite,
utillinux, dmidecode, libuuid, binutils, newt,
lua,
srtp, wget, curl,
subversionClient
}:
stdenv.mkDerivation rec {
name = "asterisk-${version}";
version = "14.1.2";
src = fetchurl {
url = "http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
let
common = {version, sha256, externals}: stdenv.mkDerivation rec {
inherit version;
name = "asterisk-${version}";
buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid binutils newt lua srtp wget curl subversionClient ];
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
];
src = fetchurl {
url = "http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
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
'' + lib.concatStringsSep "\n"
(lib.mapAttrsToList (dst: src: "cp ${src} ${dst}") externals) + ''
chmod -w externals_cache
'';
configureFlags = [
"--libdir=\${out}/lib"
"--with-lua=${lua}/lib"
"--with-pjproject-bundled"
"--with-externals-cache=$(PWD)/externals_cache"
];
preBuild = ''
make menuselect.makeopts
substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
./contrib/scripts/get_mp3_source.sh
'';
postInstall = ''
# Install sample configuration files for this version of Asterisk
make samples
'';
meta = with stdenv.lib; {
description = "Software implementation of a telephone private branch exchange (PBX)";
homepage = http://www.asterisk.org/;
license = licenses.gpl2;
maintainers = with maintainers; [ auntie DerTim1 yorickvp ];
};
};
pjproject-255 = fetchurl {
url = http://www.pjsip.org/release/2.5.5/pjproject-2.5.5.tar.bz2;
sha256 = "1wq8lpfcd4dfrbl7bgy2yzgp3ldjzq5430fqkhcqad0xfrxj0fdb";
};
in
{
asterisk-lts = common {
version = "13.13.1";
sha256 = "0yh097rrp1i681qclvwyh7l1gg2i5wx5pjrcvwpbj6g949mc98vd";
externals = {
"externals_cache/pjproject-2.5.5.tar.bz2" = pjproject-255;
};
};
asterisk-stable = common {
version = "14.1.2";
sha256 = "0w9s4334rwvpyxm169grmnb4k9yq0l2al73dyh4cb8769qcs0ij8";
externals = {
"externals_cache/pjproject-2.5.5.tar.bz2" = pjproject-255;
};
};
# Note that these sounds are included with the release tarball. They are
# provided here verbatim for the convenience of anyone wanting to build
# Asterisk from other sources.
coreSounds = fetchurl {
url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.5.tar.gz;
sha256 = "01xzbg7xy0c5zg7sixjw5025pvr4z64kfzi9zvx19im0w331h4cd";
};
mohSounds = fetchurl {
url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz;
sha256 = "449fb810d16502c3052fedf02f7e77b36206ac5a145f3dacf4177843a2fcb538";
};
# TODO: Sounds for other languages could be added here
# asterisk-git = common {
# version = "15-pre";
# sha256 = "...";
# externals = {
# "externals_cache/pjproject-2.5.5.tar.bz2" = pjproject-255;
# Note that these sounds are included with the release tarball. They are
# provided here verbatim for the convenience of anyone wanting to build
# Asterisk from other sources. Include in externals.
# "sounds/asterisk-core-sounds-en-gsm-1.5.tar.gz" = fetchurl {
# url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.5.tar.gz;
# sha256 = "01xzbg7xy0c5zg7sixjw5025pvr4z64kfzi9zvx19im0w331h4cd";
# };
# "sounds/asterisk-moh-opsound-wav-2.03.tar.gz" = fetchurl {
# url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz;
# sha256 = "449fb810d16502c3052fedf02f7e77b36206ac5a145f3dacf4177843a2fcb538";
# };
# TODO: Sounds for other languages could be added here
# }
# }.overrideDerivation (_: {src = fetchgit {...}})
buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid binutils newt lua srtp wget curl subversionClient ];
patches = [
# Disable downloading of sound files (we will fetch them
# ourselves if needed).
./disable-download.patch
# 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
];
# Use the following preConfigure section when building Asterisk from sources
# other than the release tarball.
# preConfigure = ''
# ln -s ${coreSounds} sounds/asterisk-core-sounds-en-gsm-1.5.tar.gz
# ln -s ${mohSounds} sounds/asterisk-moh-opsound-wav-2.03.tar.gz
#'';
# The default libdir is $PREFIX/usr/lib, which causes problems when paths
# compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
configureFlags = [
"--libdir=\${out}/lib"
"--with-lua=${lua}/lib"
"--with-pjproject-bundled"
];
preBuild = ''
make menuselect.makeopts
substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
./contrib/scripts/get_mp3_source.sh
'';
postInstall = ''
# Install sample configuration files for this version of Asterisk
make samples
'';
meta = with stdenv.lib; {
description = "Software implementation of a telephone private branch exchange (PBX)";
homepage = http://www.asterisk.org/;
license = licenses.gpl2;
maintainers = with maintainers; [ auntie DerTim1 ];
};
}

View File

@ -1,12 +0,0 @@
diff -ruN asterisk-14.1.2/sounds/Makefile asterisk-14.1.2-patched/sounds/Makefile
--- asterisk-14.1.2/sounds/Makefile 2016-11-10 20:43:02.000000000 +0100
+++ asterisk-14.1.2-patched/sounds/Makefile 2016-11-16 10:08:46.591615147 +0100
@@ -90,7 +90,7 @@
) && touch "$(1)$(if $(3),/$(3),)/$$@"; \
fi
-asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz: have_download
+asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz:
ifneq ($(SOUNDS_CACHE_DIR),)
$(CMD_PREFIX) \
if test ! -f "$(1)$(if $(3),/$(3),)/.$$(subst .tar.gz,,$$@)"; then \

View File

@ -10219,7 +10219,10 @@ with pkgs;
apcupsd = callPackage ../servers/apcupsd { };
asterisk = callPackage ../servers/asterisk { };
asterisk = asterisk-stable;
inherit (callPackages ../servers/asterisk { })
asterisk-stable asterisk-lts;
sabnzbd = callPackage ../servers/sabnzbd { };