From 15b28a3312f35244dbe093946f127d046555f42a Mon Sep 17 00:00:00 2001 From: Tomas Mozes <hydrapolic@gmail.com> Date: Wed, 16 Aug 2017 10:39:45 +0200 Subject: app-admin/logstash-bin: retain user installed plugins (Bug #622602) Closes: https://github.com/gentoo/gentoo/pull/5098 Package-Manager: Portage-2.3.7, Repoman-2.3.2 --- .../logstash-bin/files/logstash-plugin.eselect | 85 ++++++++++++++++++++++ .../logstash-bin/logstash-bin-5.4.3-r1.ebuild | 73 +++++++++++++++++++ app-admin/logstash-bin/logstash-bin-5.4.3.ebuild | 60 --------------- 3 files changed, 158 insertions(+), 60 deletions(-) create mode 100644 app-admin/logstash-bin/files/logstash-plugin.eselect create mode 100644 app-admin/logstash-bin/logstash-bin-5.4.3-r1.ebuild delete mode 100644 app-admin/logstash-bin/logstash-bin-5.4.3.ebuild diff --git a/app-admin/logstash-bin/files/logstash-plugin.eselect b/app-admin/logstash-bin/files/logstash-plugin.eselect new file mode 100644 index 000000000000..29678309f411 --- /dev/null +++ b/app-admin/logstash-bin/files/logstash-plugin.eselect @@ -0,0 +1,85 @@ +# -*-eselect-*- vim: ft=eselect +# Copyright 2005-2017 Gentoo Foundation +# Distributed under the terms of the GNU GPL version 2 or later + +DESCRIPTION="Manage user installed plugins of logstash" +MAINTAINER="hydrapolic@gmail.com" + +PLUGINS="/var/lib/logstash/plugins-list.txt" +LS_INSTALL_DIR="/opt/logstash" + +ls_plugin_wrapper() { + JARS_SKIP=true "${LS_INSTALL_DIR}/bin/logstash-plugin" "${1}" "${2}" || die +} + +### install action +describe_install() { + echo "Install plugin" +} + +describe_install_parameters() { + echo "<plugin>" +} + +do_install() { + [[ ${#} -lt 1 ]] && die "Please specify at least one plugin" + + local plugin + for plugin; do + ls_plugin_wrapper install "${plugin}" + echo "${plugin}" >> "${PLUGINS}" || die + done + + sort -u "${PLUGINS}" > "${PLUGINS}.tmp" || die + mv "${PLUGINS}.tmp" "${PLUGINS}" || die +} + +### list action +describe_list() { + echo "List user installed plugins" +} + +do_list() { + if [[ -f "${PLUGINS}" ]]; then + write_list_start "Installed plugins:" + + local plugin + while read -r plugin; do + write_kv_list_entry "${plugin}" + done < "${PLUGINS}" + fi +} + +### reinstall action +describe_reinstall() { + echo "Reinstall plugins" +} + +do_reinstall() { + if [[ -f "${PLUGINS}" ]]; then + local plugin + while read -r plugin; do + ls_plugin_wrapper install "${plugin}" + done < "${PLUGINS}" + fi +} + +### uninstall action +describe_uninstall() { + echo "Uninstall plugin" +} + +describe_uninstall_parameters() { + echo "<plugin>" +} + +do_uninstall() { + if [[ -f "${PLUGINS}" ]]; then + local plugin + for plugin; do + grep "^${plugin}\$" "${PLUGINS}" || write_warning_msg "Plugin ${plugin} not recorded" + sed -i "/^${plugin}\$/d" "${PLUGINS}" || die + ls_plugin_wrapper remove "${plugin}" + done + fi +} diff --git a/app-admin/logstash-bin/logstash-bin-5.4.3-r1.ebuild b/app-admin/logstash-bin/logstash-bin-5.4.3-r1.ebuild new file mode 100644 index 000000000000..f8c948c748cf --- /dev/null +++ b/app-admin/logstash-bin/logstash-bin-5.4.3-r1.ebuild @@ -0,0 +1,73 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +inherit user + +MY_PN="${PN%-bin}" +MY_P="${MY_PN}-${PV}" + +DESCRIPTION="Tool for managing events and logs" +HOMEPAGE="https://www.elastic.co/products/logstash" +SRC_URI="https://artifacts.elastic.co/downloads/${MY_PN}/${MY_P}.zip" + +# source: LICENSE.txt and NOTICE.txt +LICENSE="Apache-2.0 MIT" +SLOT="0" +KEYWORDS="~amd64" + +RESTRICT="strip" +QA_PREBUILT="opt/logstash/vendor/jruby/lib/jni/*/libjffi*.so" + +RDEPEND="virtual/jre:1.8" + +S="${WORKDIR}/${MY_P}" + +pkg_setup() { + enewgroup ${MY_PN} + enewuser ${MY_PN} -1 -1 /var/lib/${MY_PN} ${MY_PN} +} + +src_install() { + keepdir /etc/"${MY_PN}"/{conf.d,patterns,plugins} + keepdir "/var/lib/${MY_PN}" + keepdir "/var/log/${MY_PN}" + + insinto "/usr/share/${MY_PN}" + newins "${FILESDIR}/agent.conf.sample" agent.conf + + insinto "/opt/${MY_PN}" + doins -r . + fperms 0755 "/opt/${MY_PN}/bin/${MY_PN}" "/opt/${MY_PN}/vendor/jruby/bin/jruby" "/opt/${MY_PN}/bin/logstash-plugin" + + insinto /etc/logrotate.d + newins "${FILESDIR}/${MY_PN}.logrotate" "${MY_PN}" + + newconfd "${FILESDIR}/${MY_PN}.confd" "${MY_PN}" + newinitd "${FILESDIR}/${MY_PN}.initd" "${MY_PN}" + + insinto /usr/share/eselect/modules + doins "${FILESDIR}"/logstash-plugin.eselect +} + +pkg_postinst() { + ewarn "The default user changed from root to ${MY_PN}. If you wish to run as root (for" + ewarn "example to read local logs), be sure to change LS_USER and LS_GROUP in" + ewarn "${EROOT%/}/etc/conf.d/${MY_PN}" + ewarn + ewarn "Self installed plugins are removed during Logstash upgrades (Bug #622602)" + ewarn "Install the plugins via eselect module that will automatically re-install" + ewarn "all self installed plugins after Logstash upgrades." + einfo + einfo "Installing plugins:" + einfo "eselect logstash-plugin install logstash-output-gelf" + einfo + + einfo "Reinstalling self installed plugins (installed via eselect module):" + eselect logstash-plugin reinstall + + einfo + einfo "Sample configuration:" + einfo "${EROOT%/}/usr/share/${MY_PN}" +} diff --git a/app-admin/logstash-bin/logstash-bin-5.4.3.ebuild b/app-admin/logstash-bin/logstash-bin-5.4.3.ebuild deleted file mode 100644 index f5c4d8c2e292..000000000000 --- a/app-admin/logstash-bin/logstash-bin-5.4.3.ebuild +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 1999-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -EAPI=6 - -inherit user - -MY_PN="${PN%-bin}" -MY_P="${MY_PN}-${PV}" - -DESCRIPTION="Tool for managing events and logs" -HOMEPAGE="https://www.elastic.co/products/logstash" -SRC_URI="https://artifacts.elastic.co/downloads/${MY_PN}/${MY_P}.zip" - -# source: LICENSE.txt and NOTICE.txt -LICENSE="Apache-2.0 MIT" -SLOT="0" -KEYWORDS="~amd64" - -RESTRICT="strip" -QA_PREBUILT="opt/logstash/vendor/jruby/lib/jni/*/libjffi*.so" - -RDEPEND="virtual/jre:1.8" - -S="${WORKDIR}/${MY_P}" - -pkg_setup() { - enewgroup ${MY_PN} - enewuser ${MY_PN} -1 -1 /var/lib/${MY_PN} ${MY_PN} -} - -src_install() { - keepdir /etc/"${MY_PN}"/{conf.d,patterns,plugins} - keepdir "/var/log/${MY_PN}" - - insinto "/usr/share/${MY_PN}" - newins "${FILESDIR}/agent.conf.sample" agent.conf - - insinto "/opt/${MY_PN}" - doins -r . - fperms 0755 "/opt/${MY_PN}/bin/${MY_PN}" "/opt/${MY_PN}/vendor/jruby/bin/jruby" "/opt/${MY_PN}/bin/logstash-plugin" - - insinto /etc/logrotate.d - newins "${FILESDIR}/${MY_PN}.logrotate" "${MY_PN}" - - newconfd "${FILESDIR}/${MY_PN}.confd" "${MY_PN}" - newinitd "${FILESDIR}/${MY_PN}.initd" "${MY_PN}" -} - -pkg_postinst() { - ewarn "The default user changed from root to ${MY_PN}. If you wish to run as root (for" - ewarn "example to read local logs), be sure to change LS_USER and LS_GROUP in" - ewarn "${EROOT%/}/etc/conf.d/${MY_PN}" - einfo - einfo "Installing plugins: (bug #601294)" - einfo "DEBUG=1 JARS_SKIP='true' bin/logstash-plugin install logstash-output-gelf" - einfo - einfo "Sample configuration:" - einfo "${EROOT%/}/usr/share/${MY_PN}" -} -- cgit v1.2.3-65-gdbad