diff options
author | Florian Schmaus <flo@geekplace.eu> | 2021-04-08 09:08:54 +0200 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2021-06-01 09:35:41 +0000 |
commit | 26bb839b36582337bb3e4627e5e55a49004e567b (patch) | |
tree | 132e601689c5fca2322f041fbb057f7ae37dd255 /net-im/ejabberd | |
parent | dev-erlang/p1_pgsql: add 1.1.11 (diff) | |
download | gentoo-26bb839b36582337bb3e4627e5e55a49004e567b.tar.gz gentoo-26bb839b36582337bb3e4627e5e55a49004e567b.tar.bz2 gentoo-26bb839b36582337bb3e4627e5e55a49004e567b.zip |
net-im/ejabberd: add 21.04
Closes: https://bugs.gentoo.org/766686
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'net-im/ejabberd')
-rw-r--r-- | net-im/ejabberd/Manifest | 1 | ||||
-rw-r--r-- | net-im/ejabberd/ejabberd-21.04.ebuild | 271 |
2 files changed, 272 insertions, 0 deletions
diff --git a/net-im/ejabberd/Manifest b/net-im/ejabberd/Manifest index 7f4a644bda99..bc7d6279d245 100644 --- a/net-im/ejabberd/Manifest +++ b/net-im/ejabberd/Manifest @@ -1,2 +1,3 @@ DIST ejabberd-20.04.tar.gz 2022319 BLAKE2B 02ce782bc58a808f38dff58715204059c51762187abff7f5c77ff08eb13330b66485234eb2204c4336770d75303417ee74077466a07e701aa512158ff641a578 SHA512 7c478bbd73577e06f21e26804f4eb57deb52a0ebdd12e45034e810314cb73bb2ec60b55c6f266271eb45d5ebc135a39c498a29706d6d1f5087fd2b509a8844ca DIST ejabberd-20.07.tar.gz 2029485 BLAKE2B c6d9e177b150135595c4670b96386e752d795fab219619edbd5f887975b1edfc79bfe2606b57d2edb34af9fe15c8a545dc70b8d50faa7f667bac5fcef985bb4c SHA512 d31bea2bcf83c2404104a1153664abceda900dca1ef86216970eac32115da521826ee1b80b020d21dafbdff2cfee8b210de6e68ba795068f7fc51545e0e381fc +DIST ejabberd-21.04.tar.gz 1560926 BLAKE2B 9d00c892317a93e5754d6f265499e904bb7c22542495039d8cc5cd7296cd5b1c73f14844acc0f4b041b6595346ce01d633926fde9f693a7cd794afbb3c228eb8 SHA512 d30642e90be1feb8673e9d7b3b513a17d54d94405057034c706bbd43d288e89479adb0ebaf8a4e8ff0f7e394f027d01bf171690c00e4169951ceecfbc0af4dc2 diff --git a/net-im/ejabberd/ejabberd-21.04.ebuild b/net-im/ejabberd/ejabberd-21.04.ebuild new file mode 100644 index 000000000000..3f35fb5be976 --- /dev/null +++ b/net-im/ejabberd/ejabberd-21.04.ebuild @@ -0,0 +1,271 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +SSL_CERT_MANDATORY=1 + +inherit pam rebar ssl-cert systemd tmpfiles + +DESCRIPTION="Robust, scalable and extensible XMPP server" +HOMEPAGE="https://www.ejabberd.im/ https://github.com/processone/ejabberd/" +SRC_URI="https://static.process-one.net/${PN}/downloads/${PV}/${P}.tgz + -> ${P}.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~arm ~ia64 ~sparc ~x86" +REQUIRED_USE="mssql? ( odbc )" +# TODO: Add 'tools' flag. +IUSE="captcha debug full-xml ldap mssql mysql odbc pam postgres redis + roster-gw sip sqlite +stun zlib" + +RESTRICT="test" + +# TODO: Add dependencies for 'tools' flag enabled. +# TODO: tools? ( +# TODO: >=dev-erlang/luerl-0.3 +# TODO: ) +DEPEND=">=dev-lang/erlang-19.3[odbc?,ssl] + >=dev-erlang/cache_tab-1.0.28 + >=dev-erlang/eimp-1.0.20 + >=dev-erlang/fast_tls-1.1.12 + >=dev-erlang/fast_xml-1.1.46 + >=dev-erlang/fast_yaml-1.0.31 + >=dev-erlang/yconf-1.0.11 + >=dev-erlang/jiffy-1.0.5 + >=dev-erlang/jose-1.9.0 + >=dev-erlang/lager-3.6.10 + >=dev-erlang/p1_oauth2-0.6.9 + >=dev-erlang/p1_utils-1.0.22 + >=dev-erlang/stringprep-1.0.25 + >=dev-erlang/xmpp-1.5.3 + >=dev-erlang/pkix-1.0.7 + >=dev-erlang/mqtree-1.0.13 + >=dev-erlang/idna-6.0.0-r1 + >=dev-erlang/p1_acme-1.0.12 + >=dev-erlang/base64url-1.0.1 + >=net-im/jabber-base-0.01 + ldap? ( =net-nds/openldap-2* ) + mysql? ( >=dev-erlang/p1_mysql-1.0.18 ) + odbc? ( dev-db/unixODBC ) + pam? ( >=dev-erlang/epam-1.0.10 ) + postgres? ( >=dev-erlang/p1_pgsql-1.1.11 ) + redis? ( >=dev-erlang/eredis-1.0.8 ) + sip? ( >=dev-erlang/esip-1.0.42 ) + sqlite? ( >=dev-erlang/sqlite3-1.1.12 ) + stun? ( >=dev-erlang/stun-1.0.43 ) + zlib? ( >=dev-erlang/ezlib-1.0.9 )" +RDEPEND="${DEPEND} + captcha? ( media-gfx/imagemagick[truetype,png] )" + +DOCS=( CHANGELOG.md README.md ) +PATCHES=( "${FILESDIR}/${PN}-19.08-ejabberdctl.patch" + "${FILESDIR}/${PN}-17.04-0002-Dont-overwrite-service-file.patch") + +EJABBERD_CERT="${EPREFIX}/etc/ssl/ejabberd/server.pem" +# Paths in net-im/jabber-base +JABBER_ETC="${EPREFIX}/etc/jabber" +JABBER_LOG="${EPREFIX}/var/log/jabber" +JABBER_SPOOL="${EPREFIX}/var/spool/jabber" + +# Adjust example configuration file to Gentoo. +# - Use our sample certificate. +adjust_config() { + sed -rne "/^#?\s+certfiles:/{p;a\ - ${EJABBERD_CERT}" -e ":a;n;/^#?\s+-/ba};p" \ + -i "${S}/ejabberd.yml.example" \ + || die 'failed to adjust example config' + sed -re 's/^#\s+(certfiles)/\1/' \ + -i "${S}/ejabberd.yml.example" \ + || die 'failed to adjust example config' +} + +# Set paths to ejabberd lib directory consistently to point always to directory +# suffixed with version. +correct_ejabberd_paths() { + sed -e "/^EJABBERDDIR[[:space:]]*=/{s:ejabberd:${P}:}" \ + -i "${S}/Makefile.in" \ + || die 'failed to set ejabberd path in Makefile.in' + sed -e "/EJABBERD_BIN_PATH=/{s:ejabberd:${P}:}" \ + -i "${S}/ejabberdctl.template" \ + || die 'failed to set ejabberd path in ejabberdctl.template' +} + +# Get epam-wrapper from 'files' directory and correct path to lib directory in +# it. epam-wrapper is placed into work directory. It is assumed no epam-wrapper +# file exists there already. +customize_epam_wrapper() { + local epam_wrapper_src="${1}" + local epam_wrapper_dst="${S}/epam-wrapper" + + [[ -e ${epam_wrapper_dst} ]] && die 'epam-wrapper already exists' + sed -r -e "s@^(ERL_LIBS=).*\$@\1${EPREFIX}$(get_erl_libs)@" \ + "${epam_wrapper_src}" >"${epam_wrapper_dst}" \ + || die 'failed to install epam-wrapper' +} + +# Check if we are missing a default certificate. +ejabberd_cert_missing() { + if grep -qs "^\s\+- ${EJABBERD_CERT}" "${EROOT%/}${JABBER_ETC}/ejabberd.yml"; then + if [[ -f "${EROOT%/}${EJABBERD_CERT}" ]]; then + # default certificate is present in config and exists - not installing + return 1 + else + # default certificate is present in config + # but doesn't exist - need to install one + return 0 + fi + fi + # no default certificate in config - not installing + return 1 +} + +# Generate and install sample ejabberd certificate. It's installed into +# EJABBERD_CERT path. +ejabberd_cert_install() { + SSL_ORGANIZATION="${SSL_ORGANIZATION:-ejabberd XMPP Server}" + install_cert "${EJABBERD_CERT%.*}" + chown root:jabber "${EROOT%/}${EJABBERD_CERT}" || die + chmod 0440 "${EROOT%/}${EJABBERD_CERT}" || die +} + +# Get path to ejabberd lib directory. +# +# This is the path ./configure script Base for this path is path set in +# ./configure script which is /usr/lib by default. If libdir is explicitely set +# to something else than this should be adjusted here as well. +get_ejabberd_path() { + echo "/usr/$(get_libdir)/${P}" +} + +# Make ejabberd.service for systemd from upstream provided template. +make_ejabberd_service() { + sed -r \ + -e 's!@ctlscriptpath@!/usr/sbin!g' \ + -e 's!^(User|Group)=(.*)!\1=jabber!' \ + -e 's!^(After)=(.*)!\1=epmd.service network.target!' \ + -e '/^After=/ a Requires=epmd.service' \ + "${PN}.service.template" >"${PN}.service" \ + || die 'failed to make ejabberd.service' +} + +# Set paths to defined by net-im/jabber-base. +set_jabberbase_paths() { + sed -e "/^ETCDIR[[:space:]]*=/{s:@sysconfdir@/ejabberd:${JABBER_ETC}:}" \ + -e "/^LOGDIR[[:space:]]*=/{s:@localstatedir@/log/ejabberd:${JABBER_LOG}:}" \ + -e "/^SPOOLDIR[[:space:]]*=/{s:@localstatedir@/lib/ejabberd:${JABBER_SPOOL}:}" \ + -i "${S}/Makefile.in" \ + || die 'failed to set paths in Makefile.in' + sed -e "s|\(ETC_DIR:=\"\){{sysconfdir}}[^\"]*|\1${JABBER_ETC}|" \ + -e "s|\(LOGS_DIR:=\"\){{localstatedir}}[^\"]*|\1${JABBER_LOG}|" \ + -e "s|\(SPOOL_DIR:=\"\){{localstatedir}}[^\"]*|\1${JABBER_SPOOL}|" \ + -i "${S}/ejabberdctl.template" \ + || die 'failed to set paths ejabberdctl.template' +} + +src_prepare() { + default + + rebar_remove_deps + correct_ejabberd_paths + set_jabberbase_paths + make_ejabberd_service + adjust_config + customize_epam_wrapper "${FILESDIR}/epam-wrapper" + + rebar_fix_include_path fast_xml + rebar_fix_include_path p1_utils + rebar_fix_include_path xmpp + + # Fix bug #591862. ERL_LIBS should point directly to ejabberd directory + # rather than its parent which is default. That way ejabberd directory + # takes precedence is module lookup. + local ejabberd_erl_libs="$(get_ejabberd_path):$(get_erl_libs)" + sed -e "s|\(ERL_LIBS=\){{libdir}}.*|\1${ejabberd_erl_libs}|" \ + -i "${S}/ejabberdctl.template" \ + || die 'failed to set ERL_LIBS in ejabberdctl.template' +} + +src_configure() { + econf \ + --docdir="${EPREFIX}/usr/share/doc/${PF}/html" \ + --enable-user=jabber \ + $(use_enable debug) \ + $(use_enable full-xml) \ + $(use_enable mssql) \ + $(use_enable mysql) \ + $(use_enable odbc) \ + $(use_enable pam) \ + $(use_enable postgres pgsql) \ + $(use_enable redis) \ + $(use_enable roster-gw roster-gateway-workaround) \ + $(use_enable sqlite) \ + $(use_enable sip) \ + $(use_enable stun) \ + $(use_enable zlib) + + # more options to support + # --enable-elixir requires https://github.com/elixir-lang/elixir +} + +src_compile() { + emake REBAR='rebar -v' src +} + +src_install() { + default + + keepdir /var/lib/lock/ejabberdctl + rm -rf "${ED%/}/var/log" || die + rm -rf "${ED%/}/var/spool" || die + + if use pam; then + local epam_path="$(get_ejabberd_path)/priv/bin/epam" + + pamd_mimic_system xmpp auth account + into "$(get_ejabberd_path)/priv" + newbin epam-wrapper epam + fi + + newconfd "${FILESDIR}/${PN}.confd" "${PN}" + newinitd "${FILESDIR}/${PN}.initd" "${PN}" + systemd_dounit "${PN}.service" + dotmpfiles "${FILESDIR}/${PN}.tmpfiles.conf" + + insinto /etc/logrotate.d + newins "${FILESDIR}/${PN}.logrotate" "${PN}" +} + +pkg_preinst() { + if use pam; then + einfo "Adding jabber user to epam group to allow ejabberd to use PAM" \ + "authentication" + # See + # <https://docs.ejabberd.im/admin/configuration/#pam-authentication>. + # epam binary is installed by dev-erlang/epam package, therefore SUID + # is set by that package. Instead of jabber group it uses epam group, + # therefore we need to add jabber user to epam group. + usermod -a -G epam jabber || die + fi +} + +pkg_postinst() { + if [[ ! ${REPLACING_VERSIONS} ]]; then + echo + elog "For configuration instructions, please see" + elog " https://docs.ejabberd.im/" + echo + fi + if [[ " ${REPLACING_VERSIONS} " =~ \ 17\. ]]; then + ewarn If you are updating from an older version like 17.x + ewarn you may need to add an access_rules section to your + ewarn ejabberd.yml config file. + ewarn Otherwise authentication will be broken and users + ewarn will not be able to log in. + echo + fi + + if ejabberd_cert_missing; then + ejabberd_cert_install + fi +} |